trunk preprocessor: some cleanups related to sparse mode (removed SimulSparseStatement class and incorporated it into SimulStatement, determine mode at preprocessing time instead of runtime in StochSimulStatement)
git-svn-id: https://www.dynare.org/svn/dynare/trunk@2595 ac1d8469-bf42-47a9-8791-bf33cf982152time-shift
parent
2e9ce1fe1e
commit
da408a908f
|
@ -73,8 +73,8 @@ void ModelInfoStatement::writeOutput(ostream &output, const string &basename) co
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SimulStatement::SimulStatement(const OptionsList &options_list_arg) :
|
SimulStatement::SimulStatement(const OptionsList &options_list_arg, ModelTreeMode mode_arg) :
|
||||||
options_list(options_list_arg)
|
options_list(options_list_arg), mode(mode_arg)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,48 +88,32 @@ void
|
||||||
SimulStatement::writeOutput(ostream &output, const string &basename) const
|
SimulStatement::writeOutput(ostream &output, const string &basename) const
|
||||||
{
|
{
|
||||||
options_list.writeOutput(output);
|
options_list.writeOutput(output);
|
||||||
output << "simul(oo_.dr);\n";
|
if (mode == eStandardMode || mode == eDLLMode)
|
||||||
}
|
output << "simul(oo_.dr);\n";
|
||||||
|
|
||||||
SimulSparseStatement::SimulSparseStatement(const OptionsList &options_list_arg,
|
|
||||||
int mode_arg) :
|
|
||||||
options_list(options_list_arg),
|
|
||||||
mode(mode_arg)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
SimulSparseStatement::checkPass(ModFileStructure &mod_file_struct)
|
|
||||||
{
|
|
||||||
mod_file_struct.simul_present = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
SimulSparseStatement::writeOutput(ostream &output, const string &basename) const
|
|
||||||
{
|
|
||||||
options_list.writeOutput(output);
|
|
||||||
output << "if (~ options_.initval_file) & (size(oo_.endo_simul,2)<options_.periods)\n";
|
|
||||||
output << " if ~isfield(options_,'datafile')\n";
|
|
||||||
output << " make_y_;\n";
|
|
||||||
output << " make_ex_;\n";
|
|
||||||
output << " else\n";
|
|
||||||
output << " read_data_;\n";
|
|
||||||
output << " end\n";
|
|
||||||
output << "end\n";
|
|
||||||
if(mode==eSparseDLLMode)
|
|
||||||
output << "oo_.endo_simul=simulate;\n";
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//output << "oo_.endo_simul=" << basename << "_dynamic();\n";
|
output << "if (~ options_.initval_file) & (size(oo_.endo_simul,2)<options_.periods)" << endl
|
||||||
output << basename << "_dynamic;\n";
|
<< " if ~isfield(options_,'datafile')" << endl
|
||||||
|
<< " make_y_;" << endl
|
||||||
|
<< " make_ex_;" << endl
|
||||||
|
<< " else" << endl
|
||||||
|
<< " read_data_;" << endl
|
||||||
|
<< " end" << endl
|
||||||
|
<< "end" << endl;
|
||||||
|
if (mode == eSparseDLLMode)
|
||||||
|
output << "oo_.endo_simul=simulate;" << endl;
|
||||||
|
else
|
||||||
|
output << basename << "_dynamic;" << endl;
|
||||||
|
output << "dyn2vec;" << endl;
|
||||||
}
|
}
|
||||||
output << "dyn2vec;\n";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
StochSimulStatement::StochSimulStatement(const SymbolList &symbol_list_arg,
|
StochSimulStatement::StochSimulStatement(const SymbolList &symbol_list_arg,
|
||||||
const OptionsList &options_list_arg) :
|
const OptionsList &options_list_arg,
|
||||||
|
ModelTreeMode mode_arg) :
|
||||||
symbol_list(symbol_list_arg),
|
symbol_list(symbol_list_arg),
|
||||||
options_list(options_list_arg)
|
options_list(options_list_arg),
|
||||||
|
mode(mode_arg)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -157,11 +141,10 @@ StochSimulStatement::writeOutput(ostream &output, const string &basename) const
|
||||||
{
|
{
|
||||||
options_list.writeOutput(output);
|
options_list.writeOutput(output);
|
||||||
symbol_list.writeOutput("var_list_", output);
|
symbol_list.writeOutput("var_list_", output);
|
||||||
output << "if (options_.model_mode == 1 || options_.model_mode == 3)\n";
|
if (mode == eStandardMode || mode == eDLLMode)
|
||||||
output << " info = stoch_simul_sparse(var_list_);\n";
|
output << "info = stoch_simul(var_list_);" << endl;
|
||||||
output << "else\n";
|
else
|
||||||
output << " info = stoch_simul(var_list_);\n";
|
output << "info = stoch_simul_sparse(var_list_);" << endl;
|
||||||
output << "end\n";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ForecastStatement::ForecastStatement(const SymbolList &symbol_list_arg,
|
ForecastStatement::ForecastStatement(const SymbolList &symbol_list_arg,
|
||||||
|
|
|
@ -50,19 +50,9 @@ class SimulStatement : public Statement
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
const OptionsList options_list;
|
const OptionsList options_list;
|
||||||
|
const ModelTreeMode mode;
|
||||||
public:
|
public:
|
||||||
SimulStatement(const OptionsList &options_list_arg);
|
SimulStatement(const OptionsList &options_list_arg, ModelTreeMode mode_arg);
|
||||||
virtual void checkPass(ModFileStructure &mod_file_struct);
|
|
||||||
virtual void writeOutput(ostream &output, const string &basename) const;
|
|
||||||
};
|
|
||||||
|
|
||||||
class SimulSparseStatement : public Statement
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
const OptionsList options_list;
|
|
||||||
const int mode;
|
|
||||||
public:
|
|
||||||
SimulSparseStatement(const OptionsList &options_list_arg, int mode_arg);
|
|
||||||
virtual void checkPass(ModFileStructure &mod_file_struct);
|
virtual void checkPass(ModFileStructure &mod_file_struct);
|
||||||
virtual void writeOutput(ostream &output, const string &basename) const;
|
virtual void writeOutput(ostream &output, const string &basename) const;
|
||||||
};
|
};
|
||||||
|
@ -82,9 +72,11 @@ class StochSimulStatement : public Statement
|
||||||
private:
|
private:
|
||||||
const SymbolList symbol_list;
|
const SymbolList symbol_list;
|
||||||
const OptionsList options_list;
|
const OptionsList options_list;
|
||||||
|
const ModelTreeMode mode;
|
||||||
public:
|
public:
|
||||||
StochSimulStatement(const SymbolList &symbol_list_arg,
|
StochSimulStatement(const SymbolList &symbol_list_arg,
|
||||||
const OptionsList &options_list_arg);
|
const OptionsList &options_list_arg,
|
||||||
|
ModelTreeMode mode_arg);
|
||||||
virtual void checkPass(ModFileStructure &mod_file_struct);
|
virtual void checkPass(ModFileStructure &mod_file_struct);
|
||||||
virtual void writeOutput(ostream &output, const string &basename) const;
|
virtual void writeOutput(ostream &output, const string &basename) const;
|
||||||
};
|
};
|
||||||
|
|
|
@ -648,9 +648,9 @@ model_info : MODEL_INFO ';'
|
||||||
;
|
;
|
||||||
|
|
||||||
simul : SIMUL ';'
|
simul : SIMUL ';'
|
||||||
{ driver.simulate(); }
|
{ driver.simul(); }
|
||||||
| SIMUL '(' simul_options_list ')' ';'
|
| SIMUL '(' simul_options_list ')' ';'
|
||||||
{ driver.simulate(); }
|
{ driver.simul(); }
|
||||||
;
|
;
|
||||||
|
|
||||||
simul_options_list : simul_options_list COMMA simul_options
|
simul_options_list : simul_options_list COMMA simul_options
|
||||||
|
|
|
@ -676,34 +676,18 @@ void ParsingDriver::rplot()
|
||||||
|
|
||||||
void ParsingDriver::stoch_simul()
|
void ParsingDriver::stoch_simul()
|
||||||
{
|
{
|
||||||
mod_file->addStatement(new StochSimulStatement(symbol_list, options_list));
|
mod_file->addStatement(new StochSimulStatement(symbol_list, options_list, mod_file->dynamic_model.mode));
|
||||||
symbol_list.clear();
|
symbol_list.clear();
|
||||||
options_list.clear();
|
options_list.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ParsingDriver::simulate()
|
|
||||||
{
|
|
||||||
if (mod_file->dynamic_model.mode == eSparseDLLMode || mod_file->dynamic_model.mode == eSparseMode)
|
|
||||||
simul_sparse();
|
|
||||||
else
|
|
||||||
simul();
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
ParsingDriver::simul_sparse()
|
|
||||||
{
|
|
||||||
mod_file->addStatement(new SimulSparseStatement(options_list, mod_file->dynamic_model.mode));
|
|
||||||
options_list.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ParsingDriver::simul()
|
ParsingDriver::simul()
|
||||||
{
|
{
|
||||||
mod_file->addStatement(new SimulStatement(options_list));
|
mod_file->addStatement(new SimulStatement(options_list, mod_file->dynamic_model.mode));
|
||||||
options_list.clear();
|
options_list.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ParsingDriver::model_info()
|
ParsingDriver::model_info()
|
||||||
{
|
{
|
||||||
|
@ -711,7 +695,6 @@ ParsingDriver::model_info()
|
||||||
options_list.clear();
|
options_list.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ParsingDriver::check()
|
ParsingDriver::check()
|
||||||
{
|
{
|
||||||
|
|
|
@ -282,10 +282,6 @@ public:
|
||||||
void rplot();
|
void rplot();
|
||||||
//! Writes a stock_simul command
|
//! Writes a stock_simul command
|
||||||
void stoch_simul();
|
void stoch_simul();
|
||||||
//! Determine whether to write simul command or simul_sparse command
|
|
||||||
void simulate();
|
|
||||||
//! Writes a simul_sparse command
|
|
||||||
void simul_sparse();
|
|
||||||
//! Writes a simul command
|
//! Writes a simul command
|
||||||
void simul();
|
void simul();
|
||||||
//! Writes check command
|
//! Writes check command
|
||||||
|
|
Loading…
Reference in New Issue