help-glpk
[Top][All Lists]
Advanced

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

Re: [Help-glpk] Concatenate Parameter "Fields" Question


From: glpk xypron
Subject: Re: [Help-glpk] Concatenate Parameter "Fields" Question
Date: Fri, 31 Aug 2012 17:19:15 +0200

Hello Robert,

set DMD_t, dimen 4;
param Demand_t{DMD_t};
set DMD, dimen 3 := setof{(s, c, st, m) in DMD_t}(s, c & ", " & st, m);
param Demand{(s,cst,m) in DMD} := 
  sum{(s, c, st, m) in DMD_t: cst == c & ", " & st}Demand_t[s, c, st, m];
display DMD, Demand;
data;
set DMD_t :=
p1,'Dover',DE,1,
p2,'Dover',DE,1,
p2,'Tallahassee',FL,1,
p3,'Atlanta',GA,1,
p4,'Honolulu',HI,1,
p5,'Boise',ID,1,
p6,'Springfield',IL,1,
p7,'Indianapolis',IN,1,
p8,'Des Moines',IA,1;
param Demand_t :=
[p1,'Dover',DE,1]303,
[p2,'Dover',DE,1]697,
[p2,'Tallahassee',FL,1]236,
[p3,'Atlanta',GA,1]105,
[p4,'Honolulu',HI,1]163,
[p5,'Boise',ID,1]480,
[p6,'Springfield',IL,1]375,
[p7,'Indianapolis',IN,1]703,
[p8,'Des Moines',IA,1]775;
end;

Best regards

Xypron
-------- Original-Nachricht --------
> Datum: Fri, 31 Aug 2012 00:45:44 -0500
> Betreff: [Help-glpk] Concatenate Parameter "Fields" Question

> I'm currently importing demand as a set of SKU(s), City(c ), State(s),
> TransMode(m) tuple parameters.  I'd like to eliminate a dimension by
> concatenating the City and State into one element.  I see how to do this for 
> a set:
> 
> set LOC := setof{(s, c, st, m) in DMD_t}(c&", "&st);  #the set of valid
> City/State combination
> 
> set DMD := setof{(s, c, st, m) in DMD_t}(s, c&", "&st, m);  #The demand
> set: SKU, City/State, Mode
> 
> Where DMD_t is my temporary demand set of imported data with dimension 4,
> and DMD is the 3 dimension set I'd like to work with in the model.
> 
> My question: Is there a similar construct for converting a 4-tuple
> parameter to a 3-tuple?
> 
> That is, can I somehow convert:
> Parameter Demand_t[s, c, st, m] to Parameter Demand[s, l, m] by
> concatenating the city and state dimenstions.
> 
> I realize I could concatenate the fields in my input data, but I'm curious
> if there is a way to accomplish this with parameter manipulation.  I'm new
> to glpk, so apologies in advance if this is a silly question.
> 
> Thanks for your help,
> Rob
> 



reply via email to

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