How to formulate a constraint that models the maximum of a maximum value?
AnsweredHi,
I proposed a model and implemented it in CPLEX using Python. Now I'm trying to switch to Gurobi, but I can't find a way to model a constraint that finds the maximum value of some maximum values.
This is the constraint:
for j in N:
mdl.add_constraint(a[0] + mdl.max( [ (mdl.max( [t_d[0,k] + s_d[k] + t_d[k,j] - t_t[0,j], 0] ) )*z[0,k,j] for k in N if j != k] )
<= a[j] + M)
- "a" and "z" are continuous variables
- "t_d", "s_d", "t_t" and "M" are constants
0
-
Hi Benjamin,
The addGenConstrMax function is our equivalent. As noted in the description of the function you can also use gp.max_
In this particular case though I think using the max function will introduce unnecessary variables and constraints and I suggest trying the following alternative:
for j in N:
m.addConstr(a[0] <= a[j] + M)
for k in N if j != k:
m.addConstr(a[0] + (t_d[0,k] + s_d[k] + t_d[k,j] - t_t[0,j])*z[0,k,j]] <= a[j] + M)- Riley
1 -
Thank you!
0
Please sign in to leave a comment.
Comments
2 comments