* par-defn-sim.inc

DISPLAY "#### START: par-defn-sim.inc";


* START: required for running Chile application using ISIM


* start: parametro para considerar lag entre plantacion y producción


  
LOOP(ffor,

  lagforprodsel = lagforprodsim(sim,ffor);

  scalttp(t,tp,ffor,simcur)$(ORD(tp)>=ORD(t) AND ORD(tp)<ORD(t)+lagforprodsel) = 1/lagforprodsel;  

);

scalttp(t,t,ffor,simcur)$(NOT SUM((tpp,tppp,fforp), scalttp(tpp,tppp,fforp,simcur))) = 1;


* end: parametro para considerar lag entre plantacion y producción




* start: shock aumento plantacion forestal con lag


dqfsexogsimscalttp(sim,ffor,t) = SUM(tp, dqfsexogsim(sim,ffor,tp)*scalttp(tp,t,ffor,sim));

dqfsexogsimdummy(sim,ffor,t) = dqfsexogsim(sim,ffor,t);

dqfsexogsim(sim,ffor,t) = dqfsexogsimscalttp(sim,ffor,t);

* end: shock aumento plantacion forestal con lag



* start: costo y financiamiento intervenciones

ddkinssim(sim,ins2,fcap,t)$costinvgsim(sim,ins2,fcap,t) = costinvgsim(sim,ins2,fcap,t)/PK00(fcap);
dqgsim(sim,c,t)$costcongsim(sim,c,t) = costcongsim(sim,c,t)/SUM(insgov, PQD00(c,insgov));


* end: costo y financiamiento intervenciones




* END: required for running Chile application using ISIM



shrland(f,t)$(NOT shrlandsim(sim,f,t)) = shrland0(f,t);
shrland(f,t)$shrlandsim(sim,f,t)       = shrlandsim(sim,f,t);













* imponer valores simulaciones para variables exogenas

tstar(c,r,t)$(NOT tstarsim(sim,c,r,t) AND NOT tstar2sim(sim,c,r,t)) = tstar0(c,r,t);
tstar(c,r,t)$(tstarsim(sim,c,r,t) AND QER00(c,r))      = tstar0(c,r,t)*tstarsim(sim,c,r,t);
tstar(c,r,t)$(tstar2sim(sim,c,r,t) AND QER00(c,r))     = tstar2sim(sim,c,r,t);

teb(c,r,t)$(NOT tesim(sim,c,r,t)) = teb0(c,r,t);
teb(c,r,t)$tesim(sim,c,r,t)       = teb0(c,r,t)*tesim(sim,c,r,t);

tmb(c,r,t)$(NOT tmsim(sim,c,r,t) AND NOT tm2sim(sim,c,r,t)) = tmb0(c,r,t);
tmb(c,r,t)$(tmsim(sim,c,r,t) AND QMR00(c,r))                = tmb0(c,r,t)*tmsim(sim,c,r,t);
tmb(c,r,t)$(tm2sim(sim,c,r,t) AND QMR00(c,r))               = tm2sim(sim,c,r,t);

tqb(c,t)$(NOT tqbsim(sim,c,t) AND NOT tqb2sim(sim,c,t) AND NOT tqb3sim(sim,c,t)) = tqb0(c,t);
tqb(c,t)$tqbsim(sim,c,t)                                = tqb0(c,t)*tqbsim(sim,c,t);
tqb(c,t)$tqb2sim(sim,c,t)                               = tqb2sim(sim,c,t);
tqb(c,t)$tqb3sim(sim,c,t)                               = tqb0(c,t) + tqb3sim(sim,c,t);

* if at least one element of [c] in tq01sim(sim,c), use tq01sim to define tq01
tq01(c)$(NOT SUM(cp, tq01sim(sim,cp))) = tq010(c);
tq01(c)$(SUM(cp, tq01sim(sim,cp)))     = tq01sim(sim,c);


tab(a,t)$(NOT tasim(sim,a,t) AND NOT ta2sim(sim,a,t)) = tab0(a,t);
tab(a,t)$(tasim(sim,a,t) AND QA00(a))                 = tab0(a,t)*tasim(sim,a,t);
tab(a,t)$(ta2sim(sim,a,t) AND QA00(a))                = ta2sim(sim,a,t);

* if at least one element of [a] in ta01sim(sim,a), use ta01sim to define ta01
ta01(a)$(NOT SUM(ap, ta01sim(sim,ap))) = ta010(a);
ta01(a)$(SUM(ap, ta01sim(sim,ap)))     = ta01sim(sim,a);


tco2b(a,t)$(NOT tco2sim(sim,a,t) AND NOT tco22sim(sim,a,t)) = tco2b0(a,t);
tco2b(a,t)$(tco2sim(sim,a,t))                               = tco2b0(a,t)*tco2sim(sim,a,t);
tco2b(a,t)$(tco22sim(sim,a,t))                              = (tco22sim(sim,a,t)/scaling('samsol'))*scaling('emisol');
tco2b(a,t)$(tco22sim(sim,a,t))                              = tco22sim(sim,a,t);

tvacb(c,ac,t)$(TVAC00(c,ac) AND NOT tvacsim(sim,c,ac,t) AND NOT tvac2sim(sim,c,ac,t)) = tvacb0(c,ac,t);
tvacb(c,ac,t)$(TVAC00(c,ac) AND tvacsim(sim,c,ac,t)) = tvacb0(c,ac,t)*tvacsim(sim,c,ac,t);
tvacb(c,ac,t)$(TVAC00(c,ac) AND tvac2sim(sim,c,ac,t))    = tvac2sim(sim,c,ac,t);

tyb(insdng,t)$(NOT tysim(sim,insdng,t) AND NOT ty2sim(sim,insdng,t)) = tyb0(insdng,t);
tyb(insdng,t)$(tysim(sim,insdng,t) AND YI00(insdng))                 = tyb0(insdng,t)*tysim(sim,insdng,t);
tyb(insdng,t)$(ty2sim(sim,insdng,t) AND YI00(insdng))                = ty2sim(sim,insdng,t);

* if at least one element of [insdng] in ty01sim(sim,insdng), use ty01sim to define ty01
ty01(insdng)$(NOT SUM(insdngp, ty01sim(sim,insdngp))) = ty010(insdng);
ty01(insdng)$(SUM(insdngp, ty01sim(sim,insdngp)))     = ty01sim(sim,insdng);


tfactb(f,a,t)$(NOT tfactsim(sim,f,a,t) AND NOT tfact2sim(sim,f,a,t)) = tfactb0(f,a,t);
tfactb(f,a,t)$(tfactsim(sim,f,a,t) AND QF00(f,a))                    = tfactb0(f,a,t)*tfactsim(sim,f,a,t);
tfactb(f,a,t)$(tfact2sim(sim,f,a,t) AND QF00(f,a))                   = tfact2sim(sim,f,a,t);

subcb(c,ac,t)$(NOT subcsim(sim,c,ac,t) AND NOT subc2sim(sim,c,ac,t)) = subcb0(c,ac,t);
subcb(c,ac,t)$subcsim(sim,c,ac,t)                                    = subcb0(c,ac,t)*subcsim(sim,c,ac,t);
subcb(c,ac,t)$subc2sim(sim,c,ac,t)                                   = subc2sim(sim,c,ac,t);

TUSE.FX(c,d,t)$(NOT TUSE2SIM(sim,c,d,t)) = TUSE0(c,d,t);
TUSE.FX(c,d,t)$TUSE2SIM(sim,c,d,t)       = TUSE2SIM(sim,c,d,t);


PWER.FX(c,r,t)$(NOT mapcred(c,r) AND NOT pwesim(sim,c,r,t)) = PWER0(c,r,t);
PWER.FX(c,r,t)$(NOT mapcred(c,r) AND pwesim(sim,c,r,t))     = PWER0(c,r,t)*pwesim(sim,c,r,t);

PWMR.FX(c,r,t)$(NOT mapcrms(c,r) AND NOT pwmsim(sim,c,r,t)) = PWMR0(c,r,t);
PWMR.FX(c,r,t)$(NOT mapcrms(c,r) AND pwmsim(sim,c,r,t))     = PWMR0(c,r,t)*pwmsim(sim,c,r,t);

qgb(c,t)$(NOT qgbsim(sim,c,t) AND NOT qgb2sim(sim,c,t)) = qgb0(c,t);
qgb(c,t)$qgbsim(sim,c,t)                                = qgb0(c,t)*qgbsim(sim,c,t);
qgb(c,t)$qgb2sim(sim,c,t)                               = qgb0(c,t) + qgb2sim(sim,c,t)/scaling('samsol');

dqg(c,t)$(NOT dqgsim(sim,c,t)) = dqg0(c,t);
dqg(c,t)$(dqgsim(sim,c,t)) = dqgsim(sim,c,t)/scaling('samsol');


trnsfrb(ac,ins,t)$(NOT trnsfrbsim(sim,ac,ins,t)) = trnsfrb0(ac,ins,t);
trnsfrb(ac,ins,t)$trnsfrbsim(sim,ac,ins,t)       = trnsfrb0(ac,ins,t)*trnsfrbsim(sim,ac,ins,t);

