Portfolio Optimization with Upper Bound
AnsweredHello everyone, I hope you are well.
I'm starting to work with Gurobipy to optimize financial portfolios and I already started by Gurobi repository example available here. Everything goes ok until the ub parameter in the model restricts the allocation of each asset in the portfolio.
Example:
# Add matrix variable for the stocks
x = m.addMVar(len(stocks), ub=0.25)
If I run the model with this simple restriction, the model becomes infeasible.
Someone may help me or give me a hint.
Thanks a lot.
0
-
Official comment
This post is more than two 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. -
Hi Toni,
The variable attribute UB defines the maximum value a variable can take. Setting v.UB=0.25 implies that variable v must be less than or equal to 0.25 in any feasible solution.
Have you tried running computeIIS() on the infeasible model? It will help to find the smallest set of variables and constraints that make the model infeasible. Please see the following articles for more information:
- How do I determine why my model is infeasible?
- How do I use 'compute IIS' to find a subset of constraints that are causing model infeasibility?
Best regards,
Simran0
Post is closed for comments.
Comments
2 comments