Pyomo creating a variable time index
问题 I'm trying to bring this constraint in my pyomo model [ 1 I define a set for indexing over time and I want to optimize the corresponding energy variable below model.grid_time = Set(initialize=range(0, 23))) model.charging_energy = Var(model.grid_time, initialize=0) My constraint definition looks like as follows: model.limits = ConstraintList() for t in model.grid_time: model.limits.add(sum(model.charging_energy[t] for t in model.grid >= energy_demand.at[t,"total_energy_demand"]) The problem