* if at least one element of [insdng,insgov] in trnsfr01sim(sim,insdng,insgov), use trnsfr01sim to define trnsfr01
trnsfr01(insdng,insgov,t)$(NOT SUM((insdngp,insgovp), trnsfr01sim(sim,insdngp,insgov,t))) = trnsfr010(insdng,insgov,t);
trnsfr01(insdng,insgov,t)$(SUM((insdngp,insgovp), trnsfr01sim(sim,insdngp,insgov,t)))     = trnsfr01sim(sim,insdng,insgov,t);

dtrnsfr(ac,ins,t)$(NOT dtrnsfrsim(sim,ac,ins,t)) = dtrnsfr0(ac,ins,t);
dtrnsfr(ac,ins,t)$dtrnsfrsim(sim,ac,ins,t)       = dtrnsfrsim(sim,ac,ins,t)/scaling('samsol');

nffngb(t)$(NOT nffngbsim(sim,t) AND NOT nffngb2sim(sim,t)) = nffngb0(t);
nffngb(t)$nffngbsim(sim,t)                                 = nffngb0(t)*nffngbsim(sim,t);
nffngb(t)$nffngb2sim(sim,t)                                = nffngb0(t) + nffngb2sim(sim,t)/scaling('samsol');


tfpexog(a,t)$(NOT tfpexogsim(sim,a,t)) = tfpexog0(a,t);
tfpexog(a,t)$tfpexogsim(sim,a,t) = tfpexog0(a,t)*tfpexogsim(sim,a,t);

* if at least one element of [a] in tfp01sim(sim,a), use tfp01sim to define tfp01
tfp01(a)$(NOT SUM(ap, tfp01sim(sim,ap))) = tfp010(a);
tfp01(a)$(SUM(ap, tfp01sim(sim,ap)))     = tfp01sim(sim,a);

*$ONTEXT
RGDPFC.FX(t)$fixgdp01sim(sim) = RGDPFC0(t)*RGDPFCSIM(sim,t);
CALTFP.LO(t)$fixgdp01sim(sim) = -INF;
CALTFP.UP(t)$fixgdp01sim(sim) = +INF;
  
RGDPFC.LO(t)$(NOT fixgdp01sim(sim)) = -INF;
RGDPFC.UP(t)$(NOT fixgdp01sim(sim)) = +INF;
CALTFP.FX(t)$(NOT fixgdp01sim(sim)) = CALTFP0(t);
*$OFFTEXT


* start: invest as a function of tfp

DDKINSTFP.FX(ins2,fcap,t)$(NOT ddkinstfp01sim(sim,ins2,fcap)) = DDKINSTFP0(ins2,fcap,t);
DDKINSTFP.LO(ins2,fcap,t)$(ddkinstfp01sim(sim,ins2,fcap)) = -INF;
DDKINSTFP.UP(ins2,fcap,t)$(ddkinstfp01sim(sim,ins2,fcap)) = +INF;
ddkinstfp01(ins2,fcap)$(NOT ddkinstfp01sim(sim,ins2,fcap)) = ddkinstfp010(ins2,fcap);
ddkinstfp01(ins2,fcap)$(ddkinstfp01sim(sim,ins2,fcap))     = ddkinstfp01sim(sim,ins2,fcap);

* end: invest as a function of tfp


CPI.FX(t)$(NOT CPISIM(sim,t) AND numerairesim(sim)=1) = CPI0(t);
CPI.FX(t)$(CPISIM(sim,t) AND numerairesim(sim)=1)     = CPI0(t)*CPISIM(sim,t);

REXR.FX(t)$(NOT REXRSIM(sim,t) AND rowclossim(sim)=2) = REXR0(t);
REXR.FX(t)$(REXRSIM(sim,t) AND rowclossim(sim)=2)     = REXR0(t)*REXRSIM(sim,t);


dkinsb(ins2,fcap,t)$(NOT dkinsbsim(sim,ins2,fcap,t)) = dkinsb0(ins2,fcap,t);
dkinsb(ins2,fcap,t)$dkinsbsim(sim,ins2,fcap,t)       = dkinsb0(ins2,fcap,t)*dkinsbsim(sim,ins2,fcap,t);
dkinsb(ins2,fcap,t)$dkinsb2sim(sim,ins2,fcap,t)      = dkinsb0(ins2,fcap,t) + dkinsb2sim(sim,ins2,fcap,t)/scaling('samsol');

*dqinvdest(fcapng,t)$(NOT qinvngbar2sim(sim,fcapng,t)) = dqinvdest0(fcapng,t);
*dqinvdest(fcapng,t)$qinvngbar2sim(sim,fcapng,t)       = qinvngbar2sim(sim,fcapng,t)/scaling('samsol');

dqk(f,a,t)$(NOT dqksim(sim,f,a,t)) = dqk0(f,a,t);
dqk(f,a,t)$(dqksim(sim,f,a,t))     = dqksim(sim,f,a,t)/scaling('samsol');

