Debian Codegraph @

tests/bgp/ramsey-1/ramsey.mod

raw
1 var c k x;
2
3 parameters alpha gam delta beta ;
4
5 alpha=0.5;
6 gam=0.5;
7 delta=0.02;
8 beta=0.05;
9
10 model;
11 x = x(-1)*1.02;
12 c + k - x^(1-alpha)*k(-1)^alpha - (1-delta)*k(-1);
13 c^(-gam) - (1+beta)^(-1)*(alpha*x(+1)^(1-alpha)*k^(alpha-1) + 1 - delta)*c(+1)^(-gam);
14 end;
15
16 verbatim;
17
18 bgp.write(M_);
19 if isoctave
20 options = optimset('Display', 'iter', 'MaxFunEvals', 1000000,'MaxIter',100000,'Jacobian','on','TolFun',1e-7,'TolX',1e-7);
21 else
22 options = optimoptions('fsolve','Display','iter','Algorithm','levenberg-marquardt','MaxFunctionEvaluations',1000000,'MaxIterations',100000,'SpecifyObjectiveGradient',true,'FunctionTolerance',1e-6,'StepTolerance',1e-6);
23 end
24 y = 1+(rand(M_.endo_nbr,1)-.5)*.25;
25 g = ones(M_.endo_nbr,1);% 1+(rand(M_.endo_nbr,1)-.5)*.1;
26 [y, fval, exitflag] = fsolve(@ramsey.bgpfun, [y;g], options);
27 if ~isoctave
28 % Disable under Octave for the time being, it converges to a solution different
29 % from the one expected.
30 assert(max(abs(y(M_.endo_nbr+(1:M_.orig_endo_nbr))-1.02))<1e-6)
31 end
32 end;