help-glpk
[Top][All Lists]

## Re: [Help-glpk] Fwd: fraction with vars

 From: Michael Hennebry Subject: Re: [Help-glpk] Fwd: fraction with vars Date: Wed, 2 May 2012 19:40:27 -0500 (CDT) User-agent: Alpine 1.00 (DEB 882 2007-12-20)

```On Wed, 2 May 2012, Kasper Tordrup wrote:

```
```So, as an example p=1000, y=1 and w=3 and so I want to find x=333.3333

Does this make it a bit more clear?
```
```
Yes.

w and y are arrays of non-negative integer variables.
p is a vector of positive integers.
x is an array of continous variables.
If w_su is zero, then y_suj are zero and x_suj may be anything.

x_suj * w_su = p_s * y_suj

w_su = SUM k*q_suk
k

q_suk binary

SUM q_suk = 1
k

small-M method, M's are G's and L's.
q_suk = 1 -->
x_suj * k >= p_s * y_suj
x_suj * k <= p_s * y_suj

The constraints will be:
x_suj * k + G_sujk * (1-q_suk) >= p_s * y_suj
x_suj * k                      <= p_s * y_suj + L_sujk * (1-q_suk)
for all s, u, j, k

Regardless of the values of the G's and L's,
those constraints for which  q_suk=1 are valid.

The G's and L's need to be selected big enough to be valid if q_suk=0.

x_suj * k + G_sujk * (1-q_suk) >= p_s * y_suj
G_sujk * (1-q_suk) >= p_s * y_suj - x_suj * k     for all s, u, j, k
G_sujk * (1-q_suk) >= p_s * y_suj * (1-k/w_su)    for all s, u, j, k

It is sufficient that
G_sujk == p_s*max(y_suj)*(1-k/max(w_su)) == p_s*(max(w_su)-k),
assuming y_suj and w_su have the same range.

For k==max(w_su), w_su<=k-1 and it is sufficient that
G_sujk == -p_s

Likewise
L_sujk * (1-q_suk) >= p_s * y_suj * (k/w_su-1)   for all s, u, j, k

It is sufficient that
L_sujk == p_s*max(y_suj*(k/w_su-1))
== p_s*max(y_suj*(k/y_suj-1))   assuming a common range
== p_s*max(k-y_suj)
== p_s*k     assuming y_suj has lower bound of zero

--