dqk2(f,a,t)$(NOT dqk2sim(sim,f,a,t)) = dqk20(f,a,t);
dqk2(f,a,t)$(dqk2sim(sim,f,a,t))     = dqk2sim(sim,f,a,t)/scaling('samsol');


*!! ajustar para que en version dinamica sea posible introducir cambios en oferta/demanda capital
QF.FX(f,a,t)$(facclossim(sim,f)=2 AND fncap(f) AND NOT qfacgrwsim(sim,f,t)) = QF0(f,a,t);
QF.FX(f,a,t)$(facclossim(sim,f)=2 AND fncap(f) AND qfacgrwsim(sim,f,t))     = QF0(f,a,t)*qfacgrwsim(sim,f,t);

*QFS.FX(f,t)$((facclossim(sim,f)=1 OR facclossim(sim,f)=4) AND fncap(f) AND NOT qfacgrwsim(sim,f,t)) = QFS0(f,t);
*QFS.FX(f,t)$((facclossim(sim,f)=1 OR facclossim(sim,f)=4) AND fncap(f) AND qfacgrwsim(sim,f,t))     = QFS0(f,t)*qfacgrwsim(sim,f,t);

qdeforb(lndfortot,t)$(NOT qdeforbsim(sim,lndfortot,t) AND NOT qdeforb2sim(sim,lndfortot,t)) = qdeforb0(lndfortot,t);
qdeforb(lndfortot,t)$(qdeforbsim(sim,lndfortot,t))                                = qdeforb0(lndfortot,t)*qdeforbsim(sim,lndfortot,t);
qdeforb(lndfortot,t)$(qdeforb2sim(sim,lndfortot,t))                               = qdeforb0(lndfortot,t) + qdeforb2sim(sim,lndfortot,t)/scaling('qlandsol');
qdeforb(lndfortot,t)$(qdeforbsim(sim,lndfortot,t) AND qdeforb2sim(sim,lndfortot,t)) = 
  qdeforb0(lndfortot,t)*qdeforbsim(sim,lndfortot,t) + qdeforb2sim(sim,lndfortot,t)/scaling('qlandsol');

eta_qdefor(lndfortot)$(NOT eta_qdeforsim(sim,lndfortot)) = eta_qdefor0(lndfortot);
eta_qdefor(lndfortot)$(eta_qdeforsim(sim,lndfortot))     = eta_qdeforsim(sim,lndfortot);



dqdeforb(lndfortot,t)$(NOT dqdeforbsim(sim,lndfortot,t)) = dqdeforb0(lndfortot,t);
dqdeforb(lndfortot,t)$dqdeforbsim(sim,lndfortot,t)       = dqdeforbsim(sim,lndfortot,t)/scaling('qlandsol');



* start: CaC for deforestation

QDEFOR.FX(lndfortot,t)$qdeforcac2sim(sim,lndfortot,t) = qdeforcac2sim(sim,lndfortot,t)/scaling('qlandsol');
TLNDACTSCAL.LO(lndfortot,t)$qdeforcac2sim(sim,lndfortot,t) = -INF;
TLNDACTSCAL.UP(lndfortot,t)$qdeforcac2sim(sim,lndfortot,t) = +INF;

QDEFOR.LO(lndfortot,t)$(NOT qdeforcac2sim(sim,lndfortot,t)) = -INF;
QDEFOR.UP(lndfortot,t)$(NOT qdeforcac2sim(sim,lndfortot,t)) = +INF;
TLNDACTSCAL.FX(lndfortot,t)$(NOT qdeforcac2sim(sim,lndfortot,t)) = 0;

* end: CaC for deforestation


dqfortot(lndfortot,t)$(NOT dqfortotsim(sim,lndfortot,t)) = dqfortot0(lndfortot,t);
dqfortot(lndfortot,t)$(dqfortotsim(sim,lndfortot,t))     = dqfortotsim(sim,lndfortot,t)/scaling('qlandsol');

dqland(lnd,t)$(NOT dqlandsim(sim,lnd,t)) = dqland0(lnd,t);
dqland(lnd,t)$(dqlandsim(sim,lnd,t))     = dqlandsim(sim,lnd,t)/scaling('qlandsol');


qfsexog(f,t)$(NOT qfsexogsim(sim,f,t)) = qfsexog0(f,t);
qfsexog(f,t)$(qfsexogsim(sim,f,t))     = qfsexog0(f,t)*qfsexogsim(sim,f,t);


*!! not imposed if facclos=2
dqfsexog(f,t)$(NOT dqfsexogsim(sim,f,t)) = dqfsexog0(f,t);
dqfsexog(f,t)$(fland(f) AND dqfsexogsim(sim,f,t)) = dqfsexogsim(sim,f,t)/scaling('qlandsol');
dqfsexog(f,t)$(ffor(f) AND dqfsexogsim(sim,f,t))  = dqfsexogsim(sim,f,t)/scaling('qlandsol');
dqfsexog(f,t)$(flab(f) AND dqfsexogsim(sim,f,t))  = dqfsexogsim(sim,f,t)/scaling('qlabsol');



