Three or more variables with similar conditions, can they clash?
Answered
I'm not sure If I can post a follow up question with this thread - I just had one more question.
with the above condition, I added one more variable with identical constraints. After adding this third constraint, I receive the bottom message, am I not allowed to insert a third or fourth variable with similar constraints?
Prl = model.addVars(T,R, name = 'irrigation')
R = 4
#irrigation
p_r_min = 0.85
p_r_max = 0.88
p_r_ttl = 4.4
#each irrigation motor cannot exceed or fall behind the min max
model.addConstrs(Prl[t1,r] <= p_r_min for t1 in range(T) for r in range (R))
model.addConstrs(Prl[t1,r] >= p_r_max for t1 in range(T) for r in range (R)
if hoursof_ir[t1]!= 0)
KeyError: 0During handling of the above exception, another exception occurred:KeyError Traceback (most recent call last)<ipython-input-3-33f692cd7f9e> in <module> 121 #each irrigation motor cannot exceed or fall behind the min max 122 model.addConstrs(Prl[t1,r] <= p_r_min for t1 in range(T) for r in range (R))--> 123 model.addConstrs(Prl[t1,r] >= p_r_max for t1 in range(T) for r in range (R) 124 if hoursof_ir[t1]!= 0) 125 src/gurobipy/model.pxi in gurobipy.Model.addConstrs()<ipython-input-3-33f692cd7f9e> in <genexpr>(.0) 122 model.addConstrs(Prl[t1,r] <= p_r_min for t1 in range(T) for r in range (R)) 123 model.addConstrs(Prl[t1,r] >= p_r_max for t1 in range(T) for r in range (R)--> 124 if hoursof_ir[t1]!= 0) 125 126 #supplemental lighting constraint multiplying with time so that it operates during 0500-2300~/Documents/Programming_with_Python/anaconda3/lib/python3.8/site-packages/pandas/core/frame.py in __getitem__(self, key) 2798 if self.columns.nlevels > 1: 2799 return self._getitem_multilevel(key)-> 2800 indexer = self.columns.get_loc(key) 2801 if is_integer(indexer): 2802 indexer = [indexer]~/Documents/Programming_with_Python/anaconda3/lib/python3.8/site-packages/pandas/core/indexes/base.py in get_loc(self, key, method, tolerance) 2646 return self._engine.get_loc(key) 2647 except KeyError:-> 2648 return self._engine.get_loc(self._maybe_cast_indexer(key)) 2649 indexer = self.get_indexer([key], method=method, tolerance=tolerance) 2650 if indexer.ndim > 1 or indexer.size > 1:
0
-
Official comment
This post is more than three years old. Some information may not be up to date. For current information, please check the Gurobi Documentation or Knowledge Base. If you need more help, please create a new post in the community forum. Or why not try our AI Gurobot?. -
This is a continuation of this post.
0 -
Hi Olivia,
You can provide a full jupyter notebook file as described in Posting to the Community Forum. This would definitely make providing help easier.
Best regards,
Jaromił0 -
Thank you - will do !
0 -
The issue was that one pandas dataframe was not converted to list. This is resolved now.
0
Post is closed for comments.
Comments
5 comments