Re: [Fwd: conditional assignment in glpk]

Andrew Makhorin <[email protected]>
Newsgroups gmane.comp.gnu.glpk
Message-ID <1484892687.3501.9.camel@corvax>
> I see that we have conditional expressions in glpk but what about
> conditional assignment?
> 
>  
> 
> For example, suppose I have 8 binary variables y1 up to y8 whose values
> depend on another 8 binary variables x1 up to x8.
> 
> So if x1...x8 = 10010010 then y1...y8 can be one of {00110011,
> 0100110110, 01100110}.
> 
> Can we model this conditional assignment using the conditional
> expressions?
> 

You cannot use conditional expressions in this case, because this would
lead to non-linear constraints not allowed by glpk. You need to declare
your variables as binary and then use standard techniques to model
logical relations, for example, the condition

IF x1 = 1 AND ... AND x8 = 0 THEN y1 = 0

can be written as:

x1 = 0 OR ... OR x8 = 1 OR y1 = 0

and then can be modeled as

(1 - x1) + ... + x8 + (1 - y1) >= 1

where x1, ..., x8, y1 are binary variables.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.