new command `evaluate_planner_objective`

dynare#1678
issue#70
Houtan Bastani 2019-12-12 11:28:07 +01:00
parent 5430bb4bc6
commit 8dfa79a0f5
No known key found for this signature in database
GPG Key ID: 000094FB955BE169
6 changed files with 39 additions and 1 deletions

View File

@ -1008,6 +1008,22 @@ RamseyPolicyStatement::writeJsonOutput(ostream &output) const
<< "}";
}
EvaluatePlannerObjective::EvaluatePlannerObjective()
{
}
void
EvaluatePlannerObjective::writeOutput(ostream &output, const string &basename, bool minimal_workspace) const
{
output << "oo_.planner_objective_value = evaluate_planner_objective(M_, options_, oo_);" << endl;
}
void
EvaluatePlannerObjective::writeJsonOutput(ostream &output) const
{
output << R"({"statementName": "evaluate_planner_objective"})";
}
DiscretionaryPolicyStatement::DiscretionaryPolicyStatement(SymbolList symbol_list_arg,
OptionsList options_list_arg) :
symbol_list{move(symbol_list_arg)},

View File

@ -254,6 +254,14 @@ public:
void writeJsonOutput(ostream &output) const override;
};
class EvaluatePlannerObjective : public Statement
{
public:
EvaluatePlannerObjective();
void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
void writeJsonOutput(ostream &output) const override;
};
class DiscretionaryPolicyStatement : public Statement
{
private:

View File

@ -114,7 +114,7 @@ class ParsingDriver;
%token SHOCKS SHOCK_DECOMPOSITION SHOCK_GROUPS USE_SHOCK_GROUPS SIGMA_E SIMUL SIMUL_ALGO SIMUL_SEED ENDOGENOUS_TERMINAL_PERIOD
%token SMOOTHER SMOOTHER2HISTVAL SQUARE_ROOT_SOLVER STACK_SOLVE_ALGO STEADY_STATE_MODEL SOLVE_ALGO SOLVER_PERIODS ROBUST_LIN_SOLVE
%token STDERR STEADY STOCH_SIMUL SYLVESTER SYLVESTER_FIXED_POINT_TOL REGIMES REGIME REALTIME_SHOCK_DECOMPOSITION CONDITIONAL UNCONDITIONAL
%token TEX RAMSEY_MODEL RAMSEY_POLICY RAMSEY_CONSTRAINTS PLANNER_DISCOUNT DISCRETIONARY_POLICY DISCRETIONARY_TOL
%token TEX RAMSEY_MODEL RAMSEY_POLICY RAMSEY_CONSTRAINTS PLANNER_DISCOUNT DISCRETIONARY_POLICY DISCRETIONARY_TOL EVALUATE_PLANNER_OBJECTIVE
%token <string> TEX_NAME
%token UNIFORM_PDF UNIT_ROOT_VARS USE_DLL USEAUTOCORR GSA_SAMPLE_FILE USE_UNIVARIATE_FILTERS_IF_SINGULARITY_IS_DETECTED
%token VALUES VAR VAREXO VAREXO_DET VARIABLE VAROBS VAREXOBS PREDETERMINED_VARIABLES VAR_EXPECTATION VAR_EXPECTATION_MODEL PLOT_SHOCK_DECOMPOSITION MODEL_LOCAL_VARIABLE
@ -254,6 +254,7 @@ statement : parameters
| ramsey_model
| ramsey_policy
| ramsey_constraints
| evaluate_planner_objective
| discretionary_policy
| bvar_density
| bvar_forecast
@ -2349,6 +2350,10 @@ ramsey_constraint : NAME LESS expression ';'
{ driver.ramsey_constraint_add_greater_equal($1,$3); }
;
evaluate_planner_objective : EVALUATE_PLANNER_OBJECTIVE ';'
{ driver.evaluate_planner_objective(); }
;
discretionary_policy : DISCRETIONARY_POLICY ';'
{ driver.discretionary_policy(); }
| DISCRETIONARY_POLICY '(' discretionary_policy_options_list ')' ';'

View File

@ -148,6 +148,7 @@ DATE -?[0-9]+([ya]|m([1-9]|1[0-2])|q[1-4]|w([1-9]{1}|[1-4][0-9]|5[0-2]))
<INITIAL>planner_objective {BEGIN DYNARE_STATEMENT; return token::PLANNER_OBJECTIVE;}
<INITIAL>ramsey_model {BEGIN DYNARE_STATEMENT; return token::RAMSEY_MODEL;}
<INITIAL>ramsey_policy {BEGIN DYNARE_STATEMENT; return token::RAMSEY_POLICY;}
<INITIAL>evaluate_planner_objective {BEGIN DYNARE_STATEMENT; return token::EVALUATE_PLANNER_OBJECTIVE;}
<INITIAL>discretionary_policy {BEGIN DYNARE_STATEMENT; return token::DISCRETIONARY_POLICY;}
<INITIAL>identification {BEGIN DYNARE_STATEMENT; return token::IDENTIFICATION;}

View File

@ -2201,6 +2201,12 @@ ParsingDriver::add_to_ramsey_policy_list(string name)
ramsey_policy_list.push_back(move(name));
}
void
ParsingDriver::evaluate_planner_objective()
{
mod_file->addStatement(make_unique<EvaluatePlannerObjective>());
}
void
ParsingDriver::discretionary_policy()
{

View File

@ -658,6 +658,8 @@ public:
void add_ramsey_constraint(const string &name, BinaryOpcode op_code, const expr_t rhs);
//! Ramsey policy statement
void ramsey_policy();
//! Evaluate Planner Objective
void evaluate_planner_objective();
//! Discretionary policy statement
void discretionary_policy();
//! Adds a write_latex_dynamic_model statement