0

I am solving an integer programming problem with the condition

if a=0 then b=0 else b=1

where a is integer while b is binary

I looked on previous question similar to this but could not find solution. please help to define constraint equation in integer programming for above conditions.

2 Answers2

1

The first constraint is easy: a=0 ⇒ b=0 can be written as a ≥ b. The second constraint (a ≥ 1 ⇒ b=1) is more complicated. If a ≤ M where M is relatively small, then you can write this as M ⋅ b ≥ a. Otherwise, you will need to use a solver feature called indicator constraints.

Greg Glockner
  • 5,433
  • 2
  • 20
  • 23
1

Use these two constraints:

a<=bM
b<=aM

where M is a big number (M>a). When a=0, the 1st constraint is redundant, 2nd one gonna impose b=0. If a>0 then 2nd constraint is redundant, but the 1st one gonna force the b gets the value of 1 (if M is enough big).

Faraz Ramtin
  • 345
  • 3
  • 11
  • Since b is binary, you should simplify the second constraint to b <= a. – Greg Glockner Dec 15 '16 at 16:07
  • Greg, It was my misreading of your previous answer, I though the (dot) you put after M is a colon. Basically, I just anwsered what you already did.M is not necessary in the 2nd constraint as you mentioned. – Faraz Ramtin Dec 16 '16 at 20:36