* if at least one element of fcapng in iadj01sim, use iadjsim to define iadj01
iadj01(fcapng)$(NOT SUM(fcapngp, iadj01sim(sim,fcapngp))) = iadj0100(fcapng);
iadj01(fcapng)$(SUM(fcapngp, iadj01sim(sim,fcapngp)))     = iadj01sim(sim,fcapng);

* if at least one element of fcapg in iadj01sim, use iadjsim to define iadj01
iadj01(fcapg)$(NOT SUM(fcapgp, iadj01sim(sim,fcapgp))) = iadj0100(fcapg);
iadj01(fcapg)$(SUM(fcapgp, iadj01sim(sim,fcapgp)))     = iadj01sim(sim,fcapg);

qeb(c,t)$(NOT qebsim(sim,c,t)) = qeb0(c,t);
qeb(c,t)$qebsim(sim,c,t)       = qeb0(c,t)*qebsim(sim,c,t);
qeb(c,t)$qeb2sim(sim,c,t)      = qeb0(c,t) + qeb2sim(sim,c,t)/scaling('samsol');

qdb(c,t)$(NOT qdb2sim(sim,c,t)) = qdb0(c,t);
qdb(c,t)$qdb2sim(sim,c,t)       = qdb0(c,t)*qdb2sim(sim,c,t);
qdb(c,t)$qdb2sim(sim,c,t)      = qdb0(c,t) + qdb2sim(sim,c,t)/scaling('samsol');

fprdb(f,a,t)$(NOT fprdbsim(sim,f,t) AND NOT fprdabsim(sim,f,a,t)) = fprdb0(f,a,t);
fprdb(f,a,t)$(fprdbsim(sim,f,t) AND QF00(f,a))                      = fprdb0(f,a,t)*fprdbsim(sim,f,t);
fprdb(f,a,t)$(fprdabsim(sim,f,a,t) AND QF00(f,a))                   = fprdb0(f,a,t)*fprdabsim(sim,f,a,t);

theta(a,c,t)$(NOT thetasim(sim,a,c,t) AND NOT theta2sim(sim,a,c,t)) = theta0(a,c,t);
theta(a,c,t)$(thetasim(sim,a,c,t))     = theta0(a,c,t)*thetasim(sim,a,c,t);
theta(a,c,t)$(theta2sim(sim,a,c,t))     = theta2sim(sim,a,c,t);



ddkins(ins2,fcap,t)$(NOT ddkinssim(sim,ins2,fcap,t)) = ddkins0(ins2,fcap,t);
ddkins(ins2,fcap,t)$(ddkinssim(sim,ins2,fcap,t))     = ddkins0(ins2,fcap,t) + ddkinssim(sim,ins2,fcap,t)/scaling('samsol');
   
dqfins(ins,f,t)$(NOT dqfinssim(sim,ins,f,t)) = dqfins0(ins,f,t);   
dqfins(ins,f,t)$(dqfinssim(sim,ins,f,t))     = dqfins0(ins,f,t) + dqfinssim(sim,ins,f,t)/scaling('samsol');   

qfinsadj(ins,f,t)$(NOT qfinsadjsim(sim,ins,f,t)) = qfinsadj0(ins,f,t);  
qfinsadj(ins,f,t)$(qfinsadjsim(sim,ins,f,t))     = qfinsadj0(ins,f,t)*qfinsadjsim(sim,ins,f,t);  


* start: definition of mpk

* reset
mpcapgov(fcap) = 0;
mtfp(a,fcap) = 0;
mpk(a,fcap,t) = 0;

mpcapgov(fcap)$(NOT mpcapgovsim(sim,fcap)) = mpcapgov0(fcap);
mpcapgov(fcap)$(mpcapgovsim(sim,fcap))     = mpcapgovsim(sim,fcap);

* if at least one element of a in mtfpsim, use mtfpsim to define mtfp
mtfp(a,fcap)$(NOT SUM(ap, mtfpsim(sim,ap,fcap))) = mtfp0(a,fcap);
mtfp(a,fcap)$(SUM(ap, mtfpsim(sim,ap,fcap)))     = mtfpsim(sim,a,fcap);


* raw definition of MP for act a of change in cap stock fcap
* = (aggregate MP of fcap) * (share of a in GDP) * (relative strength of MP for a from fcap) 
mpksim(sim,a,fcap,t)$(mpcapgov(fcap) AND mtfp(a,fcap)) = 
  mpcapgov(fcap) * (SUM(f, SAM(f,a))/SUM((f,ap), SAM(f,ap))) * mtfp(a,fcap);
