Linearizing Max function in constraint
回答済みI'm trying to linearize the following constraints in python.
mdl = Model('MTHFVRPTW')
rtkw = mdl.addVars(vehicles, trips, vtype=GRB.CONTINUOUS) #return time of trip w of vehicle k
aac = mdl.addVars(vehicles, customers, trips, vtype=GRB.CONTINUOUS) #arrival at customer with veh k on trip w
#13
mdl.addConstrs(rtkw[k,w] >= max(aac[k,i,w], earliest[i]) for i in customers for k in vehicles for w in trips)
#14
mdl.addConstrs(aac[k,j,w] >= max(aac[k,i,w], earliest[i]) for i,j in customers for k in vehicles for w in trips)
0
-
the list earliest is a parameter of my problem, not a variable
0 -
Hi Joao,
Let us assume that you would like to implement a constraint in the form \(\max(x, c)\) with \(c\) being a constant value.
- You need to fist define an auxiliary variable \(y\)
- You can then use the method Model.addGenConstrMax() (or general constraint helper function gurobipy.max_()) to implement the relationship \(y = \max(x, c)\).
- You can then use \(y\) in place of \(\max(x, c)\) in any other constraint where the \(\max\) function appears.
Best regards,
Maliheh
0
サインインしてコメントを残してください。
コメント
2件のコメント