Rerunning the model with different data

Problems with modeling
Post Reply
chessosskar
User
User
Posts: 12
Joined: 2 years ago

Rerunning the model with different data

Post by chessosskar »

Hi
I am modelling international coal markets. I want to see how my model changes when i change demand a bit. I currently have the slope and intercept data fro my demand curves (South Asia, Americas, Europe and China all get their own demand curves). Then i want to re run the programme with slightly different data. The demand data has 8 entries and so needs to be entered as two paramters or one table. However, although i can redefine the table using $onMulti, the help page for this option suggests that this redefinition will happen immediately and before any models are run.
I thought about putting the demand data in as scalars but i think it would make the code really messy because i would manually have to rewrite all constraints rather than using sum(n, coefs(n,"intercept")

Any ideas ppl? maybe i could try $onMulti and just hope it doesnt do what i think it will do or just run the model manually 15 times (but then if i want to change something about the model, ill have to run it another 15 times.) Or maybe rewrite the model equations 15 times in the same file referring to different demand data each time? seems very clunky
Feb 4.gms
(16.77 KiB) Downloaded 133 times

thanks
chessosskar
User avatar
bussieck
Moderator
Moderator
Posts: 1047
Joined: 7 years ago

Re: Rerunning the model with different data

Post by bussieck »

If I understand you correctly you want to vary the rho and eta from the table coefs for Asia, Europe, America, and China and rerun the model:

Code: Select all

Table coefs(n,*) 'demand and supply data'
                alpha            cap      beta              rho         eta           
   Asia           0                                     762.667     7.198010732 
   Europe         0               0                     762.667     12.47749089
   Americas       0               0                     762.667     88.68732678
   China          0               0                     762.667     12.90114498
...   
If you have a formula to update the rho and eta then you can just apply the formula before the solve:

Code: Select all

set nn(n) / Asia, Europe, America, China /;
coefs(nn,'rho') = coefs(nn,'rho')*1.1;
coefs(nn,'eta') = coefs(nn,'eta')/0.9;
solve hark maximizing obj using nlp;
or if you have a selected number scenarios with data you want to enter then you can do it as follows:

Code: Select all

Table rhoeta(*,n,*)

               rho         eta           
s1.Asia       762.667      7.198010732 
s1.Europe     762.667     12.47749089
s1.Americas   762.667     88.68732678
s1.China      762.667     12.90114498
*
s2.Asia       763.667      7.00000000 
s2.Europe     763.667     12.00000000
s2.Americas   763.667     88.00000000
s2.China      763.667     12.00000000
*
s3.Asia       764.667      7.50000000 
s3.Europe     764.667     12.50000000
s3.Americas   764.667     88.50000000
s3.China      764.667     12.50000000
;

set nn(n) / Asia, Europe, America, China /;
coefs(nn,'rho') = rhoeta('s1',nn,'rho');
coefs(nn,'eta') = rhoeta('s1',nn,'eta');
solve hark maximizing obj using nlp;

coefs(nn,'rho') = rhoeta('s2',nn,'rho');
coefs(nn,'eta') = rhoeta('s2',nn,'eta');
solve hark maximizing obj using nlp;

...
I was also puzzled to see three solve statements in your code. Nothing changes for the model between the solves and you get identical solutions. But perhaps you were in the middle of development when you send the code.

-Michael
chessosskar
User
User
Posts: 12
Joined: 2 years ago

Re: Rerunning the model with different data

Post by chessosskar »

Thank you so much. That is very helpful. I would never have thought of doing it that way.
Post Reply