[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-glpk] Variable in logical expression
From: |
Michael Hennebry |
Subject: |
Re: [Help-glpk] Variable in logical expression |
Date: |
Fri, 24 Aug 2012 11:52:29 -0500 (CDT) |
User-agent: |
Alpine 1.00 (DEB 882 2007-12-20) |
On Fri, 24 Aug 2012, Mate Hegyhati wrote:
For the aforementioned case the simplest solution is probably this:
u = pos - neg;
pos <= M * x;
neg <= M * (1-x);
where M is bigger than the maximum of |u|
in this case, at most one of pos or neg is positive. If neg (u<0), then
x must be 0, if it is the pos that is positive (u>0), then x must be 1.
If both of neg and pos are 0, x can be, however, either 0 or 1.
For a tighter constraint, the two M's should be different:
one should be the upper bound on u,
the other should be the absolute value of the lower bound.
That said, upper(|u|) is better than the old standby, pick something huge.
You can also do this thing without pos and neg as well, in a form like this:
u <= 0 + M * x;
u >= 0 - M * (1-x);
On 08/24/2012 04:47 AM, address@hidden wrote:
I have a problem which has variable named 'u' and 'x'
Variabel x is binary variabel which will have value 0 if u<=0 and 1 if u>0
--
Michael address@hidden
"On Monday, I'm gonna have to tell my kindergarten class,
whom I teach not to run with scissors,
that my fiance ran me through with a broadsword." -- Lily