v4 parser: allow for empty model in some cases (actually for standalone BVAR estimation)
git-svn-id: https://www.dynare.org/svn/dynare/dynare_v4@1370 ac1d8469-bf42-47a9-8791-bf33cf982152time-shift
parent
daef6d60b6
commit
446623f576
|
@ -759,7 +759,11 @@ PlannerObjectiveStatement::~PlannerObjectiveStatement()
|
|||
void
|
||||
PlannerObjectiveStatement::checkPass(ModFileStructure &mod_file_struct)
|
||||
{
|
||||
model_tree->checkPass();
|
||||
if (model_tree->equation_number() != 1)
|
||||
{
|
||||
cerr << "Error: planer_objective: should have only one equation!" << endl;
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -26,16 +26,24 @@ ModFile::addStatement(Statement *st)
|
|||
void
|
||||
ModFile::checkPass()
|
||||
{
|
||||
model_tree.checkPass();
|
||||
|
||||
for(vector<Statement *>::iterator it = statements.begin();
|
||||
it != statements.end(); it++)
|
||||
(*it)->checkPass(mod_file_struct);
|
||||
|
||||
// Allow empty model only when doing a standalone BVAR estimation
|
||||
if (model_tree.equation_number() == 0
|
||||
&& (mod_file_struct.check_present
|
||||
|| mod_file_struct.simul_present
|
||||
|| mod_file_struct.stoch_simul_or_similar_present))
|
||||
{
|
||||
cerr << "Error: you must declare at least one model equation!" << endl;
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
if (mod_file_struct.simul_present
|
||||
&& mod_file_struct.stoch_simul_or_similar_present)
|
||||
{
|
||||
cerr << "Error: a mod file cannot contain both a simul command and one of {stoch_simul, estimation, olr, osr}" << endl;
|
||||
cerr << "Error: a mod file cannot contain both a simul command and one of {stoch_simul, estimation, osr, ramsey_policy}" << endl;
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
|
@ -43,6 +51,9 @@ ModFile::checkPass()
|
|||
void
|
||||
ModFile::computingPass()
|
||||
{
|
||||
// Mod file may have no equation (for example in a standalone BVAR estimation)
|
||||
if (model_tree.equation_number() > 0)
|
||||
{
|
||||
// Set things to compute
|
||||
if (mod_file_struct.simul_present)
|
||||
model_tree.computeJacobian = true;
|
||||
|
@ -61,6 +72,7 @@ ModFile::computingPass()
|
|||
}
|
||||
|
||||
model_tree.computingPass(global_eval_context);
|
||||
}
|
||||
|
||||
for(vector<Statement *>::iterator it = statements.begin();
|
||||
it != statements.end(); it++)
|
||||
|
@ -114,6 +126,9 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all) const
|
|||
mOutputFile << "logname_ = '" << basename << ".log';" << endl;
|
||||
mOutputFile << "diary '" << basename << ".log';" << endl;
|
||||
|
||||
|
||||
if (model_tree.equation_number() > 0)
|
||||
{
|
||||
if (model_tree.mode == eDLLMode)
|
||||
{
|
||||
mOutputFile << "if ";
|
||||
|
@ -133,19 +148,21 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all) const
|
|||
mOutputFile << "erase_compiled_function('" + basename +"_dynamic');" << endl;
|
||||
mOutputFile << interfaces::load_model_function_files(basename);
|
||||
}
|
||||
}
|
||||
|
||||
cout << "Processing outputs ..." << endl;
|
||||
|
||||
symbol_table.writeOutput(mOutputFile);
|
||||
|
||||
if (linear == 1)
|
||||
mOutputFile << "options_.linear = 1;" << endl;
|
||||
|
||||
if (model_tree.equation_number() > 0)
|
||||
{
|
||||
model_tree.writeOutput(mOutputFile);
|
||||
|
||||
cout << "Processing outputs ..." << endl;
|
||||
|
||||
model_tree.writeStaticFile(basename);
|
||||
|
||||
model_tree.writeDynamicFile(basename);
|
||||
}
|
||||
|
||||
// Print statements
|
||||
for(vector<Statement *>::const_iterator it = statements.begin();
|
||||
|
|
|
@ -1979,17 +1979,6 @@ ModelTree::addEquation(NodeID eq)
|
|||
equations.push_back(beq);
|
||||
}
|
||||
|
||||
void
|
||||
ModelTree::checkPass() const
|
||||
{
|
||||
// Exit if there is no equation in model file
|
||||
if (equations.size() == 0)
|
||||
{
|
||||
cerr << "No equation found in model file" << endl;
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ModelTree::evaluateJacobian(const eval_context_type &eval_context, jacob_map *j_m)
|
||||
{
|
||||
|
|
|
@ -115,8 +115,6 @@ public:
|
|||
bool new_SGE;
|
||||
//! Declare a node as an equation of the model
|
||||
void addEquation(NodeID eq);
|
||||
//! Do some checking
|
||||
void checkPass() const;
|
||||
//! Whether dynamic Jacobian (w.r. to endogenous) should be written
|
||||
bool computeJacobian;
|
||||
//! Whether dynamic Jacobian (w.r. to endogenous and exogenous) should be written
|
||||
|
|
|
@ -15,9 +15,9 @@ public:
|
|||
bool check_present;
|
||||
//! Whether a simul statement is present
|
||||
bool simul_present;
|
||||
//! Whether a stoch_simul, estimation, olr, osr, ramsey_policy statement is present
|
||||
//! Whether a stoch_simul, estimation, osr, ramsey_policy statement is present
|
||||
bool stoch_simul_or_similar_present;
|
||||
//! The value of the "order" option of stoch_simul, estimation, olr, osr, ramsey_policy
|
||||
//! The value of the "order" option of stoch_simul, estimation, osr, ramsey_policy
|
||||
/*! Defaults to 2 */
|
||||
int order_option;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue