Debian Codegraph @

tests/optimal_policy/neo_growth_ramsey_foresight.mod

raw
1 /*
2 * Copyright © 2021 Dynare Team
3 *
4 * This file is part of Dynare.
5 *
6 * Dynare is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * Dynare is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with Dynare. If not, see <https://www.gnu.org/licenses/>.
18 */
19 /*
20 * This file simulates a perfect-foresight version of the neo-classical growth model.
21 * It assesses the conditional and unconditional welfares computed by the evaluate_planner_objective function
22 * and compares them to a by-hand assessment stemming from the results of the model neo_growth_foresight.mod
23 */
24
25 @#include "neo_growth_ramsey_common.inc"
26
27 shocks;
28 var e;
29 periods 1;
30 values 1;
31 end;
32
33 perfect_foresight_setup(periods=200);
34 perfect_foresight_solver;
35
36 planner_objective_value = evaluate_planner_objective(M_, options_, oo_);
37
38 if ~isfile('neo_growth_foresight_results.mat')
39 error('neo_growth_foresight must be run first')
40 end;
41
42 oo1 = load(['neo_growth_foresight' filesep 'Output' filesep 'neo_growth_foresight_results'],'oo_');
43 M1 = load(['neo_growth_foresight' filesep 'Output' filesep 'neo_growth_foresight_results'],'M_');
44 options1 = load(['neo_growth_foresight' filesep 'Output' filesep 'neo_growth_foresight_results'],'options_');
45 cond_W_hand = oo1.oo_.endo_simul(strmatch('W',M1.M_.endo_names,'exact'),2);
46 unc_W_hand = oo1.oo_.endo_simul(strmatch('W',M1.M_.endo_names,'exact'),end);
47
48 if abs((unc_W_hand - planner_objective_value.unconditional)/unc_W_hand) > 1e-6;
49 error('Inaccurate unconditional welfare assessment');
50 end;
51 if abs((cond_W_hand - planner_objective_value.conditional)/cond_W_hand) > 1e-6;
52 error('Inaccurate conditional welfare assessment');
53 end;