From 03da338b05ec6832e07f194707e25259d12d5bf0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Adjemian=20=28Charybdis=29?= Date: Wed, 25 May 2016 12:45:34 +0200 Subject: [PATCH] Added more informative error messages. --- tests/lmmcp/sw_newton.mod | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/tests/lmmcp/sw_newton.mod b/tests/lmmcp/sw_newton.mod index 60b89d791..074fd8258 100644 --- a/tests/lmmcp/sw_newton.mod +++ b/tests/lmmcp/sw_newton.mod @@ -69,8 +69,22 @@ end; simul(periods=1000); +newton_solution_is_wrong = abs(evaluate_max_dynamic_residual(str2func('sw_newton_dynamic'), oo_.endo_simul, oo_.exo_simul, M_.params, oo_.steady_state, 1000, size(oo_.endo_simul, 1), 1, M_.lead_lag_incidence))>options_.dynatol.f; + lmmcp = load('sw_lmmcp_results'); -if max(max(abs(lmmcp.oo_.endo_simul-oo_.endo_simul)))>options_.dynatol.x - error('LMMCP and Newton algorithms return different results!') +lmmcp_solution_is_wrong = abs(evaluate_max_dynamic_residual(str2func('sw_newton_dynamic'), lmmcp.oo_.endo_simul, lmmcp.oo_.exo_simul, M_.params, oo_.steady_state, 1000, size(oo_.endo_simul, 1), 1, M_.lead_lag_incidence))>options_.dynatol.f; + +solutions_are_different = max(max(abs(lmmcp.oo_.endo_simul-oo_.endo_simul)))>options_.dynatol.x; + +if newton_solution_is_wrong + error('Failed to solve SW with ZLB (using Newton algorithm on stacked model)') end + +if solutions_are_different && ~lmmcp_solution_is_wrong + error('Solutions with Newton and LMMCP algorithms are different!') +end + +if lmmcp_solution_is_wrong + error('Failed to solve SW with ZLB (using LMMCP algorithm on stacked model)!') +end \ No newline at end of file