parent
1e4eadb266
commit
02ee077663
|
@ -2269,7 +2269,7 @@ PlannerObjectiveStatement::checkPass(ModFileStructure &mod_file_struct, WarningC
|
||||||
assert(model_tree.equation_number() == 1);
|
assert(model_tree.equation_number() == 1);
|
||||||
if (model_tree.exoPresentInEqs())
|
if (model_tree.exoPresentInEqs())
|
||||||
{
|
{
|
||||||
cerr << "ERROR: You cannot include exogenous variables in the planner objective. Please "
|
cerr << "ERROR: You cannot include exogenous variables (or variables of undeclared type) in the planner objective. Please "
|
||||||
<< "define an auxiliary endogenous variable like eps_aux=epsilon and use it instead "
|
<< "define an auxiliary endogenous variable like eps_aux=epsilon and use it instead "
|
||||||
<< "of the varexo." << endl;
|
<< "of the varexo." << endl;
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
|
|
@ -321,8 +321,9 @@ ParsingDriver::add_model_variable(const string &name)
|
||||||
}
|
}
|
||||||
catch (SymbolTable::UnknownSymbolNameException &e)
|
catch (SymbolTable::UnknownSymbolNameException &e)
|
||||||
{
|
{
|
||||||
// Declare variable as exogenous to continue parsing
|
/* Declare variable as exogenous to continue parsing. Processing will end
|
||||||
// processing will end at end of model block if nostrict option was not passed
|
at end of model block (or planner_objective statement) if nostrict
|
||||||
|
option was not passed. */
|
||||||
declare_exogenous(name);
|
declare_exogenous(name);
|
||||||
undeclared_model_vars.insert(name);
|
undeclared_model_vars.insert(name);
|
||||||
symb_id = mod_file->symbol_table.getID(name);
|
symb_id = mod_file->symbol_table.getID(name);
|
||||||
|
@ -785,6 +786,7 @@ ParsingDriver::end_model()
|
||||||
exit_after_write = true;
|
exit_after_write = true;
|
||||||
cerr << it.second << endl;
|
cerr << it.second << endl;
|
||||||
}
|
}
|
||||||
|
undeclared_model_variable_errors.clear();
|
||||||
|
|
||||||
if (exit_after_write)
|
if (exit_after_write)
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
@ -2022,6 +2024,21 @@ ParsingDriver::end_planner_objective(expr_t expr)
|
||||||
|
|
||||||
mod_file->addStatement(make_unique<PlannerObjectiveStatement>(*planner_objective));
|
mod_file->addStatement(make_unique<PlannerObjectiveStatement>(*planner_objective));
|
||||||
|
|
||||||
|
// Handle undeclared variables (see #81)
|
||||||
|
bool exit_after_write = false;
|
||||||
|
if (undeclared_model_variable_errors.size() > 0)
|
||||||
|
for (auto &it : undeclared_model_variable_errors)
|
||||||
|
if (nostrict)
|
||||||
|
warning(it.second);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
exit_after_write = true;
|
||||||
|
cerr << it.second << endl;
|
||||||
|
}
|
||||||
|
undeclared_model_variable_errors.clear();
|
||||||
|
if (exit_after_write)
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
|
||||||
reset_data_tree();
|
reset_data_tree();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue