## Division by zero and evaluated to UNDF error

Irena
User Posts: 1
Joined: 1 year ago

### Division by zero and evaluated to UNDF error

Hi,
I encountered an error when I tried to use GAMS to solve my cge model. Specifically, it reports some ‘division by zero (0) error’ and ‘A constant in a nonlinear expression in equation evaluated to UNDF’. In the lst file, it reports ‘problem with the Jacobian evaluation’.
For example:

Code: Select all

``````eqKEFOC(a)..
(PEN(a)/WK)*(EN(a)**(1/sigmake(a)))=e=(deltaen(a)/(1-deltaen(a)))*(K(a)**(1/sigmake(a)));``````
It then reports:
*** Error at line 424: division by zero (0)
*** Error at line 424: A constant in a nonlinear expression in equation eqKEFOC evaluated to UNDF
**** Evaluation error(s) in equation "eqKEFOC(aWater)"
Problem in RHS evaluation
Problem in Jacobian evaluation of "K(aWater)"

It occurs probably because some intermediate input in the SAM is zero. I have tried possible ways to fix it, such as setting a lower bound for the zero endogenous variables, removing the variables from the denominator to the numerator and adding very small number like 0.0001. Sadly all these failed.

Does anyone have a better idea? Many thanks.
bussieck
Moderator Posts: 1019
Joined: 7 years ago

### Re: Division by zero and evaluated to UNDF error

Not clear what is data/parameters and what is a variable in your code snippet. For zeros in data: stay away from divisions, for variables: use a good starting point. The Conopt manual has a good chapter on that: https://www.gams.com/latest/docs/S_CONO ... IAL_VALUES

-Michael