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
-
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
Please sign in to leave a comment.
Comments
1 comment