CEG Model

Problems with syntax of GAMS
Post Reply
Baud1094
User
User
Posts: 9
Joined: 4 years ago

CEG Model

Post by Baud1094 »

Hello everyone. My name is Baudouin. For my master thesis, i work on a CEG modele in GAMS. I alreay closed the modele but i have some errors. Please help me to correct errors. Thanks
Attachments
Untitled_2.gms
(36.63 KiB) Downloaded 231 times
Fred
Posts: 372
Joined: 7 years ago

Re: CEG Model

Post by Fred »

Hi,

I suggest to run with command line parameter errmsg=1 (https://www.gams.com/latest/docs/UG_Gam ... MSAOerrmsg) to reposition compilation error messages in the lst file and then go through you errors step by step by searching for four asterisks (****) in the lst file (they mark an error). You will find things like

Code: Select all

   1  $Memoire 2019
****   $210
**** 210  Unknown dollar control option. Valid are -
****        Error, Debug, Eject, Clear, onMargin, offMargin, minCol
****        maxCol, comment, dollar, onDigit, offDigit, hidden, onText
[...]
there is no such dollar control option

Code: Select all

  98  LEGUMES
****        $170
**** 170  Domain violation for element
  99  AUT_VIVR_LOC
  [...]
You define "LEGUMES" to be an element of subset X(i) where there is no such element LEGUMES in superset i.

Code: Select all

476  k(i) parametre distributif de la fonction de substitution commerciale du produit composite i
****  $195,318
**** 195  Symbol redefined with a different type
**** 318  Domain list redefined - no previous domain list - * assumed
****         when data was associated with this symbol
[...]
You cannot have a parameter k if there is already another symbol K (GAMS is not case sensitive)


There are many more errors, so I hope the hints above give you some useful hints to debug your code yourself.

Best,
Fred

PS If you want other form users to help you, I suggest to provide all the files needed to run your code (there is for example an Excel file)
Baud1094
User
User
Posts: 9
Joined: 4 years ago

Re: CEG Model

Post by Baud1094 »

Thanks for your reply.. I am corrected some errors whith your indication. But errors 148 and 141 persists. I attach the ecxel files that is the MCS (that i use for calibration)..
Attachments
Untitled_2.gms
GAMS CODE
(37.39 KiB) Downloaded 209 times
MCS2015.xlsx
MCS
(49.9 KiB) Downloaded 205 times
User avatar
Renger
Posts: 639
Joined: 7 years ago

Re: CEG Model

Post by Renger »

Hi Baud

Gams tells you exactly what is wrong with your code: In the case of the error

Code: Select all

 625  XSO(j) = Baud("Total Ligne",j);
****                               $148

148  Dimension different - The symbol is referenced with more/less
        indices as declared
Gams puts the $148 below Baud. If you go up in your code, you will find that you define and import Baud as a four-dimensional parameter. Gams tells you that you reference Baud with more/less indices as declared because you use Baud as a two-dimensional parameter. There are two missing.

Take a good look at these error messages. Most of the time they are clear enough to solve your problems.
For the $125 problem, you could try to search this forum, as it has been asked many times before.

Cheers
Renger
____________________________________
Enjoy modeling even more: Read my blog on modeling at The lazy economist
Baud1094
User
User
Posts: 9
Joined: 4 years ago

Re: CEG Model

Post by Baud1094 »

Hello thanks for your reply. Finaly i am correct all syntax error and some runtime error, except one divided by zero) that i dont understand. I note that when I call data of excel file for set "i" for variable "MO(i)", two elements (Laits_frais and Oeuf_Aut_Elev) of this set have not assignement. For me that is source of error.
Thanks....
Attachments
Untitled_2.gms
(41.06 KiB) Downloaded 211 times
User avatar
Renger
Posts: 639
Joined: 7 years ago

Re: CEG Model

Post by Renger »

Hi
If there are no imports, there will be no tariff, so you can change the code to (the $ condition on the left drops the equation when MO(IM) = 0.

Code: Select all

tm(IM)$MO(IM) = DDMO(IM)/(PWMO(IM)*EO*MO(IM));
If you correct this, you will run into other errors that are caused because you do not initialize all your variables (e.g. M, DD), so Gams assumes zero as start values which leads to problems in expressions like M(im,t)** as it is not allowed to raise zero to a power.

Cheers
Renger

Enjoy modeling even more: The lazy economist
____________________________________
Enjoy modeling even more: Read my blog on modeling at The lazy economist
Baud1094
User
User
Posts: 9
Joined: 4 years ago

Re: CEG Model

Post by Baud1094 »

Hi! Thanks for reply. I alredy initialized all variable. I try to put same condition for tm ($MO(IM)) in M(IM,t) equation. But that is not solution. I think that it is still same but condition $ not react in equation M(IM,t).
Cheers...
User avatar
Renger
Posts: 639
Joined: 7 years ago

Re: CEG Model

Post by Renger »

Hi Baud

It is the same kind of problem. You have an equation with a power in it. You can't raise zero to the power, so there are variables or parameters that cause the base to be 0.
You should always check the values in equations like that.
In your case, you have imports equal to zero for the sectors Oeuf_Aut_Elev and Lait_Frais (as in the previous problem), but they are part of the set IM(i) and IM1(i) (imported goods), so they should not be part of these sets.
Furthermore, in the equation, you have made a mistake in the parenthesis causing more problems. Check the parenthesis in the part with 1-k(i) and you will find the other error.

You can find such errors by displaying all the parameters used for setting up the equation (incl. of those used for the initialization of the variables) and defining a test parameter to display the values of parts of the equation and studying the results.
For example:

Code: Select all

test(im,t) = fi(IM)*(k(IM)*(M.L(IM,T)**(-ci(IM)))+(1-(k(IM))*(DD.L(IM,t)**(-ci(IM))))**(-1/ci(IM)));

Code: Select all

----   1377 PARAMETER test  
                            1           2           3           4           5

Mais                     UNDF        UNDF        UNDF        UNDF        UNDF
Riz                     0.379       0.379       0.379       0.379       0.379
Legumes                  UNDF        UNDF        UNDF        UNDF        UNDF
Aut_Vivr_Loc             UNDF        UNDF        UNDF        UNDF        UNDF
Aut_Vivr_Exp             UNDF        UNDF        UNDF        UNDF        UNDF
Hope this helps
Renger
____________________________________
Enjoy modeling even more: Read my blog on modeling at The lazy economist
Baud1094
User
User
Posts: 9
Joined: 4 years ago

Re: CEG Model

Post by Baud1094 »

Hello everyone .. Following a correction of a DSEG model that you helped me corrected, I made a reply with this model that presents me with errors that I can not find. Your help would be very useful for me to make the latest corrections. I joined the model and the MCS. Thank you.
Attachments
Untitled_3.gms
(80.53 KiB) Downloaded 200 times
MCS2015.xlsx
(49.91 KiB) Downloaded 204 times
Post Reply