help-glpk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-glpk] Newbie was wondering how


From: Andrew Makhorin
Subject: Re: [Help-glpk] Newbie was wondering how
Date: Fri, 24 Aug 2001 00:32:06 +0400

Thank you for your interest in GLPK.

Unfortunately the current version of GLPK/L doesn't allow writing the
"integration" formula that you need in a natural way. This formula could
be written in the form:

    xsum[i,d] := sum(t, x[i,t] where t <= d);

where 't <= d' is a predefined predicate that corresponds to the
binary relation "less than or equal to" over the domain set 'days', but
predicates of such kind are not implemented yet in the language.

Below I give an example of the model, which does that you need, however,
in an ugly way. So, if your model includes compuatations, which can't be
expressed easily using GLPK/L relational operators, probably it would be
better to use GLPK API.

------

model ugly;

set stuff = (stuff1, stuff2, stuff3);
set days  = (d1, d2, d3, d4, d5);
parameter x[stuff,days];

x[i,d] := data(i in stuff, d in days:
   stuff1  d1  20
   stuff1  d2   0
   stuff1  d3   3
   stuff1  d4   5
   stuff1  d5   7);

display x;

parameter xsum[stuff,days];

/* the following fragment is ugly simulation of the statement

      xsum[i,d] := sum(t, x[i,t] where t <= d);

   which can't be written in the current version of GLPK/L */

parameter p[days,days];

p[d,t] := table(d in days, t in days:
   d1 d2 d3 d4 d5:
d1  1  .  .  .  .
d2  1  1  .  .  .
d3  1  1  1  .  .
d4  1  1  1  1  .
d5  1  1  1  1  1 );

parameter xx[stuff,days,days];

xx[i,d,t] where p[d,t] = 1 := x[i,t];

xsum[i,d] := sum(t, xx[i,d,t]);

display xsum;

end;

------

The output from the language processor is the following:

*** display statement at line 14 ***

parameter x[stuff,days]
x[stuff1,d1] = 20
x[stuff1,d2] = 0
x[stuff1,d3] = 3
x[stuff1,d4] = 5
x[stuff1,d5] = 7

*** display statement at line 40 ***

parameter xsum[stuff,days]
xsum[stuff1,d1] = 20
xsum[stuff1,d2] = 20
xsum[stuff1,d3] = 23
xsum[stuff1,d4] = 28
xsum[stuff1,d5] = 35







reply via email to

[Prev in Thread] Current Thread [Next in Thread]