Simple Equilibrium problem with non-linear equations - division by zero

Problems with modeling
Post Reply
saeed
User
User
Posts: 4
Joined: 6 years ago

Simple Equilibrium problem with non-linear equations - division by zero

Post by saeed »

Hello, ;

I am very new to GAMS, and trying to set up a partial equilibrium model. A simplified version is below. But it seems I am not setting it up correctly. I was pretty sure I needed to use MCP I get division by zero errors.

This is the simplified model:

Code: Select all

positive variables qs, qd, p ;
parameters alpha/100/, beta/200/, es/0.4/, ed/0.1/ ;
equations supply, demand, marketclearing ;

supply.. qs =e= alpha*(p**es) ;
demand.. qd =e= beta/(p**ed) ;
marketclearing.. qs =e= qd ;

Model test /all/ ;
Solve test using MCP;
And this is what I get:

supply.. qs - (1000000000000)*p =E= 0 ; (LHS = 0)
demand.. qd - (10000000000)*p =E= 0 ; (LHS = UNDF)
User avatar
bussieck
Moderator
Moderator
Posts: 1033
Joined: 7 years ago

Re: Simple Equilibrium problem with non-linear equations - division by zero

Post by bussieck »

I think the GAMS error messages are quite useful:

Code: Select all

**** Exec Error at line 6: division by zero (0)
Line 6 reads:

Code: Select all

6  demand.. qd =e= beta/(p**ed) ;
GAMS variables have there default level at 0. So move p.l away from 0:

Code: Select all

p.l=1;
Next you get:

Code: Select all

**** Unmatched variable not free or fixed
     qs
Qs is a positive variable. MCP have special requirements (read more about this at https://www.gams.com/latest/docs/UG_Mod ... Models_MCP). Since you don't do explicit matching anyway, this model can be solved as a CNS (https://www.gams.com/latest/docs/UG_Mod ... Models_CNS). Here is the entire working model:

Code: Select all

positive variables qs, qd, p ;
parameters alpha/100/, beta/200/, es/0.4/, ed/0.1/ ;
equations supply, demand, marketclearing ;

supply.. qs =e= alpha*(p**es) ;
demand.. qd =e= beta/(p**ed) ;
marketclearing.. qs =e= qd ;

Model test /all/ ;
p.l=1;
Solve test using cns;
-Michael
saeed
User
User
Posts: 4
Joined: 6 years ago

Re: Simple Equilibrium problem with non-linear equations - division by zero

Post by saeed »

Thank you, that was very helpful!
Post Reply