0

I'm trying to formulate a constraint for a MIP problem that involves binary variable v and continuous variable i, such as:

if i = 0, v = 0, and if i > 0, v = 1

I haven't been able to think of a solution to this and I'm not sure if there is a solution. Any suggestion is greatly appreciated. Thank you!

2 Answers 2

3

You can also model this using the 'traditional' Big-M formulation which is documented in many places on the internet and in many textbooks.

Usually this is done in a pair of constraints like this:

i <= M * v

This forces i to be zero if v is zero, and also if i is non-zero then v must be 1 which covers most of your requirement, but still allows i = 0 and v = 1. In many cases the objective is trying to minimise some expression including v and that may be sufficient to encourage v=0 when i=0. But don't fall into the silly error of using a really big value for M as that will adversely affect your linear relaxations and possibly overal performance.

Then you might also need to add a further constraint to force v to zero if i is zero such as:

v <= i

which would have the effect of directly forcing v to zero if i is zero.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you very much. This works!
1

you can rely on logical constraints. In OPL you can write

dvar boolean v;
dvar float+ i;

subject to
{
  v==!(i==0);
}

And you can do the same with all CPLEX APIs

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.