# If constraints

Hello,

I am working on a MILP where i want to add the following constraint:

I have two variables o[i] that is binary and f[i] that is continuous.

I added the following constraint : m.addGenConstrIndicator( o[i], False, f[i], GRB.LESS_EQUAL, 0.0)

to force f[i] to be strictly positive whenever o[i] is equal to one.

Now, I would like to other another constraint on f[i] : whenever f[i] is strictly positive I want it to be bigger than a certain value f_budget :

m.addConstr((f[i]<=f_budget)>>(f[i]==0), name="Budget Penalty")

I added this constraint but its giving me errors . I wonder if there is a way to do it ?

I've always wondered about the order in which gurobi gives values to its variables since the two are related. Does it first designate o[i] and then look for the optimal value for f[i] ?

Regards,

Ibtissam

Please sign in to leave a comment.

## Comments

0 comments