I am fairly new to the Gurobi/Python tool set and wandering if Gurobi has a function like the exists() function in Morsel.
For example, I will get an error in using the following network flow conservation constraint because my supply and demand data does not exist for every enumeration of p and i. I can enumerate every possible combination of p and i, and set the supply/demand value to be zero but that does not seem very elegant.
m.addConstrs(
(flow.sum(p,'*',i) + supply[p,i] == flow.sum(p,i,'*') + demand[p,i]
for p in product for i in loc), "flow_balance")
I would like to know if there is a convenient way to add the supply and demand terms to the constraint only if they exist in the data.