|
From: | Kasper Tordrup |
Subject: | Re: [Help-glpk] fraction with vars |
Date: | Wed, 2 May 2012 09:03:37 +0200 |
Hi guys
Thanks for all the answers, I haven't had much time to look at them.
However I can tell you that the range of y and w are both [0..6] maybe a little higher. And if w is 0, then so are y.
Maybe this helps a little.
Best regards,
Kasper
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 * x >= pn*ypd - (1-w[i]) * (pn*11 -i* 23);
i * pd * x >= pn * y - (1-w[i]) * (pn*200-i*pd*23);
s.t. ub{i in I} :i * x <= pn*ypd + (1-w[i]) * (i * 100-pn );
i * pd * x <= pn * y + (1-w[i]) * (i*pd*100-pn*10);
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;
--
Michael address@hidden
"On Monday, I'm gonna have to tell my kindergarten class,
whom I teach not to run with scissors,
that my fiance ran me through with a broadsword." -- Lily
[Prev in Thread] | Current Thread | [Next in Thread] |