Parametric optimization with Gurobi in python?
回答済みHello,
Does gurobipy support parametric programming? For example I have an optimization problem with a variable 'x' and a constraint 'x - a <= 0'. The parameter 'a' may appear in many other constraints and in the objective function.
I want to solve this optimization problem many times with different values of 'a'. Is this possible with gurobipy?
I am looking for something similar to what can be done with cvxpy: x = cp.Variable((1,1)), a = cp.Parameter((1,1)).
Thank you,
Samuel
0
-
Hi Samuel,
There is no automatic way in gurobipy. But you can update the model by
- changing the attribute values, for example, RHS, Obj, 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
Best regards,
con = m.addConstr(x - a <= 0)
m.optimize()
# change a = 5
con.RHS=5
m.optimize()
Marika0
サインインしてコメントを残してください。
コメント
1件のコメント