Hi professor. I am student of mathematics in Equator and I began to study problems and theory related with dynamic optimization. Also, I began to learn how to program easy problems in GAMS. I don't Know if you have time for helping me. I have a big headache because of a program that I did. It tries to represent the behaviour of household that make decision about consumption and savings. The problem is in the last period since nothing is save. I know the mathematic reazons about this problem, but I tried to find some rule for avoiding it, similar to which that you use in order to endogenize the post terminal capital in a simple ramsey model). Do you know some rule for avoiding null-terminal-savings and how to introduce it in the formulation of the household problem ? Thanks a lot for the help you could give me.
$title State Variable Targetting in an NLP Framework * This program illustrates how to use recursive NLP methods * for solving an infinite-horizon optimization model with minimal * terminal effects. * Thomas F. Rutherford * December 1, 2005 $if not set horizon $set horizon 2020 set t Time periods /2005*%horizon%/, tlast(t) Last time period /%horizon%/ tfirst(t) First time period /2005/; parameter kvs Capital value share /0.3/ delta Capital depreciation rate /0.07/ r Baseline interest rate / 0.05/ g Growth rate /0.02/, phi Production scale faster L(t) Labor supply kinit Initial capital stock kterm Terminal capital stock dfactor Discount factor; L(t) = power(1+g, ord(t)-1); kinit = 0.5 * kvs / (r + delta); dfactor(t) = power(1/(1+r), ord(t)-1); phi = 1 / kinit**kvs; VARIABLES C(t) Consumption trillion US dollars, K(t) Capital stock trillion US dollars, I(t) Investment trillion US dollars, Y(t) Output net abatement and damage costs, UTILITY Maximand; POSITIVE VARIABLES Y, C, K, I; EQUATIONS UTIL Objective function CC(t) Consumption YY(t) Output KK(t) Capital balance TERMCAP Terminal capital stock constraint; CC(t).. C(t) =E= Y(t) - I(t); YY(t).. Y(t) =E= phi * L(t)**(1-kvs) * K(t)**kvs; KK(t).. K(t) =L= (1-delta)**10 * K(t-1) + 10 * I(t-1) + kinit$tfirst(t); TERMCAP.. kterm =e= sum(tlast, (1-delta)**10 * K(tlast) + 10 * I(tlast)); UTIL.. UTILITY =E= SUM(t, 10 * dfactor(t) * L(t) * LOG(C(t)/L(t))); model ramsey /all/; C.L(t) = 1; C.LO(t) = 0.01; K.L(t) = 1; K.LO(t) = 0.01; I.L(t) = 1; Y.L(t) = 1; set iter /iter1*iter12/; kterm = kinit * power(1+g,card(t)); parameter invest Investment in successive iterations; loop(iter, solve ramsey maximizing UTILITY using NLP; invest(t,iter) = I.L(t); kterm = sum(tlast(t), K.L(tlast) * Y.L(t)/Y.L(t-1)); ); set tl(*) Time periods /2010,2030,2050,2070,2090/; $setglobal domain t $setglobal labels tl $libinclude plot invest
$title GAMS Script for testing horizon sensitivity set t /2005*2040/; $if not exist 2010.gdx $call gams model --horizon=2010 gdx=2010 $if not exist 2020.gdx $call gams model --horizon=2020 gdx=2020 $if not exist 2040.gdx $call gams model --horizon=2040 gdx=2040 $call gdxmerge 2010.gdx 2020.gdx 2040.gdx set h(t) /2010,2020,2040/; variable i(h,t); $gdxin merged.gdx $load i alias (t,tt); loop(t, loop(h(tt), i.l(h,t)$(ord(t) > ord(tt)) = na;)); parameter horizon Investment paths for alternative horizons; horizon(t,h) = i.l(h,t); set tl(t) /2010,2020,2030,2040/ $setglobal domain t $setglobal labels tl $libinclude plot horizon