From ee972d96388d0d8482d92bafc81daef49e3036d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= Date: Thu, 30 Jan 2020 15:42:39 +0100 Subject: [PATCH] =?UTF-8?q?Fix=20=E2=80=9Cplanner=5Fdiscount=E2=80=9D=20op?= =?UTF-8?q?tion=20of=20=E2=80=9Cdiscretionary=5Fpolicy=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since fe0c781c06823da40609012ac1e7d6003272ffb5, the discount factor would always be equal to one. Ref. dynare#1699 --- src/ParsingDriver.cc | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/ParsingDriver.cc b/src/ParsingDriver.cc index 98a8192f..1207f43b 100644 --- a/src/ParsingDriver.cc +++ b/src/ParsingDriver.cc @@ -2222,14 +2222,20 @@ ParsingDriver::evaluate_planner_objective() void ParsingDriver::discretionary_policy() { + /* The logic here is different from “ramsey_policy” and “ramsey_model”, + because we want to allow several instances of “discretionary_policy” in + the same .mod file. */ if (!mod_file->symbol_table.exists("optimal_policy_discount_factor")) - { - declare_parameter("optimal_policy_discount_factor"); - init_param("optimal_policy_discount_factor", data_tree->One); - } + declare_parameter("optimal_policy_discount_factor"); + + if (!planner_discount) + planner_discount = data_tree->One; + init_param("optimal_policy_discount_factor", planner_discount); + mod_file->addStatement(make_unique(symbol_list, options_list)); symbol_list.clear(); options_list.clear(); + planner_discount = nullptr; } void