DISPLAY mpk00;

* scaling MP for a from f so that sum of activity-specific MPs equals aggregate MP
* if at least one element of a in mtfpsim, use mpksim to define mpk
mpk(a,fcap,t)$(tsol(t) AND NOT SUM(ap, mpksim(sim,ap,fcap,t))) = mpk0(a,fcap,t);
mpk(a,fcap,t)$(tsol(t) AND SUM(ap, mpksim(sim,ap,fcap,t)))     = mpksim(sim,a,fcap,t)/SUM(ap, mpksim(sim,ap,fcap,t)) * mpcapgov(fcap);
mpk('total',fcap,t) = SUM(a, mpk(a,fcap,t));

* end: definition of mpk


* start: re-calibrate CET


delta_esim(sim,c,t)$(delta_e(c) AND tsol(t) AND qeqdratsim(sim,c,t))   = 1 / ( (PDS0(c,t)/PE0(c,t))*(qeqdratsim(sim,c,t)*QE0(c,t)/QD0(c,t))**(1/sigma_x(c)) + 1 );
delta_dssim(sim,c,t)$(delta_DS(c) AND tsol(t) AND qeqdratsim(sim,c,t)) = 1 - delta_esim(sim,c,t);

* change phi_xsim so that QE0 and QD0 with new delta_e and delta_ds are consistent with QX0
phi_xsim(sim,c,t)$(phi_x(c) AND tsol(t) AND qeqdratsim(sim,c,t)) = 
  QX0(c,t) / ( delta_esim(sim,c,t)*QE0(c,t)**rho_x(c) + delta_dssim(sim,c,t)*QD0(c,t)**rho_x(c) ) ** (1/rho_x(c));

phi_xsim(sim,c,t)$(delta_e(c) AND tsol(t) AND NOT qeqdratsim(sim,c,t)) = phi_x(c);
delta_esim(sim,c,t)$(delta_e(c) AND tsol(t) AND NOT qeqdratsim(sim,c,t)) = delta_e(c);
delta_dssim(sim,c,t)$(delta_e(c) AND tsol(t) AND NOT qeqdratsim(sim,c,t)) = delta_ds(c);

* assumption: in ref0 scaldelta_ds, scaldelta_e y scalphi_x are always equal to 1
scaldelta_ds(c,t)$delta_ds(c) = delta_dssim(sim,c,t)/delta_ds(c);
scaldelta_e(c,t)$delta_e(c)   = delta_esim(sim,c,t)/delta_e(c);
scalphi_x(c,t)$phi_x(c)       = phi_xsim(sim,c,t)/phi_x(c);


* end: re-calibrate CET  


qtrstb(c,instrst,t)$(NOT qtrstbsim(sim,c,instrst,t) AND NOT qtrstb2sim(sim,c,instrst,t)) = qtrstb0(c,instrst,t);
qtrstb(c,instrst,t)$qtrstbsim(sim,c,instrst,t)       = qtrstb0(c,instrst,t)*qtrstbsim(sim,c,instrst,t);
qtrstb(c,instrst,t)$qtrstb2sim(sim,c,instrst,t)      = qtrstb0(c,instrst,t) + qtrstb2sim(sim,c,instrst,t)/scaling('samsol');

cedexog(c)$(NOT cedexog01sim(sim,c)) = cedexog010(c);
cedexog(c)$(cedexog01sim(sim,c))     = cedexog01sim(sim,c);



* start: phantom tax for intermediate consumption

QINT.LO(c,a,t)$(QINT00(c,a) AND NOT QINTSIM(sim,c,a,t) AND NOT QINTSIM2(sim,c,a,t)) = -INF;
QINT.UP(c,a,t)$(QINT00(c,a) AND NOT QINTSIM(sim,c,a,t) AND NOT QINTSIM2(sim,c,a,t)) = +INF;
GAMMAC.FX(c,a,t)$(QINT00(c,a) AND NOT QINTSIM(sim,c,a,t)) = GAMMAC0(c,a,t);

QINT.FX(c,a,t)$QINTSIM(sim,c,a,t) = QINT0(c,a,t)*QINTSIM(sim,c,a,t);
GAMMAC.LO(c,a,t)$QINTSIM(sim,c,a,t) = -INF;
GAMMAC.UP(c,a,t)$QINTSIM(sim,c,a,t) = +INF;

* end: phantom tax for intermediate consumption


* start: phantom tax for household consumption

QH.LO(c,h,t)$(QH00(c,h) AND NOT QHSIM(sim,c,h,t) AND NOT QHSIM2(sim,c,h,t)) = -INF;
QH.UP(c,h,t)$(QH00(c,h) AND NOT QHSIM(sim,c,h,t) AND NOT QHSIM2(sim,c,h,t)) = +INF;
GAMMAC.FX(c,h,t)$(QH00(c,h) AND NOT QHSIM(sim,c,h,t)) = GAMMAC0(c,h,t);

