Skip to main content

Maximum recursion depth exceeded while calling a Python object



1 comment

  • Riley Clement
    Gurobi Staff 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



Please sign in to leave a comment.