Page 1 of 1

rPower: FUNC DOMAIN: x**y, x=0,y<0

Posted: Mon Nov 23, 2020 9:17 am
by douglaskuo
Dear All,
I run and got the error:
rPower: FUNC DOMAIN: x**y, x=0,y<0
Files attached.
samjuly20201019.xlsx
(59.85 KiB) Downloaded 220 times
I appreciate it if someone can help.
Thanks and regards,
Douglas

--- HSRTWN20201115.gms(272) 4 Mb
*** Error at line 272: rPower: FUNC DOMAIN: x**y, x=0,y<0
--- HSRTWN20201115.gms(276) 4 Mb 1 Error
*** Error at line 276: rPower: FUNC DOMAIN: x**y, x=0,y<0
--- HSRTWN20201115.gms(312) 4 Mb 2 Errors
*** Status: Execution error(s)
--- Job HSRTWN20201115.gms Stop 11/23/20 16:10:04 elapsed 0:00:03.331
Exit code = 3
HSRTWN20201115.gms
(13.82 KiB) Downloaded 231 times

Re: rPower: FUNC DOMAIN: x**y, x=0,y<0

Posted: Mon Nov 23, 2020 9:38 am
by douglaskuo
I delete the more remark "*" (left only one).
But, I have the same errors.

Re: rPower: FUNC DOMAIN: x**y, x=0,y<0

Posted: Tue Nov 24, 2020 8:39 am
by Renger
Hi
This kind of error is mostly due to having no starting values for the variables. Gams assumes in that case 0, causing an error in the power function.
As your model is a CGE model, you should start with an equilibrium based on your SAM data. This means if you plug in all the values of your SAM and initialize your prices and production levels to their benchmark levels (most of the time equal to 1) and setting the iteration limit to zero, your model should find a solution. Just search in the forum as I have suggested this in more detail in other posts. (In my workshop, this is my "3 AM message": If I would wake you up in the night at 3 AM and ask you what is the most important thing you should do when working with CGE models, you should answer: Set the iteration limit to 0 and initialize the model properly to check the benchmark!
Eventually, it might be that during the solve the variables become negative. If you are sure that the variables are positive (like prices and quantities) you can define them as positive variables.
Cheers
Renger

Re: rPower: FUNC DOMAIN: x**y, x=0,y<0

Posted: Wed Nov 25, 2020 8:43 am
by douglaskuo
Dear Renger,
Thank you for your reply. I think the error is because the "QDA(a)" or "QE0(a)" is zero.
The code is:
deltaCET(a)=PDA0(a)*QDA0(a)**(1-rhoCET(a))/(PDA0(a)*QDA0(a)**(1-rhoCET(a))+PE0(a)*QE0(a)**(1-rhoCET(a)));
If I want to skip the code if "QDA(a)" or "QE0(a)" is zero, how can I do? Can I amend the code as below?
deltaCET(a)$(QDA(a),QE0(a))=PDA0(a)*QDA0(a)**(1-rhoCET(a))/(PDA0(a)*QDA0(a)**(1-rhoCET(a))+PE0(a)*QE0(a)**(1-rhoCET(a)));
Thank you.
Regards,
Douglas

Re: rPower: FUNC DOMAIN: x**y, x=0,y<0

Posted: Thu Nov 26, 2020 7:53 am
by Renger
Hi

You can add the dollar constraint like this:

Code: Select all

deltaCET(a)$(PDA0(a) > 0 and QE(0) > 0) =PDA0(a)*QDA0(a)**(1-rhoCET(a))/(PDA0(a)*QDA0(a)**(1-rhoCET(a))+PE0(a)*QE0(a)**(1-rhoCET(a)));
Cheers
Renger

Re: rPower: FUNC DOMAIN: x**y, x=0,y<0

Posted: Thu Nov 26, 2020 1:25 pm
by douglaskuo
Dear Renger
Thank you for the help.
Regards,
Douglas