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

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:

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)

I think the GAMS error messages are quite useful:

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

Line 6 reads:

6  demand.. qd =e= beta/(p**ed) ;

GAMS variables have there default level at 0. So move p.l away from 0:

p.l=1;

Next you get:

**** 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_ModelSolve.html#UG_ModelSolve_ModelClassificationOfModels_MCP). Since you don’t do explicit matching anyway, this model can be solved as a CNS (https://www.gams.com/latest/docs/UG_ModelSolve.html#UG_ModelSolve_ModelClassificationOfModels_CNS). Here is the entire working model:

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

Thank you, that was very helpful!