CEG Model
CEG Model
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 11 times
Re: CEG Model
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
there is no such dollar control option
You define "LEGUMES" to be an element of subset X(i) where there is no such element LEGUMES in superset i.
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)
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
[...]
Code: Select all
98 LEGUMES
**** $170
**** 170 Domain violation for element
99 AUT_VIVR_LOC
[...]
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
[...]
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)
Re: CEG Model
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 8 times

 MCS2015.xlsx
 MCS
 (49.9 KiB) Downloaded 13 times
Re: CEG Model
Hi Baud
Gams tells you exactly what is wrong with your code: In the case of the error
Gams puts the $148 below Baud. If you go up in your code, you will find that you define and import Baud as a fourdimensional parameter. Gams tells you that you reference Baud with more/less indices as declared because you use Baud as a twodimensional 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
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
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
Enjoy modeling even more: Read my blog on modeling at The lazy economist
Re: CEG Model
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....
Thanks....
 Attachments

 Untitled_2.gms
 (41.06 KiB) Downloaded 11 times
Re: CEG Model
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.
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
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));
Cheers
Renger
Enjoy modeling even more: The lazy economist
____________________________________
Enjoy modeling even more: Read my blog on modeling at The lazy economist
Enjoy modeling even more: Read my blog on modeling at The lazy economist
Re: CEG Model
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...
Cheers...
Re: CEG Model
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 1k(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:
Hope this helps
Renger
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 1k(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
Renger
____________________________________
Enjoy modeling even more: Read my blog on modeling at The lazy economist
Enjoy modeling even more: Read my blog on modeling at The lazy economist