help-glpk
[Top][All Lists]

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

 From: Michael Hennebry Subject: Re: [Help-glpk] fraction with vars Date: Sat, 28 Apr 2012 22:23:46 -0500 (CDT) User-agent: Alpine 1.00 (DEB 882 2007-12-20)

```Divisiblilty can be used to reduce the problem somewhat.

On Fri, 27 Apr 2012, Michael Hennebry wrote:

```
```# Solve
# x = p * y / w
# w * pd * x = pn * y
# where x, y, w are natural numbers and
# p = 11 / 17
# pn = 11
# pd = 17
# x in [23, 100]
# y in [10, 200]
# w in [3, 7]
```
```
# Since pn/pd is in lowest terms, y must be a multiple of pd.

```
```param w_min := 3;
param w_max := 7;

param pn := 11;
param pd := 17;

set I := {w_min..w_max};

var w{I}, binary;
var y, integer, >= 10, <= 200;
var x, integer, >= 23, <= 100;
```
```
var ypd, integer, >= 10/pd, <= 200/pd
#                     1         11
s.t. y_formula :
y = ypd*pd;

```
```s.t. lb{i in I} :
i * pd * x >= pn * y - (1-w[i]) * (pn*200-i*pd*23);
```
```     i   *    x >= pn*ypd - (1-w[i]) * (pn*11 -i*   23);

```
```s.t. ub{i in I} :
i * pd * x <= pn * y + (1-w[i]) * (i*pd*100-pn*10);
```
```     i   *    x <= pn*ypd + (1-w[i]) * (i *  100-pn   );

```
```s.t. sm :
sum{i in I} w[i] = 1;

solve;

printf "x = %f\ny = %f\nw = %f\n", x, y, sum{i in I} w[i] * i;

end;
```
```
--