QH.FX(c,h,t)$QHSIM(sim,c,h,t) = QH0(c,h,t)*QHSIM(sim,c,h,t);
GAMMAC.LO(c,h,t)$QHSIM(sim,c,h,t) = -INF;
GAMMAC.UP(c,h,t)$QHSIM(sim,c,h,t) = +INF;

* end: phantom tax for household consumption





* start: endogenous tax for exog intermediate consumption

QINT.LO(c,a,t)$(QINT00(c,a) AND NOT QINTSIM2(sim,c,a,t) AND NOT QINTSIM(sim,c,a,t)) = -INF;
QINT.UP(c,a,t)$(QINT00(c,a) AND NOT QINTSIM2(sim,c,a,t) AND NOT QINTSIM(sim,c,a,t)) = +INF;
TUSE.FX(c,a,t)$(QINT00(c,a) AND NOT QINTSIM2(sim,c,a,t)) = TUSE0(c,a,t);

QINT.FX(c,a,t)$QINTSIM2(sim,c,a,t) = QINT0(c,a,t)*QINTSIM2(sim,c,a,t);
TUSE.LO(c,a,t)$QINTSIM2(sim,c,a,t) = -INF;
TUSE.UP(c,a,t)$QINTSIM2(sim,c,a,t) = +INF;

* end: endogenous tax for exog intermediate consumption



* start: endogenous tax for exog household consumption

QH.LO(c,h,t)$(QH00(c,h) AND NOT QHSIM2(sim,c,h,t) AND NOT QHSIM(sim,c,h,t)) = -INF;
QH.UP(c,h,t)$(QH00(c,h) AND NOT QHSIM2(sim,c,h,t) AND NOT QHSIM(sim,c,h,t)) = +INF;
TUSE.FX(c,h,t)$(QH00(c,h) AND NOT QHSIM2(sim,c,h,t)) = TUSE0(c,h,t);

QH.FX(c,h,t)$QHSIM2(sim,c,h,t) = QH0(c,h,t)*QHSIM2(sim,c,h,t);
TUSE.LO(c,h,t)$QHSIM2(sim,c,h,t) = -INF;
TUSE.UP(c,h,t)$QHSIM2(sim,c,h,t) = +INF;

* end: endogenous tax for exog household consumption




* start: Price Regulation -------------------------------------------


* activities

aregpa(a)$(NOT aregpa01sim(sim,a)) = aregpa010(a);
aregpa(a)$(aregpa01sim(sim,a))     = aregpa01sim(sim,a);

REGPA.FX(a,t)$(NOT aregpa(a)) = REGPA0(a,t);
PAREAL.LO(a,t)$(NOT aregpa(a))   = -INF;
PAREAL.UP(a,t)$(NOT aregpa(a))   = +INF;

REGPA.LO(a,t)$aregpa(a) = -INF;
REGPA.UP(a,t)$aregpa(a) = +INF;
REGPA.L(a,t)$aregpa(a) = 0.5;
PAREAL.FX(a,t)$(aregpa(a) AND NOT PAREALSIM(sim,a,t)) = PAREAL0(a,t);
PAREAL.FX(a,t)$(aregpa(a) AND PAREALSIM(sim,a,t))     = PAREAL0(a,t)*PAREALSIM(sim,a,t);

* supply price composite commodities 

cregpqs(c)$(NOT cregpqs01sim(sim,c)) = cregpqs010(c);
cregpqs(c)$(cregpqs01sim(sim,c))     = cregpqs01sim(sim,c);

REGPQS.FX(c,t)$(NOT cregpqs(c)) = REGPQS0(c,t);
PQSREAL.LO(c,t)$(NOT cregpqs(c))   = -INF;
PQSREAL.UP(c,t)$(NOT cregpqs(c))   = +INF;

REGPQS.LO(c,t)$cregpqs(c) = -INF;
REGPQS.UP(c,t)$cregpqs(c) = +INF;
PQSREAL.FX(c,t)$(cregpqs(c) AND NOT PQSREALSIM(sim,c,t)) = PQSREAL0(c,t);
PQSREAL.FX(c,t)$(cregpqs(c) AND PQSREALSIM(sim,c,t))     = PQSREAL0(c,t)*PQSREALSIM(sim,c,t);

* demand price composite commodities 

cregpqd(c,d)$(NOT cregpqd01sim(sim,c,d) AND SAM(c,d)) = cregpqd010(c,d);
cregpqd(c,d)$(cregpqd01sim(sim,c,d) AND SAM(c,d))     = cregpqd01sim(sim,c,d);

