Skip to main content

Parametric optimization with Gurobi in python?

Answered

Comments

1 comment

  • Marika Karbstein
    • Gurobi Staff

    Hi Samuel,

    There is no automatic way in gurobipy. But you can update the model by

    • changing the attribute values, for example, RHSObj,  LB, or UB 
    •  using function Model.chgCoeff() to change a coefficient in a constraint

    For your example x - a <= 0, the part could look like

    a=1 # start value
    con = m.addConstr(x - a <= 0)
    m.optimize()
    # change a = 5
    con.RHS=5
    m.optimize()
    Best regards,
    Marika
    0

Please sign in to leave a comment.