Commit 1db8b0d2 authored by sebastien's avatar sebastien
Browse files

Homotopy:

* fixed bug with Octave in modes 1 and 3
* enhanced tests


git-svn-id: https://www.dynare.org/svn/dynare/trunk@2832 ac1d8469-bf42-47a9-8791-bf33cf982152
parent d448eb4e
......@@ -23,7 +23,7 @@ function homotopy1(values, step_nbr)
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2008 Dynare Team
% Copyright (C) 2008-2009 Dynare Team
%
% This file is part of Dynare.
%
......@@ -48,7 +48,7 @@ function homotopy1(values, step_nbr)
ix = find(values(:,1) == 1); % Exogenous
ixd = find(values(:,1) == 2); % Exogenous deterministic
if length([ip, ix, ixd]) ~= nv
if length([ip; ix; ixd]) ~= nv
error('HOMOTOPY mode 1: incorrect variable types specified')
end
......
......@@ -25,7 +25,7 @@ function homotopy2(values, step_nbr)
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2008 Dynare Team
% Copyright (C) 2008-2009 Dynare Team
%
% This file is part of Dynare.
%
......
......@@ -25,7 +25,7 @@ function homotopy3(values, step_nbr)
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2008 Dynare Team
% Copyright (C) 2008-2009 Dynare Team
%
% This file is part of Dynare.
%
......@@ -52,7 +52,7 @@ function homotopy3(values, step_nbr)
ix = find(values(:,1) == 1); % Exogenous
ixd = find(values(:,1) == 2); % Exogenous deterministic
if length([ip, ix, ixd]) ~= nv
if length([ip; ix; ixd]) ~= nv
error('HOMOTOPY mode 3: incorrect variable types specified')
end
......
......@@ -16,7 +16,9 @@ OCTAVE_MODS = \
arima/mod2.mod \
arima/mod2c.mod \
fs2000/fs2000.mod \
homotopy/ramst_homotopy.mod \
homotopy/homotopy1_test.mod \
homotopy/homotopy2_test.mod \
homotopy/homotopy3_test.mod \
bvar_a_la_sims/bvar_standalone.mod \
bvar_a_la_sims/bvar_and_dsge.mod
......
......@@ -6,8 +6,30 @@ alph=0.5;
gam=0.5;
delt=0.02;
aa=0.5;
bet=0.05;
model;
c + k - aa*x*k(-1)^alph - (1-delt)*k(-1);
c^(-gam) - (1+bet)^(-1)*(aa*alph*x(+1)*k^(alph-1) + 1 - delt)*c(+1)^(-gam);
end;
initval;
x = 1;
k = ((delt+bet)/(aa*x*alph))^(1/(alph-1));
c = aa*x*k^alph-delt*k;
end;
homotopy_setup;
bet, 0.05, 0.1;
x, 2;
end;
steady(homotopy_mode = @{homotopy_mode}, homotopy_steps = 50);
if abs(oo_.steady_state(1)/(aa*oo_.exo_steady_state(1)*oo_.steady_state(2)^alph-delt*oo_.steady_state(2)) - 1) > 1e-4
error('Error in homotopy for c')
end
if abs(oo_.steady_state(2)/((delt+get_param_by_name('bet'))/(aa*oo_.exo_steady_state(1)*alph))^(1/(alph-1)) - 1) > 1e-4
error('Error in homotopy for k')
end
@#define homotopy_mode = 1
@#include "common.mod"
@#define homotopy_mode = 2
@#include "common.mod"
// This test is not very thorough since homotopy will succeed at first step...
@#define homotopy_mode = 3
@#include "common.mod"
// Computes the steady state which should be arrived at in ramst_homotopy.mod
@#include "common.mod"
bet = 0.1;
initval;
x = 2;
k = ((delt+bet)/(1.0*aa*alph))^(1/(alph-1));
c = aa*k^alph-delt*k;
end;
steady;
// Contains the test for homotopy.
// The values in initval block are obtained from ramst_initial.mod
// Result of the computation should be the same than in ramst_final.mod
@#include "common.mod"
initval;
k = 12.75;
c = 1.5;
x = 1;
end;
homotopy_setup;
bet, 0.05, 0.1;
x, 2;
end;
steady(homotopy_mode = 2, homotopy_steps = 50);
//steady(homotopy_mode = 2, homotopy_steps = 50);
//steady(homotopy_mode = 3, homotopy_steps = 50);
// Computes the steady state used in initval block of ramst_homotopy.mod
@#include "common.mod"
bet=0.05;
initval;
x = 1;
k = ((delt+bet)/(1.0*aa*alph))^(1/(alph-1));
c = aa*k^alph-delt*k;
end;
steady;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment