Fix error message when “ramsey_policy” follows a “ramsey_model” statement
By the way, also fix error message when there are several “ramsey_model” or “ramsey_policy” statements. Closes: #90fix-tolerance-parameters
parent
b78ac1d31f
commit
17c5e1935d
|
@ -2054,6 +2054,13 @@ ParsingDriver::end_planner_objective(expr_t expr)
|
||||||
void
|
void
|
||||||
ParsingDriver::ramsey_model()
|
ParsingDriver::ramsey_model()
|
||||||
{
|
{
|
||||||
|
// Some checks to ensure correct error messages (see #90)
|
||||||
|
if (ramsey_policy_seen)
|
||||||
|
error("A 'ramsey_model' statement cannot follow a 'ramsey_policy' statement.");
|
||||||
|
if (ramsey_model_seen)
|
||||||
|
error("Several 'ramsey_model' statements cannot appear in a given .mod file.");
|
||||||
|
ramsey_model_seen = true;
|
||||||
|
|
||||||
if (!mod_file->symbol_table.exists("optimal_policy_discount_factor"))
|
if (!mod_file->symbol_table.exists("optimal_policy_discount_factor"))
|
||||||
{
|
{
|
||||||
if (!planner_discount)
|
if (!planner_discount)
|
||||||
|
@ -2081,6 +2088,13 @@ ParsingDriver::ramsey_policy()
|
||||||
{
|
{
|
||||||
warning("The 'ramsey_policy' statement is deprecated. Please use 'ramsey_model', 'stoch_simul', and 'evaluate_planner_objective' instead.");
|
warning("The 'ramsey_policy' statement is deprecated. Please use 'ramsey_model', 'stoch_simul', and 'evaluate_planner_objective' instead.");
|
||||||
|
|
||||||
|
// Some checks to ensure correct error messages (see #90)
|
||||||
|
if (ramsey_model_seen)
|
||||||
|
error("A 'ramsey_policy' statement cannot follow a 'ramsey_model' statement.");
|
||||||
|
if (ramsey_policy_seen)
|
||||||
|
error("Several 'ramsey_policy' statements cannot appear in a given .mod file.");
|
||||||
|
ramsey_policy_seen = true;
|
||||||
|
|
||||||
if (!mod_file->symbol_table.exists("optimal_policy_discount_factor"))
|
if (!mod_file->symbol_table.exists("optimal_policy_discount_factor"))
|
||||||
{
|
{
|
||||||
if (!planner_discount)
|
if (!planner_discount)
|
||||||
|
|
|
@ -274,6 +274,11 @@ private:
|
||||||
//! True when parsing pac_model statement
|
//! True when parsing pac_model statement
|
||||||
bool parsing_pac_model{false};
|
bool parsing_pac_model{false};
|
||||||
|
|
||||||
|
//! True if a ramsey_model statement has already been seen
|
||||||
|
bool ramsey_model_seen{false};
|
||||||
|
//! True if a ramsey_policy statement has already been seen
|
||||||
|
bool ramsey_policy_seen{false};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ParsingDriver(WarningConsolidation &warnings_arg, bool nostrict_arg) :
|
ParsingDriver(WarningConsolidation &warnings_arg, bool nostrict_arg) :
|
||||||
warnings{warnings_arg}, nostrict{nostrict_arg}
|
warnings{warnings_arg}, nostrict{nostrict_arg}
|
||||||
|
|
Loading…
Reference in New Issue