Group: sci.op-research
From: Paul Rubin
Date: Friday, March 21, 2008 7:53 PM
Subject: Re: Counting zero continuous variables

xgeneral57@gmail.com wrote:

>>> x(i)'s ae actually bounded above and below: LB(i) <= x(i) <= UB(i).
>>> But the problem is that x(i)'s can be either positive or negative.
>> Represent each x(i) with a sum of two auxiliary variables that
>> cannot be greater than zero at the same time.
>>
>
> if x(i)=xp(i)-xn(i) where xp(i) and xn(i) are two nonnegative slack
> variables, then to enforce exactly one of them to be zero I would
> need to maximize
> |x(i)|=z=xp(i)+xn(i).
> But this is not the case for me.

You still need binary variables, and I think you will also need to bound
x away from zero when it is not zero. For instance, introduce binary
variables y(i) and z(i) and a small positive constant e, then use the
following constraints:

x(i) = xp(i) - xn(i)
e*y(i) <= xp(i) <= U(i)*y(i)
e*z(i) <= xn(i) <= |L(i)|*z(i)
y(i) + z(i) <= 1.

This gives you three cases:

y(i) = 0 = z(i), x(i) = 0;
y(i) = 1, z(i) = 0, e <= x(i) <= U(i);
y(i) = 0, z(i) = 1, L(i) <= x(i) <= -e.

So if you sum up 1 - y(i) - z(i) for all i, you get the number of zeros.
Note, though, that 0 < |x(i)| < e cannot occur, so you are eliminating
some potential solutions from the feasible region.

A different approach is to say

e*y(i) <= xp(i) <= e + (U(i) - e)*y(i)
e*z(i) <= xn(i) <= e + (|L(i)| - e)*z(i)
y(i) + z(i) <= 1.

Now y(i) = 0 = z(i) means 0 <= xp(i) <= e and 0 <= xn(i) <= e, so -e <=
x(i) <= e, while y(i) = 1 means x(i) >= e and z(i) = 1 means x(i) <= -e.
The first case (both binaries zero) opens the door to both xp(i) and
xn(i) being positive, but that's harmless here. Now summing 1 - y(i) -
z(i) for all i counts the number of x(i) that are nearly zero (within e
of zero).

Last comment: you can count the number of exact zeros if x is
integer-valued. I don't think you can count the number of exact zeros
if x is divisible; I think you're limited to counting near-zeros.

/Paul