Commit 109045a9 authored by Houtan Bastani's avatar Houtan Bastani Committed by MichelJuillard
Browse files

ms-dsge: add options statement

Conflicts:
	preprocessor/ComputingTasks.cc
	preprocessor/ComputingTasks.hh
	preprocessor/ParsingDriver.cc
parent 1424f34e
......@@ -2166,7 +2166,6 @@ PriorStatement::writeCOutput(ostream &output, const string &basename)
output << "msdsgeinfo->addPrior(new ModFilePrior(" << endl
<< " index, shape, mean, mode, stdev, variance, domain));" << endl;
}
StdPriorStatement::StdPriorStatement(const string &name_arg,
......@@ -2415,6 +2414,14 @@ BasicOptionsStatement::checkPass(ModFileStructure &mod_file_struct, WarningConso
{
}
bool
BasicOptionsStatement::is_structural_innovation(const SymbolType symb_type) const
{
if (symb_type == eExogenous || symb_type == eExogenousDet)
return true;
return false;
}
void
BasicOptionsStatement::get_base_name(const SymbolType symb_type, string &lhs_field) const
{
......@@ -2442,6 +2449,16 @@ BasicOptionsStatement::writeCommonOutputHelper(ostream &output, const string &fi
output << lhs_field << "." << field << " = " << itn->second << ";" << endl;
}
void
BasicOptionsStatement::writeCOutputHelper(ostream &output, const string &field) const
{
OptionsList::num_options_t::const_iterator itn = options_list.num_options.find(field);
if (itn != options_list.num_options.end())
output << field << " = " << itn->second << ";" << endl;
else
output << field << " = " << "numeric_limits<double>::quiet_NaN();" << endl;
}
void
BasicOptionsStatement::writeOptionsOutput(ostream &output, string &lhs_field, const string &name2) const
{
......@@ -2473,6 +2490,15 @@ OptionsStatement::writeOutput(ostream &output, const string &basename) const
writeOptionsOutput(output, lhs_field, "");
}
void
OptionsStatement::writeCOutput(ostream &output, const string &basename)
{
output << endl
<< "index = param_names[\""<< name << "\"];" << endl;
writeCOutputHelper(output, "init");
output << "msdsgeinfo->addOption(new ModFileOption(index, init));" << endl;
}
StdOptionsStatement::StdOptionsStatement(const string &name_arg,
const string &subsample_name_arg,
const OptionsList &options_list_arg,
......@@ -2495,6 +2521,26 @@ StdOptionsStatement::writeOutput(ostream &output, const string &basename) const
writeOptionsOutput(output, lhs_field, "");
}
void
StdOptionsStatement::writeCOutput(ostream &output, const string &basename)
{
output << endl
<< "index = ";
if (is_structural_innovation(symbol_table.getType(name)))
output << "exo_names";
else
output << "endo_names";
output << "[\""<< name << "\"];" << endl;
writeCOutputHelper(output, "init");
if (is_structural_innovation(symbol_table.getType(name)))
output << "msdsgeinfo->addStructuralInnovationOption(new ModFileStructuralInnovationOption(";
else
output << "msdsgeinfo->addMeasurementErrorOption(new ModFileMeasurementErrorOption(";
output << "index, init));" << endl;
}
CorrOptionsStatement::CorrOptionsStatement(const string &name_arg1, const string &name_arg2,
const string &subsample_name_arg,
const OptionsList &options_list_arg,
......@@ -2698,3 +2744,30 @@ ModelDiagnosticsStatement::writeOutput(ostream &output, const string &basename)
{
output << "model_diagnostics(M_,options_,oo_);" << endl;
}
void
CorrOptionsStatement::writeCOutput(ostream &output, const string &basename)
{
output << endl
<< "index = ";
if (is_structural_innovation(symbol_table.getType(name)))
output << "exo_names";
else
output << "endo_names";
output << "[\""<< name << "\"];" << endl;
output << "index1 = ";
if (is_structural_innovation(symbol_table.getType(name1)))
output << "exo_names";
else
output << "endo_names";
output << "[\""<< name1 << "\"];" << endl;
writeCOutputHelper(output, "init");
if (is_structural_innovation(symbol_table.getType(name)))
output << "msdsgeinfo->addStructuralInnovationCorrOption(new ModFileStructuralInnovationCorrOption(";
else
output << "msdsgeinfo->addMeasurementErrorCorrOption(new ModFileMeasurementErrorCorrOption(";
output << "index, index1, init));" << endl;
}
......@@ -758,6 +758,10 @@ protected:
void writeOptionsOutput(ostream &output, string &lhs_field, const string &name2) const;
void writeCommonOutput(ostream &output, const string &lhs_field) const;
void writeCommonOutputHelper(ostream &output, const string &field, const string &lhs_field) const;
bool is_structural_innovation(const SymbolType symb_type) const;
void writeOptionsIndex(ostream &output, const string &lhs_field) const;
void writeOutputHelper(ostream &output, const string &field, const string &lhs_field) const;
void writeCOutputHelper(ostream &output, const string &field) const;
};
class OptionsStatement : public BasicOptionsStatement
......@@ -765,6 +769,7 @@ class OptionsStatement : public BasicOptionsStatement
public:
OptionsStatement(const string &name_arg, const string &subsample_name_arg, const OptionsList &options_list_arg);
virtual void writeOutput(ostream &output, const string &basename) const;
virtual void writeCOutput(ostream &output, const string &basename);
};
class StdOptionsStatement : public BasicOptionsStatement
......@@ -777,6 +782,7 @@ public:
const OptionsList &options_list_arg,
const SymbolTable &symbol_table_arg);
virtual void writeOutput(ostream &output, const string &basename) const;
virtual void writeCOutput(ostream &output, const string &basename);
};
class CorrOptionsStatement : public BasicOptionsStatement
......@@ -825,6 +831,7 @@ class ModelDiagnosticsStatement : public Statement
public:
ModelDiagnosticsStatement();
virtual void writeOutput(ostream &output, const string &basename) const;
virtual void writeCOutput(ostream &output, const string &basename);
};
#endif
......@@ -865,7 +865,9 @@ ModFile::writeCOutputFiles(const string &basename) const
<< "int chain, number_of_regimes, number_of_lags, number_of_lags_was_passed;" << endl
<< "vector<int> parameters;" << endl
<< "vector<double> duration;" << endl
<< "restriction_map_t restriction_map;" << endl << endl;
<< "restriction_map_t restriction_map;" << endl
<< "/* options args*/" << endl
<< "double init;" << endl << endl;
// Print statements
for (vector<Statement *>::const_iterator it = statements.begin();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment