adding discretionary policy for linear quadratic models, thanks to code provided by Junior
parent
cb1e8a55b1
commit
8adee6b673
|
@ -216,6 +216,53 @@ RamseyPolicyStatement::writeOutput(ostream &output, const string &basename) cons
|
|||
output << "ramsey_policy(var_list_);\n";
|
||||
}
|
||||
|
||||
DiscretionaryPolicyStatement::DiscretionaryPolicyStatement(const SymbolList &symbol_list_arg,
|
||||
const OptionsList &options_list_arg) :
|
||||
symbol_list(symbol_list_arg),
|
||||
options_list(options_list_arg)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
DiscretionaryPolicyStatement::checkPass(ModFileStructure &mod_file_struct)
|
||||
{
|
||||
mod_file_struct.discretionary_policy_present = true;
|
||||
|
||||
/* Fill in option_order of mod_file_struct
|
||||
Since discretionary policy needs one further order of derivation (for example, for 1st order
|
||||
approximation, it needs 2nd derivatives), we add 1 to the order declared by user */
|
||||
OptionsList::num_options_t::const_iterator it = options_list.num_options.find("order");
|
||||
if (it != options_list.num_options.end())
|
||||
{
|
||||
int order = atoi(it->second.c_str());
|
||||
if (order > 1)
|
||||
{
|
||||
cerr << "ERROR: discretionary_policy: order > 1 is not yet implemented" << endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
mod_file_struct.order_option = max(mod_file_struct.order_option, order + 1);
|
||||
}
|
||||
|
||||
// Fill in mod_file_struct.partial_information
|
||||
it = options_list.num_options.find("partial_information");
|
||||
if (it != options_list.num_options.end() && it->second == "1")
|
||||
mod_file_struct.partial_information = true;
|
||||
|
||||
// Option k_order_solver (implicit when order >= 3)
|
||||
it = options_list.num_options.find("k_order_solver");
|
||||
if ((it != options_list.num_options.end() && it->second == "1")
|
||||
|| mod_file_struct.order_option >= 3)
|
||||
mod_file_struct.k_order_solver = true;
|
||||
}
|
||||
|
||||
void
|
||||
DiscretionaryPolicyStatement::writeOutput(ostream &output, const string &basename) const
|
||||
{
|
||||
options_list.writeOutput(output);
|
||||
symbol_list.writeOutput("var_list_", output);
|
||||
output << "discretionary_policy(var_list_);\n";
|
||||
}
|
||||
|
||||
EstimationStatement::EstimationStatement(const SymbolList &symbol_list_arg,
|
||||
const OptionsList &options_list_arg,
|
||||
const SymbolTable &symbol_table_arg) :
|
||||
|
|
|
@ -103,6 +103,18 @@ public:
|
|||
virtual void writeOutput(ostream &output, const string &basename) const;
|
||||
};
|
||||
|
||||
class DiscretionaryPolicyStatement : public Statement
|
||||
{
|
||||
private:
|
||||
const SymbolList symbol_list;
|
||||
const OptionsList options_list;
|
||||
public:
|
||||
DiscretionaryPolicyStatement(const SymbolList &symbol_list_arg,
|
||||
const OptionsList &options_list_arg);
|
||||
virtual void checkPass(ModFileStructure &mod_file_struct);
|
||||
virtual void writeOutput(ostream &output, const string &basename) const;
|
||||
};
|
||||
|
||||
class RplotStatement : public Statement
|
||||
{
|
||||
private:
|
||||
|
|
|
@ -121,7 +121,7 @@ class ParsingDriver;
|
|||
%token RELATIVE_IRF REPLIC RPLOT SAVE_PARAMS_AND_STEADY_STATE
|
||||
%token SHOCKS SHOCK_DECOMPOSITION SIGMA_E SIMUL SIMUL_ALGO SIMUL_SEED SMOOTHER STACK_SOLVE_ALGO STEADY_STATE_MODEL SOLVE_ALGO
|
||||
%token STDERR STEADY STOCH_SIMUL
|
||||
%token TEX RAMSEY_POLICY PLANNER_DISCOUNT
|
||||
%token TEX RAMSEY_POLICY PLANNER_DISCOUNT DISCRETIONARY_POLICY
|
||||
%token <string_val> TEX_NAME
|
||||
%token UNIFORM_PDF UNIT_ROOT_VARS USE_DLL USEAUTOCORR
|
||||
%token VALUES VAR VAREXO VAREXO_DET VAROBS PREDETERMINED_VARIABLES
|
||||
|
@ -217,6 +217,7 @@ statement : parameters
|
|||
| model_info
|
||||
| planner_objective
|
||||
| ramsey_policy
|
||||
| discretionary_policy
|
||||
| bvar_density
|
||||
| bvar_forecast
|
||||
| sbvar
|
||||
|
@ -1302,6 +1303,16 @@ ramsey_policy : RAMSEY_POLICY ';'
|
|||
{ driver.ramsey_policy(); }
|
||||
;
|
||||
|
||||
discretionary_policy : DISCRETIONARY_POLICY ';'
|
||||
{ driver.discretionary_policy(); }
|
||||
| DISCRETIONARY_POLICY '(' ramsey_policy_options_list ')' ';'
|
||||
{ driver.discretionary_policy(); }
|
||||
| DISCRETIONARY_POLICY symbol_list ';'
|
||||
{ driver.discretionary_policy(); }
|
||||
| DISCRETIONARY_POLICY '(' ramsey_policy_options_list ')' symbol_list ';'
|
||||
{ driver.discretionary_policy(); }
|
||||
;
|
||||
|
||||
ramsey_policy_options_list : ramsey_policy_options_list COMMA ramsey_policy_options
|
||||
| ramsey_policy_options
|
||||
;
|
||||
|
|
|
@ -130,6 +130,7 @@ string eofbuff;
|
|||
<INITIAL>Sigma_e {BEGIN DYNARE_STATEMENT; sigma_e = 1; return token::SIGMA_E;}
|
||||
<INITIAL>planner_objective {BEGIN DYNARE_STATEMENT; return token::PLANNER_OBJECTIVE;}
|
||||
<INITIAL>ramsey_policy {BEGIN DYNARE_STATEMENT; return token::RAMSEY_POLICY;}
|
||||
<INITIAL>discretionary_policy {BEGIN DYNARE_STATEMENT; return token::DISCRETIONARY_POLICY;}
|
||||
<INITIAL>identification {BEGIN DYNARE_STATEMENT; return token::IDENTIFICATION;}
|
||||
|
||||
<INITIAL>bvar_density {BEGIN DYNARE_STATEMENT; return token::BVAR_DENSITY; }
|
||||
|
|
|
@ -1243,6 +1243,14 @@ ParsingDriver::ramsey_policy()
|
|||
options_list.clear();
|
||||
}
|
||||
|
||||
void
|
||||
ParsingDriver::discretionary_policy()
|
||||
{
|
||||
mod_file->addStatement(new DiscretionaryPolicyStatement(symbol_list, options_list));
|
||||
symbol_list.clear();
|
||||
options_list.clear();
|
||||
}
|
||||
|
||||
void
|
||||
ParsingDriver::write_latex_dynamic_model()
|
||||
{
|
||||
|
|
|
@ -376,8 +376,10 @@ public:
|
|||
void begin_planner_objective();
|
||||
//! End a planner objective statement
|
||||
void end_planner_objective(expr_t expr);
|
||||
//! ramsey policy statement
|
||||
//! Ramsey policy statement
|
||||
void ramsey_policy();
|
||||
//! Discretionary policy statement
|
||||
void discretionary_policy();
|
||||
//! Adds a write_latex_dynamic_model statement
|
||||
void write_latex_dynamic_model();
|
||||
//! Adds a write_latex_static_model statement
|
||||
|
|
|
@ -29,6 +29,7 @@ ModFileStructure::ModFileStructure() :
|
|||
osr_params_present(false),
|
||||
optim_weights_present(false),
|
||||
ramsey_policy_present(false),
|
||||
discretionary_policy_present(false),
|
||||
planner_objective_present(false),
|
||||
order_option(0),
|
||||
bvar_present(false),
|
||||
|
|
|
@ -50,6 +50,8 @@ public:
|
|||
bool optim_weights_present;
|
||||
//! Whether a ramsey_policy statement is present
|
||||
bool ramsey_policy_present;
|
||||
//! Whether a discretionary_objective statement is present
|
||||
bool discretionary_policy_present;
|
||||
//! Whether a planner_objective statement is present
|
||||
bool planner_objective_present;
|
||||
//! The value of the "order" option of stoch_simul, estimation, osr, ramsey_policy
|
||||
|
|
Loading…
Reference in New Issue