evaluate_planner_objective: add options

Related to https://git.dynare.org/Dynare/dynare/-/merge_requests/1967
pac-components
Johannes Pfeifer 2021-12-03 13:17:34 +01:00
parent a210a8fd59
commit befd432be7
4 changed files with 33 additions and 5 deletions

View File

@ -711,15 +711,26 @@ RamseyPolicyStatement::writeJsonOutput(ostream &output) const
output << "}";
}
void
EvaluatePlannerObjective::writeOutput(ostream &output, const string &basename, bool minimal_workspace) const
EvaluatePlannerObjectiveStatement::EvaluatePlannerObjectiveStatement(OptionsList options_list_arg) :
options_list{move(options_list_arg)}
{
}
void
EvaluatePlannerObjectiveStatement::writeOutput(ostream &output, const string &basename, bool minimal_workspace) const
{
options_list.writeOutput(output);
output << "oo_.planner_objective_value = evaluate_planner_objective(M_, options_, oo_);" << endl;
}
void
EvaluatePlannerObjective::writeJsonOutput(ostream &output) const
EvaluatePlannerObjectiveStatement::writeJsonOutput(ostream &output) const
{
if (options_list.getNumberOfOptions())
{
output << ", ";
options_list.writeJsonOutput(output);
}
output << R"({"statementName": "evaluate_planner_objective"})";
}

View File

@ -199,9 +199,12 @@ public:
void writeJsonOutput(ostream &output) const override;
};
class EvaluatePlannerObjective : public Statement
class EvaluatePlannerObjectiveStatement : public Statement
{
private:
const OptionsList options_list;
public:
EvaluatePlannerObjectiveStatement(OptionsList options_list_arg);
void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
void writeJsonOutput(ostream &output) const override;
};

View File

@ -2456,8 +2456,18 @@ ramsey_constraint : NAME LESS expression ';'
evaluate_planner_objective : EVALUATE_PLANNER_OBJECTIVE ';'
{ driver.evaluate_planner_objective(); }
| EVALUATE_PLANNER_OBJECTIVE '(' evaluate_planner_objective_options_list ')' ';'
{ driver.evaluate_planner_objective(); }
;
evaluate_planner_objective_options_list : evaluate_planner_objective_option COMMA evaluate_planner_objective_options_list
| evaluate_planner_objective_option
;
evaluate_planner_objective_option : o_evaluate_planner_objective_periods
| o_evaluate_planner_objective_drop
;
occbin_setup : OCCBIN_SETUP ';'
{ driver.occbin_setup(); }
| OCCBIN_SETUP '(' occbin_setup_options_list ')' ';'
@ -4037,6 +4047,9 @@ o_checks_via_subsets : CHECKS_VIA_SUBSETS EQUAL INT_NUMBER { driver.option_num("
o_max_dim_subsets_groups : MAX_DIM_SUBSETS_GROUPS EQUAL INT_NUMBER { driver.option_num("max_dim_subsets_groups", $3); };
o_zero_moments_tolerance : ZERO_MOMENTS_TOLERANCE EQUAL non_negative_number { driver.option_num("zero_moments_tolerance", $3); };
// Some options to "evaluate_planner_objective"
o_evaluate_planner_objective_periods : PERIODS EQUAL INT_NUMBER { driver.option_num("ramsey.periods", $3); };
o_evaluate_planner_objective_drop : DROP EQUAL INT_NUMBER { driver.option_num("ramsey.drop", $3); };
// Some options to "occbin_solver"
o_occbin_simul_maxit : SIMUL_MAXIT EQUAL INT_NUMBER { driver.option_num("simul.maxit", $3); };

View File

@ -2098,7 +2098,8 @@ ParsingDriver::ramsey_policy()
void
ParsingDriver::evaluate_planner_objective()
{
mod_file->addStatement(make_unique<EvaluatePlannerObjective>());
mod_file->addStatement(make_unique<EvaluatePlannerObjectiveStatement>(options_list));
options_list.clear();
}
void