Hi again guys After looking over Xypron's example, it became clear to me that you lack some information, sorry for that. The x represent a percentage of p that I need, and this means that y is <= to w. So summing up: x will always be <= to p. y will always be <= to w. if w is 0, then so are y. p is a constant. x,y and w are variables. y and w are in the range [0..6] (or close to that) and I want to calculate: x_suj = p_s * (y_suj/w_su)
Sorry for the mess, hope this clarifies it. Best regards, Kasper On Wed, May 2, 2012 at 9:03 AM, Kasper Tordrup <[email protected]> wrote: > 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 > On Apr 29, 2012 5:23 AM, "Michael Hennebry" < > [email protected]> wrote: > >> 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; >>> >> >> -- >> Michael [email protected] >> "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 >> > -- *Kasper Tordrup - Stud. M. Sc. IMADA @ University of Southern Denmark [email protected] - +45 27 44 58 49*
_______________________________________________ Help-glpk mailing list [email protected] https://lists.gnu.org/mailman/listinfo/help-glpk
