************************************************************ * Ramsey Model * ************************************************************ Sets t time / 0*98 / *** Cannot make t larger due to demo version restrictions T0(t) initial time T1(t) final time; T0(T) = yes$(ord(t) eq 1); T1(T) = yes$(ord(t) eq card(t)); Scalars a /5.0/ k /3.0/ b initial capital / 15.0 / x0 /0.0/ x1 /100.0/ Variables u(t) production output x(t) capital stock j utility; Parameters f(u) function f(u) u\(a*(1+u\k)) Equations kk(t) capital stock balance jj objective function; kk(t+1).. x(t+1) =e= f(u) - g(x); jj.. j =e= sum(t, u(t)); *** Initial values and constraints x.fx(T0)=x0; x.fx(T1)=x1; u.lo(t)=0; *** Turn off unnesessary listing option solprint = off; option limrow = 0; option limcol = 0; Model growth / all /; Solve growth maximizing j using nlp; *** Show the results display x.l, u.l; *************************************************************** * Download gnuplotxyz library to draw graphs * (http://www.uni-hamburg.de/Wiss/FB/15/Sustainability/schneider/gnuplot/) *************************************************************** Parameter PLOT_1 data for plotter; PLOT_1("graph",t,"y")=c.l(t); PLOT_1("graph",t,"x")=ord(t); $libinclude gnuplotxyz PLOT_1 x y