Error 148
Posted: Sat Dec 04, 2021 1:54 am
Hello Everyone,
I had an error148 when I tried to run my code. It's really confusing, and I can't find the problem with my equation expression. Thanks for your help!
sets
t periods /0*50/
;
alias (t,tt);
parameters
a demand curve intercept /8/
b demand curve slope /0.4/
C marginal extraction cost /2/
r discount rate /0.05/
Q total resource available /40/
lambda marginal user cost
;
variables
x(t) quantities extracted per period
p(t) price of extracted resource per period
nb present value of net benefit
;
equations
obj_func objective function
dem_curve(t) demand curve
cons total available resource
;
obj_func.. nb =e= sum(t, (exp(-r*t)) * (x(t)*(a-((0.5*b)*x(t)) -c)));
dem_curve(t).. p(t) =e= a - (b*x(t));
cons.. Q =e= sum(t,x(t));
model extraction /obj_func, dem_curve, cons/;
* set lower bounds to avoid errors and ensure a meaningful solution
x.lo = 0;
p.lo = 0;
solve extraction using nlp maximizing nb;
lambda(t)$(x.l(t) > 0) = exp(-r*t)*(a - b*x(t)-c);
display lambda;
I had an error148 when I tried to run my code. It's really confusing, and I can't find the problem with my equation expression. Thanks for your help!
sets
t periods /0*50/
;
alias (t,tt);
parameters
a demand curve intercept /8/
b demand curve slope /0.4/
C marginal extraction cost /2/
r discount rate /0.05/
Q total resource available /40/
lambda marginal user cost
;
variables
x(t) quantities extracted per period
p(t) price of extracted resource per period
nb present value of net benefit
;
equations
obj_func objective function
dem_curve(t) demand curve
cons total available resource
;
obj_func.. nb =e= sum(t, (exp(-r*t)) * (x(t)*(a-((0.5*b)*x(t)) -c)));
dem_curve(t).. p(t) =e= a - (b*x(t));
cons.. Q =e= sum(t,x(t));
model extraction /obj_func, dem_curve, cons/;
* set lower bounds to avoid errors and ensure a meaningful solution
x.lo = 0;
p.lo = 0;
solve extraction using nlp maximizing nb;
lambda(t)$(x.l(t) > 0) = exp(-r*t)*(a - b*x(t)-c);
display lambda;