help-glpk
[Top][All Lists]
Advanced

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

[Help-glpk] Re: http://en.wikibooks.org/wiki/GLPK/Electricity_markets


From: glpk xypron
Subject: [Help-glpk] Re: http://en.wikibooks.org/wiki/GLPK/Electricity_markets
Date: Tue, 06 Jul 2010 21:27:54 +0200

Hello Harley,

> One problem I had with the data section for an example that I havent yet 
> added is that I couldnt work out the correct way to implement a param 
> data structure to read in the following data. The only way I could get 
> it going was to use an external CSV file.
> 
> For parameters defined as:
> 
>    set UNITS;
>    param no_bands;
>    set BANDS := 1..no_bands;
>    set UNITBANDS dimen 2;
>    param offerprice {UNITS, BANDS};
>    param offeravail {UNITS, BANDS};
>    param reg_offerprice {UNITS, BANDS};
>    param reg_offeravail {UNITS, BANDS};
> 
>    table data IN "CSV" "energy_regulation_offers.csv": UNITBANDS <- 
> [unit,band], offerprice ~ energyprice, offeravail ~ energyavail, 
> reg_offerprice ~ regprice, reg_offeravail ~ regavail;
> 
> The data section had:
> 
>    param no_bands := 5;
> 
>    param : UNITS :   capacity   reg_capacity  :=
>             1         10         5
>             2         10         5
>             3         10         5
>             4         10         5
>             5         10         5
>             6         10         5
>             7         10         5
>             8         10         5
>             9         10         5
>            10         10         5
>    ;
> 
> where the external data was in a csv file [energy_regulation_offers.csv]:
> 
>    unit,band,energyprice,energyavail,regprice,regavail
>    1,1,2,2,1,1
>    1,2,4,2,2,1
>    1,3,6,2,3,1
>    1,4,8,2,4,1
> etc...
> 
> I couldnt find any combination of param data structure that could define 
> the same data without using the CSV file. Do you have any idea what the 
> param data structure should look like, as I would like to include all of 
> the model and data in the one file for the wiki example?

set CSV, dimen 6;

set BANDS := setof{(u,b,ep,ea,rp,ra) in CSV} b;
set UNITBANDS := setof{(u,b,ep,ea,rp,ra) in CSV} (u,b);
param offerprice{(u,b) in UNITBANDS}     := sum{(u,b,ep,ea,rp,ra) in CSV} ep;
param offeravail{(u,b) in UNITBANDS}     := sum{(u,b,ep,ea,rp,ra) in CSV} ea;
param reg_offerprice{(u,b) in UNITBANDS} := sum{(u,b,ep,ea,rp,ra) in CSV} rp;
param reg_offeravail{(u,b) in UNITBANDS} := sum{(u,b,ep,ea,rp,ra) in CSV} ra;

display offerprice, offeravail, reg_offerprice, reg_offeravail;

data;
# unit,band,energyprice,energyavail,regprice,regavail
set CSV :=
   (1,1,2,2,1,1)
   (1,2,4,2,2,1)
   (1,3,6,2,3,1)
   (1,4,8,2,4,1)
   (2,1,2,2,2,1)
   (2,2,4,2,3,0)
   (2,3,6,2,4,1)
   (2,4,8,2,5,1)
   (3,1,2,1.5,1,1)
   (3,3,6,1.6,3,1)
   (3,4,8,2,4,1)
   (4,1,2,2,1,1)
   (4,2,4,2,2,1)
   (4,4,8,2,4,1)
   (5,2,4,2,2,1)
   (5,3,6,2,3,1)
   (5,4,8,2,4,1);
end;

Best regards

Xypron
-- 
GMX DSL: Internet-, Telefon- und Handy-Flat ab 19,99 EUR/mtl.  
Bis zu 150 EUR Startguthaben inklusive! http://portal.gmx.net/de/go/dsl



reply via email to

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