Skip to main content

Maximum recursion depth exceeded while calling a Python object

Answered

Comments

2 comments

  • Official comment
    Simranjit Kaur
    • Gurobi Staff
    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.
  • Riley Clement
    • Gurobi Staff

    Hi Adnan,

    While I'm not sure exactly how the recursion arises, the root of the problem here is that your objective contains terms which are the product of three variables.

    I'd recommend you read our article How do I model multilinear terms in Gurobi? for a thorough understanding.

    Using the concepts in that article you can resolve your problem by replacing the line where you set the objective with the following:

    aux = m.addMVar( (G-1), lb=-float("inf"), name="aux")
    m.addConstrs(aux[g] == w_t_var.T@A_g[g,:,:]@w_t_var for g in range(G-1))
    m.setObjective(gp.quicksum(z_var[g]*aux[g] for g in range(G-1)), GRB.MINIMIZE)

    - Riley

     

    1

Post is closed for comments.