help-glpk
[Top][All Lists]
Advanced

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

Re: [Help-glpk] Different constraint for first element of a set than for


From: xypron
Subject: Re: [Help-glpk] Different constraint for first element of a set than for other elements
Date: Wed, 3 Feb 2010 13:51:00 -0800 (PST)

Hello Marc,

sets in GMPL are unsorted. Hence there is no first element. Introducing
ordered sets
has been discussed:
http://lists.gnu.org/archive/html/help-glpk/2008-12/msg00135.html

For numeric sets the lowest element can be determined (in time O(n^2)).

set I:= {10..12};
param m := sum{i in I : forall{j in I} i <= j} i;
display m;

If you need labels for months you can use a symbolic parameter:
set I:={1..12};
param month{I},symbolic;
display month[4];
data;
param month :=
  1 JAN
  2 FEB
  3 MAR
  4 APR
  5 MAY
  6 JUN
  7 JUL
  8 AUG
  9 SEP
 10 OCT
 11 NOV
 12 DEC;
end;

Best regards

Xypron

Marc Goetschalckx wrote:
> 
> Following are the two constraints:
> subject to Supply_Capacity {i in SUPPLIERS, t in OTHER_PERIODS}:
>     purchase [i,t] <= capacity [i,t] + inventory [i,t-1] - inventory [i,t]
> ;
> 
> subject to Supply_Capacity_Initial {i in SUPPLIERS, t in INITIAL_PERIOD}:
>     purchase [i,t] <= capacity [i,t] + initial_inventory [i] - 
> inventory[i,t];
> 
> Is there a function, similar to card() that returns the first element of 
> a set?
> 

-- 
View this message in context: 
http://old.nabble.com/Different-constraint-for-first-element-of-a-set-than-for-other-elements-tp27413242p27444094.html
Sent from the Gnu - GLPK - Help mailing list archive at Nabble.com.





reply via email to

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