"Indexing" variables Topic is solved

Problems with syntax of GAMS
Post Reply
abhosekar
Moderator
Moderator
Posts: 295
Joined: 3 years ago

Re: "Indexing" variables

Post by abhosekar »

It is not clear what you are trying to do. It is also difficult to point out the error without looking at .gms file. I am not sure if the line you have mentioned in the question is the code or pseudo code.
Assuming it is your code,

Few things to look at:
1. How do you define set k, l? Do both k and l have '1' and '2' elements in it or is the domain of variable s is being violated?
2. The equal sign in gams is =e=
3. The statement should end with a semicolon
4. If you are not using set l in the equation, then you need not define equation as D(l). Writing D.. should suffice.

Please take a look at https://www.gams.com/latest/docs/UG_MAI ... l_Examples for tutorials.

- Atharv
abhosekar
Moderator
Moderator
Posts: 295
Joined: 3 years ago

Re: "Indexing" variables

Post by abhosekar »

Several issues.
1. you are defining set l as /pa, le/ but in defining parameter Cc, you use paris and lemans. Same with set k which gives you domain violation error.
2. The tables in your code is not aligned. Columns need to aligned. Please refer https://www.gams.com/latest/docs/UG_Dat ... try_Tables to see how tables are defined.
An example would be as follows.

Code: Select all

     
   Pa   Le
Re 89.6 213
Na 240 115;
3. you are defining variable s(k, l). As a result GAMS expects you index s with 'Re', 'Na', 'Pa', 'Le'. You are indexing with '1' and '2' which are not in sets k and l. The equation should be rewritten as follows:
s( 'Re','Pa') + s('Le','Re') =e= s('Re','Le') + s( 'Na','Le');

- Atharv
User avatar
kevinlech
User
User
Posts: 1
Joined: 3 years ago

Re: "Indexing" variables

Post by kevinlech »

This is really helpful to me, thank you
Post Reply