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
-
正式なコメント
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. -
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
投稿コメントは受け付けていません。
コメント
2件のコメント