var_forecast: move var declaration from options_ to M_, simplify structure in which it is stored
parent
85a7d72515
commit
b08a397983
|
@ -171,19 +171,20 @@ PriorPosteriorFunctionStatement::writeOutput(ostream &output, const string &base
|
||||||
<< "'" << type << "');" << endl;
|
<< "'" << type << "');" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
VARStatement::VARStatement(const SymbolList &symbol_list_arg,
|
VarModelStatement::VarModelStatement(const SymbolList &symbol_list_arg,
|
||||||
const OptionsList &options_list_arg,
|
const OptionsList &options_list_arg,
|
||||||
const SymbolTable &symbol_table_arg) :
|
const string &name_arg,
|
||||||
|
const SymbolTable &symbol_table_arg) :
|
||||||
symbol_list(symbol_list_arg),
|
symbol_list(symbol_list_arg),
|
||||||
options_list(options_list_arg),
|
options_list(options_list_arg),
|
||||||
|
name(name_arg),
|
||||||
symbol_table(symbol_table_arg)
|
symbol_table(symbol_table_arg)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
VARStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings)
|
VarModelStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings)
|
||||||
{
|
{
|
||||||
mod_file_struct.var_model_present = true;
|
|
||||||
vector<string> symbols = symbol_list.get_symbols();
|
vector<string> symbols = symbol_list.get_symbols();
|
||||||
for (vector<string>::const_iterator it = symbols.begin(); it != symbols.end(); it++)
|
for (vector<string>::const_iterator it = symbols.begin(); it != symbols.end(); it++)
|
||||||
if (symbol_table.getType(*it) != eEndogenous)
|
if (symbol_table.getType(*it) != eEndogenous)
|
||||||
|
@ -192,27 +193,27 @@ VARStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsolidation
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
OptionsList::num_options_t::const_iterator it = options_list.num_options.find("var(varidx).order");
|
OptionsList::num_options_t::const_iterator it = options_list.num_options.find("var.order");
|
||||||
if (it == options_list.num_options.end())
|
if (it == options_list.num_options.end())
|
||||||
{
|
{
|
||||||
cerr << "ERROR: You must provide the order option to the var command." << endl;
|
cerr << "ERROR: You must provide the order option to the var_model statement." << endl;
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
OptionsList::string_options_t::const_iterator it1 = options_list.string_options.find("var(varidx).name");
|
if (name.empty())
|
||||||
if (it1 == options_list.string_options.end())
|
|
||||||
{
|
{
|
||||||
cerr << "ERROR: You must provide the model_name option to the var command." << endl;
|
cerr << "ERROR: You must provide the model_name option to the var_model statement." << endl;
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
VARStatement::writeOutput(ostream &output, const string &basename, bool minimal_workspace) const
|
VarModelStatement::writeOutput(ostream &output, const string &basename, bool minimal_workspace) const
|
||||||
{
|
{
|
||||||
options_list.writeOutput(output);
|
options_list.writeOutput(output);
|
||||||
symbol_list.writeOutput("options_.var(varidx).var_list_", output);
|
symbol_list.writeOutput("options_.var.var_list_", output);
|
||||||
output << "varidx = varidx + 1;" << endl;
|
output << "M_.var." << name << " = options_.var;" << endl
|
||||||
|
<< "clear options_.var;" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
StochSimulStatement::StochSimulStatement(const SymbolList &symbol_list_arg,
|
StochSimulStatement::StochSimulStatement(const SymbolList &symbol_list_arg,
|
||||||
|
|
|
@ -110,16 +110,18 @@ public:
|
||||||
virtual void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const;
|
virtual void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class VARStatement : public Statement
|
class VarModelStatement : public Statement
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
const SymbolList symbol_list;
|
const SymbolList symbol_list;
|
||||||
const OptionsList options_list;
|
const OptionsList options_list;
|
||||||
const SymbolTable &symbol_table;
|
const string &name;
|
||||||
|
const SymbolTable &symbol_table;
|
||||||
public:
|
public:
|
||||||
VARStatement(const SymbolList &symbol_list_arg,
|
VarModelStatement(const SymbolList &symbol_list_arg,
|
||||||
const OptionsList &options_list_arg,
|
const OptionsList &options_list_arg,
|
||||||
const SymbolTable &symbol_table_arg);
|
const string &name_arg,
|
||||||
|
const SymbolTable &symbol_table_arg);
|
||||||
virtual void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings);
|
virtual void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings);
|
||||||
virtual void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const;
|
virtual void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const;
|
||||||
};
|
};
|
||||||
|
|
|
@ -347,7 +347,7 @@ var : VAR var_list ';'
|
||||||
{ driver.end_nonstationary_var(true, $6); }
|
{ driver.end_nonstationary_var(true, $6); }
|
||||||
;
|
;
|
||||||
|
|
||||||
var_model : VAR '(' var_model_options_list ')' symbol_list ';' { driver.var_model(); } ;
|
var_model : VAR_MODEL '(' var_model_options_list ')' symbol_list ';' { driver.var_model(); } ;
|
||||||
|
|
||||||
var_model_options_list : var_model_options_list COMMA var_model_options
|
var_model_options_list : var_model_options_list COMMA var_model_options
|
||||||
| var_model_options
|
| var_model_options
|
||||||
|
@ -2827,8 +2827,8 @@ o_simul_seed : SIMUL_SEED EQUAL INT_NUMBER { driver.error("'simul_seed' option i
|
||||||
o_qz_criterium : QZ_CRITERIUM EQUAL non_negative_number { driver.option_num("qz_criterium", $3); };
|
o_qz_criterium : QZ_CRITERIUM EQUAL non_negative_number { driver.option_num("qz_criterium", $3); };
|
||||||
o_qz_zero_threshold : QZ_ZERO_THRESHOLD EQUAL non_negative_number { driver.option_num("qz_zero_threshold", $3); };
|
o_qz_zero_threshold : QZ_ZERO_THRESHOLD EQUAL non_negative_number { driver.option_num("qz_zero_threshold", $3); };
|
||||||
o_file : FILE EQUAL filename { driver.option_str("file", $3); };
|
o_file : FILE EQUAL filename { driver.option_str("file", $3); };
|
||||||
o_var_name : MODEL_NAME EQUAL symbol { driver.option_str("var(varidx).name", $3); };
|
o_var_name : MODEL_NAME EQUAL symbol { driver.option_str("var.model_name", $3); };
|
||||||
o_var_order : ORDER EQUAL INT_NUMBER { driver.option_num("var(varidx).order", $3); };
|
o_var_order : ORDER EQUAL INT_NUMBER { driver.option_num("var.order", $3); };
|
||||||
o_series : SERIES EQUAL symbol { driver.option_str("series", $3); };
|
o_series : SERIES EQUAL symbol { driver.option_str("series", $3); };
|
||||||
o_datafile : DATAFILE EQUAL filename { driver.option_str("datafile", $3); };
|
o_datafile : DATAFILE EQUAL filename { driver.option_str("datafile", $3); };
|
||||||
o_dirname : DIRNAME EQUAL filename { driver.option_str("dirname", $3); };
|
o_dirname : DIRNAME EQUAL filename { driver.option_str("dirname", $3); };
|
||||||
|
|
|
@ -808,9 +808,6 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all, bool clear_glo
|
||||||
static_model.writeOutput(mOutputFile, block);
|
static_model.writeOutput(mOutputFile, block);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mod_file_struct.var_model_present)
|
|
||||||
mOutputFile << "varidx = 1;" << endl;
|
|
||||||
|
|
||||||
// Print statements
|
// Print statements
|
||||||
for (vector<Statement *>::const_iterator it = statements.begin();
|
for (vector<Statement *>::const_iterator it = statements.begin();
|
||||||
it != statements.end(); it++)
|
it != statements.end(); it++)
|
||||||
|
|
|
@ -1282,7 +1282,11 @@ ParsingDriver::stoch_simul()
|
||||||
void
|
void
|
||||||
ParsingDriver::var_model()
|
ParsingDriver::var_model()
|
||||||
{
|
{
|
||||||
mod_file->addStatement(new VARStatement(symbol_list, options_list, mod_file->symbol_table));
|
OptionsList::string_options_t::const_iterator it = options_list.string_options.find("var.model_name");
|
||||||
|
if (it == options_list.string_options.end())
|
||||||
|
error("You must pass the model_name option to the var_model statement.");
|
||||||
|
const string *name = new string(it->second);
|
||||||
|
mod_file->addStatement(new VarModelStatement(symbol_list, options_list, *name, mod_file->symbol_table));
|
||||||
symbol_list.clear();
|
symbol_list.clear();
|
||||||
options_list.clear();
|
options_list.clear();
|
||||||
}
|
}
|
||||||
|
|
|
@ -122,8 +122,6 @@ public:
|
||||||
int orig_eq_nbr;
|
int orig_eq_nbr;
|
||||||
//! Stores the number of equations added to the Ramsey model
|
//! Stores the number of equations added to the Ramsey model
|
||||||
int ramsey_eq_nbr;
|
int ramsey_eq_nbr;
|
||||||
//! Whether a VAR statement is present
|
|
||||||
bool var_model_present;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class Statement
|
class Statement
|
||||||
|
|
Loading…
Reference in New Issue