### Comments

3 comments

If $$b,d$$ are constants, you could determine whether $$d\leq b$$ a priori and then implement your condition as

d = 5
b = 4
a = min(b,d)
q = m.addVar(vtype=GRB.BINARY,name="q")
y = m.addVar(vtype=GRB.CONTINUOUS,name="y")
m.addConstr(y == q * a)

Best regards,
Jaromił

Hi Jaromil,

these $b$ and $d$ aren't known a priori and are in the form of a list.

Hi Syed,

In this case, could you elaborate more on the nature of the $$b$$ and $$d$$ terms? If they are both constant parameters, then both values should be available when the model is constructed. Otherwise they depend on the values of some other optimization variables making $$b$$ and $$d$$ optimization variables as well. How does the fact that $$b,d$$ are lists take effect here? Do you actually want to introduce multiple constraints of the above form or do you want to check whether all values in $$d$$ are $$\leq$$ than $$b$$?

Best regards,
Jaromił

Please sign in to leave a comment.