When I print the following it selects the correct values: df[(df['Pdem']>0)].
However, I am not able to work this into an if condition (without the ValueError: The truth value of a DataFrame is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all()
. - error) that sets the constraints at the right timeslots. I do not want any() or all() as i want the decision to be made per row of the dataframe.
I would like to set different constraints for Pb in Gurobi per timeslot based on the size of Pdem per timeslot (T = total hours). I have tried various things such as loc (shown below), iterrows and regular boolean expressions.
Any advice would be greatly appreciated.
UPDATE: Following did the trick
model.addConstrs(((Pgen [t] - Pdem[t]) < 0) >> 0 <= P_grid_b[t] <= Pgridmax for t in range(T))
model.addConstrs((Pdem[t] == 0) >> 0 <= P_grid_b[t] <= 0 for t in range(T))