help-glpk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-glpk] Variable in logical expression


From: Mate Hegyhati
Subject: Re: [Help-glpk] Variable in logical expression
Date: Fri, 24 Aug 2012 07:31:20 +0200
User-agent: Mozilla/5.0 (X11; Linux i686; rv:14.0) Gecko/20120714 Thunderbird/14.0

Dear Ajeng Dewi,

You can not do this exactly. You can do the following: if u < 0 then
x=0, and if u>0 then x=1, but int he case of u==0, x should remain
"undefined". (Suppose, that You could do what You asked for, and then
add the constraint y=1. This would basically enforce u>0, that is not
possible in LP)

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.


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);

if u > 0 then the second is satisfied, and the first can be satisfied
only if x==1. Similarly, if u < 0, the first is satisfied, and the
second needs x to be 0. And again, if u==0, x can be either 0 or 1.

Best regards,

Mate

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
> How can I write this problem?
> Thanks in advance
> Ajeng Dewi Citra Langeni
> Industrial Engineering
> Institut Teknologi Bandung
> +6285 641 91 000 1
> 
> 
> _______________________________________________
> Help-glpk mailing list
> address@hidden
> https://lists.gnu.org/mailman/listinfo/help-glpk
> 

Attachment: hegyhati.vcf
Description: Vcard

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]