Skip to main content

Lot constraints for portfolio optimization-- how to enforce lot constraints on number of stocks

Answered

Comments

3 comments

  • Official comment
    Simranjit Kaur
    • Gurobi Staff
    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?.
  • Maliheh Aramon
    • Gurobi Staff
    Hi Rajeev, 
     
    If the lot constraints should ensure 1) \(n\) stocks are selected and 2) if a stock is selected, its investment value is \(\geq 0.05\), then you just need to change the type of the \(x\) variables from continues to semi-continuous, forcing variables \(x\) to take a value of 0, or a value between the specified lower and upper bounds. Specifically, you need to define the \(x\) variables as:
    x = m.addMVar(len(stocks), vtype=GRB.SEMICONT, lb=0.05, name="x")
    Your explanation of the lot constraints is not super clear to me. I inferred the above meaning from your code. If this does not represent the constraints you are looking for to implement, please clarify.
     
    Best regards,
    Maliheh
    0
  • Rajeev Sharan
    • Gurobi-versary
    • First Comment
    • First Question

    Thanks a lot, Maliheh! It works and solved my problem-- made me learn as I am very new to Gurobi.

    Regards,

    Raj

     

    0

Post is closed for comments.