rPower: FUNC DOMAIN: x**y, x=0,y<0 Topic is solved

Problems with syntax of GAMS
Post Reply
douglaskuo
User
User
Posts: 21
Joined: 2 months ago

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

Post by douglaskuo » 1 month ago

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 16 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 24 times

douglaskuo
User
User
Posts: 21
Joined: 2 months ago

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

Post by douglaskuo » 1 month ago

I delete the more remark "*" (left only one).
But, I have the same errors.

User avatar
Renger
Posts: 633
Joined: 4 years ago

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

Post by Renger » 1 month ago

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
____________________________________
Enjoy modeling even more: Read my blog on modeling at The lazy economist

douglaskuo
User
User
Posts: 21
Joined: 2 months ago

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

Post by douglaskuo » 1 month ago

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

User avatar
Renger
Posts: 633
Joined: 4 years ago

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

Post by Renger » 1 month ago

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
____________________________________
Enjoy modeling even more: Read my blog on modeling at The lazy economist

douglaskuo
User
User
Posts: 21
Joined: 2 months ago

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

Post by douglaskuo » 1 month ago

Dear Renger
Thank you for the help.
Regards,
Douglas

Post Reply