[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-glpk] [Fwd: conditional assignment in glpk]
From: |
Andrew Makhorin |
Subject: |
Re: [Help-glpk] [Fwd: conditional assignment in glpk] |
Date: |
Fri, 20 Jan 2017 09:11:27 +0300 |
> 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.