i'm using Gurobi,
I have 2 decision variables x
and y
, and i want to linearize some constraints, here's my code :
m.addConstr( x == max(0, y) )
m.addConstr( x >= 0 )
i'm using Gurobi,
I have 2 decision variables x
and y
, and i want to linearize some constraints, here's my code :
m.addConstr( x == max(0, y) )
m.addConstr( x >= 0 )
Assuming Objective Function is a minimization, and you just want to track the max value of something, say an energy peak,
If m.addConstr( x >= 0 ) is a real requirement, then you can just set y=x, which makes no sense as x will stay non-negative by itself with no need for y
OR
you can use
m.addConstr(x>=0)
m.addConstr(x>=y)
and put x in the objective function with positive cost coeff. This will keep x tied to max(0,y)
ref https://orinanobworld.blogspot.com/2011/01/max-and-min-functions-in-mip.html