Hi,

I am relatively new to GAMS and am stuck on how to formulate a NLP I am working on. So far I have read through the https://www.gams.com/latest/docs/UG_NLP_GoodFormulations.html docs which have helped with a few bugs but one remains. I am getting a FUNC DOMAIN: x**y, x < 0 error in the objective function when I should not be. See below for the code. Here is the strange part, if I remove the “logsum” portion (the denominator) in the objective function the program complies just fine (no exponentiation error) but when I include the logsum variable in the denominator the error occurs. I have tried flipping the sign of beta and putting that portion of the obj function in the denominator but that doesn’t help.

```
set c column lables /ID, work_dist, income, hhsize, sales_price, unit_sqft, sum_residential_unit, avg_unit_sqft, avg_lot_sqft, l_sales_price, l_unit_sqft, fixed_portion, dist_from_min, b1, b2, b3, row, row_and_ID/
i row lables /i1*i1000/
alias(i,k);
parameter p(i,c);
*$call GDXXRW df_10k_1.xlsx trace=3 par=p rng=Sheet1!a1:s1000 cdim=1 rdim= 1
$GDXIN df_10k_1.gdx
$LOAD p
$GDXIN
free variable profit;
parameter
b3(i)
fixed_portion(i)
sales_price(i);
b3(i) = p(i,'b3');
fixed_portion(i) = p(i,'fixed_portion');
sales_price(i) = p(i,'sales_price');
positive variables subsidy(i) 'subsidy';
subsidy.lo(i) = .0001;
variable logsum;
logsum.lo = .001
scalar budget_constraint /10000/;
scalar beta /-0.114/;
scalar J /1000/;
equations
obj
denom
eq1(i)
eq2(i)
;
denom.. logsum =e= sum(k, fixed_portion(k) * (sales_price(k)-subsidy(k))**beta);
obj..profit =e= sum(i, ((b3(i) - subsidy(i)) * fixed_portion(i)* (sales_price(i)-subsidy(i))**beta) / logsum);
eq1(i).. subsidy(i)=l= budget_constraint;
eq2(i).. subsidy(i)=g= 0;
Model subsidy_opt_test /All/;
option optCR = 1e-6, optCA =1e-6;
solve subsidy_opt_test using NLP maximizing profit;
```