REGPQD.FX(c,d,t)$(NOT cregpqd(c,d) AND SAM(c,d)) = REGPQD0(c,d,t);
PQDREAL.LO(c,d,t)$(NOT cregpqd(c,d) AND SAM(c,d))   = -INF;
PQDREAL.UP(c,d,t)$(NOT cregpqd(c,d) AND SAM(c,d))   = +INF;

REGPQD.LO(c,d,t)$(cregpqd(c,d) AND SAM(c,d)) = -INF;
REGPQD.UP(c,d,t)$(cregpqd(c,d) AND SAM(c,d)) = +INF;
PQDREAL.FX(c,d,t)$(cregpqd(c,d) AND NOT PQDREALSIM(sim,c,d,t) AND SAM(c,d)) = PQDREAL0(c,d,t);
PQDREAL.FX(c,d,t)$(cregpqd(c,d) AND PQDREALSIM(sim,c,d,t) AND SAM(c,d))     = PQDREAL0(c,d,t)*PQDREALSIM(sim,c,d,t);

* domestic commodities

cregpds(c)$(NOT cregpds01sim(sim,c)) = cregpds010(c);
cregpds(c)$(cregpds01sim(sim,c))     = cregpds01sim(sim,c);


REGPDS.FX(c,t)$(NOT cregpds(c)) = REGPDS0(c,t);
PDSREAL.LO(c,t)$(NOT cregpds(c))   = -INF;
PDSREAL.UP(c,t)$(NOT cregpds(c))   = +INF;

REGPDS.LO(c,t)$cregpds(c) = -INF;
REGPDS.UP(c,t)$cregpds(c) = +INF;
PDSREAL.FX(c,t)$(cregpds(c) AND NOT PDSREALSIM(sim,c,t)) = PDSREAL0(c,t);
PDSREAL.FX(c,t)$(cregpds(c) AND PDSREALSIM(sim,c,t))     = PDSREAL0(c,t)*PDSREALSIM(sim,c,t);

* end: Price Regulation ---------------------------------------------

qheff(c,h,t)$(NOT qheffsim(sim,c,h,t)) = qheff0(c,h,t);
qheff(c,h,t)$(qheffsim(sim,c,h,t))     = qheff0(c,h,t)*qheffsim(sim,c,h,t);


ica(c,a,t)$(NOT icasim(sim,c,a,t)) = ica0(c,a,t);
ica(c,a,t)$(icasim(sim,c,a,t))     = ica0(c,a,t)*icasim(sim,c,a,t);

iva(a,t)$(NOT ivasim(sim,a,t)) = iva0(a,t);
iva(a,t)$(ivasim(sim,a,t))     = iva0(a,t)*ivasim(sim,a,t);

inta(a,t)$(NOT intasim(sim,a,t)) = inta0(a,t);
inta(a,t)$(intasim(sim,a,t))     = inta0(a,t)*intasim(sim,a,t);

fdib(fcapng,t)$(NOT fdisim(sim,fcapng,t)) = fdib0(fcapng,t);  
fdib(fcapng,t)$fdisim(sim,fcapng,t)       = fdib0(fcapng,t)*fdisim(sim,fcapng,t);  
fdib(fcapng,t)$fdi2sim(sim,fcapng,t)      = fdib0(fcapng,t) + fdi2sim(sim,fcapng,t)/scaling('samsol');  

 
*govrecindexsim(sim,netforfingov,t)$(NOT NFFGSIM(sim,t)) = 0;
*govrecindexsim(sim,netforfingov,t)$NFFGSIM(sim,t)       = (NFFGSIM(sim,t)/scaling('samsol') + NFFG0(t))/NFFG0(t);

NFFG.FX(t)$(govclossim(sim,t) NE 3 AND govrecrulesim(sim,'netforfingov') EQ 1 AND NOT NFFGSIM(sim,t)) = NFFG0(t);
NFFG.FX(t)$(govclossim(sim,t) NE 3 AND govrecrulesim(sim,'netforfingov') EQ 1 AND NFFGSIM(sim,t))     = NFFG0(t) + NFFGSIM(sim,t)/scaling('samsol');



iemi(ghg,ac,acp,t)$(NOT iemisim(sim,ghg,ac,acp,t)) = iemi0(ghg,ac,acp,t);
iemi(ghg,ac,acp,t)$(iemisim(sim,ghg,ac,acp,t))     = iemi0(ghg,ac,acp,t)*iemisim(sim,ghg,ac,acp,t);


* if at least one element of a in ainvff01sim, use ainvff01sim to define ainvff01
ainvff01(a)$(NOT SUM(ap, ainvff01sim(sim,ap))) = ainvff010(a);
ainvff01(a)$(SUM(ap, ainvff01sim(sim,ap)))     = ainvff01sim(sim,a);




DISPLAY "#### END: par-defn-sim.inc";

