Write constraint
AnsweredPlease visit the following (LINK) to have access the google colab file.
At this cell (LINK), I am trying to write the following constraint
### Constraints
- **Maximum investment**
x_1 + x_2 = a
I have tried the following code
m.addConstr(sum(StockWeight[i] for i in range(0,2)) == MaxInvest, name = 'MaxInvest')but the output is wrong.
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 try Gurobot, our chatbot interface offering instant, expert-level support. -
Could you elaborate what exactly is wrong with this constraint?
The code you wrote adds the constraint
MaxInvest: StockWeight[0] + StockWeight[1] = MaxInvest
0 -
I solved it Jaromił Najman, thanks for the support.
0
Post is closed for comments.
Comments
3 comments