A cost-energy trade-off model in smart energy grids