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.
if df.loc[df.Pdem]>0:
model.addConstrs(0 <= Pb[t] <= Pmax for t in range(T))
else:
model.addConstrs(0 <= Pb[t] <= 0 for t in range(T))
Aucun commentaire:
Enregistrer un commentaire