Python filter list with mathematical operation in add.constr -> NotImplementedError
I need to add a constraint so that my decision var must be in a interval, so I tried to filter somethong like this:
m.addConstrs( (O[i] == 1 for i in L if x[i] >= a[i] and x[i] <= a[i]+b), "co" )
Unfortunately, the term "a[i] + b" seems not to be a valid construction for Gurobi
Traceback (most recent call last):
...
File "model.pxi", line 3062, in gurobipy.Model.addConstrs
...
File "linexpr.pxi", line 434, in gurobipy.LinExpr.__richcmp__
NotImplementedError
Any suggestions?
Thanks in advance
-
正式なコメント
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?. -
What are O[i], x[i], a[i], and b here?
If the value of your decision variable must be in a certain interval, it sounds like you may want to consider creating your variable with a lower bound and an upper bound.
Otherwise an indicator variable type constraint might apply to this situation.
0
投稿コメントは受け付けていません。
コメント
2件のコメント