diff --git a/matlab/homotopy1.m b/matlab/homotopy1.m index 1d76eda5d3f16676000a3f02466fa83f9d3d7a34..db11e1de418dc1022c93a1f742adba45d283cd52 100644 --- a/matlab/homotopy1.m +++ b/matlab/homotopy1.m @@ -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 diff --git a/matlab/homotopy2.m b/matlab/homotopy2.m index 2425e12c5a04071265cef431c578ad9ca6203ee7..eb53778d2a428d2322374a214d9be802744c72a3 100644 --- a/matlab/homotopy2.m +++ b/matlab/homotopy2.m @@ -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. % diff --git a/matlab/homotopy3.m b/matlab/homotopy3.m index c3fc9ddbe8513d823d537f31a770886e25e597c8..15148fd227d2ad9871660a45335d7eac9d177361 100644 --- a/matlab/homotopy3.m +++ b/matlab/homotopy3.m @@ -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 diff --git a/tests/Makefile.in b/tests/Makefile.in index 1e18007528f570b98e25cc0d5a74bc235ed220fb..ac940d3813c0019fad53d31bfa89a1c29ef26784 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -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 diff --git a/tests/homotopy/common.mod b/tests/homotopy/common.mod index c643542c57be63b108eaab8ab48e8c1caf9d74d6..347dd464ab64b3cbb022ccfb07ef9682fa98bc57 100644 --- a/tests/homotopy/common.mod +++ b/tests/homotopy/common.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 diff --git a/tests/homotopy/homotopy1_test.mod b/tests/homotopy/homotopy1_test.mod new file mode 100644 index 0000000000000000000000000000000000000000..fe24c5194df0b0ac485db806d9644ddf68430144 --- /dev/null +++ b/tests/homotopy/homotopy1_test.mod @@ -0,0 +1,2 @@ +@#define homotopy_mode = 1 +@#include "common.mod" diff --git a/tests/homotopy/homotopy2_test.mod b/tests/homotopy/homotopy2_test.mod new file mode 100644 index 0000000000000000000000000000000000000000..cf0b8a80d8f805995e7ab7c3e812884abd0e33c4 --- /dev/null +++ b/tests/homotopy/homotopy2_test.mod @@ -0,0 +1,2 @@ +@#define homotopy_mode = 2 +@#include "common.mod" diff --git a/tests/homotopy/homotopy3_test.mod b/tests/homotopy/homotopy3_test.mod new file mode 100644 index 0000000000000000000000000000000000000000..74b5fc6115b447556b5ce2bd070a95110c859027 --- /dev/null +++ b/tests/homotopy/homotopy3_test.mod @@ -0,0 +1,4 @@ +// This test is not very thorough since homotopy will succeed at first step... + +@#define homotopy_mode = 3 +@#include "common.mod" diff --git a/tests/homotopy/ramst_final.mod b/tests/homotopy/ramst_final.mod deleted file mode 100644 index 6e49900aafaf6099d44b1dd1b4abdb36f8b34677..0000000000000000000000000000000000000000 --- a/tests/homotopy/ramst_final.mod +++ /dev/null @@ -1,13 +0,0 @@ -// 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; diff --git a/tests/homotopy/ramst_homotopy.mod b/tests/homotopy/ramst_homotopy.mod deleted file mode 100644 index 368311d3ed79ee8a9df74ef97811ff5a2e26f3d3..0000000000000000000000000000000000000000 --- a/tests/homotopy/ramst_homotopy.mod +++ /dev/null @@ -1,20 +0,0 @@ -// 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); diff --git a/tests/homotopy/ramst_initial.mod b/tests/homotopy/ramst_initial.mod deleted file mode 100644 index 0d74511ddc0e97a8a7304688938613d0f25593b6..0000000000000000000000000000000000000000 --- a/tests/homotopy/ramst_initial.mod +++ /dev/null @@ -1,13 +0,0 @@ -// 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;