- get rid of block and bytcode variable in SimulStatement and StochSimulStatement

- minimalist version of dynamicmodel when no dynamic model is needed

git-svn-id: https://www.dynare.org/svn/dynare/trunk@2883 ac1d8469-bf42-47a9-8791-bf33cf982152
time-shift
ferhat 2009-09-02 16:44:15 +00:00
parent 74232e9ee5
commit 164eb22f87
4 changed files with 44 additions and 33 deletions

View File

@ -79,8 +79,8 @@ void ModelInfoStatement::writeOutput(ostream &output, const string &basename) co
}
SimulStatement::SimulStatement(const OptionsList &options_list_arg, bool block_arg, bool byte_code_arg) :
options_list(options_list_arg), byte_code(byte_code_arg), block(block_arg)
SimulStatement::SimulStatement(const OptionsList &options_list_arg) :
options_list(options_list_arg)
{
}
@ -98,11 +98,9 @@ SimulStatement::writeOutput(ostream &output, const string &basename) const
}
StochSimulStatement::StochSimulStatement(const SymbolList &symbol_list_arg,
const OptionsList &options_list_arg,
bool block_arg) :
const OptionsList &options_list_arg) :
symbol_list(symbol_list_arg),
options_list(options_list_arg),
block(block_arg)
options_list(options_list_arg)
{
}
@ -130,10 +128,7 @@ StochSimulStatement::writeOutput(ostream &output, const string &basename) const
{
options_list.writeOutput(output);
symbol_list.writeOutput("var_list_", output);
if (!block)
output << "info = stoch_simul(var_list_);" << endl;
else
output << "info = stoch_simul_sparse(var_list_);" << endl;
output << "info = stoch_simul(var_list_);" << endl;
}
ForecastStatement::ForecastStatement(const SymbolList &symbol_list_arg,

View File

@ -52,10 +52,8 @@ class SimulStatement : public Statement
{
private:
const OptionsList options_list;
const bool byte_code;
const bool block;
public:
SimulStatement(const OptionsList &options_list_arg, bool block_arg, bool byte_code_arg);
SimulStatement(const OptionsList &options_list_arg);
virtual void checkPass(ModFileStructure &mod_file_struct);
virtual void writeOutput(ostream &output, const string &basename) const;
};
@ -75,11 +73,9 @@ class StochSimulStatement : public Statement
private:
const SymbolList symbol_list;
const OptionsList options_list;
bool block;
public:
StochSimulStatement(const SymbolList &symbol_list_arg,
const OptionsList &options_list_arg,
bool block_arg);
const OptionsList &options_list_arg);
virtual void checkPass(ModFileStructure &mod_file_struct);
virtual void writeOutput(ostream &output, const string &basename) const;
};

View File

@ -154,6 +154,9 @@ void
ModFile::computingPass(bool no_tmp_terms)
{
// Mod file may have no equation (for example in a standalone BVAR estimation)
bool dynamic_model_needed = mod_file_struct.simul_present || mod_file_struct.check_present || mod_file_struct.stoch_simul_present
|| mod_file_struct.estimation_present|| mod_file_struct.forecast_present || mod_file_struct.osr_present
|| mod_file_struct.ramsey_policy_present;
if (dynamic_model.equation_number() > 0)
{
// Compute static model and its derivatives
@ -168,21 +171,25 @@ ModFile::computingPass(bool no_tmp_terms)
static_model.computingPass(block, false, no_tmp_terms);
}
// Set things to compute for dynamic model
if (mod_file_struct.simul_present)
dynamic_model.computingPass(false, false, false, false, global_eval_context, no_tmp_terms, block, use_dll);
else
if (dynamic_model_needed)
{
if (mod_file_struct.order_option < 1 || mod_file_struct.order_option > 3)
if (mod_file_struct.simul_present)
dynamic_model.computingPass(false, false, false, false, global_eval_context, no_tmp_terms, block, use_dll);
else
{
cerr << "ERROR: Incorrect order option..." << endl;
exit(EXIT_FAILURE);
if (mod_file_struct.order_option < 1 || mod_file_struct.order_option > 3)
{
cerr << "ERROR: Incorrect order option..." << endl;
exit(EXIT_FAILURE);
}
bool hessian = mod_file_struct.order_option >= 2;
bool thirdDerivatives = mod_file_struct.order_option == 3;
bool paramsDerivatives = mod_file_struct.identification_present;
dynamic_model.computingPass(true, hessian, thirdDerivatives, paramsDerivatives, global_eval_context, no_tmp_terms, false, use_dll);
}
bool hessian = mod_file_struct.order_option >= 2;
bool thirdDerivatives = mod_file_struct.order_option == 3;
bool paramsDerivatives = mod_file_struct.identification_present;
dynamic_model.computingPass(true, hessian, thirdDerivatives, paramsDerivatives, global_eval_context, no_tmp_terms, false, use_dll);
}
else
dynamic_model.computingPass(true, false, false, false, global_eval_context, no_tmp_terms, false, false);
}
for(vector<Statement *>::iterator it = statements.begin();
@ -194,7 +201,9 @@ void
ModFile::writeOutputFiles(const string &basename, bool clear_all) const
{
ofstream mOutputFile;
bool dynamic_model_needed = mod_file_struct.simul_present || mod_file_struct.check_present || mod_file_struct.stoch_simul_present
|| mod_file_struct.estimation_present|| mod_file_struct.forecast_present || mod_file_struct.osr_present
|| mod_file_struct.ramsey_policy_present;
if (basename.size())
{
string fname(basename);
@ -269,7 +278,10 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all) const
if (dynamic_model.equation_number() > 0)
{
dynamic_model.writeOutput(mOutputFile, basename, block, byte_code, use_dll);
if(dynamic_model_needed)
dynamic_model.writeOutput(mOutputFile, basename, block, byte_code, use_dll);
else
dynamic_model.writeOutput(mOutputFile, basename, false, false, false);
if (!byte_code)
static_model.writeOutput(mOutputFile, block);
}
@ -296,8 +308,16 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all) const
static_dll_model.writeStaticFile(basename, block);
else
static_model.writeStaticFile(basename, block);
dynamic_model.writeDynamicFile(basename, block, byte_code, use_dll);
dynamic_model.writeParamsDerivativesFile(basename);
if(dynamic_model_needed)
{
dynamic_model.writeDynamicFile(basename, block, byte_code, use_dll);
dynamic_model.writeParamsDerivativesFile(basename);
}
else
{
/*dynamic_model.writeDynamicFile(basename, false, false, false);
dynamic_model.writeParamsDerivativesFile(basename);*/
}
}
cout << "done" << endl;

View File

@ -694,7 +694,7 @@ void ParsingDriver::rplot()
void ParsingDriver::stoch_simul()
{
mod_file->addStatement(new StochSimulStatement(symbol_list, options_list, mod_file->block));
mod_file->addStatement(new StochSimulStatement(symbol_list, options_list));
symbol_list.clear();
options_list.clear();
}
@ -702,7 +702,7 @@ void ParsingDriver::stoch_simul()
void
ParsingDriver::simul()
{
mod_file->addStatement(new SimulStatement(options_list, mod_file->block, mod_file->byte_code));
mod_file->addStatement(new SimulStatement(options_list));
options_list.clear();
}