[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-glpk] fraction with vars
From: |
glpk xypron |
Subject: |
Re: [Help-glpk] fraction with vars |
Date: |
Fri, 27 Apr 2012 20:58:52 +0200 |
Hello Kasper,
see example below.
Best regards
Xypron
# Solve
# x = p * y / w
# where x, y, w are natural numbers and
# p = 11 / 17
# x in [23, 100]
# y in [10, 200]
# w in [3, 7]
param eps := 1E-5;
param M := 1000;
param w_min := 3;
param w_max := 7;
param p := 11 / 17;
set I := {w_min..w_max};
var w{I}, binary;
var y, integer, >= 10, <= 200;
var x, integer, >= 23, <= 100;
s.t. ub{i in I} :
x <= p * y / i + M * (1 - w[i]) + eps;
s.t. lb{i in I} :
x >= p * y / i - M * (1 - w[i]) - eps;
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;
-------- Original-Nachricht --------
> Datum: Fri, 27 Apr 2012 09:57:10 +0200
> Von: Kasper Tordrup <address@hidden>
> An: help-glpk <address@hidden>
> Betreff: [Help-glpk] fraction with vars
> Hi guys
> I have a problem with calculating a fraction, the reason is that both the
> nominator and denominator are variables.
> So I am looking for some way to make this linear:
> x_suj = p_s * (y_suj/w_su) or well just find what this fraction is:
> y_suj/w_su
> where p_s is a constant, x,y and w are integer variables. and I also need
> to avoid the division with 0 problem.
> Anyone know some tips/tricks for this?
>
> Regards,
> Kasper
--
NEU: FreePhone 3-fach-Flat mit kostenlosem Smartphone!
Jetzt informieren: http://mobile.1und1.de/?ac=OM.PW.PW003K20328T7073a