Hello, I wish to linearize the following constrain:
a (integer) is in {1..15} and b is binary thank u
asked
BastaN |

if you are using something like CPLEX (or perhaps other solvers) then there is a so called "indicator constraint" which can help you to model it. Otherwise, you can simply write it like: a <= b M b <= a where M is a big M value. if a is non zero then b is forced to take 1 and of course b<=a if a is 0 then b cannot be non zero and a<= M b becomes redundant
answered
ShahinG |

Assuming you really meant that a is in {0..15}, you can write b <= a <= 15 b If a is any number in the range 1..15 then this can only be satisfied by b = 1, while if a is 0 then this can only be satisfied by b = 0. Replacing 15 with some large number M will work as well, but will in general offer no advantage and may make the problem harder to solve.
answered
4er |

Perhaps you have a typo. If a is an integer in {1..15}, as you say, then it is always > 0. Hence you have an unconditional constraint b = 1. You need to tell us how to fix your typo before a corresponding solution can be provided.