One-to-one Mapping for stochastic analysis

Problems with syntax of GAMS
Post Reply
Corsafan95
User
User
Posts: 4
Joined: 5 years ago

One-to-one Mapping for stochastic analysis

Post by Corsafan95 »

Dear Community,

currently I'm writing my master-thesis using GAMS. I would now like to combine different load-profiles from an Excel-Sheet in order to investigate the impact of the sum of the different load profiles on the scaling of the PV-plant and the Energy-Storage. The following extract shows the most important lines from my model:

Set
t time in hours / h1*h8760 /
;

Parameter
input(*,*)
load_sum(t) electricity demand of the dwelling or community
PVgen(t) PV-generation profile
;
$call gdxxrw i=dataset_DoubleDwelling_Loop.xlsx o=dataset_DoubleDwelling_Loop.gdx par=input rng=Time_series!A1 dim=2
$if errorlevel 1 $abort 'problems while reading the Excel-file'
$gdxin dataset_DoubleDwelling_Loop.gdx
$load input

load_sum(t) = input(t,'%instance%') + inputr(t,'%random%');
PVgen(t) = input(t,'PVgen')
;

In order to run the model for different instances (%instance%) and random numbers (%random%) I've written the following .gms, which contains Sets for i and r

set i instances /7, 9, 12/
r random /28, 4, 16/
;

file frun / Run_DoubleDwelling_Loop.gms /;

put frun '* Run file to run ' card(i):0 'instance of TestGeneration'
/" "
/" ";


loop((i,r),
put / '$call gams Quartiersspeicher_DoubleDwelling_Loop.gms --instance=' i.tl:0 ' --random=' ord(r):0:0 ''
/ " ";
);

By executing this file I get something like this:

* Run file to run 3.00instance of TestGeneration


$call gams Quartiersspeicher_DoubleDwelling_Loop.gms --instance=7 --random=1

$call gams Quartiersspeicher_DoubleDwelling_Loop.gms --instance=7 --random=2

$call gams Quartiersspeicher_DoubleDwelling_Loop.gms --instance=7 --random=3

$call gams Quartiersspeicher_DoubleDwelling_Loop.gms --instance=9 --random=1

$call gams Quartiersspeicher_DoubleDwelling_Loop.gms --instance=9 --random=2

$call gams Quartiersspeicher_DoubleDwelling_Loop.gms --instance=9 --random=3

$call gams Quartiersspeicher_DoubleDwelling_Loop.gms --instance=12 --random=1

$call gams Quartiersspeicher_DoubleDwelling_Loop.gms --instance=12 --random=2

$call gams Quartiersspeicher_DoubleDwelling_Loop.gms --instance=12 --random=3

My problem now is that I do not want to combine each element of set i with each element of set r. I only want to map each element once. I hope the following example illustrates my issue.
Imagine there are the following two sets:

set i instances /7, 9, 12/
r random /28, 4, 16/

The following combinations I wish to investigate:

7 + 28
9 + 4
12 + 16

Maybe it is possible to solve this problem by using a twodimensional set, but I don't know how this should works.
The GAMS-environment is new for me and I hope someone can helps.

Thank you very much!

Kind regards
Corsafan95
User avatar
bussieck
Moderator
Moderator
Posts: 1033
Joined: 7 years ago

Re: One-to-one Mapping for stochastic analysis

Post by bussieck »

Hi,

create a two-dimensional set ir(i,r) and loop over this:

Code: Select all

set i instances /7, 9, 12/
    r random /28, 4, 16/
    ir(i,r) / 7.28, 9.4, 12.16 /;
loop(ir(i,r), ...);     
-Michael
Corsafan95
User
User
Posts: 4
Joined: 5 years ago

Re: One-to-one Mapping for stochastic analysis

Post by Corsafan95 »

Hi,
thanks for your support, the two dimensional set works fine.

Is there any possibility to include the two dimensional set from an Excel spreadsheet? The reading in of an one dimensional set is no problem but I could not find something about a set with more than one dimension.

Kind regards
User avatar
bussieck
Moderator
Moderator
Posts: 1033
Joined: 7 years ago

Re: One-to-one Mapping for stochastic analysis

Post by bussieck »

Capture.JPG
Capture.JPG (22.43 KiB) Viewed 3956 times

Code: Select all

set i /1*100/, r/1*100/, ir(i,r);
$call gdxxrw x.xlsx set=ir rng=sheet1!a1 rdim=2 cdim=0
$if errorlevel 1 $abort trouble with gdxxrw
$gdxin x.gdx
$load ir
-Michael
Corsafan95
User
User
Posts: 4
Joined: 5 years ago

Re: One-to-one Mapping for stochastic analysis

Post by Corsafan95 »

Thanks for your advice, it works very well! :)
Post Reply