Hi everyone,

I had a problem with expressing the following equation

Here ε and η are constant parameters. z(t) and x(t) should be two variables with set t. I tried to write the equation as this: z(t+1) =e= z(t)*(1-1/η) + ε *x(t)

However, the code failed and returned error 149. I want to know how to express t+1 for my variable z(t) or I need to find the general equation for z(t)?

Thanks for your help!

Here is my first attempt

```
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 /80/
d marginal cost of "backup tech" /6/
e constant cost of GHG /0.25/
eta residence time of GHG /100/
epsilon emission factor /0.1/
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
v(t) quantities of renewable energy extracted per period
z(t) GHG stock
;
equations
obj_func objective function
dem_curve(t) demand curve
cons total available resource
GHG_stock GHG stock equation of motion
;
obj_func.. nb =e= sum(t, exp(-r*t.val) * (a*(x(t)+v(t))- 0.5*b*(x(t)+v(t))**2 - c*x(t)-d*v(t)-e*z(t)**2)) ;
dem_curve(t).. p(t) =e= a - (b*(x(t)+v(t)));
cons.. sum(t,x(t)) =e= Q;
GHG_stock.. z(t+1) =e= z(t)*(1-1/eta) + epsilon*x(t)
model extraction /obj_func, dem_curve, cons,GHG_stock/;
* set lower bounds to avoid errors and ensure a meaningful solution
x.lo(t) = 0;
p.lo(t) = 0;
v.lo(t) = 0;
z.fx(t)$(ord(t)=1) =1;
solve extraction using nlp maximizing nb;
lambda(t)$(x.l(t) > 0) = exp(-r*t.val)*(a - b*x.l(t)-c);
display lambda;
```

And my second attempt returns error 143 that a suffix is missing

```
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 /80/
d marginal cost of "backup tech" /6/
e constant cost of GHG /0.25/
eta residence time of GHG /100/
epsilon emission factor /0.1/
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
v(t) quantities of renewable energy extracted per period
z(t) GHG stock
;
equations
obj_func objective function
dem_curve(t) demand curve
cons total available resource
GHG_stock GHG stock equation of motion
;
obj_func.. nb =e= sum(t, exp(-r*t.val) * (a*(x(t)+v(t))- 0.5*b*(x(t)+v(t))**2 - c*x(t)-d*v(t)-e*z(t)**2)) ;
dem_curve(t).. p(t) =e= a - (b*(x(t)+v(t)));
cons.. sum(t,x(t)) =e= Q;
model extraction /obj_func, dem_curve, cons/;
* set lower bounds to avoid errors and ensure a meaningful solution
x.lo(t) = 0;
p.lo(t) = 0;
v.lo(t) = 0;
loop(t,
z.fx(t)$(ord(t)=1) =1;
z(t+1) = z(t)*(1-1/eta) + epsilon*x(t);
solve extraction using nlp maximizing nb;
)
lambda(t)$(x.l(t) > 0) = exp(-r*t.val)*(a - b*x.l(t)-c);
display lambda;
```