Help with loop

Hi all,

I need to write a loop to solve the equations below.

utility(ii,t)$(ord(t) le card(a)-1).. u=e=(1/(1-1/gamma))*sum(a,ss(a)*((1+beta(ii))**(1-ord(a)))*(1-1/gamma)*log((c(ii,a,t)**(1-1/rho)+alpha*l(ii,a,t)**(1-1/rho))**(1/(1-1/rho))));

asset(ii,a,t).. as(ii,a,t)=e=(1+r)*as(ii,a-1,t-1)+w(t)*e(ii,a)*(1-l(ii,a,t))+AP(ii,a,t)+NSB(ii,a,t)+SP(ii,a,t)-Tax(ii,a,t)-(1+tau_c)*c(ii,a,t);

income_test(ii,a,t).. API(ii,a,t)=e=max{min{p,p-theta*(inc(iii,a,t)-IT)},0}$(ord(a) ge 45);

solve model /all/;
solve model using dnlp maximizing u;

I am able to loop ii by creating a dynamic set

iii(ii) /1*3/ *dynamic set for ii,
 iii(ii)=no; 
 loop(ii,
 iii(ii)=yes;
 *solve statement
 );

However, as set t and a have orders and lags I am getting errors if I try to write a dynamic set and to turn it off by tt(t)=no;

I need to solve the model by

loop(t,
loop(ii,
);
);

Thanks for all the support you can give me.
Fabio

Hi Fabio
If you use t as a loop you run into problems as you have t-1. In that case, you should remove this variable with index t-1 and replace it by a parameter that is given a value after the solve of the previous loop:
Here a small example:

 K(t) =E= K(t-1) + I(t);

becomes

* Start value for kprev in year 0
kprev = 10;
equations..
...
	K(t) =E= kprev + I(t);
loop(t, 
     solve mymodel;
     kprev = K.L(t);

Cheers
Renger

Hi Renger,

Thanks for your reply.

Fabio