help-glpk
[Top][All Lists]
Advanced

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

Re: [Help-glpk] Sign of an integer


From: Andrew Makhorin
Subject: Re: [Help-glpk] Sign of an integer
Date: Mon, 7 Apr 2008 13:02:51 +0400

> i am searching for an expression equal to the mathematicl sign function.
> I have a sum in a "subject to" statement, and i want the returning value of
> this sum to be zero if the sum is 0 or to be one if the sum is greater than
> 0.

> Example:
> subject to rooms{a in A}: sum{b in B} sign(sum{c in C} x[a,b,c]) <= r;
> whereas x is a variable only containing binary values.

> any ideas?

var sx{a in A, b in B}, binary;
/* sx[a,b] is sign(sum{c in C} x[a,b,c]) */
/* in other word, sx[a,b] is logical_or{c in C} x[a,b,c] */

s.t. foo{a in A, b in B}: sum{c in C} x[a,b,c] <= card(C) * sx[a,b];

s.t. rooms{a in A}: sum{b in B} sx[a,b] <= r;





reply via email to

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