integer linear if then else

 0 Hello, I wish to linearize the following constrain: if(a>0) then b = 1 else b = 0  a (integer) is in {1..15} and b is binary thank u asked 22 Aug '16, 04:25 BastaN 11●3 accept rate: 0% 1 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. (22 Aug '16, 12:06) Mark L Stone

 1 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 22 Aug '16, 10:53 ShahinG 281●2●13 accept rate: 0%
 0 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 23 Aug '16, 10:39 4er 641●2●7 accept rate: 0%
 toggle preview community wiki

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "Title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported

Tags:

×231
×190