How to code in a neat way?

Problems with syntax of GAMS
Post Reply
alirez.t
User
User
Posts: 1
Joined: 1 month ago

How to code in a neat way?

Post by alirez.t » 1 month ago

Hello guys,

I just wonder if anyone could help me to write these codes better by using vector notation or loop maybe (just three last line before display). I appreciate it.

Code: Select all

Set
SOL           List of all solves           /"1st solve", '2nd solve'/
J             sectoral Production units    /1,2,3/
T             time                         /2000*2004/;

Parameter
OTHER(T)      Emissions of other greenhouse gasses         
Coef(J,T)     coefficient CO2 emission from total production
RES(SOL,T)    Results for for different scenarios;
OTHER(T)=5;

Table
Coef (J,T)
   2000
1  0.01
2  0.04
3  0.025;

coef("1",T) = 0.01*(0.95**(ORD(T)-1));
coef("2",T) = 0.04*(0.95**(ORD(T)-1));
coef("3",T) = 0.025*(0.95**(ORD(T)-1));

display Coef; 

GFA
User
User
Posts: 34
Joined: 3 years ago

Re: How to code in a neat way?

Post by GFA » 1 month ago

Hi,

One way would be to write it like this:

Code: Select all

Coef (J,T) = Coef (J,"2000")*(0.95**(ORD(T)-1));
Cheers,
GFA

Post Reply