Preprocessor: uniformize typedef names (with a "_t" suffix)

issue#70
Sébastien Villemot 2010-09-16 19:00:48 +02:00
parent c3c8fa5cca
commit c8fdd5d9d1
26 changed files with 752 additions and 752 deletions

View File

@ -999,7 +999,7 @@ public:
}; };
#ifdef BYTE_CODE #ifdef BYTE_CODE
typedef vector<pair<Tags, void * > > tags_liste_type; typedef vector<pair<Tags, void * > > tags_liste_t;
class CodeLoad class CodeLoad
{ {
private: private:
@ -1017,10 +1017,10 @@ public:
{ {
return code; return code;
}; };
inline tags_liste_type inline tags_liste_t
get_op_code(string file_name) get_op_code(string file_name)
{ {
tags_liste_type tags_liste; tags_liste_t tags_liste;
ifstream CompiledCode; ifstream CompiledCode;
streamoff Code_Size; streamoff Code_Size;
CompiledCode.open((file_name + ".cod").c_str(), std::ios::in | std::ios::binary| std::ios::ate); CompiledCode.open((file_name + ".cod").c_str(), std::ios::in | std::ios::binary| std::ios::ate);

View File

@ -112,7 +112,7 @@ StochSimulStatement::checkPass(ModFileStructure &mod_file_struct)
mod_file_struct.stoch_simul_present = true; mod_file_struct.stoch_simul_present = true;
// Fill in option_order of mod_file_struct // Fill in option_order of mod_file_struct
OptionsList::num_options_type::const_iterator it = options_list.num_options.find("order"); OptionsList::num_options_t::const_iterator it = options_list.num_options.find("order");
if (it != options_list.num_options.end()) if (it != options_list.num_options.end())
mod_file_struct.order_option = max(mod_file_struct.order_option, atoi(it->second.c_str())); mod_file_struct.order_option = max(mod_file_struct.order_option, atoi(it->second.c_str()));
@ -175,7 +175,7 @@ RamseyPolicyStatement::checkPass(ModFileStructure &mod_file_struct)
/* Fill in option_order of mod_file_struct /* Fill in option_order of mod_file_struct
Since ramsey policy needs one further order of derivation (for example, for 1st order Since ramsey policy needs one further order of derivation (for example, for 1st order
approximation, it needs 2nd derivatives), we add 1 to the order declared by user */ approximation, it needs 2nd derivatives), we add 1 to the order declared by user */
OptionsList::num_options_type::const_iterator it = options_list.num_options.find("order"); OptionsList::num_options_t::const_iterator it = options_list.num_options.find("order");
if (it != options_list.num_options.end()) if (it != options_list.num_options.end())
{ {
int order = atoi(it->second.c_str()); int order = atoi(it->second.c_str());
@ -222,7 +222,7 @@ EstimationStatement::checkPass(ModFileStructure &mod_file_struct)
mod_file_struct.estimation_present = true; mod_file_struct.estimation_present = true;
// Fill in option_order of mod_file_struct // Fill in option_order of mod_file_struct
OptionsList::num_options_type::const_iterator it = options_list.num_options.find("order"); OptionsList::num_options_t::const_iterator it = options_list.num_options.find("order");
if (it != options_list.num_options.end()) if (it != options_list.num_options.end())
mod_file_struct.order_option = max(mod_file_struct.order_option, atoi(it->second.c_str())); mod_file_struct.order_option = max(mod_file_struct.order_option, atoi(it->second.c_str()));
@ -237,7 +237,7 @@ EstimationStatement::checkPass(ModFileStructure &mod_file_struct)
mod_file_struct.dsge_var_calibrated = it->second; mod_file_struct.dsge_var_calibrated = it->second;
// Fill in mod_file_struct.dsge_var_estimated // Fill in mod_file_struct.dsge_var_estimated
OptionsList::string_options_type::const_iterator it_str = options_list.string_options.find("dsge_var"); OptionsList::string_options_t::const_iterator it_str = options_list.string_options.find("dsge_var");
if (it_str != options_list.string_options.end()) if (it_str != options_list.string_options.end())
mod_file_struct.dsge_var_estimated = true; mod_file_struct.dsge_var_estimated = true;
@ -280,7 +280,7 @@ DynareSensitivityStatement::DynareSensitivityStatement(const OptionsList &option
void void
DynareSensitivityStatement::checkPass(ModFileStructure &mod_file_struct) DynareSensitivityStatement::checkPass(ModFileStructure &mod_file_struct)
{ {
OptionsList::num_options_type::const_iterator it = options_list.num_options.find("identification"); OptionsList::num_options_t::const_iterator it = options_list.num_options.find("identification");
if (it != options_list.num_options.end() if (it != options_list.num_options.end()
&& it->second == "1") && it->second == "1")
mod_file_struct.identification_present = true; mod_file_struct.identification_present = true;
@ -366,8 +366,8 @@ EstimatedParamsStatement::checkPass(ModFileStructure &mod_file_struct)
if (it->prior == "1") //BETA_PDF is associated with "1" in DynareBison.yy if (it->prior == "1") //BETA_PDF is associated with "1" in DynareBison.yy
try try
{ {
if (it->mean->eval(eval_context_type()) == 0.5 && if (it->mean->eval(eval_context_t()) == 0.5 &&
it->std->eval(eval_context_type()) == 0.5) it->std->eval(eval_context_t()) == 0.5)
{ {
cerr << "ERROR: The prior density is not defined for the beta distribution when the mean = standard deviation = 0.5." << endl; cerr << "ERROR: The prior density is not defined for the beta distribution when the mean = standard deviation = 0.5." << endl;
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
@ -586,7 +586,7 @@ EstimatedParamsBoundsStatement::writeOutput(ostream &output, const string &basen
} }
} }
ObservationTrendsStatement::ObservationTrendsStatement(const trend_elements_type &trend_elements_arg, ObservationTrendsStatement::ObservationTrendsStatement(const trend_elements_t &trend_elements_arg,
const SymbolTable &symbol_table_arg) : const SymbolTable &symbol_table_arg) :
trend_elements(trend_elements_arg), trend_elements(trend_elements_arg),
symbol_table(symbol_table_arg) symbol_table(symbol_table_arg)
@ -598,7 +598,7 @@ ObservationTrendsStatement::writeOutput(ostream &output, const string &basename)
{ {
output << "options_.trend_coeff_ = {};" << endl; output << "options_.trend_coeff_ = {};" << endl;
trend_elements_type::const_iterator it; trend_elements_t::const_iterator it;
for (it = trend_elements.begin(); it != trend_elements.end(); it++) for (it = trend_elements.begin(); it != trend_elements.end(); it++)
{ {
@ -615,9 +615,9 @@ ObservationTrendsStatement::writeOutput(ostream &output, const string &basename)
} }
} }
CalibVarStatement::CalibVarStatement(const calib_var_type &calib_var_arg, CalibVarStatement::CalibVarStatement(const calib_var_t &calib_var_arg,
const calib_covar_type &calib_covar_arg, const calib_covar_t &calib_covar_arg,
const calib_ac_type &calib_ac_arg, const calib_ac_t &calib_ac_arg,
const SymbolTable &symbol_table_arg) : const SymbolTable &symbol_table_arg) :
calib_var(calib_var_arg), calib_var(calib_var_arg),
calib_covar(calib_covar_arg), calib_covar(calib_covar_arg),
@ -642,7 +642,7 @@ CalibVarStatement::writeOutput(ostream &output, const string &basename) const
} }
// Print calibration variances // Print calibration variances
for (calib_var_type::const_iterator it = calib_var.begin(); for (calib_var_t::const_iterator it = calib_var.begin();
it != calib_var.end(); it++) it != calib_var.end(); it++)
{ {
const string &name = it->first; const string &name = it->first;
@ -669,7 +669,7 @@ CalibVarStatement::writeOutput(ostream &output, const string &basename) const
} }
// Print calibration covariances // Print calibration covariances
for (calib_covar_type::const_iterator it = calib_covar.begin(); for (calib_covar_t::const_iterator it = calib_covar.begin();
it != calib_covar.end(); it++) it != calib_covar.end(); it++)
{ {
const string &name1 = it->first.first; const string &name1 = it->first.first;
@ -700,7 +700,7 @@ CalibVarStatement::writeOutput(ostream &output, const string &basename) const
// Print calibration autocorrelations // Print calibration autocorrelations
int max_iar = 3; int max_iar = 3;
for (calib_ac_type::const_iterator it = calib_ac.begin(); for (calib_ac_t::const_iterator it = calib_ac.begin();
it != calib_ac.end(); it++) it != calib_ac.end(); it++)
{ {
const string &name = it->first.first; const string &name = it->first.first;
@ -764,7 +764,7 @@ OsrStatement::checkPass(ModFileStructure &mod_file_struct)
mod_file_struct.osr_present = true; mod_file_struct.osr_present = true;
// Fill in option_order of mod_file_struct // Fill in option_order of mod_file_struct
OptionsList::num_options_type::const_iterator it = options_list.num_options.find("order"); OptionsList::num_options_t::const_iterator it = options_list.num_options.find("order");
if (it != options_list.num_options.end()) if (it != options_list.num_options.end())
mod_file_struct.order_option = max(mod_file_struct.order_option, atoi(it->second.c_str())); mod_file_struct.order_option = max(mod_file_struct.order_option, atoi(it->second.c_str()));
@ -788,8 +788,8 @@ OsrStatement::writeOutput(ostream &output, const string &basename) const
output << "osr(var_list_,osr_params_,obj_var_,optim_weights_);\n"; output << "osr(var_list_,osr_params_,obj_var_,optim_weights_);\n";
} }
OptimWeightsStatement::OptimWeightsStatement(const var_weights_type &var_weights_arg, OptimWeightsStatement::OptimWeightsStatement(const var_weights_t &var_weights_arg,
const covar_weights_type &covar_weights_arg, const covar_weights_t &covar_weights_arg,
const SymbolTable &symbol_table_arg) : const SymbolTable &symbol_table_arg) :
var_weights(var_weights_arg), var_weights(var_weights_arg),
covar_weights(covar_weights_arg), covar_weights(covar_weights_arg),
@ -806,7 +806,7 @@ OptimWeightsStatement::writeOutput(ostream &output, const string &basename) cons
<< "optim_weights_ = sparse(M_.endo_nbr,M_.endo_nbr);" << endl << "optim_weights_ = sparse(M_.endo_nbr,M_.endo_nbr);" << endl
<< "obj_var_ = [];" << endl << endl; << "obj_var_ = [];" << endl << endl;
for (var_weights_type::const_iterator it = var_weights.begin(); for (var_weights_t::const_iterator it = var_weights.begin();
it != var_weights.end(); it++) it != var_weights.end(); it++)
{ {
const string &name = it->first; const string &name = it->first;
@ -818,7 +818,7 @@ OptimWeightsStatement::writeOutput(ostream &output, const string &basename) cons
output << "obj_var_ = [obj_var_; " << id << "];\n"; output << "obj_var_ = [obj_var_; " << id << "];\n";
} }
for (covar_weights_type::const_iterator it = covar_weights.begin(); for (covar_weights_t::const_iterator it = covar_weights.begin();
it != covar_weights.end(); it++) it != covar_weights.end(); it++)
{ {
const string &name1 = it->first.first; const string &name1 = it->first.first;
@ -863,7 +863,7 @@ DynaTypeStatement::writeOutput(ostream &output, const string &basename) const
<< "',var_list_);" << endl; << "',var_list_);" << endl;
} }
ModelComparisonStatement::ModelComparisonStatement(const filename_list_type &filename_list_arg, ModelComparisonStatement::ModelComparisonStatement(const filename_list_t &filename_list_arg,
const OptionsList &options_list_arg) : const OptionsList &options_list_arg) :
filename_list(filename_list_arg), filename_list(filename_list_arg),
options_list(options_list_arg) options_list(options_list_arg)
@ -878,7 +878,7 @@ ModelComparisonStatement::writeOutput(ostream &output, const string &basename) c
output << "ModelNames_ = {};" << endl; output << "ModelNames_ = {};" << endl;
output << "ModelPriors_ = [];" << endl; output << "ModelPriors_ = [];" << endl;
for (filename_list_type::const_iterator it = filename_list.begin(); for (filename_list_t::const_iterator it = filename_list.begin();
it != filename_list.end(); it++) it != filename_list.end(); it++)
{ {
output << "ModelNames_ = { ModelNames_{:} '" << (*it).first << "'};" << endl; output << "ModelNames_ = { ModelNames_{:} '" << (*it).first << "'};" << endl;
@ -906,7 +906,7 @@ PlannerObjectiveStatement::checkPass(ModFileStructure &mod_file_struct)
void void
PlannerObjectiveStatement::computingPass() PlannerObjectiveStatement::computingPass()
{ {
model_tree->computingPass(eval_context_type(), false, true, false, false); model_tree->computingPass(eval_context_t(), false, true, false, false);
} }
void void
@ -1072,7 +1072,7 @@ PlotConditionalForecastStatement::writeOutput(ostream &output, const string &bas
output << "plot_icforecast(var_list_, " << periods << ");" << endl; output << "plot_icforecast(var_list_, " << periods << ");" << endl;
} }
SvarIdentificationStatement::SvarIdentificationStatement(const svar_identification_exclusion_type &exclusion_arg, SvarIdentificationStatement::SvarIdentificationStatement(const svar_identification_exclusion_t &exclusion_arg,
const bool &upper_cholesky_present_arg, const bool &upper_cholesky_present_arg,
const bool &lower_cholesky_present_arg, const bool &lower_cholesky_present_arg,
const SymbolTable &symbol_table_arg) : const SymbolTable &symbol_table_arg) :
@ -1087,7 +1087,7 @@ int
SvarIdentificationStatement::getMaxLag() const SvarIdentificationStatement::getMaxLag() const
{ {
int max_lag = 0; int max_lag = 0;
for (svar_identification_exclusion_type::const_iterator it = exclusion.begin(); it != exclusion.end(); it++) for (svar_identification_exclusion_t::const_iterator it = exclusion.begin(); it != exclusion.end(); it++)
if (it->first.first > max_lag) if (it->first.first > max_lag)
max_lag = it->first.first; max_lag = it->first.first;
@ -1151,7 +1151,7 @@ SvarIdentificationStatement::writeOutput(ostream &output, const string &basename
output << "options_.ms.Qi = zeros(" << n << ", " << n << ", " << n << ");" << endl; output << "options_.ms.Qi = zeros(" << n << ", " << n << ", " << n << ");" << endl;
output << "options_.ms.Ri = zeros(" << k << ", " << k << ", " << n << ");" << endl; output << "options_.ms.Ri = zeros(" << k << ", " << k << ", " << n << ");" << endl;
for (svar_identification_exclusion_type::const_iterator it = exclusion.begin(); it != exclusion.end(); it++) for (svar_identification_exclusion_t::const_iterator it = exclusion.begin(); it != exclusion.end(); it++)
{ {
for (unsigned int h = 0; h < it->second.size(); h++) for (unsigned int h = 0; h < it->second.size(); h++)
{ {
@ -1197,7 +1197,7 @@ MarkovSwitchingStatement::MarkovSwitchingStatement(const OptionsList &options_li
void void
MarkovSwitchingStatement::writeOutput(ostream &output, const string &basename) const MarkovSwitchingStatement::writeOutput(ostream &output, const string &basename) const
{ {
OptionsList::num_options_type::const_iterator itChain, itState, itNOS, itDuration; OptionsList::num_options_t::const_iterator itChain, itState, itNOS, itDuration;
itChain = options_list.num_options.find("ms.chain"); itChain = options_list.num_options.find("ms.chain");
if (itChain == options_list.num_options.end()) if (itChain == options_list.num_options.end())
@ -1237,8 +1237,8 @@ SvarStatement::SvarStatement(const OptionsList &options_list_arg) :
void void
SvarStatement::writeOutput(ostream &output, const string &basename) const SvarStatement::writeOutput(ostream &output, const string &basename) const
{ {
OptionsList::num_options_type::const_iterator it0, it1, it2; OptionsList::num_options_t::const_iterator it0, it1, it2;
OptionsList::vec_int_options_type::const_iterator itv; OptionsList::vec_int_options_t::const_iterator itv;
it0 = options_list.num_options.find("ms.chain"); it0 = options_list.num_options.find("ms.chain");
if (it0 != options_list.num_options.end()) if (it0 != options_list.num_options.end())

View File

@ -169,12 +169,12 @@ public:
class ObservationTrendsStatement : public Statement class ObservationTrendsStatement : public Statement
{ {
public: public:
typedef map<string, NodeID> trend_elements_type; typedef map<string, NodeID> trend_elements_t;
private: private:
const trend_elements_type trend_elements; const trend_elements_t trend_elements;
const SymbolTable &symbol_table; const SymbolTable &symbol_table;
public: public:
ObservationTrendsStatement(const trend_elements_type &trend_elements_arg, ObservationTrendsStatement(const trend_elements_t &trend_elements_arg,
const SymbolTable &symbol_table_arg); const SymbolTable &symbol_table_arg);
virtual void writeOutput(ostream &output, const string &basename) const; virtual void writeOutput(ostream &output, const string &basename) const;
}; };
@ -225,12 +225,12 @@ public:
class ModelComparisonStatement : public Statement class ModelComparisonStatement : public Statement
{ {
public: public:
typedef vector<pair<string, string> > filename_list_type; typedef vector<pair<string, string> > filename_list_t;
private: private:
filename_list_type filename_list; filename_list_t filename_list;
OptionsList options_list; OptionsList options_list;
public: public:
ModelComparisonStatement(const filename_list_type &filename_list_arg, ModelComparisonStatement(const filename_list_t &filename_list_arg,
const OptionsList &options_list_arg); const OptionsList &options_list_arg);
virtual void writeOutput(ostream &output, const string &basename) const; virtual void writeOutput(ostream &output, const string &basename) const;
}; };
@ -298,15 +298,15 @@ public:
class OptimWeightsStatement : public Statement class OptimWeightsStatement : public Statement
{ {
public: public:
typedef map<string, NodeID> var_weights_type; typedef map<string, NodeID> var_weights_t;
typedef map<pair<string, string>, NodeID> covar_weights_type; typedef map<pair<string, string>, NodeID> covar_weights_t;
private: private:
const var_weights_type var_weights; const var_weights_t var_weights;
const covar_weights_type covar_weights; const covar_weights_t covar_weights;
const SymbolTable &symbol_table; const SymbolTable &symbol_table;
public: public:
OptimWeightsStatement(const var_weights_type &var_weights_arg, OptimWeightsStatement(const var_weights_t &var_weights_arg,
const covar_weights_type &covar_weights_arg, const covar_weights_t &covar_weights_arg,
const SymbolTable &symbol_table_arg); const SymbolTable &symbol_table_arg);
virtual void writeOutput(ostream &output, const string &basename) const; virtual void writeOutput(ostream &output, const string &basename) const;
}; };
@ -324,20 +324,20 @@ class CalibVarStatement : public Statement
{ {
public: public:
//! Maps a variable to a pair (weight, expression) //! Maps a variable to a pair (weight, expression)
typedef map<string, pair<string, NodeID> > calib_var_type; typedef map<string, pair<string, NodeID> > calib_var_t;
//! Maps a pair of variables to a pair (weight, expression) //! Maps a pair of variables to a pair (weight, expression)
typedef map<pair<string, string>, pair<string, NodeID> > calib_covar_type; typedef map<pair<string, string>, pair<string, NodeID> > calib_covar_t;
//! Maps a pair (variable, autocorr) to a pair (weight, expression) //! Maps a pair (variable, autocorr) to a pair (weight, expression)
typedef map<pair<string, int>, pair<string, NodeID> > calib_ac_type; typedef map<pair<string, int>, pair<string, NodeID> > calib_ac_t;
private: private:
const calib_var_type calib_var; const calib_var_t calib_var;
const calib_covar_type calib_covar; const calib_covar_t calib_covar;
const calib_ac_type calib_ac; const calib_ac_t calib_ac;
const SymbolTable &symbol_table; const SymbolTable &symbol_table;
public: public:
CalibVarStatement(const calib_var_type &calib_var_arg, CalibVarStatement(const calib_var_t &calib_var_arg,
const calib_covar_type &calib_covar_arg, const calib_covar_t &calib_covar_arg,
const calib_ac_type &calib_ac_arg, const calib_ac_t &calib_ac_arg,
const SymbolTable &symbol_table_arg); const SymbolTable &symbol_table_arg);
virtual void writeOutput(ostream &output, const string &basename) const; virtual void writeOutput(ostream &output, const string &basename) const;
}; };
@ -465,15 +465,15 @@ public:
class SvarIdentificationStatement : public Statement class SvarIdentificationStatement : public Statement
{ {
public: public:
typedef map<pair<int, int>, vector<int> > svar_identification_exclusion_type; typedef map<pair<int, int>, vector<int> > svar_identification_exclusion_t;
private: private:
const svar_identification_exclusion_type exclusion; const svar_identification_exclusion_t exclusion;
const bool upper_cholesky_present; const bool upper_cholesky_present;
const bool lower_cholesky_present; const bool lower_cholesky_present;
const SymbolTable &symbol_table; const SymbolTable &symbol_table;
int getMaxLag() const; int getMaxLag() const;
public: public:
SvarIdentificationStatement(const svar_identification_exclusion_type &exclusion_arg, SvarIdentificationStatement(const svar_identification_exclusion_t &exclusion_arg,
const bool &upper_cholesky_present_arg, const bool &upper_cholesky_present_arg,
const bool &lower_cholesky_present_arg, const bool &lower_cholesky_present_arg,
const SymbolTable &symbol_table_arg); const SymbolTable &symbol_table_arg);

View File

@ -46,7 +46,7 @@ DataTree::DataTree(SymbolTable &symbol_table_arg,
DataTree::~DataTree() DataTree::~DataTree()
{ {
for (node_list_type::iterator it = node_list.begin(); it != node_list.end(); it++) for (node_list_t::iterator it = node_list.begin(); it != node_list.end(); it++)
delete *it; delete *it;
} }
@ -55,7 +55,7 @@ DataTree::AddNumConstant(const string &value)
{ {
int id = num_constants.AddConstant(value); int id = num_constants.AddConstant(value);
num_const_node_map_type::iterator it = num_const_node_map.find(id); num_const_node_map_t::iterator it = num_const_node_map.find(id);
if (it != num_const_node_map.end()) if (it != num_const_node_map.end())
return it->second; return it->second;
else else
@ -65,7 +65,7 @@ DataTree::AddNumConstant(const string &value)
VariableNode * VariableNode *
DataTree::AddVariableInternal(int symb_id, int lag) DataTree::AddVariableInternal(int symb_id, int lag)
{ {
variable_node_map_type::iterator it = variable_node_map.find(make_pair(symb_id, lag)); variable_node_map_t::iterator it = variable_node_map.find(make_pair(symb_id, lag));
if (it != variable_node_map.end()) if (it != variable_node_map.end())
return it->second; return it->second;
else else
@ -467,7 +467,7 @@ DataTree::AddExternalFunction(int symb_id, const vector<NodeID> &arguments)
{ {
assert(symbol_table.getType(symb_id) == eExternalFunction); assert(symbol_table.getType(symb_id) == eExternalFunction);
external_function_node_map_type::iterator it = external_function_node_map.find(make_pair(arguments, symb_id)); external_function_node_map_t::iterator it = external_function_node_map.find(make_pair(arguments, symb_id));
if (it != external_function_node_map.end()) if (it != external_function_node_map.end())
return it->second; return it->second;
@ -479,7 +479,7 @@ DataTree::AddFirstDerivExternalFunctionNode(int top_level_symb_id, const vector<
{ {
assert(symbol_table.getType(top_level_symb_id) == eExternalFunction); assert(symbol_table.getType(top_level_symb_id) == eExternalFunction);
first_deriv_external_function_node_map_type::iterator it = first_deriv_external_function_node_map_t::iterator it =
first_deriv_external_function_node_map.find(make_pair(make_pair(arguments, input_index), first_deriv_external_function_node_map.find(make_pair(make_pair(arguments, input_index),
top_level_symb_id)); top_level_symb_id));
if (it != first_deriv_external_function_node_map.end()) if (it != first_deriv_external_function_node_map.end())
@ -493,7 +493,7 @@ DataTree::AddSecondDerivExternalFunctionNode(int top_level_symb_id, const vector
{ {
assert(symbol_table.getType(top_level_symb_id) == eExternalFunction); assert(symbol_table.getType(top_level_symb_id) == eExternalFunction);
second_deriv_external_function_node_map_type::iterator it = second_deriv_external_function_node_map_t::iterator it =
second_deriv_external_function_node_map.find(make_pair(make_pair(arguments, second_deriv_external_function_node_map.find(make_pair(make_pair(arguments,
make_pair(input_index1, input_index2)), make_pair(input_index1, input_index2)),
top_level_symb_id)); top_level_symb_id));
@ -506,7 +506,7 @@ DataTree::AddSecondDerivExternalFunctionNode(int top_level_symb_id, const vector
bool bool
DataTree::isSymbolUsed(int symb_id) const DataTree::isSymbolUsed(int symb_id) const
{ {
for (variable_node_map_type::const_iterator it = variable_node_map.begin(); for (variable_node_map_t::const_iterator it = variable_node_map.begin();
it != variable_node_map.end(); it++) it != variable_node_map.end(); it++)
if (it->first.first == symb_id) if (it->first.first == symb_id)
return true; return true;
@ -532,7 +532,7 @@ DataTree::getDynJacobianCol(int deriv_id) const throw (UnknownDerivIDException)
bool bool
DataTree::isUnaryOpUsed(UnaryOpcode opcode) const DataTree::isUnaryOpUsed(UnaryOpcode opcode) const
{ {
for (unary_op_node_map_type::const_iterator it = unary_op_node_map.begin(); for (unary_op_node_map_t::const_iterator it = unary_op_node_map.begin();
it != unary_op_node_map.end(); it++) it != unary_op_node_map.end(); it++)
if (it->first.second == opcode) if (it->first.second == opcode)
return true; return true;
@ -543,7 +543,7 @@ DataTree::isUnaryOpUsed(UnaryOpcode opcode) const
bool bool
DataTree::isBinaryOpUsed(BinaryOpcode opcode) const DataTree::isBinaryOpUsed(BinaryOpcode opcode) const
{ {
for (binary_op_node_map_type::const_iterator it = binary_op_node_map.begin(); for (binary_op_node_map_t::const_iterator it = binary_op_node_map.begin();
it != binary_op_node_map.end(); it++) it != binary_op_node_map.end(); it++)
if (it->first.second == opcode) if (it->first.second == opcode)
return true; return true;
@ -554,7 +554,7 @@ DataTree::isBinaryOpUsed(BinaryOpcode opcode) const
bool bool
DataTree::isTrinaryOpUsed(TrinaryOpcode opcode) const DataTree::isTrinaryOpUsed(TrinaryOpcode opcode) const
{ {
for (trinary_op_node_map_type::const_iterator it = trinary_op_node_map.begin(); for (trinary_op_node_map_t::const_iterator it = trinary_op_node_map.begin();
it != trinary_op_node_map.end(); it++) it != trinary_op_node_map.end(); it++)
if (it->first.second == opcode) if (it->first.second == opcode)
return true; return true;
@ -565,7 +565,7 @@ DataTree::isTrinaryOpUsed(TrinaryOpcode opcode) const
bool bool
DataTree::isExternalFunctionUsed(int symb_id) const DataTree::isExternalFunctionUsed(int symb_id) const
{ {
for (external_function_node_map_type::const_iterator it = external_function_node_map.begin(); for (external_function_node_map_t::const_iterator it = external_function_node_map.begin();
it != external_function_node_map.end(); it++) it != external_function_node_map.end(); it++)
if (it->first.second == symb_id) if (it->first.second == symb_id)
return true; return true;
@ -576,7 +576,7 @@ DataTree::isExternalFunctionUsed(int symb_id) const
bool bool
DataTree::isFirstDerivExternalFunctionUsed(int symb_id) const DataTree::isFirstDerivExternalFunctionUsed(int symb_id) const
{ {
for (first_deriv_external_function_node_map_type::const_iterator it = first_deriv_external_function_node_map.begin(); for (first_deriv_external_function_node_map_t::const_iterator it = first_deriv_external_function_node_map.begin();
it != first_deriv_external_function_node_map.end(); it++) it != first_deriv_external_function_node_map.end(); it++)
if (it->first.second == symb_id) if (it->first.second == symb_id)
return true; return true;
@ -587,7 +587,7 @@ DataTree::isFirstDerivExternalFunctionUsed(int symb_id) const
bool bool
DataTree::isSecondDerivExternalFunctionUsed(int symb_id) const DataTree::isSecondDerivExternalFunctionUsed(int symb_id) const
{ {
for (second_deriv_external_function_node_map_type::const_iterator it = second_deriv_external_function_node_map.begin(); for (second_deriv_external_function_node_map_t::const_iterator it = second_deriv_external_function_node_map.begin();
it != second_deriv_external_function_node_map.end(); it++) it != second_deriv_external_function_node_map.end(); it++)
if (it->first.second == symb_id) if (it->first.second == symb_id)
return true; return true;

View File

@ -54,23 +54,23 @@ protected:
//! A reference to the external functions table //! A reference to the external functions table
ExternalFunctionsTable &external_functions_table; ExternalFunctionsTable &external_functions_table;
typedef map<int, NumConstNode *> num_const_node_map_type; typedef map<int, NumConstNode *> num_const_node_map_t;
num_const_node_map_type num_const_node_map; num_const_node_map_t num_const_node_map;
//! Pair (symbol_id, lag) used as key //! Pair (symbol_id, lag) used as key
typedef map<pair<int, int>, VariableNode *> variable_node_map_type; typedef map<pair<int, int>, VariableNode *> variable_node_map_t;
variable_node_map_type variable_node_map; variable_node_map_t variable_node_map;
typedef map<pair<NodeID, UnaryOpcode>, UnaryOpNode *> unary_op_node_map_type; typedef map<pair<NodeID, UnaryOpcode>, UnaryOpNode *> unary_op_node_map_t;
unary_op_node_map_type unary_op_node_map; unary_op_node_map_t unary_op_node_map;
typedef map<pair<pair<NodeID, NodeID>, BinaryOpcode>, BinaryOpNode *> binary_op_node_map_type; typedef map<pair<pair<NodeID, NodeID>, BinaryOpcode>, BinaryOpNode *> binary_op_node_map_t;
binary_op_node_map_type binary_op_node_map; binary_op_node_map_t binary_op_node_map;
typedef map<pair<pair<pair<NodeID, NodeID>, NodeID>, TrinaryOpcode>, TrinaryOpNode *> trinary_op_node_map_type; typedef map<pair<pair<pair<NodeID, NodeID>, NodeID>, TrinaryOpcode>, TrinaryOpNode *> trinary_op_node_map_t;
trinary_op_node_map_type trinary_op_node_map; trinary_op_node_map_t trinary_op_node_map;
typedef map<pair<vector<NodeID>, int>, ExternalFunctionNode *> external_function_node_map_type; typedef map<pair<vector<NodeID>, int>, ExternalFunctionNode *> external_function_node_map_t;
external_function_node_map_type external_function_node_map; external_function_node_map_t external_function_node_map;
typedef map<pair<pair<vector<NodeID>, int>, int>, FirstDerivExternalFunctionNode *> first_deriv_external_function_node_map_type; typedef map<pair<pair<vector<NodeID>, int>, int>, FirstDerivExternalFunctionNode *> first_deriv_external_function_node_map_t;
first_deriv_external_function_node_map_type first_deriv_external_function_node_map; first_deriv_external_function_node_map_t first_deriv_external_function_node_map;
typedef map<pair<pair<vector<NodeID>, pair<int, int> >, int>, SecondDerivExternalFunctionNode *> second_deriv_external_function_node_map_type; typedef map<pair<pair<vector<NodeID>, pair<int, int> >, int>, SecondDerivExternalFunctionNode *> second_deriv_external_function_node_map_t;
second_deriv_external_function_node_map_type second_deriv_external_function_node_map; second_deriv_external_function_node_map_t second_deriv_external_function_node_map;
//! Stores local variables value (maps symbol ID to corresponding node) //! Stores local variables value (maps symbol ID to corresponding node)
map<int, NodeID> local_variables_table; map<int, NodeID> local_variables_table;
@ -79,9 +79,9 @@ protected:
VariableNode *AddVariableInternal(int symb_id, int lag); VariableNode *AddVariableInternal(int symb_id, int lag);
private: private:
typedef list<NodeID> node_list_type; typedef list<NodeID> node_list_t;
//! The list of nodes //! The list of nodes
node_list_type node_list; node_list_t node_list;
//! A counter for filling ExprNode's idx field //! A counter for filling ExprNode's idx field
int node_counter; int node_counter;
@ -250,7 +250,7 @@ inline NodeID
DataTree::AddUnaryOp(UnaryOpcode op_code, NodeID arg, int arg_exp_info_set, const string &arg_exp_info_set_name) DataTree::AddUnaryOp(UnaryOpcode op_code, NodeID arg, int arg_exp_info_set, const string &arg_exp_info_set_name)
{ {
// If the node already exists in tree, share it // If the node already exists in tree, share it
unary_op_node_map_type::iterator it = unary_op_node_map.find(make_pair(arg, op_code)); unary_op_node_map_t::iterator it = unary_op_node_map.find(make_pair(arg, op_code));
if (it != unary_op_node_map.end()) if (it != unary_op_node_map.end())
return it->second; return it->second;
@ -261,7 +261,7 @@ DataTree::AddUnaryOp(UnaryOpcode op_code, NodeID arg, int arg_exp_info_set, cons
{ {
try try
{ {
double argval = arg->eval(eval_context_type()); double argval = arg->eval(eval_context_t());
double val = UnaryOpNode::eval_opcode(op_code, argval); double val = UnaryOpNode::eval_opcode(op_code, argval);
return AddPossiblyNegativeConstant(val); return AddPossiblyNegativeConstant(val);
} }
@ -275,15 +275,15 @@ DataTree::AddUnaryOp(UnaryOpcode op_code, NodeID arg, int arg_exp_info_set, cons
inline NodeID inline NodeID
DataTree::AddBinaryOp(NodeID arg1, BinaryOpcode op_code, NodeID arg2) DataTree::AddBinaryOp(NodeID arg1, BinaryOpcode op_code, NodeID arg2)
{ {
binary_op_node_map_type::iterator it = binary_op_node_map.find(make_pair(make_pair(arg1, arg2), op_code)); binary_op_node_map_t::iterator it = binary_op_node_map.find(make_pair(make_pair(arg1, arg2), op_code));
if (it != binary_op_node_map.end()) if (it != binary_op_node_map.end())
return it->second; return it->second;
// Try to reduce to a constant // Try to reduce to a constant
try try
{ {
double argval1 = arg1->eval(eval_context_type()); double argval1 = arg1->eval(eval_context_t());
double argval2 = arg2->eval(eval_context_type()); double argval2 = arg2->eval(eval_context_t());
double val = BinaryOpNode::eval_opcode(argval1, op_code, argval2); double val = BinaryOpNode::eval_opcode(argval1, op_code, argval2);
return AddPossiblyNegativeConstant(val); return AddPossiblyNegativeConstant(val);
} }
@ -296,16 +296,16 @@ DataTree::AddBinaryOp(NodeID arg1, BinaryOpcode op_code, NodeID arg2)
inline NodeID inline NodeID
DataTree::AddTrinaryOp(NodeID arg1, TrinaryOpcode op_code, NodeID arg2, NodeID arg3) DataTree::AddTrinaryOp(NodeID arg1, TrinaryOpcode op_code, NodeID arg2, NodeID arg3)
{ {
trinary_op_node_map_type::iterator it = trinary_op_node_map.find(make_pair(make_pair(make_pair(arg1, arg2), arg3), op_code)); trinary_op_node_map_t::iterator it = trinary_op_node_map.find(make_pair(make_pair(make_pair(arg1, arg2), arg3), op_code));
if (it != trinary_op_node_map.end()) if (it != trinary_op_node_map.end())
return it->second; return it->second;
// Try to reduce to a constant // Try to reduce to a constant
try try
{ {
double argval1 = arg1->eval(eval_context_type()); double argval1 = arg1->eval(eval_context_t());
double argval2 = arg2->eval(eval_context_type()); double argval2 = arg2->eval(eval_context_t());
double argval3 = arg3->eval(eval_context_type()); double argval3 = arg3->eval(eval_context_t());
double val = TrinaryOpNode::eval_opcode(argval1, op_code, argval2, argval3); double val = TrinaryOpNode::eval_opcode(argval1, op_code, argval2, argval3);
return AddPossiblyNegativeConstant(val); return AddPossiblyNegativeConstant(val);
} }

View File

@ -57,9 +57,9 @@ DynamicModel::AddVariable(int symb_id, int lag)
} }
void void
DynamicModel::compileDerivative(ofstream &code_file, int eq, int symb_id, int lag, const map_idx_type &map_idx) const DynamicModel::compileDerivative(ofstream &code_file, int eq, int symb_id, int lag, const map_idx_t &map_idx) const
{ {
first_derivatives_type::const_iterator it = first_derivatives.find(make_pair(eq, getDerivID(symbol_table.getID(eEndogenous, symb_id), lag))); first_derivatives_t::const_iterator it = first_derivatives.find(make_pair(eq, getDerivID(symbol_table.getID(eEndogenous, symb_id), lag)));
if (it != first_derivatives.end()) if (it != first_derivatives.end())
(it->second)->compile(code_file, false, temporary_terms, map_idx, true, false); (it->second)->compile(code_file, false, temporary_terms, map_idx, true, false);
else else
@ -70,7 +70,7 @@ DynamicModel::compileDerivative(ofstream &code_file, int eq, int symb_id, int la
} }
void void
DynamicModel::compileChainRuleDerivative(ofstream &code_file, int eqr, int varr, int lag, const map_idx_type &map_idx) const DynamicModel::compileChainRuleDerivative(ofstream &code_file, int eqr, int varr, int lag, const map_idx_t &map_idx) const
{ {
map<pair<int, pair<int, int> >, NodeID>::const_iterator it = first_chain_rule_derivatives.find(make_pair(eqr, make_pair(varr, lag))); map<pair<int, pair<int, int> >, NodeID>::const_iterator it = first_chain_rule_derivatives.find(make_pair(eqr, make_pair(varr, lag)));
if (it != first_chain_rule_derivatives.end()) if (it != first_chain_rule_derivatives.end())
@ -100,15 +100,15 @@ DynamicModel::computeTemporaryTermsOrdered()
map<NodeID, pair<int, int> > first_occurence; map<NodeID, pair<int, int> > first_occurence;
map<NodeID, int> reference_count; map<NodeID, int> reference_count;
BinaryOpNode *eq_node; BinaryOpNode *eq_node;
first_derivatives_type::const_iterator it; first_derivatives_t::const_iterator it;
first_chain_rule_derivatives_type::const_iterator it_chr; first_chain_rule_derivatives_t::const_iterator it_chr;
ostringstream tmp_s; ostringstream tmp_s;
v_temporary_terms.clear(); v_temporary_terms.clear();
map_idx.clear(); map_idx.clear();
unsigned int nb_blocks = getNbBlocks(); unsigned int nb_blocks = getNbBlocks();
v_temporary_terms = vector<vector<temporary_terms_type> >(nb_blocks); v_temporary_terms = vector<vector<temporary_terms_t> >(nb_blocks);
v_temporary_terms_inuse = vector<temporary_terms_inuse_type>(nb_blocks); v_temporary_terms_inuse = vector<temporary_terms_inuse_t>(nb_blocks);
temporary_terms.clear(); temporary_terms.clear();
if (!global_temporary_terms) if (!global_temporary_terms)
@ -120,7 +120,7 @@ DynamicModel::computeTemporaryTermsOrdered()
unsigned int block_size = getBlockSize(block); unsigned int block_size = getBlockSize(block);
unsigned int block_nb_mfs = getBlockMfs(block); unsigned int block_nb_mfs = getBlockMfs(block);
unsigned int block_nb_recursives = block_size - block_nb_mfs; unsigned int block_nb_recursives = block_size - block_nb_mfs;
v_temporary_terms[block] = vector<temporary_terms_type>(block_size); v_temporary_terms[block] = vector<temporary_terms_t>(block_size);
for (unsigned int i = 0; i < block_size; i++) for (unsigned int i = 0; i < block_size; i++)
{ {
if (i < block_nb_recursives && isBlockEquationRenormalized(block, i)) if (i < block_nb_recursives && isBlockEquationRenormalized(block, i))
@ -131,14 +131,14 @@ DynamicModel::computeTemporaryTermsOrdered()
eq_node->computeTemporaryTerms(reference_count, temporary_terms, first_occurence, block, v_temporary_terms, i); eq_node->computeTemporaryTerms(reference_count, temporary_terms, first_occurence, block, v_temporary_terms, i);
} }
} }
for (t_block_derivatives_equation_variable_laglead_nodeid::const_iterator it = blocks_derivatives[block].begin(); it != (blocks_derivatives[block]).end(); it++) for (block_derivatives_equation_variable_laglead_nodeid_t::const_iterator it = blocks_derivatives[block].begin(); it != (blocks_derivatives[block]).end(); it++)
{ {
NodeID id = it->second.second; NodeID id = it->second.second;
id->computeTemporaryTerms(reference_count, temporary_terms, first_occurence, block, v_temporary_terms, block_size-1); id->computeTemporaryTerms(reference_count, temporary_terms, first_occurence, block, v_temporary_terms, block_size-1);
} }
for (t_derivative::const_iterator it = derivative_endo[block].begin(); it != derivative_endo[block].end(); it++) for (derivative_t::const_iterator it = derivative_endo[block].begin(); it != derivative_endo[block].end(); it++)
it->second->computeTemporaryTerms(reference_count, temporary_terms, first_occurence, block, v_temporary_terms, block_size-1); it->second->computeTemporaryTerms(reference_count, temporary_terms, first_occurence, block, v_temporary_terms, block_size-1);
for (t_derivative::const_iterator it = derivative_other_endo[block].begin(); it != derivative_other_endo[block].end(); it++) for (derivative_t::const_iterator it = derivative_other_endo[block].begin(); it != derivative_other_endo[block].end(); it++)
it->second->computeTemporaryTerms(reference_count, temporary_terms, first_occurence, block, v_temporary_terms, block_size-1); it->second->computeTemporaryTerms(reference_count, temporary_terms, first_occurence, block, v_temporary_terms, block_size-1);
set<int> temporary_terms_in_use; set<int> temporary_terms_in_use;
@ -154,7 +154,7 @@ DynamicModel::computeTemporaryTermsOrdered()
unsigned int block_size = getBlockSize(block); unsigned int block_size = getBlockSize(block);
unsigned int block_nb_mfs = getBlockMfs(block); unsigned int block_nb_mfs = getBlockMfs(block);
unsigned int block_nb_recursives = block_size - block_nb_mfs; unsigned int block_nb_recursives = block_size - block_nb_mfs;
v_temporary_terms[block] = vector<temporary_terms_type>(block_size); v_temporary_terms[block] = vector<temporary_terms_t>(block_size);
for (unsigned int i = 0; i < block_size; i++) for (unsigned int i = 0; i < block_size; i++)
{ {
if (i < block_nb_recursives && isBlockEquationRenormalized(block, i)) if (i < block_nb_recursives && isBlockEquationRenormalized(block, i))
@ -165,14 +165,14 @@ DynamicModel::computeTemporaryTermsOrdered()
eq_node->computeTemporaryTerms(reference_count, temporary_terms, first_occurence, block, v_temporary_terms, i); eq_node->computeTemporaryTerms(reference_count, temporary_terms, first_occurence, block, v_temporary_terms, i);
} }
} }
for (t_block_derivatives_equation_variable_laglead_nodeid::const_iterator it = blocks_derivatives[block].begin(); it != (blocks_derivatives[block]).end(); it++) for (block_derivatives_equation_variable_laglead_nodeid_t::const_iterator it = blocks_derivatives[block].begin(); it != (blocks_derivatives[block]).end(); it++)
{ {
NodeID id = it->second.second; NodeID id = it->second.second;
id->computeTemporaryTerms(reference_count, temporary_terms, first_occurence, block, v_temporary_terms, block_size-1); id->computeTemporaryTerms(reference_count, temporary_terms, first_occurence, block, v_temporary_terms, block_size-1);
} }
for (t_derivative::const_iterator it = derivative_endo[block].begin(); it != derivative_endo[block].end(); it++) for (derivative_t::const_iterator it = derivative_endo[block].begin(); it != derivative_endo[block].end(); it++)
it->second->computeTemporaryTerms(reference_count, temporary_terms, first_occurence, block, v_temporary_terms, block_size-1); it->second->computeTemporaryTerms(reference_count, temporary_terms, first_occurence, block, v_temporary_terms, block_size-1);
for (t_derivative::const_iterator it = derivative_other_endo[block].begin(); it != derivative_other_endo[block].end(); it++) for (derivative_t::const_iterator it = derivative_other_endo[block].begin(); it != derivative_other_endo[block].end(); it++)
it->second->computeTemporaryTerms(reference_count, temporary_terms, first_occurence, block, v_temporary_terms, block_size-1); it->second->computeTemporaryTerms(reference_count, temporary_terms, first_occurence, block, v_temporary_terms, block_size-1);
} }
for (unsigned int block = 0; block < nb_blocks; block++) for (unsigned int block = 0; block < nb_blocks; block++)
@ -192,14 +192,14 @@ DynamicModel::computeTemporaryTermsOrdered()
eq_node->collectTemporary_terms(temporary_terms, temporary_terms_in_use, block); eq_node->collectTemporary_terms(temporary_terms, temporary_terms_in_use, block);
} }
} }
for (t_block_derivatives_equation_variable_laglead_nodeid::const_iterator it = blocks_derivatives[block].begin(); it != (blocks_derivatives[block]).end(); it++) for (block_derivatives_equation_variable_laglead_nodeid_t::const_iterator it = blocks_derivatives[block].begin(); it != (blocks_derivatives[block]).end(); it++)
{ {
NodeID id = it->second.second; NodeID id = it->second.second;
id->collectTemporary_terms(temporary_terms, temporary_terms_in_use, block); id->collectTemporary_terms(temporary_terms, temporary_terms_in_use, block);
} }
for (t_derivative::const_iterator it = derivative_endo[block].begin(); it != derivative_endo[block].end(); it++) for (derivative_t::const_iterator it = derivative_endo[block].begin(); it != derivative_endo[block].end(); it++)
it->second->collectTemporary_terms(temporary_terms, temporary_terms_in_use, block); it->second->collectTemporary_terms(temporary_terms, temporary_terms_in_use, block);
for (t_derivative::const_iterator it = derivative_other_endo[block].begin(); it != derivative_other_endo[block].end(); it++) for (derivative_t::const_iterator it = derivative_other_endo[block].begin(); it != derivative_other_endo[block].end(); it++)
it->second->collectTemporary_terms(temporary_terms, temporary_terms_in_use, block); it->second->collectTemporary_terms(temporary_terms, temporary_terms_in_use, block);
v_temporary_terms_inuse[block] = temporary_terms_in_use; v_temporary_terms_inuse[block] = temporary_terms_in_use;
} }
@ -212,7 +212,7 @@ DynamicModel::computeTemporaryTermsMapping()
{ {
// Add a mapping form node ID to temporary terms order // Add a mapping form node ID to temporary terms order
int j = 0; int j = 0;
for (temporary_terms_type::const_iterator it = temporary_terms.begin(); for (temporary_terms_t::const_iterator it = temporary_terms.begin();
it != temporary_terms.end(); it++) it != temporary_terms.end(); it++)
map_idx[(*it)->idx] = j++; map_idx[(*it)->idx] = j++;
} }
@ -227,7 +227,7 @@ DynamicModel::writeModelEquationsOrdered_M(const string &dynamic_basename) const
BinaryOpNode *eq_node; BinaryOpNode *eq_node;
ostringstream Uf[symbol_table.endo_nbr()]; ostringstream Uf[symbol_table.endo_nbr()];
map<NodeID, int> reference_count; map<NodeID, int> reference_count;
temporary_terms_type local_temporary_terms; temporary_terms_t local_temporary_terms;
ofstream output; ofstream output;
int nze, nze_exo, nze_other_endo; int nze, nze_exo, nze_other_endo;
vector<int> feedback_variables; vector<int> feedback_variables;
@ -347,14 +347,14 @@ DynamicModel::writeModelEquationsOrdered_M(const string &dynamic_basename) const
if (v_temporary_terms_inuse[block].size()) if (v_temporary_terms_inuse[block].size())
{ {
tmp_output.str(""); tmp_output.str("");
for (temporary_terms_inuse_type::const_iterator it = v_temporary_terms_inuse[block].begin(); for (temporary_terms_inuse_t::const_iterator it = v_temporary_terms_inuse[block].begin();
it != v_temporary_terms_inuse[block].end(); it++) it != v_temporary_terms_inuse[block].end(); it++)
tmp_output << " T" << *it; tmp_output << " T" << *it;
output << " global" << tmp_output.str() << ";\n"; output << " global" << tmp_output.str() << ";\n";
} }
if (simulation_type == SOLVE_TWO_BOUNDARIES_COMPLETE || simulation_type == SOLVE_TWO_BOUNDARIES_SIMPLE) if (simulation_type == SOLVE_TWO_BOUNDARIES_COMPLETE || simulation_type == SOLVE_TWO_BOUNDARIES_SIMPLE)
{ {
temporary_terms_type tt2; temporary_terms_t tt2;
tt2.clear(); tt2.clear();
for (int i = 0; i < (int) block_size; i++) for (int i = 0; i < (int) block_size; i++)
{ {
@ -362,7 +362,7 @@ DynamicModel::writeModelEquationsOrdered_M(const string &dynamic_basename) const
{ {
output << " " << "% //Temporary variables initialization" << endl output << " " << "% //Temporary variables initialization" << endl
<< " " << "T_zeros = zeros(y_kmin+periods, 1);" << endl; << " " << "T_zeros = zeros(y_kmin+periods, 1);" << endl;
for (temporary_terms_type::const_iterator it = v_temporary_terms[block][i].begin(); for (temporary_terms_t::const_iterator it = v_temporary_terms[block][i].begin();
it != v_temporary_terms[block][i].end(); it++) it != v_temporary_terms[block][i].end(); it++)
{ {
output << " "; output << " ";
@ -398,12 +398,12 @@ DynamicModel::writeModelEquationsOrdered_M(const string &dynamic_basename) const
// The equations // The equations
for (unsigned int i = 0; i < block_size; i++) for (unsigned int i = 0; i < block_size; i++)
{ {
temporary_terms_type tt2; temporary_terms_t tt2;
tt2.clear(); tt2.clear();
if (v_temporary_terms[block].size()) if (v_temporary_terms[block].size())
{ {
output << " " << "% //Temporary variables" << endl; output << " " << "% //Temporary variables" << endl;
for (temporary_terms_type::const_iterator it = v_temporary_terms[block][i].begin(); for (temporary_terms_t::const_iterator it = v_temporary_terms[block][i].begin();
it != v_temporary_terms[block][i].end(); it++) it != v_temporary_terms[block][i].end(); it++)
{ {
output << " " << sps; output << " " << sps;
@ -509,7 +509,7 @@ DynamicModel::writeModelEquationsOrdered_M(const string &dynamic_basename) const
{ {
case EVALUATE_BACKWARD: case EVALUATE_BACKWARD:
case EVALUATE_FORWARD: case EVALUATE_FORWARD:
for (t_derivative::const_iterator it = derivative_endo[block].begin(); it != derivative_endo[block].end(); it++) for (derivative_t::const_iterator it = derivative_endo[block].begin(); it != derivative_endo[block].end(); it++)
{ {
int lag = it->first.first; int lag = it->first.first;
int eq = it->first.second.first; int eq = it->first.second.first;
@ -526,7 +526,7 @@ DynamicModel::writeModelEquationsOrdered_M(const string &dynamic_basename) const
<< ") " << var+1 << ") " << var+1
<< ", equation=" << eq+1 << endl; << ", equation=" << eq+1 << endl;
} }
for (t_derivative::const_iterator it = derivative_other_endo[block].begin(); it != derivative_other_endo[block].end(); it++) for (derivative_t::const_iterator it = derivative_other_endo[block].begin(); it != derivative_other_endo[block].end(); it++)
{ {
int lag = it->first.first; int lag = it->first.first;
int eq = it->first.second.first; int eq = it->first.second.first;
@ -550,7 +550,7 @@ DynamicModel::writeModelEquationsOrdered_M(const string &dynamic_basename) const
case SOLVE_FORWARD_SIMPLE: case SOLVE_FORWARD_SIMPLE:
case SOLVE_BACKWARD_COMPLETE: case SOLVE_BACKWARD_COMPLETE:
case SOLVE_FORWARD_COMPLETE: case SOLVE_FORWARD_COMPLETE:
for (t_derivative::const_iterator it = derivative_endo[block].begin(); it != derivative_endo[block].end(); it++) for (derivative_t::const_iterator it = derivative_endo[block].begin(); it != derivative_endo[block].end(); it++)
{ {
int lag = it->first.first; int lag = it->first.first;
unsigned int eq = it->first.second.first; unsigned int eq = it->first.second.first;
@ -565,7 +565,7 @@ DynamicModel::writeModelEquationsOrdered_M(const string &dynamic_basename) const
<< ", equation=" << eq+1 << endl; << ", equation=" << eq+1 << endl;
} }
for (t_derivative::const_iterator it = derivative_other_endo[block].begin(); it != derivative_other_endo[block].end(); it++) for (derivative_t::const_iterator it = derivative_other_endo[block].begin(); it != derivative_other_endo[block].end(); it++)
{ {
int lag = it->first.first; int lag = it->first.first;
unsigned int eq = it->first.second.first; unsigned int eq = it->first.second.first;
@ -582,7 +582,7 @@ DynamicModel::writeModelEquationsOrdered_M(const string &dynamic_basename) const
output << " varargout{1}=g1_x;\n"; output << " varargout{1}=g1_x;\n";
output << " varargout{2}=g1_o;\n"; output << " varargout{2}=g1_o;\n";
output << " else" << endl; output << " else" << endl;
for (t_block_derivatives_equation_variable_laglead_nodeid::const_iterator it = blocks_derivatives[block].begin(); it != (blocks_derivatives[block]).end(); it++) for (block_derivatives_equation_variable_laglead_nodeid_t::const_iterator it = blocks_derivatives[block].begin(); it != (blocks_derivatives[block]).end(); it++)
{ {
unsigned int eq = it->first.first; unsigned int eq = it->first.first;
unsigned int var = it->first.second; unsigned int var = it->first.second;
@ -602,7 +602,7 @@ DynamicModel::writeModelEquationsOrdered_M(const string &dynamic_basename) const
case SOLVE_TWO_BOUNDARIES_SIMPLE: case SOLVE_TWO_BOUNDARIES_SIMPLE:
case SOLVE_TWO_BOUNDARIES_COMPLETE: case SOLVE_TWO_BOUNDARIES_COMPLETE:
output << " if ~jacobian_eval" << endl; output << " if ~jacobian_eval" << endl;
for (t_block_derivatives_equation_variable_laglead_nodeid::const_iterator it = blocks_derivatives[block].begin(); it != (blocks_derivatives[block]).end(); it++) for (block_derivatives_equation_variable_laglead_nodeid_t::const_iterator it = blocks_derivatives[block].begin(); it != (blocks_derivatives[block]).end(); it++)
{ {
unsigned int eq = it->first.first; unsigned int eq = it->first.first;
unsigned int var = it->first.second; unsigned int var = it->first.second;
@ -682,7 +682,7 @@ DynamicModel::writeModelEquationsOrdered_M(const string &dynamic_basename) const
output << " else" << endl; output << " else" << endl;
for (t_derivative::const_iterator it = derivative_endo[block].begin(); it != derivative_endo[block].end(); it++) for (derivative_t::const_iterator it = derivative_endo[block].begin(); it != derivative_endo[block].end(); it++)
{ {
int lag = it->first.first; int lag = it->first.first;
unsigned int eq = it->first.second.first; unsigned int eq = it->first.second.first;
@ -695,7 +695,7 @@ DynamicModel::writeModelEquationsOrdered_M(const string &dynamic_basename) const
<< ") " << var+1 << ") " << var+1
<< ", equation=" << eq+1 << endl; << ", equation=" << eq+1 << endl;
} }
for (t_derivative::const_iterator it = derivative_other_endo[block].begin(); it != derivative_other_endo[block].end(); it++) for (derivative_t::const_iterator it = derivative_other_endo[block].begin(); it != derivative_other_endo[block].end(); it++)
{ {
int lag = it->first.first; int lag = it->first.first;
unsigned int eq = it->first.second.first; unsigned int eq = it->first.second.first;
@ -722,7 +722,7 @@ DynamicModel::writeModelEquationsOrdered_M(const string &dynamic_basename) const
} }
void void
DynamicModel::writeModelEquationsCode(string &file_name, const string &bin_basename, const map_idx_type &map_idx) const DynamicModel::writeModelEquationsCode(string &file_name, const string &bin_basename, const map_idx_t &map_idx) const
{ {
ostringstream tmp_output; ostringstream tmp_output;
ofstream code_file; ofstream code_file;
@ -778,7 +778,7 @@ DynamicModel::writeModelEquationsCode(string &file_name, const string &bin_basen
vector<vector<pair<pair<int, int>, int > > > derivatives; vector<vector<pair<pair<int, int>, int > > > derivatives;
derivatives.resize(symbol_table.endo_nbr()); derivatives.resize(symbol_table.endo_nbr());
count_u = symbol_table.endo_nbr(); count_u = symbol_table.endo_nbr();
for (first_derivatives_type::const_iterator it = first_derivatives.begin(); for (first_derivatives_t::const_iterator it = first_derivatives.begin();
it != first_derivatives.end(); it++) it != first_derivatives.end(); it++)
{ {
int deriv_id = it->first.second; int deriv_id = it->first.second;
@ -835,7 +835,7 @@ DynamicModel::writeModelEquationsCode(string &file_name, const string &bin_basen
void void
DynamicModel::writeModelEquationsCode_Block(string &file_name, const string &bin_basename, const map_idx_type &map_idx) const DynamicModel::writeModelEquationsCode_Block(string &file_name, const string &bin_basename, const map_idx_t &map_idx) const
{ {
struct Uff_l struct Uff_l
{ {
@ -913,11 +913,11 @@ DynamicModel::writeModelEquationsCode_Block(string &file_name, const string &bin
for (i = 0; i < (int) block_size; i++) for (i = 0; i < (int) block_size; i++)
{ {
//The Temporary terms //The Temporary terms
temporary_terms_type tt2; temporary_terms_t tt2;
tt2.clear(); tt2.clear();
if (v_temporary_terms[block][i].size()) if (v_temporary_terms[block][i].size())
{ {
for (temporary_terms_type::const_iterator it = v_temporary_terms[block][i].begin(); for (temporary_terms_t::const_iterator it = v_temporary_terms[block][i].begin();
it != v_temporary_terms[block][i].end(); it++) it != v_temporary_terms[block][i].end(); it++)
{ {
FNUMEXPR_ fnumexpr(TemporaryTerm, (int)(map_idx.find((*it)->idx)->second)); FNUMEXPR_ fnumexpr(TemporaryTerm, (int)(map_idx.find((*it)->idx)->second));
@ -937,10 +937,10 @@ DynamicModel::writeModelEquationsCode_Block(string &file_name, const string &bin
} }
} }
#ifdef DEBUGC #ifdef DEBUGC
for (temporary_terms_type::const_iterator it = v_temporary_terms[block][i].begin(); for (temporary_terms_t::const_iterator it = v_temporary_terms[block][i].begin();
it != v_temporary_terms[block][i].end(); it++) it != v_temporary_terms[block][i].end(); it++)
{ {
map_idx_type::const_iterator ii = map_idx.find((*it)->idx); map_idx_t::const_iterator ii = map_idx.find((*it)->idx);
cout << "map_idx[" << (*it)->idx <<"]=" << ii->second << "\n"; cout << "map_idx[" << (*it)->idx <<"]=" << ii->second << "\n";
} }
#endif #endif
@ -1028,7 +1028,7 @@ DynamicModel::writeModelEquationsCode_Block(string &file_name, const string &bin
case SOLVE_TWO_BOUNDARIES_COMPLETE: case SOLVE_TWO_BOUNDARIES_COMPLETE:
case SOLVE_TWO_BOUNDARIES_SIMPLE: case SOLVE_TWO_BOUNDARIES_SIMPLE:
count_u = feedback_variables.size(); count_u = feedback_variables.size();
for (t_block_derivatives_equation_variable_laglead_nodeid::const_iterator it = blocks_derivatives[block].begin(); it != (blocks_derivatives[block]).end(); it++) for (block_derivatives_equation_variable_laglead_nodeid_t::const_iterator it = blocks_derivatives[block].begin(); it != (blocks_derivatives[block]).end(); it++)
{ {
unsigned int eq = it->first.first; unsigned int eq = it->first.first;
unsigned int var = it->first.second; unsigned int var = it->first.second;
@ -1270,7 +1270,7 @@ DynamicModel::Write_Inf_To_Bin_File_Block(const string &dynamic_basename, const
unsigned int block_size = getBlockSize(num); unsigned int block_size = getBlockSize(num);
unsigned int block_mfs = getBlockMfs(num); unsigned int block_mfs = getBlockMfs(num);
unsigned int block_recursive = block_size - block_mfs; unsigned int block_recursive = block_size - block_mfs;
for (t_block_derivatives_equation_variable_laglead_nodeid::const_iterator it = blocks_derivatives[num].begin(); it != (blocks_derivatives[num]).end(); it++) for (block_derivatives_equation_variable_laglead_nodeid_t::const_iterator it = blocks_derivatives[num].begin(); it != (blocks_derivatives[num]).end(); it++)
{ {
unsigned int eq = it->first.first; unsigned int eq = it->first.first;
unsigned int var = it->first.second; unsigned int var = it->first.second;
@ -1335,7 +1335,7 @@ DynamicModel::writeSparseDynamicMFile(const string &dynamic_basename, const stri
//Temporary variables declaration //Temporary variables declaration
OK = true; OK = true;
ostringstream tmp_output; ostringstream tmp_output;
for (temporary_terms_type::const_iterator it = temporary_terms.begin(); for (temporary_terms_t::const_iterator it = temporary_terms.begin();
it != temporary_terms.end(); it++) it != temporary_terms.end(); it++)
{ {
if (OK) if (OK)
@ -1349,7 +1349,7 @@ DynamicModel::writeSparseDynamicMFile(const string &dynamic_basename, const stri
mDynamicModelFile << " T_init=zeros(1,options_.periods+M_.maximum_lag+M_.maximum_lead);\n"; mDynamicModelFile << " T_init=zeros(1,options_.periods+M_.maximum_lag+M_.maximum_lead);\n";
tmp_output.str(""); tmp_output.str("");
for (temporary_terms_type::const_iterator it = temporary_terms.begin(); for (temporary_terms_t::const_iterator it = temporary_terms.begin();
it != temporary_terms.end(); it++) it != temporary_terms.end(); it++)
{ {
tmp_output << " "; tmp_output << " ";
@ -1655,7 +1655,7 @@ DynamicModel::writeDynamicModel(ostream &DynamicOutput, bool use_dll) const
int hessianColsNbr = dynJacobianColsNbr * dynJacobianColsNbr; int hessianColsNbr = dynJacobianColsNbr * dynJacobianColsNbr;
// Writing Jacobian // Writing Jacobian
for (first_derivatives_type::const_iterator it = first_derivatives.begin(); for (first_derivatives_t::const_iterator it = first_derivatives.begin();
it != first_derivatives.end(); it++) it != first_derivatives.end(); it++)
{ {
int eq = it->first.first; int eq = it->first.first;
@ -1671,7 +1671,7 @@ DynamicModel::writeDynamicModel(ostream &DynamicOutput, bool use_dll) const
// Writing Hessian // Writing Hessian
int k = 0; // Keep the line of a 2nd derivative in v2 int k = 0; // Keep the line of a 2nd derivative in v2
for (second_derivatives_type::const_iterator it = second_derivatives.begin(); for (second_derivatives_t::const_iterator it = second_derivatives.begin();
it != second_derivatives.end(); it++) it != second_derivatives.end(); it++)
{ {
int eq = it->first.first; int eq = it->first.first;
@ -1718,7 +1718,7 @@ DynamicModel::writeDynamicModel(ostream &DynamicOutput, bool use_dll) const
// Writing third derivatives // Writing third derivatives
k = 0; // Keep the line of a 3rd derivative in v3 k = 0; // Keep the line of a 3rd derivative in v3
for (third_derivatives_type::const_iterator it = third_derivatives.begin(); for (third_derivatives_t::const_iterator it = third_derivatives.begin();
it != third_derivatives.end(); it++) it != third_derivatives.end(); it++)
{ {
int eq = it->first.first; int eq = it->first.first;
@ -1935,7 +1935,7 @@ DynamicModel::writeOutput(ostream &output, const string &basename, bool block_de
tmp_s_eq << " " << getBlockEquationID(block, i)+1; tmp_s_eq << " " << getBlockEquationID(block, i)+1;
} }
it_exogenous = exogenous.begin(); it_exogenous = exogenous.begin();
for (t_lag_var::const_iterator it = exo_block[block].begin(); it != exo_block[block].end(); it++) for (lag_var_t::const_iterator it = exo_block[block].begin(); it != exo_block[block].end(); it++)
it_exogenous = set_union(it->second.begin(), it->second.end(), exogenous.begin(), exogenous.end(), it_exogenous); it_exogenous = set_union(it->second.begin(), it->second.end(), exogenous.begin(), exogenous.end(), it_exogenous);
output << "M_.block_structure.block(" << block+1 << ").num = " << block+1 << ";\n"; output << "M_.block_structure.block(" << block+1 << ").num = " << block+1 << ";\n";
output << "M_.block_structure.block(" << block+1 << ").Simulation_Type = " << simulation_type << ";\n"; output << "M_.block_structure.block(" << block+1 << ").Simulation_Type = " << simulation_type << ";\n";
@ -1963,15 +1963,15 @@ DynamicModel::writeOutput(ostream &output, const string &basename, bool block_de
tmp_s.str(""); tmp_s.str("");
count_lead_lag_incidence = 0; count_lead_lag_incidence = 0;
dynamic_jacob_map reordered_dynamic_jacobian; dynamic_jacob_map_t reordered_dynamic_jacobian;
for (t_block_derivatives_equation_variable_laglead_nodeid::const_iterator it = blocks_derivatives[block].begin(); it != blocks_derivatives[block].end(); it++) for (block_derivatives_equation_variable_laglead_nodeid_t::const_iterator it = blocks_derivatives[block].begin(); it != blocks_derivatives[block].end(); it++)
reordered_dynamic_jacobian[make_pair(it->second.first, make_pair(it->first.second, it->first.first))] = it->second.second; reordered_dynamic_jacobian[make_pair(it->second.first, make_pair(it->first.second, it->first.first))] = it->second.second;
output << "M_.block_structure.block(" << block+1 << ").lead_lag_incidence = [];\n"; output << "M_.block_structure.block(" << block+1 << ").lead_lag_incidence = [];\n";
int last_var = -1; int last_var = -1;
for (int lag = -max_lag_endo; lag < max_lead_endo+1; lag++) for (int lag = -max_lag_endo; lag < max_lead_endo+1; lag++)
{ {
last_var = 0; last_var = 0;
for (dynamic_jacob_map::const_iterator it = reordered_dynamic_jacobian.begin(); it != reordered_dynamic_jacobian.end(); it++) for (dynamic_jacob_map_t::const_iterator it = reordered_dynamic_jacobian.begin(); it != reordered_dynamic_jacobian.end(); it++)
{ {
if (lag == it->first.first && last_var != it->first.second.first) if (lag == it->first.first && last_var != it->first.second.first)
{ {
@ -2001,7 +2001,7 @@ DynamicModel::writeOutput(ostream &output, const string &basename, bool block_de
output << " " << equation_reordered[i]+1; output << " " << equation_reordered[i]+1;
output << "];\n"; output << "];\n";
map<pair< int, pair<int, int> >, int> lag_row_incidence; map<pair< int, pair<int, int> >, int> lag_row_incidence;
for (first_derivatives_type::const_iterator it = first_derivatives.begin(); for (first_derivatives_t::const_iterator it = first_derivatives.begin();
it != first_derivatives.end(); it++) it != first_derivatives.end(); it++)
{ {
int deriv_id = it->first.second; int deriv_id = it->first.second;
@ -2078,7 +2078,7 @@ map<pair<int, pair<int, int > >, NodeID>
DynamicModel::collect_first_order_derivatives_endogenous() DynamicModel::collect_first_order_derivatives_endogenous()
{ {
map<pair<int, pair<int, int > >, NodeID> endo_derivatives; map<pair<int, pair<int, int > >, NodeID> endo_derivatives;
for (first_derivatives_type::iterator it2 = first_derivatives.begin(); for (first_derivatives_t::iterator it2 = first_derivatives.begin();
it2 != first_derivatives.end(); it2++) it2 != first_derivatives.end(); it2++)
{ {
if (getTypeByDerivID(it2->first.second) == eEndogenous) if (getTypeByDerivID(it2->first.second) == eEndogenous)
@ -2094,7 +2094,7 @@ DynamicModel::collect_first_order_derivatives_endogenous()
void void
DynamicModel::computingPass(bool jacobianExo, bool hessian, bool thirdDerivatives, bool paramsDerivatives, DynamicModel::computingPass(bool jacobianExo, bool hessian, bool thirdDerivatives, bool paramsDerivatives,
const eval_context_type &eval_context, bool no_tmp_terms, bool block, bool use_dll, bool bytecode) const eval_context_t &eval_context, bool no_tmp_terms, bool block, bool use_dll, bool bytecode)
{ {
assert(jacobianExo || !(hessian || thirdDerivatives || paramsDerivatives)); assert(jacobianExo || !(hessian || thirdDerivatives || paramsDerivatives));
@ -2142,7 +2142,7 @@ DynamicModel::computingPass(bool jacobianExo, bool hessian, bool thirdDerivative
if (block) if (block)
{ {
jacob_map contemporaneous_jacobian, static_jacobian; jacob_map_t contemporaneous_jacobian, static_jacobian;
// for each block contains pair<Size, Feddback_variable> // for each block contains pair<Size, Feddback_variable>
vector<pair<int, int> > blocks; vector<pair<int, int> > blocks;
@ -2241,14 +2241,14 @@ DynamicModel::get_Derivatives(int block)
} }
void void
DynamicModel::computeChainRuleJacobian(t_blocks_derivatives &blocks_derivatives) DynamicModel::computeChainRuleJacobian(blocks_derivatives_t &blocks_derivatives)
{ {
map<int, NodeID> recursive_variables; map<int, NodeID> recursive_variables;
unsigned int nb_blocks = getNbBlocks(); unsigned int nb_blocks = getNbBlocks();
blocks_derivatives = t_blocks_derivatives(nb_blocks); blocks_derivatives = blocks_derivatives_t(nb_blocks);
for (unsigned int block = 0; block < nb_blocks; block++) for (unsigned int block = 0; block < nb_blocks; block++)
{ {
t_block_derivatives_equation_variable_laglead_nodeid tmp_derivatives; block_derivatives_equation_variable_laglead_nodeid_t tmp_derivatives;
recursive_variables.clear(); recursive_variables.clear();
BlockSimulationType simulation_type = getBlockSimulationType(block); BlockSimulationType simulation_type = getBlockSimulationType(block);
int block_size = getBlockSize(block); int block_size = getBlockSize(block);
@ -2256,7 +2256,7 @@ DynamicModel::computeChainRuleJacobian(t_blocks_derivatives &blocks_derivatives)
int block_nb_recursives = block_size - block_nb_mfs; int block_nb_recursives = block_size - block_nb_mfs;
if (simulation_type == SOLVE_TWO_BOUNDARIES_COMPLETE || simulation_type == SOLVE_TWO_BOUNDARIES_SIMPLE) if (simulation_type == SOLVE_TWO_BOUNDARIES_COMPLETE || simulation_type == SOLVE_TWO_BOUNDARIES_SIMPLE)
{ {
blocks_derivatives.push_back(t_block_derivatives_equation_variable_laglead_nodeid(0)); blocks_derivatives.push_back(block_derivatives_equation_variable_laglead_nodeid_t(0));
for (int i = 0; i < block_nb_recursives; i++) for (int i = 0; i < block_nb_recursives; i++)
{ {
if (getBlockEquationType(block, i) == E_EVALUATE_S) if (getBlockEquationType(block, i) == E_EVALUATE_S)
@ -2293,7 +2293,7 @@ DynamicModel::computeChainRuleJacobian(t_blocks_derivatives &blocks_derivatives)
else if (simulation_type == SOLVE_BACKWARD_SIMPLE || simulation_type == SOLVE_FORWARD_SIMPLE else if (simulation_type == SOLVE_BACKWARD_SIMPLE || simulation_type == SOLVE_FORWARD_SIMPLE
|| simulation_type == SOLVE_BACKWARD_COMPLETE || simulation_type == SOLVE_FORWARD_COMPLETE) || simulation_type == SOLVE_BACKWARD_COMPLETE || simulation_type == SOLVE_FORWARD_COMPLETE)
{ {
blocks_derivatives.push_back(t_block_derivatives_equation_variable_laglead_nodeid(0)); blocks_derivatives.push_back(block_derivatives_equation_variable_laglead_nodeid_t(0));
for (int i = 0; i < block_nb_recursives; i++) for (int i = 0; i < block_nb_recursives; i++)
{ {
if (getBlockEquationType(block, i) == E_EVALUATE_S) if (getBlockEquationType(block, i) == E_EVALUATE_S)
@ -2337,19 +2337,19 @@ DynamicModel::collect_block_first_order_derivatives()
variable_2_block[getBlockVariableID(block, i)] = block; variable_2_block[getBlockVariableID(block, i)] = block;
} }
} }
other_endo_block = vector<t_lag_var>(nb_blocks); other_endo_block = vector<lag_var_t>(nb_blocks);
exo_block = vector<t_lag_var>(nb_blocks); exo_block = vector<lag_var_t>(nb_blocks);
exo_det_block = vector<t_lag_var>(nb_blocks); exo_det_block = vector<lag_var_t>(nb_blocks);
derivative_endo = vector<t_derivative>(nb_blocks); derivative_endo = vector<derivative_t>(nb_blocks);
derivative_other_endo = vector<t_derivative>(nb_blocks); derivative_other_endo = vector<derivative_t>(nb_blocks);
derivative_exo = vector<t_derivative>(nb_blocks); derivative_exo = vector<derivative_t>(nb_blocks);
derivative_exo_det = vector<t_derivative>(nb_blocks); derivative_exo_det = vector<derivative_t>(nb_blocks);
endo_max_leadlag_block = vector<pair<int, int> >(nb_blocks, make_pair(0, 0)); endo_max_leadlag_block = vector<pair<int, int> >(nb_blocks, make_pair(0, 0));
other_endo_max_leadlag_block = vector<pair<int, int> >(nb_blocks, make_pair(0, 0)); other_endo_max_leadlag_block = vector<pair<int, int> >(nb_blocks, make_pair(0, 0));
exo_max_leadlag_block = vector<pair<int, int> >(nb_blocks, make_pair(0, 0)); exo_max_leadlag_block = vector<pair<int, int> >(nb_blocks, make_pair(0, 0));
exo_det_max_leadlag_block = vector<pair<int, int> >(nb_blocks, make_pair(0, 0)); exo_det_max_leadlag_block = vector<pair<int, int> >(nb_blocks, make_pair(0, 0));
max_leadlag_block = vector<pair<int, int> >(nb_blocks, make_pair(0, 0)); max_leadlag_block = vector<pair<int, int> >(nb_blocks, make_pair(0, 0));
for (first_derivatives_type::iterator it2 = first_derivatives.begin(); for (first_derivatives_t::iterator it2 = first_derivatives.begin();
it2 != first_derivatives.end(); it2++) it2 != first_derivatives.end(); it2++)
{ {
int eq = it2->first.first; int eq = it2->first.first;
@ -2357,8 +2357,8 @@ DynamicModel::collect_block_first_order_derivatives()
int lag = getLagByDerivID(it2->first.second); int lag = getLagByDerivID(it2->first.second);
int block_eq = equation_2_block[eq]; int block_eq = equation_2_block[eq];
int block_var = variable_2_block[var]; int block_var = variable_2_block[var];
t_derivative tmp_derivative; derivative_t tmp_derivative;
t_lag_var lag_var; lag_var_t lag_var;
switch (getTypeByDerivID(it2->first.second)) switch (getTypeByDerivID(it2->first.second))
{ {
case eEndogenous: case eEndogenous:
@ -2655,7 +2655,7 @@ DynamicModel::computeParamsDerivatives()
residuals_params_derivatives[make_pair(eq, param)] = d1; residuals_params_derivatives[make_pair(eq, param)] = d1;
} }
for (first_derivatives_type::const_iterator it2 = residuals_params_derivatives.begin(); for (first_derivatives_t::const_iterator it2 = residuals_params_derivatives.begin();
it2 != residuals_params_derivatives.end(); it2++) it2 != residuals_params_derivatives.end(); it2++)
{ {
int eq = it2->first.first; int eq = it2->first.first;
@ -2668,7 +2668,7 @@ DynamicModel::computeParamsDerivatives()
residuals_params_second_derivatives[make_pair(eq, make_pair(param1, param))] = d2; residuals_params_second_derivatives[make_pair(eq, make_pair(param1, param))] = d2;
} }
for (first_derivatives_type::const_iterator it2 = first_derivatives.begin(); for (first_derivatives_t::const_iterator it2 = first_derivatives.begin();
it2 != first_derivatives.end(); it2++) it2 != first_derivatives.end(); it2++)
{ {
int eq = it2->first.first; int eq = it2->first.first;
@ -2681,7 +2681,7 @@ DynamicModel::computeParamsDerivatives()
jacobian_params_derivatives[make_pair(eq, make_pair(var, param))] = d2; jacobian_params_derivatives[make_pair(eq, make_pair(var, param))] = d2;
} }
for (second_derivatives_type::const_iterator it2 = jacobian_params_derivatives.begin(); for (second_derivatives_t::const_iterator it2 = jacobian_params_derivatives.begin();
it2 != jacobian_params_derivatives.end(); it2++) it2 != jacobian_params_derivatives.end(); it2++)
{ {
int eq = it2->first.first; int eq = it2->first.first;
@ -2695,7 +2695,7 @@ DynamicModel::computeParamsDerivatives()
jacobian_params_second_derivatives[make_pair(eq, make_pair(var, make_pair(param1, param)))] = d2; jacobian_params_second_derivatives[make_pair(eq, make_pair(var, make_pair(param1, param)))] = d2;
} }
for (second_derivatives_type::const_iterator it2 = second_derivatives.begin(); for (second_derivatives_t::const_iterator it2 = second_derivatives.begin();
it2 != second_derivatives.end(); it2++) it2 != second_derivatives.end(); it2++)
{ {
int eq = it2->first.first; int eq = it2->first.first;
@ -2717,11 +2717,11 @@ DynamicModel::computeParamsDerivativesTemporaryTerms()
map<NodeID, int> reference_count; map<NodeID, int> reference_count;
params_derivs_temporary_terms.clear(); params_derivs_temporary_terms.clear();
for (first_derivatives_type::iterator it = residuals_params_derivatives.begin(); for (first_derivatives_t::iterator it = residuals_params_derivatives.begin();
it != residuals_params_derivatives.end(); it++) it != residuals_params_derivatives.end(); it++)
it->second->computeTemporaryTerms(reference_count, params_derivs_temporary_terms, true); it->second->computeTemporaryTerms(reference_count, params_derivs_temporary_terms, true);
for (second_derivatives_type::iterator it = jacobian_params_derivatives.begin(); for (second_derivatives_t::iterator it = jacobian_params_derivatives.begin();
it != jacobian_params_derivatives.end(); it++) it != jacobian_params_derivatives.end(); it++)
it->second->computeTemporaryTerms(reference_count, params_derivs_temporary_terms, true); it->second->computeTemporaryTerms(reference_count, params_derivs_temporary_terms, true);
} }
@ -2759,7 +2759,7 @@ DynamicModel::writeParamsDerivativesFile(const string &basename) const
paramsDerivsFile << "rp = zeros(" << equation_number() << ", " paramsDerivsFile << "rp = zeros(" << equation_number() << ", "
<< symbol_table.param_nbr() << ");" << endl; << symbol_table.param_nbr() << ");" << endl;
for (first_derivatives_type::const_iterator it = residuals_params_derivatives.begin(); for (first_derivatives_t::const_iterator it = residuals_params_derivatives.begin();
it != residuals_params_derivatives.end(); it++) it != residuals_params_derivatives.end(); it++)
{ {
int eq = it->first.first; int eq = it->first.first;
@ -2777,7 +2777,7 @@ DynamicModel::writeParamsDerivativesFile(const string &basename) const
paramsDerivsFile << "gp = zeros(" << equation_number() << ", " << dynJacobianColsNbr << ", " paramsDerivsFile << "gp = zeros(" << equation_number() << ", " << dynJacobianColsNbr << ", "
<< symbol_table.param_nbr() << ");" << endl; << symbol_table.param_nbr() << ");" << endl;
for (second_derivatives_type::const_iterator it = jacobian_params_derivatives.begin(); for (second_derivatives_t::const_iterator it = jacobian_params_derivatives.begin();
it != jacobian_params_derivatives.end(); it++) it != jacobian_params_derivatives.end(); it++)
{ {
int eq = it->first.first; int eq = it->first.first;
@ -2801,7 +2801,7 @@ DynamicModel::writeParamsDerivativesFile(const string &basename) const
<< ",4);" << endl; << ",4);" << endl;
int i = 1; int i = 1;
for (second_derivatives_type::const_iterator it = residuals_params_second_derivatives.begin(); for (second_derivatives_t::const_iterator it = residuals_params_second_derivatives.begin();
it != residuals_params_second_derivatives.end(); ++it, i++) it != residuals_params_second_derivatives.end(); ++it, i++)
{ {
int eq = it->first.first; int eq = it->first.first;
@ -2825,7 +2825,7 @@ DynamicModel::writeParamsDerivativesFile(const string &basename) const
<< ",5);" << endl; << ",5);" << endl;
i = 1; i = 1;
for (third_derivatives_type::const_iterator it = jacobian_params_second_derivatives.begin(); for (third_derivatives_t::const_iterator it = jacobian_params_second_derivatives.begin();
it != jacobian_params_second_derivatives.end(); ++it, i++) it != jacobian_params_second_derivatives.end(); ++it, i++)
{ {
int eq = it->first.first; int eq = it->first.first;
@ -2855,7 +2855,7 @@ DynamicModel::writeParamsDerivativesFile(const string &basename) const
paramsDerivsFile << "hp = zeros(" << hessian_params_derivatives.size() << ",5);" << endl; paramsDerivsFile << "hp = zeros(" << hessian_params_derivatives.size() << ",5);" << endl;
i = 1; i = 1;
for (third_derivatives_type::const_iterator it = hessian_params_derivatives.begin(); for (third_derivatives_t::const_iterator it = hessian_params_derivatives.begin();
it != hessian_params_derivatives.end(); ++it, i++) it != hessian_params_derivatives.end(); ++it, i++)
{ {
int eq = it->first.first; int eq = it->first.first;
@ -2885,7 +2885,7 @@ DynamicModel::writeParamsDerivativesFile(const string &basename) const
void void
DynamicModel::writeChainRuleDerivative(ostream &output, int eqr, int varr, int lag, DynamicModel::writeChainRuleDerivative(ostream &output, int eqr, int varr, int lag,
ExprNodeOutputType output_type, ExprNodeOutputType output_type,
const temporary_terms_type &temporary_terms) const const temporary_terms_t &temporary_terms) const
{ {
map<pair<int, pair<int, int> >, NodeID>::const_iterator it = first_chain_rule_derivatives.find(make_pair(eqr, make_pair(varr, lag))); map<pair<int, pair<int, int> >, NodeID>::const_iterator it = first_chain_rule_derivatives.find(make_pair(eqr, make_pair(varr, lag)));
if (it != first_chain_rule_derivatives.end()) if (it != first_chain_rule_derivatives.end())
@ -3087,7 +3087,7 @@ DynamicModel::transformPredeterminedVariables()
} }
void void
DynamicModel::fillEvalContext(eval_context_type &eval_context) const DynamicModel::fillEvalContext(eval_context_t &eval_context) const
{ {
// First, auxiliary variables // First, auxiliary variables
for (deque<BinaryOpNode *>::const_iterator it = aux_equations.begin(); for (deque<BinaryOpNode *>::const_iterator it = aux_equations.begin();

View File

@ -62,47 +62,47 @@ private:
Only non-null derivatives are stored in the map. Only non-null derivatives are stored in the map.
Parameter indices are those of the getDerivID() method. Parameter indices are those of the getDerivID() method.
*/ */
first_derivatives_type residuals_params_derivatives; first_derivatives_t residuals_params_derivatives;
//! Second derivatives of the residuals w.r. to parameters //! Second derivatives of the residuals w.r. to parameters
/*! First index is equation number, second and third indeces are parameters. /*! First index is equation number, second and third indeces are parameters.
Only non-null derivatives are stored in the map. Only non-null derivatives are stored in the map.
Parameter indices are those of the getDerivID() method. Parameter indices are those of the getDerivID() method.
*/ */
second_derivatives_type residuals_params_second_derivatives; second_derivatives_t residuals_params_second_derivatives;
//! Derivatives of the jacobian w.r. to parameters //! Derivatives of the jacobian w.r. to parameters
/*! First index is equation number, second is endo/exo/exo_det variable, and third is parameter. /*! First index is equation number, second is endo/exo/exo_det variable, and third is parameter.
Only non-null derivatives are stored in the map. Only non-null derivatives are stored in the map.
Variable and parameter indices are those of the getDerivID() method. Variable and parameter indices are those of the getDerivID() method.
*/ */
second_derivatives_type jacobian_params_derivatives; second_derivatives_t jacobian_params_derivatives;
//! Second derivatives of the jacobian w.r. to parameters //! Second derivatives of the jacobian w.r. to parameters
/*! First index is equation number, second is endo/exo/exo_det variable, and third and fourth are parameters. /*! First index is equation number, second is endo/exo/exo_det variable, and third and fourth are parameters.
Only non-null derivatives are stored in the map. Only non-null derivatives are stored in the map.
Variable and parameter indices are those of the getDerivID() method. Variable and parameter indices are those of the getDerivID() method.
*/ */
third_derivatives_type jacobian_params_second_derivatives; third_derivatives_t jacobian_params_second_derivatives;
//! Derivatives of the hessian w.r. to parameters //! Derivatives of the hessian w.r. to parameters
/*! First index is equation number, first and second are endo/exo/exo_det variable, and third is parameter. /*! First index is equation number, first and second are endo/exo/exo_det variable, and third is parameter.
Only non-null derivatives are stored in the map. Only non-null derivatives are stored in the map.
Variable and parameter indices are those of the getDerivID() method. Variable and parameter indices are those of the getDerivID() method.
*/ */
third_derivatives_type hessian_params_derivatives; third_derivatives_t hessian_params_derivatives;
//! Temporary terms for the file containing parameters dervicatives //! Temporary terms for the file containing parameters dervicatives
temporary_terms_type params_derivs_temporary_terms; temporary_terms_t params_derivs_temporary_terms;
//! Temporary terms for block decomposed models //! Temporary terms for block decomposed models
vector< vector<temporary_terms_type> > v_temporary_terms; vector< vector<temporary_terms_t> > v_temporary_terms;
vector<temporary_terms_inuse_type> v_temporary_terms_inuse; vector<temporary_terms_inuse_t> v_temporary_terms_inuse;
//! Store the derivatives or the chainrule derivatives:map<pair< equation, pair< variable, lead_lag >, NodeID> //! Store the derivatives or the chainrule derivatives:map<pair< equation, pair< variable, lead_lag >, NodeID>
typedef map< pair< int, pair< int, int> >, NodeID> first_chain_rule_derivatives_type; typedef map< pair< int, pair< int, int> >, NodeID> first_chain_rule_derivatives_t;
first_chain_rule_derivatives_type first_chain_rule_derivatives; first_chain_rule_derivatives_t first_chain_rule_derivatives;
//! Writes dynamic model file (Matlab version) //! Writes dynamic model file (Matlab version)
void writeDynamicMFile(const string &dynamic_basename) const; void writeDynamicMFile(const string &dynamic_basename) const;
@ -117,24 +117,24 @@ private:
//! Writes the Block reordred structure of the model in M output //! Writes the Block reordred structure of the model in M output
void writeModelEquationsOrdered_M(const string &dynamic_basename) const; void writeModelEquationsOrdered_M(const string &dynamic_basename) const;
//! Writes the code of the Block reordred structure of the model in virtual machine bytecode //! Writes the code of the Block reordred structure of the model in virtual machine bytecode
void writeModelEquationsCode_Block(string &file_name, const string &bin_basename, const map_idx_type &map_idx) const; void writeModelEquationsCode_Block(string &file_name, const string &bin_basename, const map_idx_t &map_idx) const;
//! Writes the code of the model in virtual machine bytecode //! Writes the code of the model in virtual machine bytecode
void writeModelEquationsCode(string &file_name, const string &bin_basename, const map_idx_type &map_idx) const; void writeModelEquationsCode(string &file_name, const string &bin_basename, const map_idx_t &map_idx) const;
//! Computes jacobian and prepares for equation normalization //! Computes jacobian and prepares for equation normalization
/*! Using values from initval/endval blocks and parameter initializations: /*! Using values from initval/endval blocks and parameter initializations:
- computes the jacobian for the model w.r. to contemporaneous variables - computes the jacobian for the model w.r. to contemporaneous variables
- removes edges of the incidence matrix when derivative w.r. to the corresponding variable is too close to zero (below the cutoff) - removes edges of the incidence matrix when derivative w.r. to the corresponding variable is too close to zero (below the cutoff)
*/ */
//void evaluateJacobian(const eval_context_type &eval_context, jacob_map *j_m, bool dynamic); //void evaluateJacobian(const eval_context_t &eval_context, jacob_map *j_m, bool dynamic);
//! return a map on the block jacobian //! return a map on the block jacobian
map<pair<pair<int, pair<int, int> >, pair<int, int> >, int> get_Derivatives(int block); map<pair<pair<int, pair<int, int> >, pair<int, int> >, int> get_Derivatives(int block);
//! Computes chain rule derivatives of the Jacobian w.r. to endogenous variables //! Computes chain rule derivatives of the Jacobian w.r. to endogenous variables
void computeChainRuleJacobian(t_blocks_derivatives &blocks_derivatives); void computeChainRuleJacobian(blocks_derivatives_t &blocks_derivatives);
string reform(string name) const; string reform(string name) const;
map_idx_type map_idx; map_idx_t map_idx;
//! sorts the temporary terms in the blocks order //! sorts the temporary terms in the blocks order
void computeTemporaryTermsOrdered(); void computeTemporaryTermsOrdered();
@ -142,9 +142,9 @@ private:
//! creates a mapping from the index of temporary terms to a natural index //! creates a mapping from the index of temporary terms to a natural index
void computeTemporaryTermsMapping(); void computeTemporaryTermsMapping();
//! Write derivative code of an equation w.r. to a variable //! Write derivative code of an equation w.r. to a variable
void compileDerivative(ofstream &code_file, int eq, int symb_id, int lag, const map_idx_type &map_idx) const; void compileDerivative(ofstream &code_file, int eq, int symb_id, int lag, const map_idx_t &map_idx) const;
//! Write chain rule derivative code of an equation w.r. to a variable //! Write chain rule derivative code of an equation w.r. to a variable
void compileChainRuleDerivative(ofstream &code_file, int eq, int var, int lag, const map_idx_type &map_idx) const; void compileChainRuleDerivative(ofstream &code_file, int eq, int var, int lag, const map_idx_t &map_idx) const;
//! Get the type corresponding to a derivation ID //! Get the type corresponding to a derivation ID
virtual SymbolType getTypeByDerivID(int deriv_id) const throw (UnknownDerivIDException); virtual SymbolType getTypeByDerivID(int deriv_id) const throw (UnknownDerivIDException);
@ -175,7 +175,7 @@ private:
void sparseHelper(int order, ostream &output, int row_nb, int col_nb, ExprNodeOutputType output_type) const; void sparseHelper(int order, ostream &output, int row_nb, int col_nb, ExprNodeOutputType output_type) const;
//! Write chain rule derivative of a recursive equation w.r. to a variable //! Write chain rule derivative of a recursive equation w.r. to a variable
void writeChainRuleDerivative(ostream &output, int eq, int var, int lag, ExprNodeOutputType output_type, const temporary_terms_type &temporary_terms) const; void writeChainRuleDerivative(ostream &output, int eq, int var, int lag, ExprNodeOutputType output_type, const temporary_terms_t &temporary_terms) const;
//! Collecte the derivatives w.r. to endogenous of the block, to endogenous of previouys blocks and to exogenous //! Collecte the derivatives w.r. to endogenous of the block, to endogenous of previouys blocks and to exogenous
void collect_block_first_order_derivatives(); void collect_block_first_order_derivatives();
@ -192,29 +192,29 @@ private:
vector<int> equation_reordered, variable_reordered, inv_equation_reordered, inv_variable_reordered; vector<int> equation_reordered, variable_reordered, inv_equation_reordered, inv_variable_reordered;
//! Vector describing equations: BlockSimulationType, if BlockSimulationType == EVALUATE_s then a NodeID on the new normalized equation //! Vector describing equations: BlockSimulationType, if BlockSimulationType == EVALUATE_s then a NodeID on the new normalized equation
t_equation_type_and_normalized_equation equation_type_and_normalized_equation; equation_type_and_normalized_equation_t equation_type_and_normalized_equation;
//! for each block contains pair< Simulation_Type, pair < Block_Size, Recursive_part_Size > > //! for each block contains pair< Simulation_Type, pair < Block_Size, Recursive_part_Size > >
t_block_type_firstequation_size_mfs block_type_firstequation_size_mfs; block_type_firstequation_size_mfs_t block_type_firstequation_size_mfs;
//! for all blocks derivatives description //! for all blocks derivatives description
t_blocks_derivatives blocks_derivatives; blocks_derivatives_t blocks_derivatives;
//! The jacobian without the elements below the cutoff //! The jacobian without the elements below the cutoff
dynamic_jacob_map dynamic_jacobian; dynamic_jacob_map_t dynamic_jacobian;
//! Vector indicating if the block is linear in endogenous variable (true) or not (false) //! Vector indicating if the block is linear in endogenous variable (true) or not (false)
vector<bool> blocks_linear; vector<bool> blocks_linear;
//! Map the derivatives for a block pair<lag, make_pair(make_pair(eq, var)), NodeID> //! Map the derivatives for a block pair<lag, make_pair(make_pair(eq, var)), NodeID>
typedef map<pair< int, pair<int, int> >, NodeID> t_derivative; typedef map<pair< int, pair<int, int> >, NodeID> derivative_t;
//! Vector of derivative for each blocks //! Vector of derivative for each blocks
vector<t_derivative> derivative_endo, derivative_other_endo, derivative_exo, derivative_exo_det; vector<derivative_t> derivative_endo, derivative_other_endo, derivative_exo, derivative_exo_det;
//!List for each block and for each lag-leag all the other endogenous variables and exogenous variables //!List for each block and for each lag-leag all the other endogenous variables and exogenous variables
typedef set<int> t_var; typedef set<int> var_t;
typedef map<int, t_var> t_lag_var; typedef map<int, var_t> lag_var_t;
vector<t_lag_var> other_endo_block, exo_block, exo_det_block; vector<lag_var_t> other_endo_block, exo_block, exo_det_block;
//!Maximum lead and lag for each block on endogenous of the block, endogenous of the previous blocks, exogenous and deterministic exogenous //!Maximum lead and lag for each block on endogenous of the block, endogenous of the previous blocks, exogenous and deterministic exogenous
vector<pair<int, int> > endo_max_leadlag_block, other_endo_max_leadlag_block, exo_max_leadlag_block, exo_det_max_leadlag_block, max_leadlag_block; vector<pair<int, int> > endo_max_leadlag_block, other_endo_max_leadlag_block, exo_max_leadlag_block, exo_det_max_leadlag_block, max_leadlag_block;
@ -245,7 +245,7 @@ public:
\param no_tmp_terms if true, no temporary terms will be computed in the dynamic files \param no_tmp_terms if true, no temporary terms will be computed in the dynamic files
*/ */
void computingPass(bool jacobianExo, bool hessian, bool thirdDerivatives, bool paramsDerivatives, void computingPass(bool jacobianExo, bool hessian, bool thirdDerivatives, bool paramsDerivatives,
const eval_context_type &eval_context, bool no_tmp_terms, bool block, bool use_dll, bool bytecode); const eval_context_t &eval_context, bool no_tmp_terms, bool block, bool use_dll, bool bytecode);
//! Writes model initialization and lead/lag incidence matrix to output //! Writes model initialization and lead/lag incidence matrix to output
void writeOutput(ostream &output, const string &basename, bool block, bool byte_code, bool use_dll, int order) const; void writeOutput(ostream &output, const string &basename, bool block, bool byte_code, bool use_dll, int order) const;
@ -297,7 +297,7 @@ public:
void transformPredeterminedVariables(); void transformPredeterminedVariables();
//! Fills eval context with values of model local variables and auxiliary variables //! Fills eval context with values of model local variables and auxiliary variables
void fillEvalContext(eval_context_type &eval_context) const; void fillEvalContext(eval_context_t &eval_context) const;
//! Return the number of blocks //! Return the number of blocks
virtual unsigned int virtual unsigned int

View File

@ -71,14 +71,14 @@ ExprNode::getDerivative(int deriv_id)
} }
int int
ExprNode::precedence(ExprNodeOutputType output_type, const temporary_terms_type &temporary_terms) const ExprNode::precedence(ExprNodeOutputType output_type, const temporary_terms_t &temporary_terms) const
{ {
// For a constant, a variable, or a unary op, the precedence is maximal // For a constant, a variable, or a unary op, the precedence is maximal
return 100; return 100;
} }
int int
ExprNode::cost(const temporary_terms_type &temporary_terms, bool is_matlab) const ExprNode::cost(const temporary_terms_t &temporary_terms, bool is_matlab) const
{ {
// For a terminal node, the cost is null // For a terminal node, the cost is null
return 0; return 0;
@ -115,7 +115,7 @@ ExprNode::collectModelLocalVariables(set<int> &result) const
void void
ExprNode::computeTemporaryTerms(map<NodeID, int> &reference_count, ExprNode::computeTemporaryTerms(map<NodeID, int> &reference_count,
temporary_terms_type &temporary_terms, temporary_terms_t &temporary_terms,
bool is_matlab) const bool is_matlab) const
{ {
// Nothing to do for a terminal node // Nothing to do for a terminal node
@ -123,10 +123,10 @@ ExprNode::computeTemporaryTerms(map<NodeID, int> &reference_count,
void void
ExprNode::computeTemporaryTerms(map<NodeID, int> &reference_count, ExprNode::computeTemporaryTerms(map<NodeID, int> &reference_count,
temporary_terms_type &temporary_terms, temporary_terms_t &temporary_terms,
map<NodeID, pair<int, int> > &first_occurence, map<NodeID, pair<int, int> > &first_occurence,
int Curr_block, int Curr_block,
vector<vector<temporary_terms_type> > &v_temporary_terms, vector<vector<temporary_terms_t> > &v_temporary_terms,
int equation) const int equation) const
{ {
// Nothing to do for a terminal node // Nothing to do for a terminal node
@ -141,26 +141,26 @@ ExprNode::normalizeEquation(int var_endo, vector<pair<int, pair<NodeID, NodeID>
void void
ExprNode::writeOutput(ostream &output) const ExprNode::writeOutput(ostream &output) const
{ {
writeOutput(output, oMatlabOutsideModel, temporary_terms_type()); writeOutput(output, oMatlabOutsideModel, temporary_terms_t());
} }
void void
ExprNode::writeOutput(ostream &output, ExprNodeOutputType output_type) const ExprNode::writeOutput(ostream &output, ExprNodeOutputType output_type) const
{ {
writeOutput(output, output_type, temporary_terms_type()); writeOutput(output, output_type, temporary_terms_t());
} }
void void
ExprNode::writeOutput(ostream &output, ExprNodeOutputType output_type, const temporary_terms_type &temporary_terms) const ExprNode::writeOutput(ostream &output, ExprNodeOutputType output_type, const temporary_terms_t &temporary_terms) const
{ {
deriv_node_temp_terms_type tef_terms; deriv_node_temp_terms_t tef_terms;
writeOutput(output, output_type, temporary_terms, tef_terms); writeOutput(output, output_type, temporary_terms, tef_terms);
} }
void void
ExprNode::writeExternalFunctionOutput(ostream &output, ExprNodeOutputType output_type, ExprNode::writeExternalFunctionOutput(ostream &output, ExprNodeOutputType output_type,
const temporary_terms_type &temporary_terms, const temporary_terms_t &temporary_terms,
deriv_node_temp_terms_type &tef_terms) const deriv_node_temp_terms_t &tef_terms) const
{ {
// Nothing to do // Nothing to do
} }
@ -271,19 +271,19 @@ NumConstNode::computeDerivative(int deriv_id)
} }
void void
NumConstNode::collectTemporary_terms(const temporary_terms_type &temporary_terms, temporary_terms_inuse_type &temporary_terms_inuse, int Curr_Block) const NumConstNode::collectTemporary_terms(const temporary_terms_t &temporary_terms, temporary_terms_inuse_t &temporary_terms_inuse, int Curr_Block) const
{ {
temporary_terms_type::const_iterator it = temporary_terms.find(const_cast<NumConstNode *>(this)); temporary_terms_t::const_iterator it = temporary_terms.find(const_cast<NumConstNode *>(this));
if (it != temporary_terms.end()) if (it != temporary_terms.end())
temporary_terms_inuse.insert(idx); temporary_terms_inuse.insert(idx);
} }
void void
NumConstNode::writeOutput(ostream &output, ExprNodeOutputType output_type, NumConstNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
const temporary_terms_type &temporary_terms, const temporary_terms_t &temporary_terms,
deriv_node_temp_terms_type &tef_terms) const deriv_node_temp_terms_t &tef_terms) const
{ {
temporary_terms_type::const_iterator it = temporary_terms.find(const_cast<NumConstNode *>(this)); temporary_terms_t::const_iterator it = temporary_terms.find(const_cast<NumConstNode *>(this));
if (it != temporary_terms.end()) if (it != temporary_terms.end())
if (output_type == oMatlabDynamicModelSparse) if (output_type == oMatlabDynamicModelSparse)
output << "T" << idx << "(it_)"; output << "T" << idx << "(it_)";
@ -294,13 +294,13 @@ NumConstNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
} }
double double
NumConstNode::eval(const eval_context_type &eval_context) const throw (EvalException) NumConstNode::eval(const eval_context_t &eval_context) const throw (EvalException)
{ {
return (datatree.num_constants.getDouble(id)); return (datatree.num_constants.getDouble(id));
} }
void void
NumConstNode::compile(ostream &CompileCode, bool lhs_rhs, const temporary_terms_type &temporary_terms, const map_idx_type &map_idx, bool dynamic, bool steady_dynamic) const NumConstNode::compile(ostream &CompileCode, bool lhs_rhs, const temporary_terms_t &temporary_terms, const map_idx_t &map_idx, bool dynamic, bool steady_dynamic) const
{ {
FLDC_ fldc(datatree.num_constants.getDouble(id)); FLDC_ fldc(datatree.num_constants.getDouble(id));
fldc.write(CompileCode); fldc.write(CompileCode);
@ -483,9 +483,9 @@ VariableNode::computeDerivative(int deriv_id)
} }
void void
VariableNode::collectTemporary_terms(const temporary_terms_type &temporary_terms, temporary_terms_inuse_type &temporary_terms_inuse, int Curr_Block) const VariableNode::collectTemporary_terms(const temporary_terms_t &temporary_terms, temporary_terms_inuse_t &temporary_terms_inuse, int Curr_Block) const
{ {
temporary_terms_type::const_iterator it = temporary_terms.find(const_cast<VariableNode *>(this)); temporary_terms_t::const_iterator it = temporary_terms.find(const_cast<VariableNode *>(this));
if (it != temporary_terms.end()) if (it != temporary_terms.end())
temporary_terms_inuse.insert(idx); temporary_terms_inuse.insert(idx);
if (type == eModelLocalVariable) if (type == eModelLocalVariable)
@ -494,11 +494,11 @@ VariableNode::collectTemporary_terms(const temporary_terms_type &temporary_terms
void void
VariableNode::writeOutput(ostream &output, ExprNodeOutputType output_type, VariableNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
const temporary_terms_type &temporary_terms, const temporary_terms_t &temporary_terms,
deriv_node_temp_terms_type &tef_terms) const deriv_node_temp_terms_t &tef_terms) const
{ {
// If node is a temporary term // If node is a temporary term
temporary_terms_type::const_iterator it = temporary_terms.find(const_cast<VariableNode *>(this)); temporary_terms_t::const_iterator it = temporary_terms.find(const_cast<VariableNode *>(this));
if (it != temporary_terms.end()) if (it != temporary_terms.end())
{ {
if (output_type == oMatlabDynamicModelSparse) if (output_type == oMatlabDynamicModelSparse)
@ -679,9 +679,9 @@ VariableNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
} }
double double
VariableNode::eval(const eval_context_type &eval_context) const throw (EvalException) VariableNode::eval(const eval_context_t &eval_context) const throw (EvalException)
{ {
eval_context_type::const_iterator it = eval_context.find(symb_id); eval_context_t::const_iterator it = eval_context.find(symb_id);
if (it == eval_context.end()) if (it == eval_context.end())
throw EvalException(); throw EvalException();
@ -689,7 +689,7 @@ VariableNode::eval(const eval_context_type &eval_context) const throw (EvalExcep
} }
void void
VariableNode::compile(ostream &CompileCode, bool lhs_rhs, const temporary_terms_type &temporary_terms, const map_idx_type &map_idx, bool dynamic, bool steady_dynamic) const VariableNode::compile(ostream &CompileCode, bool lhs_rhs, const temporary_terms_t &temporary_terms, const map_idx_t &map_idx, bool dynamic, bool steady_dynamic) const
{ {
if (type == eModelLocalVariable || type == eModFileLocalVariable) if (type == eModelLocalVariable || type == eModFileLocalVariable)
datatree.local_variables_table[symb_id]->compile(CompileCode, lhs_rhs, temporary_terms, map_idx, dynamic, steady_dynamic); datatree.local_variables_table[symb_id]->compile(CompileCode, lhs_rhs, temporary_terms, map_idx, dynamic, steady_dynamic);
@ -761,10 +761,10 @@ VariableNode::compile(ostream &CompileCode, bool lhs_rhs, const temporary_terms_
void void
VariableNode::computeTemporaryTerms(map<NodeID, int> &reference_count, VariableNode::computeTemporaryTerms(map<NodeID, int> &reference_count,
temporary_terms_type &temporary_terms, temporary_terms_t &temporary_terms,
map<NodeID, pair<int, int> > &first_occurence, map<NodeID, pair<int, int> > &first_occurence,
int Curr_block, int Curr_block,
vector<vector<temporary_terms_type> > &v_temporary_terms, vector<vector<temporary_terms_t> > &v_temporary_terms,
int equation) const int equation) const
{ {
if (type == eModelLocalVariable) if (type == eModelLocalVariable)
@ -1220,10 +1220,10 @@ UnaryOpNode::computeDerivative(int deriv_id)
} }
int int
UnaryOpNode::cost(const temporary_terms_type &temporary_terms, bool is_matlab) const UnaryOpNode::cost(const temporary_terms_t &temporary_terms, bool is_matlab) const
{ {
// For a temporary term, the cost is null // For a temporary term, the cost is null
temporary_terms_type::const_iterator it = temporary_terms.find(const_cast<UnaryOpNode *>(this)); temporary_terms_t::const_iterator it = temporary_terms.find(const_cast<UnaryOpNode *>(this));
if (it != temporary_terms.end()) if (it != temporary_terms.end())
return 0; return 0;
@ -1314,7 +1314,7 @@ UnaryOpNode::cost(const temporary_terms_type &temporary_terms, bool is_matlab) c
void void
UnaryOpNode::computeTemporaryTerms(map<NodeID, int> &reference_count, UnaryOpNode::computeTemporaryTerms(map<NodeID, int> &reference_count,
temporary_terms_type &temporary_terms, temporary_terms_t &temporary_terms,
bool is_matlab) const bool is_matlab) const
{ {
NodeID this2 = const_cast<UnaryOpNode *>(this); NodeID this2 = const_cast<UnaryOpNode *>(this);
@ -1335,10 +1335,10 @@ UnaryOpNode::computeTemporaryTerms(map<NodeID, int> &reference_count,
void void
UnaryOpNode::computeTemporaryTerms(map<NodeID, int> &reference_count, UnaryOpNode::computeTemporaryTerms(map<NodeID, int> &reference_count,
temporary_terms_type &temporary_terms, temporary_terms_t &temporary_terms,
map<NodeID, pair<int, int> > &first_occurence, map<NodeID, pair<int, int> > &first_occurence,
int Curr_block, int Curr_block,
vector< vector<temporary_terms_type> > &v_temporary_terms, vector< vector<temporary_terms_t> > &v_temporary_terms,
int equation) const int equation) const
{ {
NodeID this2 = const_cast<UnaryOpNode *>(this); NodeID this2 = const_cast<UnaryOpNode *>(this);
@ -1361,9 +1361,9 @@ UnaryOpNode::computeTemporaryTerms(map<NodeID, int> &reference_count,
} }
void void
UnaryOpNode::collectTemporary_terms(const temporary_terms_type &temporary_terms, temporary_terms_inuse_type &temporary_terms_inuse, int Curr_Block) const UnaryOpNode::collectTemporary_terms(const temporary_terms_t &temporary_terms, temporary_terms_inuse_t &temporary_terms_inuse, int Curr_Block) const
{ {
temporary_terms_type::const_iterator it = temporary_terms.find(const_cast<UnaryOpNode *>(this)); temporary_terms_t::const_iterator it = temporary_terms.find(const_cast<UnaryOpNode *>(this));
if (it != temporary_terms.end()) if (it != temporary_terms.end())
temporary_terms_inuse.insert(idx); temporary_terms_inuse.insert(idx);
else else
@ -1372,11 +1372,11 @@ UnaryOpNode::collectTemporary_terms(const temporary_terms_type &temporary_terms,
void void
UnaryOpNode::writeOutput(ostream &output, ExprNodeOutputType output_type, UnaryOpNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
const temporary_terms_type &temporary_terms, const temporary_terms_t &temporary_terms,
deriv_node_temp_terms_type &tef_terms) const deriv_node_temp_terms_t &tef_terms) const
{ {
// If node is a temporary term // If node is a temporary term
temporary_terms_type::const_iterator it = temporary_terms.find(const_cast<UnaryOpNode *>(this)); temporary_terms_t::const_iterator it = temporary_terms.find(const_cast<UnaryOpNode *>(this));
if (it != temporary_terms.end()) if (it != temporary_terms.end())
{ {
if (output_type == oMatlabDynamicModelSparse) if (output_type == oMatlabDynamicModelSparse)
@ -1502,8 +1502,8 @@ UnaryOpNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
void void
UnaryOpNode::writeExternalFunctionOutput(ostream &output, ExprNodeOutputType output_type, UnaryOpNode::writeExternalFunctionOutput(ostream &output, ExprNodeOutputType output_type,
const temporary_terms_type &temporary_terms, const temporary_terms_t &temporary_terms,
deriv_node_temp_terms_type &tef_terms) const deriv_node_temp_terms_t &tef_terms) const
{ {
arg->writeExternalFunctionOutput(output, output_type, temporary_terms, tef_terms); arg->writeExternalFunctionOutput(output, output_type, temporary_terms, tef_terms);
} }
@ -1559,7 +1559,7 @@ UnaryOpNode::eval_opcode(UnaryOpcode op_code, double v) throw (EvalException)
} }
double double
UnaryOpNode::eval(const eval_context_type &eval_context) const throw (EvalException) UnaryOpNode::eval(const eval_context_t &eval_context) const throw (EvalException)
{ {
double v = arg->eval(eval_context); double v = arg->eval(eval_context);
@ -1567,20 +1567,20 @@ UnaryOpNode::eval(const eval_context_type &eval_context) const throw (EvalExcept
} }
void void
UnaryOpNode::compile(ostream &CompileCode, bool lhs_rhs, const temporary_terms_type &temporary_terms, const map_idx_type &map_idx, bool dynamic, bool steady_dynamic) const UnaryOpNode::compile(ostream &CompileCode, bool lhs_rhs, const temporary_terms_t &temporary_terms, const map_idx_t &map_idx, bool dynamic, bool steady_dynamic) const
{ {
temporary_terms_type::const_iterator it = temporary_terms.find(const_cast<UnaryOpNode *>(this)); temporary_terms_t::const_iterator it = temporary_terms.find(const_cast<UnaryOpNode *>(this));
if (it != temporary_terms.end()) if (it != temporary_terms.end())
{ {
if (dynamic) if (dynamic)
{ {
map_idx_type::const_iterator ii = map_idx.find(idx); map_idx_t::const_iterator ii = map_idx.find(idx);
FLDT_ fldt(ii->second); FLDT_ fldt(ii->second);
fldt.write(CompileCode); fldt.write(CompileCode);
} }
else else
{ {
map_idx_type::const_iterator ii = map_idx.find(idx); map_idx_t::const_iterator ii = map_idx.find(idx);
FLDST_ fldst(ii->second); FLDST_ fldst(ii->second);
fldst.write(CompileCode); fldst.write(CompileCode);
} }
@ -2057,9 +2057,9 @@ BinaryOpNode::computeDerivative(int deriv_id)
} }
int int
BinaryOpNode::precedence(ExprNodeOutputType output_type, const temporary_terms_type &temporary_terms) const BinaryOpNode::precedence(ExprNodeOutputType output_type, const temporary_terms_t &temporary_terms) const
{ {
temporary_terms_type::const_iterator it = temporary_terms.find(const_cast<BinaryOpNode *>(this)); temporary_terms_t::const_iterator it = temporary_terms.find(const_cast<BinaryOpNode *>(this));
// A temporary term behaves as a variable // A temporary term behaves as a variable
if (it != temporary_terms.end()) if (it != temporary_terms.end())
return 100; return 100;
@ -2097,9 +2097,9 @@ BinaryOpNode::precedence(ExprNodeOutputType output_type, const temporary_terms_t
} }
int int
BinaryOpNode::cost(const temporary_terms_type &temporary_terms, bool is_matlab) const BinaryOpNode::cost(const temporary_terms_t &temporary_terms, bool is_matlab) const
{ {
temporary_terms_type::const_iterator it = temporary_terms.find(const_cast<BinaryOpNode *>(this)); temporary_terms_t::const_iterator it = temporary_terms.find(const_cast<BinaryOpNode *>(this));
// For a temporary term, the cost is null // For a temporary term, the cost is null
if (it != temporary_terms.end()) if (it != temporary_terms.end())
return 0; return 0;
@ -2163,7 +2163,7 @@ BinaryOpNode::cost(const temporary_terms_type &temporary_terms, bool is_matlab)
void void
BinaryOpNode::computeTemporaryTerms(map<NodeID, int> &reference_count, BinaryOpNode::computeTemporaryTerms(map<NodeID, int> &reference_count,
temporary_terms_type &temporary_terms, temporary_terms_t &temporary_terms,
bool is_matlab) const bool is_matlab) const
{ {
NodeID this2 = const_cast<BinaryOpNode *>(this); NodeID this2 = const_cast<BinaryOpNode *>(this);
@ -2190,10 +2190,10 @@ BinaryOpNode::computeTemporaryTerms(map<NodeID, int> &reference_count,
void void
BinaryOpNode::computeTemporaryTerms(map<NodeID, int> &reference_count, BinaryOpNode::computeTemporaryTerms(map<NodeID, int> &reference_count,
temporary_terms_type &temporary_terms, temporary_terms_t &temporary_terms,
map<NodeID, pair<int, int> > &first_occurence, map<NodeID, pair<int, int> > &first_occurence,
int Curr_block, int Curr_block,
vector<vector<temporary_terms_type> > &v_temporary_terms, vector<vector<temporary_terms_t> > &v_temporary_terms,
int equation) const int equation) const
{ {
NodeID this2 = const_cast<BinaryOpNode *>(this); NodeID this2 = const_cast<BinaryOpNode *>(this);
@ -2262,7 +2262,7 @@ BinaryOpNode::eval_opcode(double v1, BinaryOpcode op_code, double v2) throw (Eva
} }
double double
BinaryOpNode::eval(const eval_context_type &eval_context) const throw (EvalException) BinaryOpNode::eval(const eval_context_t &eval_context) const throw (EvalException)
{ {
double v1 = arg1->eval(eval_context); double v1 = arg1->eval(eval_context);
double v2 = arg2->eval(eval_context); double v2 = arg2->eval(eval_context);
@ -2271,21 +2271,21 @@ BinaryOpNode::eval(const eval_context_type &eval_context) const throw (EvalExcep
} }
void void
BinaryOpNode::compile(ostream &CompileCode, bool lhs_rhs, const temporary_terms_type &temporary_terms, const map_idx_type &map_idx, bool dynamic, bool steady_dynamic) const BinaryOpNode::compile(ostream &CompileCode, bool lhs_rhs, const temporary_terms_t &temporary_terms, const map_idx_t &map_idx, bool dynamic, bool steady_dynamic) const
{ {
// If current node is a temporary term // If current node is a temporary term
temporary_terms_type::const_iterator it = temporary_terms.find(const_cast<BinaryOpNode *>(this)); temporary_terms_t::const_iterator it = temporary_terms.find(const_cast<BinaryOpNode *>(this));
if (it != temporary_terms.end()) if (it != temporary_terms.end())
{ {
if (dynamic) if (dynamic)
{ {
map_idx_type::const_iterator ii = map_idx.find(idx); map_idx_t::const_iterator ii = map_idx.find(idx);
FLDT_ fldt(ii->second); FLDT_ fldt(ii->second);
fldt.write(CompileCode); fldt.write(CompileCode);
} }
else else
{ {
map_idx_type::const_iterator ii = map_idx.find(idx); map_idx_t::const_iterator ii = map_idx.find(idx);
FLDST_ fldst(ii->second); FLDST_ fldst(ii->second);
fldst.write(CompileCode); fldst.write(CompileCode);
} }
@ -2298,9 +2298,9 @@ BinaryOpNode::compile(ostream &CompileCode, bool lhs_rhs, const temporary_terms_
} }
void void
BinaryOpNode::collectTemporary_terms(const temporary_terms_type &temporary_terms, temporary_terms_inuse_type &temporary_terms_inuse, int Curr_Block) const BinaryOpNode::collectTemporary_terms(const temporary_terms_t &temporary_terms, temporary_terms_inuse_t &temporary_terms_inuse, int Curr_Block) const
{ {
temporary_terms_type::const_iterator it = temporary_terms.find(const_cast<BinaryOpNode *>(this)); temporary_terms_t::const_iterator it = temporary_terms.find(const_cast<BinaryOpNode *>(this));
if (it != temporary_terms.end()) if (it != temporary_terms.end())
temporary_terms_inuse.insert(idx); temporary_terms_inuse.insert(idx);
else else
@ -2312,11 +2312,11 @@ BinaryOpNode::collectTemporary_terms(const temporary_terms_type &temporary_terms
void void
BinaryOpNode::writeOutput(ostream &output, ExprNodeOutputType output_type, BinaryOpNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
const temporary_terms_type &temporary_terms, const temporary_terms_t &temporary_terms,
deriv_node_temp_terms_type &tef_terms) const deriv_node_temp_terms_t &tef_terms) const
{ {
// If current node is a temporary term // If current node is a temporary term
temporary_terms_type::const_iterator it = temporary_terms.find(const_cast<BinaryOpNode *>(this)); temporary_terms_t::const_iterator it = temporary_terms.find(const_cast<BinaryOpNode *>(this));
if (it != temporary_terms.end()) if (it != temporary_terms.end())
{ {
if (output_type == oMatlabDynamicModelSparse) if (output_type == oMatlabDynamicModelSparse)
@ -2473,8 +2473,8 @@ BinaryOpNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
void void
BinaryOpNode::writeExternalFunctionOutput(ostream &output, ExprNodeOutputType output_type, BinaryOpNode::writeExternalFunctionOutput(ostream &output, ExprNodeOutputType output_type,
const temporary_terms_type &temporary_terms, const temporary_terms_t &temporary_terms,
deriv_node_temp_terms_type &tef_terms) const deriv_node_temp_terms_t &tef_terms) const
{ {
arg1->writeExternalFunctionOutput(output, output_type, temporary_terms, tef_terms); arg1->writeExternalFunctionOutput(output, output_type, temporary_terms, tef_terms);
arg2->writeExternalFunctionOutput(output, output_type, temporary_terms, tef_terms); arg2->writeExternalFunctionOutput(output, output_type, temporary_terms, tef_terms);
@ -2490,7 +2490,7 @@ BinaryOpNode::collectVariables(SymbolType type_arg, set<pair<int, int> > &result
NodeID NodeID
BinaryOpNode::Compute_RHS(NodeID arg1, NodeID arg2, int op, int op_type) const BinaryOpNode::Compute_RHS(NodeID arg1, NodeID arg2, int op, int op_type) const
{ {
temporary_terms_type temp; temporary_terms_t temp;
switch (op_type) switch (op_type)
{ {
case 0: /*Unary Operator*/ case 0: /*Unary Operator*/
@ -3077,9 +3077,9 @@ TrinaryOpNode::computeDerivative(int deriv_id)
} }
int int
TrinaryOpNode::precedence(ExprNodeOutputType output_type, const temporary_terms_type &temporary_terms) const TrinaryOpNode::precedence(ExprNodeOutputType output_type, const temporary_terms_t &temporary_terms) const
{ {
temporary_terms_type::const_iterator it = temporary_terms.find(const_cast<TrinaryOpNode *>(this)); temporary_terms_t::const_iterator it = temporary_terms.find(const_cast<TrinaryOpNode *>(this));
// A temporary term behaves as a variable // A temporary term behaves as a variable
if (it != temporary_terms.end()) if (it != temporary_terms.end())
return 100; return 100;
@ -3095,9 +3095,9 @@ TrinaryOpNode::precedence(ExprNodeOutputType output_type, const temporary_terms_
} }
int int
TrinaryOpNode::cost(const temporary_terms_type &temporary_terms, bool is_matlab) const TrinaryOpNode::cost(const temporary_terms_t &temporary_terms, bool is_matlab) const
{ {
temporary_terms_type::const_iterator it = temporary_terms.find(const_cast<TrinaryOpNode *>(this)); temporary_terms_t::const_iterator it = temporary_terms.find(const_cast<TrinaryOpNode *>(this));
// For a temporary term, the cost is null // For a temporary term, the cost is null
if (it != temporary_terms.end()) if (it != temporary_terms.end())
return 0; return 0;
@ -3127,7 +3127,7 @@ TrinaryOpNode::cost(const temporary_terms_type &temporary_terms, bool is_matlab)
void void
TrinaryOpNode::computeTemporaryTerms(map<NodeID, int> &reference_count, TrinaryOpNode::computeTemporaryTerms(map<NodeID, int> &reference_count,
temporary_terms_type &temporary_terms, temporary_terms_t &temporary_terms,
bool is_matlab) const bool is_matlab) const
{ {
NodeID this2 = const_cast<TrinaryOpNode *>(this); NodeID this2 = const_cast<TrinaryOpNode *>(this);
@ -3153,10 +3153,10 @@ TrinaryOpNode::computeTemporaryTerms(map<NodeID, int> &reference_count,
void void
TrinaryOpNode::computeTemporaryTerms(map<NodeID, int> &reference_count, TrinaryOpNode::computeTemporaryTerms(map<NodeID, int> &reference_count,
temporary_terms_type &temporary_terms, temporary_terms_t &temporary_terms,
map<NodeID, pair<int, int> > &first_occurence, map<NodeID, pair<int, int> > &first_occurence,
int Curr_block, int Curr_block,
vector<vector<temporary_terms_type> > &v_temporary_terms, vector<vector<temporary_terms_t> > &v_temporary_terms,
int equation) const int equation) const
{ {
NodeID this2 = const_cast<TrinaryOpNode *>(this); NodeID this2 = const_cast<TrinaryOpNode *>(this);
@ -3195,7 +3195,7 @@ TrinaryOpNode::eval_opcode(double v1, TrinaryOpcode op_code, double v2, double v
} }
double double
TrinaryOpNode::eval(const eval_context_type &eval_context) const throw (EvalException) TrinaryOpNode::eval(const eval_context_t &eval_context) const throw (EvalException)
{ {
double v1 = arg1->eval(eval_context); double v1 = arg1->eval(eval_context);
double v2 = arg2->eval(eval_context); double v2 = arg2->eval(eval_context);
@ -3205,21 +3205,21 @@ TrinaryOpNode::eval(const eval_context_type &eval_context) const throw (EvalExce
} }
void void
TrinaryOpNode::compile(ostream &CompileCode, bool lhs_rhs, const temporary_terms_type &temporary_terms, const map_idx_type &map_idx, bool dynamic, bool steady_dynamic) const TrinaryOpNode::compile(ostream &CompileCode, bool lhs_rhs, const temporary_terms_t &temporary_terms, const map_idx_t &map_idx, bool dynamic, bool steady_dynamic) const
{ {
// If current node is a temporary term // If current node is a temporary term
temporary_terms_type::const_iterator it = temporary_terms.find(const_cast<TrinaryOpNode *>(this)); temporary_terms_t::const_iterator it = temporary_terms.find(const_cast<TrinaryOpNode *>(this));
if (it != temporary_terms.end()) if (it != temporary_terms.end())
{ {
if (dynamic) if (dynamic)
{ {
map_idx_type::const_iterator ii = map_idx.find(idx); map_idx_t::const_iterator ii = map_idx.find(idx);
FLDT_ fldt(ii->second); FLDT_ fldt(ii->second);
fldt.write(CompileCode); fldt.write(CompileCode);
} }
else else
{ {
map_idx_type::const_iterator ii = map_idx.find(idx); map_idx_t::const_iterator ii = map_idx.find(idx);
FLDST_ fldst(ii->second); FLDST_ fldst(ii->second);
fldst.write(CompileCode); fldst.write(CompileCode);
} }
@ -3233,9 +3233,9 @@ TrinaryOpNode::compile(ostream &CompileCode, bool lhs_rhs, const temporary_terms
} }
void void
TrinaryOpNode::collectTemporary_terms(const temporary_terms_type &temporary_terms, temporary_terms_inuse_type &temporary_terms_inuse, int Curr_Block) const TrinaryOpNode::collectTemporary_terms(const temporary_terms_t &temporary_terms, temporary_terms_inuse_t &temporary_terms_inuse, int Curr_Block) const
{ {
temporary_terms_type::const_iterator it = temporary_terms.find(const_cast<TrinaryOpNode *>(this)); temporary_terms_t::const_iterator it = temporary_terms.find(const_cast<TrinaryOpNode *>(this));
if (it != temporary_terms.end()) if (it != temporary_terms.end())
temporary_terms_inuse.insert(idx); temporary_terms_inuse.insert(idx);
else else
@ -3248,11 +3248,11 @@ TrinaryOpNode::collectTemporary_terms(const temporary_terms_type &temporary_term
void void
TrinaryOpNode::writeOutput(ostream &output, ExprNodeOutputType output_type, TrinaryOpNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
const temporary_terms_type &temporary_terms, const temporary_terms_t &temporary_terms,
deriv_node_temp_terms_type &tef_terms) const deriv_node_temp_terms_t &tef_terms) const
{ {
// If current node is a temporary term // If current node is a temporary term
temporary_terms_type::const_iterator it = temporary_terms.find(const_cast<TrinaryOpNode *>(this)); temporary_terms_t::const_iterator it = temporary_terms.find(const_cast<TrinaryOpNode *>(this));
if (it != temporary_terms.end()) if (it != temporary_terms.end())
{ {
output << "T" << idx; output << "T" << idx;
@ -3316,8 +3316,8 @@ TrinaryOpNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
void void
TrinaryOpNode::writeExternalFunctionOutput(ostream &output, ExprNodeOutputType output_type, TrinaryOpNode::writeExternalFunctionOutput(ostream &output, ExprNodeOutputType output_type,
const temporary_terms_type &temporary_terms, const temporary_terms_t &temporary_terms,
deriv_node_temp_terms_type &tef_terms) const deriv_node_temp_terms_t &tef_terms) const
{ {
arg1->writeExternalFunctionOutput(output, output_type, temporary_terms, tef_terms); arg1->writeExternalFunctionOutput(output, output_type, temporary_terms, tef_terms);
arg2->writeExternalFunctionOutput(output, output_type, temporary_terms, tef_terms); arg2->writeExternalFunctionOutput(output, output_type, temporary_terms, tef_terms);
@ -3546,7 +3546,7 @@ ExternalFunctionNode::getChainRuleDerivative(int deriv_id, const map<int, NodeID
void void
ExternalFunctionNode::computeTemporaryTerms(map<NodeID, int> &reference_count, ExternalFunctionNode::computeTemporaryTerms(map<NodeID, int> &reference_count,
temporary_terms_type &temporary_terms, temporary_terms_t &temporary_terms,
bool is_matlab) const bool is_matlab) const
{ {
temporary_terms.insert(const_cast<ExternalFunctionNode *>(this)); temporary_terms.insert(const_cast<ExternalFunctionNode *>(this));
@ -3554,8 +3554,8 @@ ExternalFunctionNode::computeTemporaryTerms(map<NodeID, int> &reference_count,
void void
ExternalFunctionNode::writeExternalFunctionArguments(ostream &output, ExprNodeOutputType output_type, ExternalFunctionNode::writeExternalFunctionArguments(ostream &output, ExprNodeOutputType output_type,
const temporary_terms_type &temporary_terms, const temporary_terms_t &temporary_terms,
deriv_node_temp_terms_type &tef_terms) const deriv_node_temp_terms_t &tef_terms) const
{ {
for (vector<NodeID>::const_iterator it = arguments.begin(); for (vector<NodeID>::const_iterator it = arguments.begin();
it != arguments.end(); it++) it != arguments.end(); it++)
@ -3569,8 +3569,8 @@ ExternalFunctionNode::writeExternalFunctionArguments(ostream &output, ExprNodeOu
void void
ExternalFunctionNode::writeOutput(ostream &output, ExprNodeOutputType output_type, ExternalFunctionNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
const temporary_terms_type &temporary_terms, const temporary_terms_t &temporary_terms,
deriv_node_temp_terms_type &tef_terms) const deriv_node_temp_terms_t &tef_terms) const
{ {
if (output_type == oMatlabOutsideModel) if (output_type == oMatlabOutsideModel)
{ {
@ -3580,7 +3580,7 @@ ExternalFunctionNode::writeOutput(ostream &output, ExprNodeOutputType output_typ
return; return;
} }
temporary_terms_type::const_iterator it = temporary_terms.find(const_cast<ExternalFunctionNode *>(this)); temporary_terms_t::const_iterator it = temporary_terms.find(const_cast<ExternalFunctionNode *>(this));
if (it != temporary_terms.end()) if (it != temporary_terms.end())
{ {
if (output_type == oMatlabDynamicModelSparse) if (output_type == oMatlabDynamicModelSparse)
@ -3595,8 +3595,8 @@ ExternalFunctionNode::writeOutput(ostream &output, ExprNodeOutputType output_typ
void void
ExternalFunctionNode::writeExternalFunctionOutput(ostream &output, ExprNodeOutputType output_type, ExternalFunctionNode::writeExternalFunctionOutput(ostream &output, ExprNodeOutputType output_type,
const temporary_terms_type &temporary_terms, const temporary_terms_t &temporary_terms,
deriv_node_temp_terms_type &tef_terms) const deriv_node_temp_terms_t &tef_terms) const
{ {
int first_deriv_symb_id = datatree.external_functions_table.getFirstDerivSymbID(symb_id); int first_deriv_symb_id = datatree.external_functions_table.getFirstDerivSymbID(symb_id);
assert(first_deriv_symb_id != eExtFunSetButNoNameProvided); assert(first_deriv_symb_id != eExtFunSetButNoNameProvided);
@ -3628,10 +3628,10 @@ ExternalFunctionNode::writeExternalFunctionOutput(ostream &output, ExprNodeOutpu
void void
ExternalFunctionNode::computeTemporaryTerms(map<NodeID, int> &reference_count, ExternalFunctionNode::computeTemporaryTerms(map<NodeID, int> &reference_count,
temporary_terms_type &temporary_terms, temporary_terms_t &temporary_terms,
map<NodeID, pair<int, int> > &first_occurence, map<NodeID, pair<int, int> > &first_occurence,
int Curr_block, int Curr_block,
vector< vector<temporary_terms_type> > &v_temporary_terms, vector< vector<temporary_terms_t> > &v_temporary_terms,
int equation) const int equation) const
{ {
cerr << "ExternalFunctionNode::computeTemporaryTerms: not implemented" << endl; cerr << "ExternalFunctionNode::computeTemporaryTerms: not implemented" << endl;
@ -3647,9 +3647,9 @@ ExternalFunctionNode::collectVariables(SymbolType type_arg, set<pair<int, int> >
} }
void void
ExternalFunctionNode::collectTemporary_terms(const temporary_terms_type &temporary_terms, temporary_terms_inuse_type &temporary_terms_inuse, int Curr_Block) const ExternalFunctionNode::collectTemporary_terms(const temporary_terms_t &temporary_terms, temporary_terms_inuse_t &temporary_terms_inuse, int Curr_Block) const
{ {
temporary_terms_type::const_iterator it = temporary_terms.find(const_cast<ExternalFunctionNode *>(this)); temporary_terms_t::const_iterator it = temporary_terms.find(const_cast<ExternalFunctionNode *>(this));
if (it != temporary_terms.end()) if (it != temporary_terms.end())
temporary_terms_inuse.insert(idx); temporary_terms_inuse.insert(idx);
else else
@ -3659,13 +3659,13 @@ ExternalFunctionNode::collectTemporary_terms(const temporary_terms_type &tempora
} }
double double
ExternalFunctionNode::eval(const eval_context_type &eval_context) const throw (EvalException) ExternalFunctionNode::eval(const eval_context_t &eval_context) const throw (EvalException)
{ {
throw EvalException(); throw EvalException();
} }
void void
ExternalFunctionNode::compile(ostream &CompileCode, bool lhs_rhs, const temporary_terms_type &temporary_terms, const map_idx_type &map_idx, bool dynamic, bool steady_dynamic) const ExternalFunctionNode::compile(ostream &CompileCode, bool lhs_rhs, const temporary_terms_t &temporary_terms, const map_idx_t &map_idx, bool dynamic, bool steady_dynamic) const
{ {
cerr << "ExternalFunctionNode::compile: operation impossible!" << endl; cerr << "ExternalFunctionNode::compile: operation impossible!" << endl;
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
@ -3810,18 +3810,18 @@ ExternalFunctionNode::buildSimilarExternalFunctionNode(vector<NodeID> &alt_args,
} }
bool bool
ExternalFunctionNode::alreadyWrittenAsTefTerm(int the_symb_id, deriv_node_temp_terms_type &tef_terms) const ExternalFunctionNode::alreadyWrittenAsTefTerm(int the_symb_id, deriv_node_temp_terms_t &tef_terms) const
{ {
deriv_node_temp_terms_type::const_iterator it = tef_terms.find(make_pair(the_symb_id, arguments)); deriv_node_temp_terms_t::const_iterator it = tef_terms.find(make_pair(the_symb_id, arguments));
if (it != tef_terms.end()) if (it != tef_terms.end())
return true; return true;
return false; return false;
} }
int int
ExternalFunctionNode::getIndxInTefTerms(int the_symb_id, deriv_node_temp_terms_type &tef_terms) const throw (UnknownFunctionNameAndArgs) ExternalFunctionNode::getIndxInTefTerms(int the_symb_id, deriv_node_temp_terms_t &tef_terms) const throw (UnknownFunctionNameAndArgs)
{ {
deriv_node_temp_terms_type::const_iterator it = tef_terms.find(make_pair(the_symb_id, arguments)); deriv_node_temp_terms_t::const_iterator it = tef_terms.find(make_pair(the_symb_id, arguments));
if (it != tef_terms.end()) if (it != tef_terms.end())
return it->second; return it->second;
throw UnknownFunctionNameAndArgs(); throw UnknownFunctionNameAndArgs();
@ -3852,7 +3852,7 @@ FirstDerivExternalFunctionNode::FirstDerivExternalFunctionNode(DataTree &datatre
void void
FirstDerivExternalFunctionNode::computeTemporaryTerms(map<NodeID, int> &reference_count, FirstDerivExternalFunctionNode::computeTemporaryTerms(map<NodeID, int> &reference_count,
temporary_terms_type &temporary_terms, temporary_terms_t &temporary_terms,
bool is_matlab) const bool is_matlab) const
{ {
temporary_terms.insert(const_cast<FirstDerivExternalFunctionNode *>(this)); temporary_terms.insert(const_cast<FirstDerivExternalFunctionNode *>(this));
@ -3860,10 +3860,10 @@ FirstDerivExternalFunctionNode::computeTemporaryTerms(map<NodeID, int> &referenc
void void
FirstDerivExternalFunctionNode::computeTemporaryTerms(map<NodeID, int> &reference_count, FirstDerivExternalFunctionNode::computeTemporaryTerms(map<NodeID, int> &reference_count,
temporary_terms_type &temporary_terms, temporary_terms_t &temporary_terms,
map<NodeID, pair<int, int> > &first_occurence, map<NodeID, pair<int, int> > &first_occurence,
int Curr_block, int Curr_block,
vector< vector<temporary_terms_type> > &v_temporary_terms, vector< vector<temporary_terms_t> > &v_temporary_terms,
int equation) const int equation) const
{ {
cerr << "FirstDerivExternalFunctionNode::computeTemporaryTerms: not implemented" << endl; cerr << "FirstDerivExternalFunctionNode::computeTemporaryTerms: not implemented" << endl;
@ -3886,13 +3886,13 @@ FirstDerivExternalFunctionNode::composeDerivatives(const vector<NodeID> &dargs)
void void
FirstDerivExternalFunctionNode::writeOutput(ostream &output, ExprNodeOutputType output_type, FirstDerivExternalFunctionNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
const temporary_terms_type &temporary_terms, const temporary_terms_t &temporary_terms,
deriv_node_temp_terms_type &tef_terms) const deriv_node_temp_terms_t &tef_terms) const
{ {
assert(output_type != oMatlabOutsideModel); assert(output_type != oMatlabOutsideModel);
// If current node is a temporary term // If current node is a temporary term
temporary_terms_type::const_iterator it = temporary_terms.find(const_cast<FirstDerivExternalFunctionNode *>(this)); temporary_terms_t::const_iterator it = temporary_terms.find(const_cast<FirstDerivExternalFunctionNode *>(this));
if (it != temporary_terms.end()) if (it != temporary_terms.end())
{ {
if (output_type == oMatlabDynamicModelSparse) if (output_type == oMatlabDynamicModelSparse)
@ -3916,8 +3916,8 @@ FirstDerivExternalFunctionNode::writeOutput(ostream &output, ExprNodeOutputType
void void
FirstDerivExternalFunctionNode::writeExternalFunctionOutput(ostream &output, ExprNodeOutputType output_type, FirstDerivExternalFunctionNode::writeExternalFunctionOutput(ostream &output, ExprNodeOutputType output_type,
const temporary_terms_type &temporary_terms, const temporary_terms_t &temporary_terms,
deriv_node_temp_terms_type &tef_terms) const deriv_node_temp_terms_t &tef_terms) const
{ {
assert(output_type != oMatlabOutsideModel); assert(output_type != oMatlabOutsideModel);
int first_deriv_symb_id = datatree.external_functions_table.getFirstDerivSymbID(symb_id); int first_deriv_symb_id = datatree.external_functions_table.getFirstDerivSymbID(symb_id);
@ -3960,7 +3960,7 @@ SecondDerivExternalFunctionNode::SecondDerivExternalFunctionNode(DataTree &datat
void void
SecondDerivExternalFunctionNode::computeTemporaryTerms(map<NodeID, int> &reference_count, SecondDerivExternalFunctionNode::computeTemporaryTerms(map<NodeID, int> &reference_count,
temporary_terms_type &temporary_terms, temporary_terms_t &temporary_terms,
bool is_matlab) const bool is_matlab) const
{ {
temporary_terms.insert(const_cast<SecondDerivExternalFunctionNode *>(this)); temporary_terms.insert(const_cast<SecondDerivExternalFunctionNode *>(this));
@ -3968,10 +3968,10 @@ SecondDerivExternalFunctionNode::computeTemporaryTerms(map<NodeID, int> &referen
void void
SecondDerivExternalFunctionNode::computeTemporaryTerms(map<NodeID, int> &reference_count, SecondDerivExternalFunctionNode::computeTemporaryTerms(map<NodeID, int> &reference_count,
temporary_terms_type &temporary_terms, temporary_terms_t &temporary_terms,
map<NodeID, pair<int, int> > &first_occurence, map<NodeID, pair<int, int> > &first_occurence,
int Curr_block, int Curr_block,
vector< vector<temporary_terms_type> > &v_temporary_terms, vector< vector<temporary_terms_t> > &v_temporary_terms,
int equation) const int equation) const
{ {
cerr << "SecondDerivExternalFunctionNode::computeTemporaryTerms: not implemented" << endl; cerr << "SecondDerivExternalFunctionNode::computeTemporaryTerms: not implemented" << endl;
@ -3987,13 +3987,13 @@ SecondDerivExternalFunctionNode::computeDerivative(int deriv_id)
void void
SecondDerivExternalFunctionNode::writeOutput(ostream &output, ExprNodeOutputType output_type, SecondDerivExternalFunctionNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
const temporary_terms_type &temporary_terms, const temporary_terms_t &temporary_terms,
deriv_node_temp_terms_type &tef_terms) const deriv_node_temp_terms_t &tef_terms) const
{ {
assert(output_type != oMatlabOutsideModel); assert(output_type != oMatlabOutsideModel);
// If current node is a temporary term // If current node is a temporary term
temporary_terms_type::const_iterator it = temporary_terms.find(const_cast<SecondDerivExternalFunctionNode *>(this)); temporary_terms_t::const_iterator it = temporary_terms.find(const_cast<SecondDerivExternalFunctionNode *>(this));
if (it != temporary_terms.end()) if (it != temporary_terms.end())
{ {
if (output_type == oMatlabDynamicModelSparse) if (output_type == oMatlabDynamicModelSparse)
@ -4017,8 +4017,8 @@ SecondDerivExternalFunctionNode::writeOutput(ostream &output, ExprNodeOutputType
void void
SecondDerivExternalFunctionNode::writeExternalFunctionOutput(ostream &output, ExprNodeOutputType output_type, SecondDerivExternalFunctionNode::writeExternalFunctionOutput(ostream &output, ExprNodeOutputType output_type,
const temporary_terms_type &temporary_terms, const temporary_terms_t &temporary_terms,
deriv_node_temp_terms_type &tef_terms) const deriv_node_temp_terms_t &tef_terms) const
{ {
assert(output_type != oMatlabOutsideModel); assert(output_type != oMatlabOutsideModel);
int second_deriv_symb_id = datatree.external_functions_table.getSecondDerivSymbID(symb_id); int second_deriv_symb_id = datatree.external_functions_table.getSecondDerivSymbID(symb_id);

View File

@ -43,19 +43,19 @@ struct ExprNodeLess;
//! Type for set of temporary terms //! Type for set of temporary terms
/*! They are ordered by index number thanks to ExprNodeLess */ /*! They are ordered by index number thanks to ExprNodeLess */
typedef set<NodeID, ExprNodeLess> temporary_terms_type; typedef set<NodeID, ExprNodeLess> temporary_terms_t;
//! set of temporary terms used in a block //! set of temporary terms used in a block
typedef set<int> temporary_terms_inuse_type; typedef set<int> temporary_terms_inuse_t;
typedef map<int, int> map_idx_type; typedef map<int, int> map_idx_t;
//! Type for evaluation contexts //! Type for evaluation contexts
/*! The key is a symbol id. Lags are assumed to be null */ /*! The key is a symbol id. Lags are assumed to be null */
typedef map<int, double> eval_context_type; typedef map<int, double> eval_context_t;
//! Type for tracking first/second derivative functions that have already been written as temporary terms //! Type for tracking first/second derivative functions that have already been written as temporary terms
typedef map<pair<int, vector<NodeID> >, int> deriv_node_temp_terms_type; typedef map<pair<int, vector<NodeID> >, int> deriv_node_temp_terms_t;
//! Possible types of output when writing ExprNode(s) //! Possible types of output when writing ExprNode(s)
enum ExprNodeOutputType enum ExprNodeOutputType
@ -143,7 +143,7 @@ protected:
//! Cost of computing current node //! Cost of computing current node
/*! Nodes included in temporary_terms are considered having a null cost */ /*! Nodes included in temporary_terms are considered having a null cost */
virtual int cost(const temporary_terms_type &temporary_terms, bool is_matlab) const; virtual int cost(const temporary_terms_t &temporary_terms, bool is_matlab) const;
public: public:
ExprNode(DataTree &datatree_arg); ExprNode(DataTree &datatree_arg);
@ -166,11 +166,11 @@ public:
//! Returns precedence of node //! Returns precedence of node
/*! Equals 100 for constants, variables, unary ops, and temporary terms */ /*! Equals 100 for constants, variables, unary ops, and temporary terms */
virtual int precedence(ExprNodeOutputType output_type, const temporary_terms_type &temporary_terms) const; virtual int precedence(ExprNodeOutputType output_t, const temporary_terms_t &temporary_terms) const;
//! Fills temporary_terms set, using reference counts //! Fills temporary_terms set, using reference counts
/*! A node will be marked as a temporary term if it is referenced at least two times (i.e. has at least two parents), and has a computing cost (multiplied by reference count) greater to datatree.min_cost */ /*! A node will be marked as a temporary term if it is referenced at least two times (i.e. has at least two parents), and has a computing cost (multiplied by reference count) greater to datatree.min_cost */
virtual void computeTemporaryTerms(map<NodeID, int> &reference_count, temporary_terms_type &temporary_terms, bool is_matlab) const; virtual void computeTemporaryTerms(map<NodeID, int> &reference_count, temporary_terms_t &temporary_terms, bool is_matlab) const;
//! Writes output of node, using a Txxx notation for nodes in temporary_terms, and specifiying the set of already written external functions //! Writes output of node, using a Txxx notation for nodes in temporary_terms, and specifiying the set of already written external functions
/*! /*!
@ -179,7 +179,7 @@ public:
\param[in] temporary_terms the nodes that are marked as temporary terms \param[in] temporary_terms the nodes that are marked as temporary terms
\param[in,out] tef_terms the set of already written external function nodes \param[in,out] tef_terms the set of already written external function nodes
*/ */
virtual void writeOutput(ostream &output, ExprNodeOutputType output_type, const temporary_terms_type &temporary_terms, deriv_node_temp_terms_type &tef_terms) const = 0; virtual void writeOutput(ostream &output, ExprNodeOutputType output_type, const temporary_terms_t &temporary_terms, deriv_node_temp_terms_t &tef_terms) const = 0;
//! Writes output of node (with no temporary terms and with "outside model" output type) //! Writes output of node (with no temporary terms and with "outside model" output type)
void writeOutput(ostream &output) const; void writeOutput(ostream &output) const;
@ -188,12 +188,12 @@ public:
void writeOutput(ostream &output, ExprNodeOutputType output_type) const; void writeOutput(ostream &output, ExprNodeOutputType output_type) const;
//! Writes output of node, using a Txxx notation for nodes in temporary_terms //! Writes output of node, using a Txxx notation for nodes in temporary_terms
void writeOutput(ostream &output, ExprNodeOutputType output_type, const temporary_terms_type &temporary_terms) const; void writeOutput(ostream &output, ExprNodeOutputType output_type, const temporary_terms_t &temporary_terms) const;
//! Writes the output for an external function, ensuring that the external function is called as few times as possible using temporary terms //! Writes the output for an external function, ensuring that the external function is called as few times as possible using temporary terms
virtual void writeExternalFunctionOutput(ostream &output, ExprNodeOutputType output_type, virtual void writeExternalFunctionOutput(ostream &output, ExprNodeOutputType output_type,
const temporary_terms_type &temporary_terms, const temporary_terms_t &temporary_terms,
deriv_node_temp_terms_type &tef_terms) const; deriv_node_temp_terms_t &tef_terms) const;
//! Computes the set of all variables of a given symbol type in the expression //! Computes the set of all variables of a given symbol type in the expression
/*! /*!
@ -227,12 +227,12 @@ public:
*/ */
virtual void collectModelLocalVariables(set<int> &result) const; virtual void collectModelLocalVariables(set<int> &result) const;
virtual void collectTemporary_terms(const temporary_terms_type &temporary_terms, temporary_terms_inuse_type &temporary_terms_inuse, int Curr_Block) const = 0; virtual void collectTemporary_terms(const temporary_terms_t &temporary_terms, temporary_terms_inuse_t &temporary_terms_inuse, int Curr_Block) const = 0;
virtual void computeTemporaryTerms(map<NodeID, int> &reference_count, virtual void computeTemporaryTerms(map<NodeID, int> &reference_count,
temporary_terms_type &temporary_terms, temporary_terms_t &temporary_terms,
map<NodeID, pair<int, int> > &first_occurence, map<NodeID, pair<int, int> > &first_occurence,
int Curr_block, int Curr_block,
vector< vector<temporary_terms_type> > &v_temporary_terms, vector< vector<temporary_terms_t> > &v_temporary_terms,
int equation) const; int equation) const;
class EvalException class EvalException
@ -240,8 +240,8 @@ public:
{ {
}; };
virtual double eval(const eval_context_type &eval_context) const throw (EvalException) = 0; virtual double eval(const eval_context_t &eval_context) const throw (EvalException) = 0;
virtual void compile(ostream &CompileCode, bool lhs_rhs, const temporary_terms_type &temporary_terms, const map_idx_type &map_idx, bool dynamic, bool steady_dynamic) const = 0; virtual void compile(ostream &CompileCode, bool lhs_rhs, const temporary_terms_t &temporary_terms, const map_idx_t &map_idx, bool dynamic, bool steady_dynamic) const = 0;
//! Creates a static version of this node //! Creates a static version of this node
/*! /*!
This method duplicates the current node by creating a similar node from which all leads/lags have been stripped, This method duplicates the current node by creating a similar node from which all leads/lags have been stripped,
@ -383,11 +383,11 @@ public:
return id; return id;
}; };
virtual void prepareForDerivation(); virtual void prepareForDerivation();
virtual void writeOutput(ostream &output, ExprNodeOutputType output_type, const temporary_terms_type &temporary_terms, deriv_node_temp_terms_type &tef_terms) const; virtual void writeOutput(ostream &output, ExprNodeOutputType output_type, const temporary_terms_t &temporary_terms, deriv_node_temp_terms_t &tef_terms) const;
virtual void collectVariables(SymbolType type_arg, set<pair<int, int> > &result) const; virtual void collectVariables(SymbolType type_arg, set<pair<int, int> > &result) const;
virtual void collectTemporary_terms(const temporary_terms_type &temporary_terms, temporary_terms_inuse_type &temporary_terms_inuse, int Curr_Block) const; virtual void collectTemporary_terms(const temporary_terms_t &temporary_terms, temporary_terms_inuse_t &temporary_terms_inuse, int Curr_Block) const;
virtual double eval(const eval_context_type &eval_context) const throw (EvalException); virtual double eval(const eval_context_t &eval_context) const throw (EvalException);
virtual void compile(ostream &CompileCode, bool lhs_rhs, const temporary_terms_type &temporary_terms, const map_idx_type &map_idx, bool dynamic, bool steady_dynamic) const; virtual void compile(ostream &CompileCode, bool lhs_rhs, const temporary_terms_t &temporary_terms, const map_idx_t &map_idx, bool dynamic, bool steady_dynamic) const;
virtual NodeID toStatic(DataTree &static_datatree) const; virtual NodeID toStatic(DataTree &static_datatree) const;
virtual pair<int, NodeID> normalizeEquation(int symb_id_endo, vector<pair<int, pair<NodeID, NodeID> > > &List_of_Op_RHS) const; virtual pair<int, NodeID> normalizeEquation(int symb_id_endo, vector<pair<int, pair<NodeID, NodeID> > > &List_of_Op_RHS) const;
virtual NodeID getChainRuleDerivative(int deriv_id, const map<int, NodeID> &recursive_variables); virtual NodeID getChainRuleDerivative(int deriv_id, const map<int, NodeID> &recursive_variables);
@ -419,17 +419,17 @@ private:
public: public:
VariableNode(DataTree &datatree_arg, int symb_id_arg, int lag_arg); VariableNode(DataTree &datatree_arg, int symb_id_arg, int lag_arg);
virtual void prepareForDerivation(); virtual void prepareForDerivation();
virtual void writeOutput(ostream &output, ExprNodeOutputType output_type, const temporary_terms_type &temporary_terms, deriv_node_temp_terms_type &tef_terms) const; virtual void writeOutput(ostream &output, ExprNodeOutputType output_type, const temporary_terms_t &temporary_terms, deriv_node_temp_terms_t &tef_terms) const;
virtual void collectVariables(SymbolType type_arg, set<pair<int, int> > &result) const; virtual void collectVariables(SymbolType type_arg, set<pair<int, int> > &result) const;
virtual void computeTemporaryTerms(map<NodeID, int> &reference_count, virtual void computeTemporaryTerms(map<NodeID, int> &reference_count,
temporary_terms_type &temporary_terms, temporary_terms_t &temporary_terms,
map<NodeID, pair<int, int> > &first_occurence, map<NodeID, pair<int, int> > &first_occurence,
int Curr_block, int Curr_block,
vector< vector<temporary_terms_type> > &v_temporary_terms, vector< vector<temporary_terms_t> > &v_temporary_terms,
int equation) const; int equation) const;
virtual void collectTemporary_terms(const temporary_terms_type &temporary_terms, temporary_terms_inuse_type &temporary_terms_inuse, int Curr_Block) const; virtual void collectTemporary_terms(const temporary_terms_t &temporary_terms, temporary_terms_inuse_t &temporary_terms_inuse, int Curr_Block) const;
virtual double eval(const eval_context_type &eval_context) const throw (EvalException); virtual double eval(const eval_context_t &eval_context) const throw (EvalException);
virtual void compile(ostream &CompileCode, bool lhs_rhs, const temporary_terms_type &temporary_terms, const map_idx_type &map_idx, bool dynamic, bool steady_dynamic) const; virtual void compile(ostream &CompileCode, bool lhs_rhs, const temporary_terms_t &temporary_terms, const map_idx_t &map_idx, bool dynamic, bool steady_dynamic) const;
virtual NodeID toStatic(DataTree &static_datatree) const; virtual NodeID toStatic(DataTree &static_datatree) const;
int int
get_symb_id() const get_symb_id() const
@ -465,28 +465,28 @@ private:
const string expectation_information_set_name; const string expectation_information_set_name;
const UnaryOpcode op_code; const UnaryOpcode op_code;
virtual NodeID computeDerivative(int deriv_id); virtual NodeID computeDerivative(int deriv_id);
virtual int cost(const temporary_terms_type &temporary_terms, bool is_matlab) const; virtual int cost(const temporary_terms_t &temporary_terms, bool is_matlab) const;
//! Returns the derivative of this node if darg is the derivative of the argument //! Returns the derivative of this node if darg is the derivative of the argument
NodeID composeDerivatives(NodeID darg); NodeID composeDerivatives(NodeID darg);
public: public:
UnaryOpNode(DataTree &datatree_arg, UnaryOpcode op_code_arg, const NodeID arg_arg, const int expectation_information_set_arg, const string &expectation_information_set_name_arg); UnaryOpNode(DataTree &datatree_arg, UnaryOpcode op_code_arg, const NodeID arg_arg, const int expectation_information_set_arg, const string &expectation_information_set_name_arg);
virtual void prepareForDerivation(); virtual void prepareForDerivation();
virtual void computeTemporaryTerms(map<NodeID, int> &reference_count, temporary_terms_type &temporary_terms, bool is_matlab) const; virtual void computeTemporaryTerms(map<NodeID, int> &reference_count, temporary_terms_t &temporary_terms, bool is_matlab) const;
virtual void writeOutput(ostream &output, ExprNodeOutputType output_type, const temporary_terms_type &temporary_terms, deriv_node_temp_terms_type &tef_terms) const; virtual void writeOutput(ostream &output, ExprNodeOutputType output_type, const temporary_terms_t &temporary_terms, deriv_node_temp_terms_t &tef_terms) const;
virtual void writeExternalFunctionOutput(ostream &output, ExprNodeOutputType output_type, virtual void writeExternalFunctionOutput(ostream &output, ExprNodeOutputType output_type,
const temporary_terms_type &temporary_terms, const temporary_terms_t &temporary_terms,
deriv_node_temp_terms_type &tef_terms) const; deriv_node_temp_terms_t &tef_terms) const;
virtual void computeTemporaryTerms(map<NodeID, int> &reference_count, virtual void computeTemporaryTerms(map<NodeID, int> &reference_count,
temporary_terms_type &temporary_terms, temporary_terms_t &temporary_terms,
map<NodeID, pair<int, int> > &first_occurence, map<NodeID, pair<int, int> > &first_occurence,
int Curr_block, int Curr_block,
vector< vector<temporary_terms_type> > &v_temporary_terms, vector< vector<temporary_terms_t> > &v_temporary_terms,
int equation) const; int equation) const;
virtual void collectVariables(SymbolType type_arg, set<pair<int, int> > &result) const; virtual void collectVariables(SymbolType type_arg, set<pair<int, int> > &result) const;
virtual void collectTemporary_terms(const temporary_terms_type &temporary_terms, temporary_terms_inuse_type &temporary_terms_inuse, int Curr_Block) const; virtual void collectTemporary_terms(const temporary_terms_t &temporary_terms, temporary_terms_inuse_t &temporary_terms_inuse, int Curr_Block) const;
static double eval_opcode(UnaryOpcode op_code, double v) throw (EvalException); static double eval_opcode(UnaryOpcode op_code, double v) throw (EvalException);
virtual double eval(const eval_context_type &eval_context) const throw (EvalException); virtual double eval(const eval_context_t &eval_context) const throw (EvalException);
virtual void compile(ostream &CompileCode, bool lhs_rhs, const temporary_terms_type &temporary_terms, const map_idx_type &map_idx, bool dynamic, bool steady_dynamic) const; virtual void compile(ostream &CompileCode, bool lhs_rhs, const temporary_terms_t &temporary_terms, const map_idx_t &map_idx, bool dynamic, bool steady_dynamic) const;
//! Returns operand //! Returns operand
NodeID NodeID
get_arg() const get_arg() const
@ -526,30 +526,30 @@ private:
const NodeID arg1, arg2; const NodeID arg1, arg2;
const BinaryOpcode op_code; const BinaryOpcode op_code;
virtual NodeID computeDerivative(int deriv_id); virtual NodeID computeDerivative(int deriv_id);
virtual int cost(const temporary_terms_type &temporary_terms, bool is_matlab) const; virtual int cost(const temporary_terms_t &temporary_terms, bool is_matlab) const;
//! Returns the derivative of this node if darg1 and darg2 are the derivatives of the arguments //! Returns the derivative of this node if darg1 and darg2 are the derivatives of the arguments
NodeID composeDerivatives(NodeID darg1, NodeID darg2); NodeID composeDerivatives(NodeID darg1, NodeID darg2);
public: public:
BinaryOpNode(DataTree &datatree_arg, const NodeID arg1_arg, BinaryOpNode(DataTree &datatree_arg, const NodeID arg1_arg,
BinaryOpcode op_code_arg, const NodeID arg2_arg); BinaryOpcode op_code_arg, const NodeID arg2_arg);
virtual void prepareForDerivation(); virtual void prepareForDerivation();
virtual int precedence(ExprNodeOutputType output_type, const temporary_terms_type &temporary_terms) const; virtual int precedence(ExprNodeOutputType output_type, const temporary_terms_t &temporary_terms) const;
virtual void computeTemporaryTerms(map<NodeID, int> &reference_count, temporary_terms_type &temporary_terms, bool is_matlab) const; virtual void computeTemporaryTerms(map<NodeID, int> &reference_count, temporary_terms_t &temporary_terms, bool is_matlab) const;
virtual void writeOutput(ostream &output, ExprNodeOutputType output_type, const temporary_terms_type &temporary_terms, deriv_node_temp_terms_type &tef_terms) const; virtual void writeOutput(ostream &output, ExprNodeOutputType output_type, const temporary_terms_t &temporary_terms, deriv_node_temp_terms_t &tef_terms) const;
virtual void writeExternalFunctionOutput(ostream &output, ExprNodeOutputType output_type, virtual void writeExternalFunctionOutput(ostream &output, ExprNodeOutputType output_type,
const temporary_terms_type &temporary_terms, const temporary_terms_t &temporary_terms,
deriv_node_temp_terms_type &tef_terms) const; deriv_node_temp_terms_t &tef_terms) const;
virtual void computeTemporaryTerms(map<NodeID, int> &reference_count, virtual void computeTemporaryTerms(map<NodeID, int> &reference_count,
temporary_terms_type &temporary_terms, temporary_terms_t &temporary_terms,
map<NodeID, pair<int, int> > &first_occurence, map<NodeID, pair<int, int> > &first_occurence,
int Curr_block, int Curr_block,
vector< vector<temporary_terms_type> > &v_temporary_terms, vector< vector<temporary_terms_t> > &v_temporary_terms,
int equation) const; int equation) const;
virtual void collectVariables(SymbolType type_arg, set<pair<int, int> > &result) const; virtual void collectVariables(SymbolType type_arg, set<pair<int, int> > &result) const;
virtual void collectTemporary_terms(const temporary_terms_type &temporary_terms, temporary_terms_inuse_type &temporary_terms_inuse, int Curr_Block) const; virtual void collectTemporary_terms(const temporary_terms_t &temporary_terms, temporary_terms_inuse_t &temporary_terms_inuse, int Curr_Block) const;
static double eval_opcode(double v1, BinaryOpcode op_code, double v2) throw (EvalException); static double eval_opcode(double v1, BinaryOpcode op_code, double v2) throw (EvalException);
virtual double eval(const eval_context_type &eval_context) const throw (EvalException); virtual double eval(const eval_context_t &eval_context) const throw (EvalException);
virtual void compile(ostream &CompileCode, bool lhs_rhs, const temporary_terms_type &temporary_terms, const map_idx_type &map_idx, bool dynamic, bool steady_dynamic) const; virtual void compile(ostream &CompileCode, bool lhs_rhs, const temporary_terms_t &temporary_terms, const map_idx_t &map_idx, bool dynamic, bool steady_dynamic) const;
virtual NodeID Compute_RHS(NodeID arg1, NodeID arg2, int op, int op_type) const; virtual NodeID Compute_RHS(NodeID arg1, NodeID arg2, int op, int op_type) const;
//! Returns first operand //! Returns first operand
NodeID NodeID
@ -597,30 +597,30 @@ private:
const NodeID arg1, arg2, arg3; const NodeID arg1, arg2, arg3;
const TrinaryOpcode op_code; const TrinaryOpcode op_code;
virtual NodeID computeDerivative(int deriv_id); virtual NodeID computeDerivative(int deriv_id);
virtual int cost(const temporary_terms_type &temporary_terms, bool is_matlab) const; virtual int cost(const temporary_terms_t &temporary_terms, bool is_matlab) const;
//! Returns the derivative of this node if darg1, darg2 and darg3 are the derivatives of the arguments //! Returns the derivative of this node if darg1, darg2 and darg3 are the derivatives of the arguments
NodeID composeDerivatives(NodeID darg1, NodeID darg2, NodeID darg3); NodeID composeDerivatives(NodeID darg1, NodeID darg2, NodeID darg3);
public: public:
TrinaryOpNode(DataTree &datatree_arg, const NodeID arg1_arg, TrinaryOpNode(DataTree &datatree_arg, const NodeID arg1_arg,
TrinaryOpcode op_code_arg, const NodeID arg2_arg, const NodeID arg3_arg); TrinaryOpcode op_code_arg, const NodeID arg2_arg, const NodeID arg3_arg);
virtual void prepareForDerivation(); virtual void prepareForDerivation();
virtual int precedence(ExprNodeOutputType output_type, const temporary_terms_type &temporary_terms) const; virtual int precedence(ExprNodeOutputType output_type, const temporary_terms_t &temporary_terms) const;
virtual void computeTemporaryTerms(map<NodeID, int> &reference_count, temporary_terms_type &temporary_terms, bool is_matlab) const; virtual void computeTemporaryTerms(map<NodeID, int> &reference_count, temporary_terms_t &temporary_terms, bool is_matlab) const;
virtual void writeOutput(ostream &output, ExprNodeOutputType output_type, const temporary_terms_type &temporary_terms, deriv_node_temp_terms_type &tef_terms) const; virtual void writeOutput(ostream &output, ExprNodeOutputType output_type, const temporary_terms_t &temporary_terms, deriv_node_temp_terms_t &tef_terms) const;
virtual void writeExternalFunctionOutput(ostream &output, ExprNodeOutputType output_type, virtual void writeExternalFunctionOutput(ostream &output, ExprNodeOutputType output_type,
const temporary_terms_type &temporary_terms, const temporary_terms_t &temporary_terms,
deriv_node_temp_terms_type &tef_terms) const; deriv_node_temp_terms_t &tef_terms) const;
virtual void computeTemporaryTerms(map<NodeID, int> &reference_count, virtual void computeTemporaryTerms(map<NodeID, int> &reference_count,
temporary_terms_type &temporary_terms, temporary_terms_t &temporary_terms,
map<NodeID, pair<int, int> > &first_occurence, map<NodeID, pair<int, int> > &first_occurence,
int Curr_block, int Curr_block,
vector< vector<temporary_terms_type> > &v_temporary_terms, vector< vector<temporary_terms_t> > &v_temporary_terms,
int equation) const; int equation) const;
virtual void collectVariables(SymbolType type_arg, set<pair<int, int> > &result) const; virtual void collectVariables(SymbolType type_arg, set<pair<int, int> > &result) const;
virtual void collectTemporary_terms(const temporary_terms_type &temporary_terms, temporary_terms_inuse_type &temporary_terms_inuse, int Curr_Block) const; virtual void collectTemporary_terms(const temporary_terms_t &temporary_terms, temporary_terms_inuse_t &temporary_terms_inuse, int Curr_Block) const;
static double eval_opcode(double v1, TrinaryOpcode op_code, double v2, double v3) throw (EvalException); static double eval_opcode(double v1, TrinaryOpcode op_code, double v2, double v3) throw (EvalException);
virtual double eval(const eval_context_type &eval_context) const throw (EvalException); virtual double eval(const eval_context_t &eval_context) const throw (EvalException);
virtual void compile(ostream &CompileCode, bool lhs_rhs, const temporary_terms_type &temporary_terms, const map_idx_type &map_idx, bool dynamic, bool steady_dynamic) const; virtual void compile(ostream &CompileCode, bool lhs_rhs, const temporary_terms_t &temporary_terms, const map_idx_t &map_idx, bool dynamic, bool steady_dynamic) const;
virtual NodeID toStatic(DataTree &static_datatree) const; virtual NodeID toStatic(DataTree &static_datatree) const;
virtual pair<int, NodeID> normalizeEquation(int symb_id_endo, vector<pair<int, pair<NodeID, NodeID> > > &List_of_Op_RHS) const; virtual pair<int, NodeID> normalizeEquation(int symb_id_endo, vector<pair<int, pair<NodeID, NodeID> > > &List_of_Op_RHS) const;
virtual NodeID getChainRuleDerivative(int deriv_id, const map<int, NodeID> &recursive_variables); virtual NodeID getChainRuleDerivative(int deriv_id, const map<int, NodeID> &recursive_variables);
@ -655,30 +655,30 @@ protected:
const int symb_id; const int symb_id;
const vector<NodeID> arguments; const vector<NodeID> arguments;
//! Returns true if the given external function has been written as a temporary term //! Returns true if the given external function has been written as a temporary term
bool alreadyWrittenAsTefTerm(int the_symb_id, deriv_node_temp_terms_type &tef_terms) const; bool alreadyWrittenAsTefTerm(int the_symb_id, deriv_node_temp_terms_t &tef_terms) const;
//! Returns the index in the tef_terms map of this external function //! Returns the index in the tef_terms map of this external function
int getIndxInTefTerms(int the_symb_id, deriv_node_temp_terms_type &tef_terms) const throw (UnknownFunctionNameAndArgs); int getIndxInTefTerms(int the_symb_id, deriv_node_temp_terms_t &tef_terms) const throw (UnknownFunctionNameAndArgs);
//! Helper function to write output arguments of any given external function //! Helper function to write output arguments of any given external function
void writeExternalFunctionArguments(ostream &output, ExprNodeOutputType output_type, const temporary_terms_type &temporary_terms, deriv_node_temp_terms_type &tef_terms) const; void writeExternalFunctionArguments(ostream &output, ExprNodeOutputType output_type, const temporary_terms_t &temporary_terms, deriv_node_temp_terms_t &tef_terms) const;
public: public:
ExternalFunctionNode(DataTree &datatree_arg, int symb_id_arg, ExternalFunctionNode(DataTree &datatree_arg, int symb_id_arg,
const vector<NodeID> &arguments_arg); const vector<NodeID> &arguments_arg);
virtual void prepareForDerivation(); virtual void prepareForDerivation();
virtual void computeTemporaryTerms(map<NodeID, int> &reference_count, temporary_terms_type &temporary_terms, bool is_matlab) const; virtual void computeTemporaryTerms(map<NodeID, int> &reference_count, temporary_terms_t &temporary_terms, bool is_matlab) const;
virtual void writeOutput(ostream &output, ExprNodeOutputType output_type, const temporary_terms_type &temporary_terms, deriv_node_temp_terms_type &tef_terms) const; virtual void writeOutput(ostream &output, ExprNodeOutputType output_type, const temporary_terms_t &temporary_terms, deriv_node_temp_terms_t &tef_terms) const;
virtual void writeExternalFunctionOutput(ostream &output, ExprNodeOutputType output_type, virtual void writeExternalFunctionOutput(ostream &output, ExprNodeOutputType output_type,
const temporary_terms_type &temporary_terms, const temporary_terms_t &temporary_terms,
deriv_node_temp_terms_type &tef_terms) const; deriv_node_temp_terms_t &tef_terms) const;
virtual void computeTemporaryTerms(map<NodeID, int> &reference_count, virtual void computeTemporaryTerms(map<NodeID, int> &reference_count,
temporary_terms_type &temporary_terms, temporary_terms_t &temporary_terms,
map<NodeID, pair<int, int> > &first_occurence, map<NodeID, pair<int, int> > &first_occurence,
int Curr_block, int Curr_block,
vector< vector<temporary_terms_type> > &v_temporary_terms, vector< vector<temporary_terms_t> > &v_temporary_terms,
int equation) const; int equation) const;
virtual void collectVariables(SymbolType type_arg, set<pair<int, int> > &result) const; virtual void collectVariables(SymbolType type_arg, set<pair<int, int> > &result) const;
virtual void collectTemporary_terms(const temporary_terms_type &temporary_terms, temporary_terms_inuse_type &temporary_terms_inuse, int Curr_Block) const; virtual void collectTemporary_terms(const temporary_terms_t &temporary_terms, temporary_terms_inuse_t &temporary_terms_inuse, int Curr_Block) const;
virtual double eval(const eval_context_type &eval_context) const throw (EvalException); virtual double eval(const eval_context_t &eval_context) const throw (EvalException);
virtual void compile(ostream &CompileCode, bool lhs_rhs, const temporary_terms_type &temporary_terms, const map_idx_type &map_idx, bool dynamic, bool steady_dynamic) const; virtual void compile(ostream &CompileCode, bool lhs_rhs, const temporary_terms_t &temporary_terms, const map_idx_t &map_idx, bool dynamic, bool steady_dynamic) const;
virtual NodeID toStatic(DataTree &static_datatree) const; virtual NodeID toStatic(DataTree &static_datatree) const;
virtual pair<int, NodeID> normalizeEquation(int symb_id_endo, vector<pair<int, pair<NodeID, NodeID> > > &List_of_Op_RHS) const; virtual pair<int, NodeID> normalizeEquation(int symb_id_endo, vector<pair<int, pair<NodeID, NodeID> > > &List_of_Op_RHS) const;
virtual NodeID getChainRuleDerivative(int deriv_id, const map<int, NodeID> &recursive_variables); virtual NodeID getChainRuleDerivative(int deriv_id, const map<int, NodeID> &recursive_variables);
@ -708,17 +708,17 @@ public:
int top_level_symb_id_arg, int top_level_symb_id_arg,
const vector<NodeID> &arguments_arg, const vector<NodeID> &arguments_arg,
int inputIndex_arg); int inputIndex_arg);
virtual void computeTemporaryTerms(map<NodeID, int> &reference_count, temporary_terms_type &temporary_terms, bool is_matlab) const; virtual void computeTemporaryTerms(map<NodeID, int> &reference_count, temporary_terms_t &temporary_terms, bool is_matlab) const;
virtual void computeTemporaryTerms(map<NodeID, int> &reference_count, virtual void computeTemporaryTerms(map<NodeID, int> &reference_count,
temporary_terms_type &temporary_terms, temporary_terms_t &temporary_terms,
map<NodeID, pair<int, int> > &first_occurence, map<NodeID, pair<int, int> > &first_occurence,
int Curr_block, int Curr_block,
vector< vector<temporary_terms_type> > &v_temporary_terms, vector< vector<temporary_terms_t> > &v_temporary_terms,
int equation) const; int equation) const;
virtual void writeOutput(ostream &output, ExprNodeOutputType output_type, const temporary_terms_type &temporary_terms, deriv_node_temp_terms_type &tef_terms) const; virtual void writeOutput(ostream &output, ExprNodeOutputType output_type, const temporary_terms_t &temporary_terms, deriv_node_temp_terms_t &tef_terms) const;
virtual void writeExternalFunctionOutput(ostream &output, ExprNodeOutputType output_type, virtual void writeExternalFunctionOutput(ostream &output, ExprNodeOutputType output_type,
const temporary_terms_type &temporary_terms, const temporary_terms_t &temporary_terms,
deriv_node_temp_terms_type &tef_terms) const; deriv_node_temp_terms_t &tef_terms) const;
}; };
class SecondDerivExternalFunctionNode : public ExternalFunctionNode class SecondDerivExternalFunctionNode : public ExternalFunctionNode
@ -733,17 +733,17 @@ public:
const vector<NodeID> &arguments_arg, const vector<NodeID> &arguments_arg,
int inputIndex1_arg, int inputIndex1_arg,
int inputIndex2_arg); int inputIndex2_arg);
virtual void computeTemporaryTerms(map<NodeID, int> &reference_count, temporary_terms_type &temporary_terms, bool is_matlab) const; virtual void computeTemporaryTerms(map<NodeID, int> &reference_count, temporary_terms_t &temporary_terms, bool is_matlab) const;
virtual void computeTemporaryTerms(map<NodeID, int> &reference_count, virtual void computeTemporaryTerms(map<NodeID, int> &reference_count,
temporary_terms_type &temporary_terms, temporary_terms_t &temporary_terms,
map<NodeID, pair<int, int> > &first_occurence, map<NodeID, pair<int, int> > &first_occurence,
int Curr_block, int Curr_block,
vector< vector<temporary_terms_type> > &v_temporary_terms, vector< vector<temporary_terms_t> > &v_temporary_terms,
int equation) const; int equation) const;
virtual void writeOutput(ostream &output, ExprNodeOutputType output_type, const temporary_terms_type &temporary_terms, deriv_node_temp_terms_type &tef_terms) const; virtual void writeOutput(ostream &output, ExprNodeOutputType output_type, const temporary_terms_t &temporary_terms, deriv_node_temp_terms_t &tef_terms) const;
virtual void writeExternalFunctionOutput(ostream &output, ExprNodeOutputType output_type, virtual void writeExternalFunctionOutput(ostream &output, ExprNodeOutputType output_type,
const temporary_terms_type &temporary_terms, const temporary_terms_t &temporary_terms,
deriv_node_temp_terms_type &tef_terms) const; deriv_node_temp_terms_t &tef_terms) const;
}; };
#endif #endif

View File

@ -24,29 +24,29 @@
namespace MFS namespace MFS
{ {
void void
Suppress(AdjacencyList_type::vertex_descriptor vertex_to_eliminate, AdjacencyList_type &G) Suppress(AdjacencyList_t::vertex_descriptor vertex_to_eliminate, AdjacencyList_t &G)
{ {
clear_vertex(vertex_to_eliminate, G); clear_vertex(vertex_to_eliminate, G);
remove_vertex(vertex_to_eliminate, G); remove_vertex(vertex_to_eliminate, G);
} }
void void
Suppress(int vertex_num, AdjacencyList_type &G) Suppress(int vertex_num, AdjacencyList_t &G)
{ {
Suppress(vertex(vertex_num, G), G); Suppress(vertex(vertex_num, G), G);
} }
void void
Eliminate(AdjacencyList_type::vertex_descriptor vertex_to_eliminate, AdjacencyList_type &G) Eliminate(AdjacencyList_t::vertex_descriptor vertex_to_eliminate, AdjacencyList_t &G)
{ {
if (in_degree(vertex_to_eliminate, G) > 0 && out_degree(vertex_to_eliminate, G) > 0) if (in_degree(vertex_to_eliminate, G) > 0 && out_degree(vertex_to_eliminate, G) > 0)
{ {
AdjacencyList_type::in_edge_iterator it_in, in_end; AdjacencyList_t::in_edge_iterator it_in, in_end;
AdjacencyList_type::out_edge_iterator it_out, out_end; AdjacencyList_t::out_edge_iterator it_out, out_end;
for (tie(it_in, in_end) = in_edges(vertex_to_eliminate, G); it_in != in_end; ++it_in) for (tie(it_in, in_end) = in_edges(vertex_to_eliminate, G); it_in != in_end; ++it_in)
for (tie(it_out, out_end) = out_edges(vertex_to_eliminate, G); it_out != out_end; ++it_out) for (tie(it_out, out_end) = out_edges(vertex_to_eliminate, G); it_out != out_end; ++it_out)
{ {
AdjacencyList_type::edge_descriptor ed; AdjacencyList_t::edge_descriptor ed;
bool exist; bool exist;
tie(ed, exist) = edge(source(*it_in, G), target(*it_out, G), G); tie(ed, exist) = edge(source(*it_in, G), target(*it_out, G), G);
if (!exist) if (!exist)
@ -57,11 +57,11 @@ namespace MFS
} }
bool bool
has_cycle_dfs(AdjacencyList_type &g, AdjacencyList_type::vertex_descriptor u, color_type &color, vector<int> &circuit_stack) has_cycle_dfs(AdjacencyList_t &g, AdjacencyList_t::vertex_descriptor u, color_t &color, vector<int> &circuit_stack)
{ {
property_map<AdjacencyList_type, vertex_index_t>::type v_index = get(vertex_index, g); property_map<AdjacencyList_t, vertex_index_t>::type v_index = get(vertex_index, g);
color[u] = gray_color; color[u] = gray_color;
graph_traits<AdjacencyList_type>::out_edge_iterator vi, vi_end; graph_traits<AdjacencyList_t>::out_edge_iterator vi, vi_end;
for (tie(vi, vi_end) = out_edges(u, g); vi != vi_end; ++vi) for (tie(vi, vi_end) = out_edges(u, g); vi != vi_end; ++vi)
if (color[target(*vi, g)] == white_color && has_cycle_dfs(g, target(*vi, g), color, circuit_stack)) if (color[target(*vi, g)] == white_color && has_cycle_dfs(g, target(*vi, g), color, circuit_stack))
{ {
@ -80,11 +80,11 @@ namespace MFS
} }
bool bool
has_cycle(vector<int> &circuit_stack, AdjacencyList_type &g) has_cycle(vector<int> &circuit_stack, AdjacencyList_t &g)
{ {
// Initialize color map to white // Initialize color map to white
color_type color; color_t color;
graph_traits<AdjacencyList_type>::vertex_iterator vi, vi_end; graph_traits<AdjacencyList_t>::vertex_iterator vi, vi_end;
for (tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) for (tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi)
color[*vi] = white_color; color[*vi] = white_color;
@ -97,32 +97,32 @@ namespace MFS
} }
void void
Print(AdjacencyList_type &G) Print(AdjacencyList_t &G)
{ {
AdjacencyList_type::vertex_iterator it, it_end; AdjacencyList_t::vertex_iterator it, it_end;
property_map<AdjacencyList_type, vertex_index_t>::type v_index = get(vertex_index, G); property_map<AdjacencyList_t, vertex_index_t>::type v_index = get(vertex_index, G);
cout << "Graph\n"; cout << "Graph\n";
cout << "-----\n"; cout << "-----\n";
for (tie(it, it_end) = vertices(G); it != it_end; ++it) for (tie(it, it_end) = vertices(G); it != it_end; ++it)
{ {
cout << "vertex[" << v_index[*it] + 1 << "] <-"; cout << "vertex[" << v_index[*it] + 1 << "] <-";
AdjacencyList_type::in_edge_iterator it_in, in_end; AdjacencyList_t::in_edge_iterator it_in, in_end;
for (tie(it_in, in_end) = in_edges(*it, G); it_in != in_end; ++it_in) for (tie(it_in, in_end) = in_edges(*it, G); it_in != in_end; ++it_in)
cout << v_index[source(*it_in, G)] + 1 << " "; cout << v_index[source(*it_in, G)] + 1 << " ";
cout << "\n ->"; cout << "\n ->";
AdjacencyList_type::out_edge_iterator it_out, out_end; AdjacencyList_t::out_edge_iterator it_out, out_end;
for (tie(it_out, out_end) = out_edges(*it, G); it_out != out_end; ++it_out) for (tie(it_out, out_end) = out_edges(*it, G); it_out != out_end; ++it_out)
cout << v_index[target(*it_out, G)] + 1 << " "; cout << v_index[target(*it_out, G)] + 1 << " ";
cout << "\n"; cout << "\n";
} }
} }
AdjacencyList_type AdjacencyList_t
AM_2_AdjacencyList(bool *AM, unsigned int n) AM_2_AdjacencyList(bool *AM, unsigned int n)
{ {
AdjacencyList_type G(n); AdjacencyList_t G(n);
property_map<AdjacencyList_type, vertex_index_t>::type v_index = get(vertex_index, G); property_map<AdjacencyList_t, vertex_index_t>::type v_index = get(vertex_index, G);
property_map<AdjacencyList_type, vertex_index1_t>::type v_index1 = get(vertex_index1, G); property_map<AdjacencyList_t, vertex_index1_t>::type v_index1 = get(vertex_index1, G);
for (unsigned int i = 0; i < n; i++) for (unsigned int i = 0; i < n; i++)
{ {
put(v_index, vertex(i, G), i); put(v_index, vertex(i, G), i);
@ -168,13 +168,13 @@ namespace MFS
return G; return G;
} }
AdjacencyList_type AdjacencyList_t
GraphvizDigraph_2_AdjacencyList(GraphvizDigraph &G1, set<int> select_index) GraphvizDigraph_2_AdjacencyList(GraphvizDigraph &G1, set<int> select_index)
{ {
unsigned int n = select_index.size(); unsigned int n = select_index.size();
AdjacencyList_type G(n); AdjacencyList_t G(n);
property_map<AdjacencyList_type, vertex_index_t>::type v_index = get(vertex_index, G); property_map<AdjacencyList_t, vertex_index_t>::type v_index = get(vertex_index, G);
property_map<AdjacencyList_type, vertex_index1_t>::type v_index1 = get(vertex_index1, G); property_map<AdjacencyList_t, vertex_index1_t>::type v_index1 = get(vertex_index1, G);
property_map<GraphvizDigraph, vertex_index_t>::type v1_index = get(vertex_index, G1); property_map<GraphvizDigraph, vertex_index_t>::type v1_index = get(vertex_index, G1);
set<int>::iterator it = select_index.begin(); set<int>::iterator it = select_index.begin();
map<int, int> reverse_index; map<int, int> reverse_index;
@ -199,12 +199,12 @@ namespace MFS
return G; return G;
} }
vector_vertex_descriptor vector_vertex_descriptor_t
Collect_Doublet(AdjacencyList_type::vertex_descriptor vertex, AdjacencyList_type &G) Collect_Doublet(AdjacencyList_t::vertex_descriptor vertex, AdjacencyList_t &G)
{ {
AdjacencyList_type::in_edge_iterator it_in, in_end; AdjacencyList_t::in_edge_iterator it_in, in_end;
AdjacencyList_type::out_edge_iterator it_out, out_end; AdjacencyList_t::out_edge_iterator it_out, out_end;
vector<AdjacencyList_type::vertex_descriptor> Doublet; vector<AdjacencyList_t::vertex_descriptor> Doublet;
if (in_degree(vertex, G) > 0 && out_degree(vertex, G) > 0) if (in_degree(vertex, G) > 0 && out_degree(vertex, G) > 0)
for (tie(it_in, in_end) = in_edges(vertex, G); it_in != in_end; ++it_in) for (tie(it_in, in_end) = in_edges(vertex, G); it_in != in_end; ++it_in)
for (tie(it_out, out_end) = out_edges(vertex, G); it_out != out_end; ++it_out) for (tie(it_out, out_end) = out_edges(vertex, G); it_out != out_end; ++it_out)
@ -214,12 +214,12 @@ namespace MFS
} }
bool bool
Vertex_Belong_to_a_Clique(AdjacencyList_type::vertex_descriptor vertex, AdjacencyList_type &G) Vertex_Belong_to_a_Clique(AdjacencyList_t::vertex_descriptor vertex, AdjacencyList_t &G)
{ {
vector<AdjacencyList_type::vertex_descriptor> liste; vector<AdjacencyList_t::vertex_descriptor> liste;
bool agree = true; bool agree = true;
AdjacencyList_type::in_edge_iterator it_in, in_end; AdjacencyList_t::in_edge_iterator it_in, in_end;
AdjacencyList_type::out_edge_iterator it_out, out_end; AdjacencyList_t::out_edge_iterator it_out, out_end;
tie(it_in, in_end) = in_edges(vertex, G); tie(it_in, in_end) = in_edges(vertex, G);
tie(it_out, out_end) = out_edges(vertex, G); tie(it_out, out_end) = out_edges(vertex, G);
while (it_in != in_end && it_out != out_end && agree) while (it_in != in_end && it_out != out_end && agree)
@ -239,7 +239,7 @@ namespace MFS
unsigned int j = i + 1; unsigned int j = i + 1;
while (j < liste.size() && agree) while (j < liste.size() && agree)
{ {
AdjacencyList_type::edge_descriptor ed; AdjacencyList_t::edge_descriptor ed;
bool exist1, exist2; bool exist1, exist2;
tie(ed, exist1) = edge(liste[i], liste[j], G); tie(ed, exist1) = edge(liste[i], liste[j], G);
tie(ed, exist2) = edge(liste[j], liste[i], G); tie(ed, exist2) = edge(liste[j], liste[i], G);
@ -253,13 +253,13 @@ namespace MFS
} }
bool bool
Elimination_of_Vertex_With_One_or_Less_Indegree_or_Outdegree_Step(AdjacencyList_type &G) Elimination_of_Vertex_With_One_or_Less_Indegree_or_Outdegree_Step(AdjacencyList_t &G)
{ {
bool something_has_been_done = false; bool something_has_been_done = false;
bool not_a_loop; bool not_a_loop;
int i; int i;
AdjacencyList_type::vertex_iterator it, it1, ita, it_end; AdjacencyList_t::vertex_iterator it, it1, ita, it_end;
property_map<AdjacencyList_type, vertex_index_t>::type v_index = get(vertex_index, G); property_map<AdjacencyList_t, vertex_index_t>::type v_index = get(vertex_index, G);
for (tie(it, it_end) = vertices(G), i = 0; it != it_end; ++it, i++) for (tie(it, it_end) = vertices(G), i = 0; it != it_end; ++it, i++)
{ {
int in_degree_n = in_degree(*it, G); int in_degree_n = in_degree(*it, G);
@ -269,7 +269,7 @@ namespace MFS
not_a_loop = true; not_a_loop = true;
if (in_degree_n >= 1 && out_degree_n >= 1) // Do not eliminate a vertex if it loops on itself! if (in_degree_n >= 1 && out_degree_n >= 1) // Do not eliminate a vertex if it loops on itself!
{ {
AdjacencyList_type::in_edge_iterator it_in, in_end; AdjacencyList_t::in_edge_iterator it_in, in_end;
for (tie(it_in, in_end) = in_edges(*it, G); it_in != in_end; ++it_in) for (tie(it_in, in_end) = in_edges(*it, G); it_in != in_end; ++it_in)
if (source(*it_in, G) == target(*it_in, G)) if (source(*it_in, G) == target(*it_in, G))
{ {
@ -282,7 +282,7 @@ namespace MFS
if (not_a_loop) if (not_a_loop)
{ {
#ifdef verbose #ifdef verbose
property_map<AdjacencyList_type, vertex_index_t>::type v_index = get(vertex_index, G); property_map<AdjacencyList_t, vertex_index_t>::type v_index = get(vertex_index, G);
cout << "->eliminate vertex[" << v_index[*it] + 1 << "]\n"; cout << "->eliminate vertex[" << v_index[*it] + 1 << "]\n";
#endif #endif
Eliminate(*it, G); Eliminate(*it, G);
@ -305,9 +305,9 @@ namespace MFS
} }
bool bool
Elimination_of_Vertex_belonging_to_a_clique_Step(AdjacencyList_type &G) Elimination_of_Vertex_belonging_to_a_clique_Step(AdjacencyList_t &G)
{ {
AdjacencyList_type::vertex_iterator it, it1, ita, it_end; AdjacencyList_t::vertex_iterator it, it1, ita, it_end;
bool something_has_been_done = false; bool something_has_been_done = false;
int i; int i;
for (tie(it, it_end) = vertices(G), i = 0; it != it_end; ++it, i++) for (tie(it, it_end) = vertices(G), i = 0; it != it_end; ++it, i++)
@ -315,7 +315,7 @@ namespace MFS
if (Vertex_Belong_to_a_Clique(*it, G)) if (Vertex_Belong_to_a_Clique(*it, G))
{ {
#ifdef verbose #ifdef verbose
property_map<AdjacencyList_type, vertex_index_t>::type v_index = get(vertex_index, G); property_map<AdjacencyList_t, vertex_index_t>::type v_index = get(vertex_index, G);
cout << "eliminate vertex[" << v_index[*it] + 1 << "]\n"; cout << "eliminate vertex[" << v_index[*it] + 1 << "]\n";
#endif #endif
Eliminate(*it, G); Eliminate(*it, G);
@ -334,25 +334,25 @@ namespace MFS
} }
bool bool
Suppression_of_Vertex_X_if_it_loops_store_in_set_of_feedback_vertex_Step(set<int> &feed_back_vertices, AdjacencyList_type &G) Suppression_of_Vertex_X_if_it_loops_store_in_set_of_feedback_vertex_Step(set<int> &feed_back_vertices, AdjacencyList_t &G)
{ {
bool something_has_been_done = false; bool something_has_been_done = false;
AdjacencyList_type::vertex_iterator it, it_end, ita; AdjacencyList_t::vertex_iterator it, it_end, ita;
int i = 0; int i = 0;
for (tie(it, it_end) = vertices(G); it != it_end; ++it, i++) for (tie(it, it_end) = vertices(G); it != it_end; ++it, i++)
{ {
AdjacencyList_type::edge_descriptor ed; AdjacencyList_t::edge_descriptor ed;
bool exist; bool exist;
tie(ed, exist) = edge(*it, *it, G); tie(ed, exist) = edge(*it, *it, G);
if (exist) if (exist)
{ {
#ifdef verbose #ifdef verbose
property_map<AdjacencyList_type, vertex_index_t>::type v_index = get(vertex_index, G); property_map<AdjacencyList_t, vertex_index_t>::type v_index = get(vertex_index, G);
cout << "store v[*it] = " << v_index[*it]+1 << "\n"; cout << "store v[*it] = " << v_index[*it]+1 << "\n";
#endif #endif
property_map<AdjacencyList_type, vertex_index1_t>::type v_index1 = get(vertex_index1, G); property_map<AdjacencyList_t, vertex_index1_t>::type v_index1 = get(vertex_index1, G);
feed_back_vertices.insert(v_index1[*it]); feed_back_vertices.insert(v_index1[*it]);
/*property_map<AdjacencyList_type, vertex_index_t>::type v_index = get(vertex_index, G); /*property_map<AdjacencyList_t, vertex_index_t>::type v_index = get(vertex_index, G);
feed_back_vertices.insert(v_index[*it] );*/ feed_back_vertices.insert(v_index[*it] );*/
Suppress(*it, G); Suppress(*it, G);
something_has_been_done = true; something_has_been_done = true;
@ -369,13 +369,13 @@ namespace MFS
return something_has_been_done; return something_has_been_done;
} }
AdjacencyList_type AdjacencyList_t
Minimal_set_of_feedback_vertex(set<int> &feed_back_vertices, const AdjacencyList_type &G1) Minimal_set_of_feedback_vertex(set<int> &feed_back_vertices, const AdjacencyList_t &G1)
{ {
bool something_has_been_done = true; bool something_has_been_done = true;
int cut_ = 0; int cut_ = 0;
feed_back_vertices.clear(); feed_back_vertices.clear();
AdjacencyList_type G(G1); AdjacencyList_t G(G1);
while (num_vertices(G) > 0) while (num_vertices(G) > 0)
{ {
while (something_has_been_done && num_vertices(G) > 0) while (something_has_been_done && num_vertices(G) > 0)
@ -411,7 +411,7 @@ namespace MFS
{ {
/*if nothing has been done in the five previous rule then cut the vertex with the maximum in_degree+out_degree*/ /*if nothing has been done in the five previous rule then cut the vertex with the maximum in_degree+out_degree*/
unsigned int max_degree = 0, num = 0; unsigned int max_degree = 0, num = 0;
AdjacencyList_type::vertex_iterator it, it_end, max_degree_index; AdjacencyList_t::vertex_iterator it, it_end, max_degree_index;
for (tie(it, it_end) = vertices(G); it != it_end; ++it, num++) for (tie(it, it_end) = vertices(G); it != it_end; ++it, num++)
{ {
if (in_degree(*it, G) + out_degree(*it, G) > max_degree) if (in_degree(*it, G) + out_degree(*it, G) > max_degree)
@ -420,14 +420,14 @@ namespace MFS
max_degree_index = it; max_degree_index = it;
} }
} }
property_map<AdjacencyList_type, vertex_index1_t>::type v_index1 = get(vertex_index1, G); property_map<AdjacencyList_t, vertex_index1_t>::type v_index1 = get(vertex_index1, G);
feed_back_vertices.insert(v_index1[*max_degree_index]); feed_back_vertices.insert(v_index1[*max_degree_index]);
/*property_map<AdjacencyList_type, vertex_index_t>::type v_index = get(vertex_index, G); /*property_map<AdjacencyList_t, vertex_index_t>::type v_index = get(vertex_index, G);
feed_back_vertices.insert(v_index[*max_degree_index]);*/ feed_back_vertices.insert(v_index[*max_degree_index]);*/
//cout << "v_index1[*max_degree_index] = " << v_index1[*max_degree_index] << "\n"; //cout << "v_index1[*max_degree_index] = " << v_index1[*max_degree_index] << "\n";
cut_++; cut_++;
#ifdef verbose #ifdef verbose
property_map<AdjacencyList_type, vertex_index_t>::type v_index = get(vertex_index, G); property_map<AdjacencyList_t, vertex_index_t>::type v_index = get(vertex_index, G);
cout << "--> cut vertex " << v_index[*max_degree_index] + 1 << "\n"; cout << "--> cut vertex " << v_index[*max_degree_index] + 1 << "\n";
#endif #endif
Suppress(*max_degree_index, G); Suppress(*max_degree_index, G);
@ -451,10 +451,10 @@ namespace MFS
}; };
void void
Reorder_the_recursive_variables(const AdjacencyList_type &G1, set<int> &feedback_vertices, vector< int> &Reordered_Vertices) Reorder_the_recursive_variables(const AdjacencyList_t &G1, set<int> &feedback_vertices, vector< int> &Reordered_Vertices)
{ {
AdjacencyList_type G(G1); AdjacencyList_t G(G1);
property_map<AdjacencyList_type, vertex_index_t>::type v_index = get(vertex_index, G); property_map<AdjacencyList_t, vertex_index_t>::type v_index = get(vertex_index, G);
set<int>::iterator its, ita; set<int>::iterator its, ita;
set<int, rev> fv; set<int, rev> fv;
for (its = feedback_vertices.begin(); its != feedback_vertices.end(); its++) for (its = feedback_vertices.begin(); its != feedback_vertices.end(); its++)
@ -466,7 +466,7 @@ namespace MFS
while (something_has_been_done) while (something_has_been_done)
{ {
something_has_been_done = false; something_has_been_done = false;
AdjacencyList_type::vertex_iterator it, it_end, ita; AdjacencyList_t::vertex_iterator it, it_end, ita;
for (tie(it, it_end) = vertices(G), i = 0; it != it_end; ++it, i++) for (tie(it, it_end) = vertices(G), i = 0; it != it_end; ++it, i++)
{ {
if (in_degree(*it, G) == 0) if (in_degree(*it, G) == 0)

View File

@ -34,46 +34,46 @@ namespace MFS
property<vertex_index1_t, int, property<vertex_index1_t, int,
property<vertex_degree_t, int, property<vertex_degree_t, int,
property<vertex_in_degree_t, int, property<vertex_in_degree_t, int,
property<vertex_out_degree_t, int > > > > > VertexProperty; property<vertex_out_degree_t, int > > > > > VertexProperty_t;
typedef adjacency_list<listS, listS, bidirectionalS, VertexProperty> AdjacencyList_type; typedef adjacency_list<listS, listS, bidirectionalS, VertexProperty_t> AdjacencyList_t;
typedef map<graph_traits<AdjacencyList_type>::vertex_descriptor, default_color_type> color_type; typedef map<graph_traits<AdjacencyList_t>::vertex_descriptor, default_color_type> color_t;
typedef vector<AdjacencyList_type::vertex_descriptor> vector_vertex_descriptor; typedef vector<AdjacencyList_t::vertex_descriptor> vector_vertex_descriptor_t;
//! Eliminate a vertex i //! Eliminate a vertex i
/*! For a vertex i replace all edges e_k_i and e_i_j by a shorcut e_k_j and then Suppress the vertex i*/ /*! For a vertex i replace all edges e_k_i and e_i_j by a shorcut e_k_j and then Suppress the vertex i*/
void Eliminate(AdjacencyList_type::vertex_descriptor vertex_to_eliminate, AdjacencyList_type &G); void Eliminate(AdjacencyList_t::vertex_descriptor vertex_to_eliminate, AdjacencyList_t &G);
//! Collect all doublets (edges e_i_k such that there is an edge e_k_i with k!=i in the graph) //! Collect all doublets (edges e_i_k such that there is an edge e_k_i with k!=i in the graph)
/*! Returns the vector of doublets */ /*! Returns the vector of doublets */
vector_vertex_descriptor Collect_Doublet(AdjacencyList_type::vertex_descriptor vertex, AdjacencyList_type &G); vector_vertex_descriptor_t Collect_Doublet(AdjacencyList_t::vertex_descriptor vertex, AdjacencyList_t &G);
//! Detect all the clique (all vertex in a clique are related to each other) in the graph //! Detect all the clique (all vertex in a clique are related to each other) in the graph
bool Vertex_Belong_to_a_Clique(AdjacencyList_type::vertex_descriptor vertex, AdjacencyList_type &G); bool Vertex_Belong_to_a_Clique(AdjacencyList_t::vertex_descriptor vertex, AdjacencyList_t &G);
//! Graph reduction: eliminating purely intermediate variables or variables outside of any circuit //! Graph reduction: eliminating purely intermediate variables or variables outside of any circuit
bool Elimination_of_Vertex_With_One_or_Less_Indegree_or_Outdegree_Step(AdjacencyList_type &G); bool Elimination_of_Vertex_With_One_or_Less_Indegree_or_Outdegree_Step(AdjacencyList_t &G);
//! Graph reduction: elimination of a vertex inside a clique //! Graph reduction: elimination of a vertex inside a clique
bool Elimination_of_Vertex_belonging_to_a_clique_Step(AdjacencyList_type &G); bool Elimination_of_Vertex_belonging_to_a_clique_Step(AdjacencyList_t &G);
//! A vertex belong to the feedback vertex set if the vertex loops on itself. //! A vertex belong to the feedback vertex set if the vertex loops on itself.
/*! We have to suppress this vertex and store it into the feedback set.*/ /*! We have to suppress this vertex and store it into the feedback set.*/
bool Suppression_of_Vertex_X_if_it_loops_store_in_set_of_feedback_vertex_Step(set<int> &feed_back_vertices, AdjacencyList_type &G1); bool Suppression_of_Vertex_X_if_it_loops_store_in_set_of_feedback_vertex_Step(set<int> &feed_back_vertices, AdjacencyList_t &G1);
//! Print the Graph //! Print the Graph
void Print(GraphvizDigraph &G); void Print(GraphvizDigraph &G);
void Print(AdjacencyList_type &G); void Print(AdjacencyList_t &G);
//! Create a GraphvizDigraph from a Adjacency Matrix (an incidence Matrix without the diagonal terms) //! Create a GraphvizDigraph from a Adjacency Matrix (an incidence Matrix without the diagonal terms)
GraphvizDigraph AM_2_GraphvizDigraph(bool *AM, unsigned int n); GraphvizDigraph AM_2_GraphvizDigraph(bool *AM, unsigned int n);
//! Create an adjacency graph from a Adjacency Matrix (an incidence Matrix without the diagonal terms) //! Create an adjacency graph from a Adjacency Matrix (an incidence Matrix without the diagonal terms)
AdjacencyList_type AM_2_AdjacencyList(bool *AMp, unsigned int n); AdjacencyList_t AM_2_AdjacencyList(bool *AMp, unsigned int n);
//! Create an adjacency graph from a GraphvizDigraph //! Create an adjacency graph from a GraphvizDigraph
AdjacencyList_type GraphvizDigraph_2_AdjacencyList(GraphvizDigraph &G1, set<int> select_index); AdjacencyList_t GraphvizDigraph_2_AdjacencyList(GraphvizDigraph &G1, set<int> select_index);
//! Check if the graph contains any cycle (true if the model contains at least one cycle, false otherwise) //! Check if the graph contains any cycle (true if the model contains at least one cycle, false otherwise)
bool has_cycle(vector<int> &circuit_stack, AdjacencyList_type &g); bool has_cycle(vector<int> &circuit_stack, AdjacencyList_t &g);
bool has_cycle_dfs(AdjacencyList_type &g, AdjacencyList_type::vertex_descriptor u, color_type &color, vector<int> &circuit_stack); bool has_cycle_dfs(AdjacencyList_t &g, AdjacencyList_t::vertex_descriptor u, color_t &color, vector<int> &circuit_stack);
//! Return the feedback set //! Return the feedback set
AdjacencyList_type Minimal_set_of_feedback_vertex(set<int> &feed_back_vertices, const AdjacencyList_type &G); AdjacencyList_t Minimal_set_of_feedback_vertex(set<int> &feed_back_vertices, const AdjacencyList_t &G);
//! Clear all in and out edges of vertex_to_eliminate and remove vertex_to_eliminate from the graph //! Clear all in and out edges of vertex_to_eliminate and remove vertex_to_eliminate from the graph
void Suppress(AdjacencyList_type::vertex_descriptor vertex_to_eliminate, AdjacencyList_type &G); void Suppress(AdjacencyList_t::vertex_descriptor vertex_to_eliminate, AdjacencyList_t &G);
void Suppress(int vertex_num, AdjacencyList_type &G); void Suppress(int vertex_num, AdjacencyList_t &G);
//! Reorder the recursive variables //! Reorder the recursive variables
/*! They appear first in a quasi triangular form and they are followed by the feedback variables */ /*! They appear first in a quasi triangular form and they are followed by the feedback variables */
void Reorder_the_recursive_variables(const AdjacencyList_type &G1, set<int> &feedback_vertices, vector< int> &Reordered_Vertices); void Reorder_the_recursive_variables(const AdjacencyList_t &G1, set<int> &feedback_vertices, vector< int> &Reordered_Vertices);
}; };
#endif // _MINIMUMFEEDBACKSET_HH #endif // _MINIMUMFEEDBACKSET_HH

View File

@ -71,7 +71,7 @@ public:
//! Global evaluation context //! Global evaluation context
/*! Filled using initval blocks and parameters initializations */ /*! Filled using initval blocks and parameters initializations */
eval_context_type global_eval_context; eval_context_t global_eval_context;
private: private:
//! List of statements //! List of statements

View File

@ -34,7 +34,7 @@ using namespace boost;
using namespace MFS; using namespace MFS;
bool bool
ModelTree::computeNormalization(const jacob_map &contemporaneous_jacobian, bool verbose) ModelTree::computeNormalization(const jacob_map_t &contemporaneous_jacobian, bool verbose)
{ {
const int n = equation_number(); const int n = equation_number();
@ -51,7 +51,7 @@ ModelTree::computeNormalization(const jacob_map &contemporaneous_jacobian, bool
// Fill in the graph // Fill in the graph
set<pair<int, int> > endo; set<pair<int, int> > endo;
for (jacob_map::const_iterator it = contemporaneous_jacobian.begin(); it != contemporaneous_jacobian.end(); it++) for (jacob_map_t::const_iterator it = contemporaneous_jacobian.begin(); it != contemporaneous_jacobian.end(); it++)
add_edge(it->first.first + n, it->first.second, g); add_edge(it->first.first + n, it->first.second, g);
// Compute maximum cardinality matching // Compute maximum cardinality matching
@ -137,7 +137,7 @@ ModelTree::computeNormalization(const jacob_map &contemporaneous_jacobian, bool
} }
void void
ModelTree::computeNonSingularNormalization(jacob_map &contemporaneous_jacobian, double cutoff, jacob_map &static_jacobian, dynamic_jacob_map &dynamic_jacobian) ModelTree::computeNonSingularNormalization(jacob_map_t &contemporaneous_jacobian, double cutoff, jacob_map_t &static_jacobian, dynamic_jacob_map_t &dynamic_jacobian)
{ {
bool check = false; bool check = false;
@ -147,13 +147,13 @@ ModelTree::computeNonSingularNormalization(jacob_map &contemporaneous_jacobian,
// compute the maximum value of each row of the contemporaneous Jacobian matrix // compute the maximum value of each row of the contemporaneous Jacobian matrix
//jacob_map normalized_contemporaneous_jacobian; //jacob_map normalized_contemporaneous_jacobian;
jacob_map normalized_contemporaneous_jacobian(contemporaneous_jacobian); jacob_map_t normalized_contemporaneous_jacobian(contemporaneous_jacobian);
vector<double> max_val(n, 0.0); vector<double> max_val(n, 0.0);
for (jacob_map::const_iterator iter = contemporaneous_jacobian.begin(); iter != contemporaneous_jacobian.end(); iter++) for (jacob_map_t::const_iterator iter = contemporaneous_jacobian.begin(); iter != contemporaneous_jacobian.end(); iter++)
if (fabs(iter->second) > max_val[iter->first.first]) if (fabs(iter->second) > max_val[iter->first.first])
max_val[iter->first.first] = fabs(iter->second); max_val[iter->first.first] = fabs(iter->second);
for (jacob_map::iterator iter = normalized_contemporaneous_jacobian.begin(); iter != normalized_contemporaneous_jacobian.end(); iter++) for (jacob_map_t::iterator iter = normalized_contemporaneous_jacobian.begin(); iter != normalized_contemporaneous_jacobian.end(); iter++)
iter->second /= max_val[iter->first.first]; iter->second /= max_val[iter->first.first];
//We start with the highest value of the cutoff and try to normalize the model //We start with the highest value of the cutoff and try to normalize the model
@ -162,9 +162,9 @@ ModelTree::computeNonSingularNormalization(jacob_map &contemporaneous_jacobian,
int suppressed = 0; int suppressed = 0;
while (!check && current_cutoff > 1e-19) while (!check && current_cutoff > 1e-19)
{ {
jacob_map tmp_normalized_contemporaneous_jacobian; jacob_map_t tmp_normalized_contemporaneous_jacobian;
int suppress = 0; int suppress = 0;
for (jacob_map::iterator iter = normalized_contemporaneous_jacobian.begin(); iter != normalized_contemporaneous_jacobian.end(); iter++) for (jacob_map_t::iterator iter = normalized_contemporaneous_jacobian.begin(); iter != normalized_contemporaneous_jacobian.end(); iter++)
if (fabs(iter->second) > max(current_cutoff, cutoff)) if (fabs(iter->second) > max(current_cutoff, cutoff))
tmp_normalized_contemporaneous_jacobian[make_pair(iter->first.first, iter->first.second)] = iter->second; tmp_normalized_contemporaneous_jacobian[make_pair(iter->first.first, iter->first.second)] = iter->second;
else else
@ -186,7 +186,7 @@ ModelTree::computeNonSingularNormalization(jacob_map &contemporaneous_jacobian,
{ {
cout << "Normalization failed with cutoff, trying symbolic normalization..." << endl; cout << "Normalization failed with cutoff, trying symbolic normalization..." << endl;
//if no non-singular normalization can be found, try to find a normalization even with a potential singularity //if no non-singular normalization can be found, try to find a normalization even with a potential singularity
jacob_map tmp_normalized_contemporaneous_jacobian; jacob_map_t tmp_normalized_contemporaneous_jacobian;
set<pair<int, int> > endo; set<pair<int, int> > endo;
for (int i = 0; i < n; i++) for (int i = 0; i < n; i++)
{ {
@ -199,7 +199,7 @@ ModelTree::computeNonSingularNormalization(jacob_map &contemporaneous_jacobian,
if (check) if (check)
{ {
// Update the jacobian matrix // Update the jacobian matrix
for (jacob_map::const_iterator it = tmp_normalized_contemporaneous_jacobian.begin(); it != tmp_normalized_contemporaneous_jacobian.end(); it++) for (jacob_map_t::const_iterator it = tmp_normalized_contemporaneous_jacobian.begin(); it != tmp_normalized_contemporaneous_jacobian.end(); it++)
{ {
if (static_jacobian.find(make_pair(it->first.first, it->first.second)) == static_jacobian.end()) if (static_jacobian.find(make_pair(it->first.first, it->first.second)) == static_jacobian.end())
static_jacobian[make_pair(it->first.first, it->first.second)] = 0; static_jacobian[make_pair(it->first.first, it->first.second)] = 0;
@ -242,11 +242,11 @@ ModelTree::computeNormalizedEquations(multimap<int, int> &endo2eqs) const
} }
void void
ModelTree::evaluateAndReduceJacobian(const eval_context_type &eval_context, jacob_map &contemporaneous_jacobian, jacob_map &static_jacobian, dynamic_jacob_map &dynamic_jacobian, double cutoff, bool verbose) ModelTree::evaluateAndReduceJacobian(const eval_context_t &eval_context, jacob_map_t &contemporaneous_jacobian, jacob_map_t &static_jacobian, dynamic_jacob_map_t &dynamic_jacobian, double cutoff, bool verbose)
{ {
int nb_elements_contemparenous_Jacobian = 0; int nb_elements_contemparenous_Jacobian = 0;
set<pair<int, int> > jacobian_elements_to_delete; set<pair<int, int> > jacobian_elements_to_delete;
for (first_derivatives_type::const_iterator it = first_derivatives.begin(); for (first_derivatives_t::const_iterator it = first_derivatives.begin();
it != first_derivatives.end(); it++) it != first_derivatives.end(); it++)
{ {
int deriv_id = it->first.second; int deriv_id = it->first.second;
@ -304,7 +304,7 @@ ModelTree::evaluateAndReduceJacobian(const eval_context_type &eval_context, jaco
} }
void void
ModelTree::computePrologueAndEpilogue(const jacob_map &static_jacobian_arg, vector<int> &equation_reordered, vector<int> &variable_reordered) ModelTree::computePrologueAndEpilogue(const jacob_map_t &static_jacobian_arg, vector<int> &equation_reordered, vector<int> &variable_reordered)
{ {
vector<int> eq2endo(equation_number(), 0); vector<int> eq2endo(equation_number(), 0);
equation_reordered.resize(equation_number()); equation_reordered.resize(equation_number());
@ -319,7 +319,7 @@ ModelTree::computePrologueAndEpilogue(const jacob_map &static_jacobian_arg, vect
equation_reordered[i] = i; equation_reordered[i] = i;
variable_reordered[*it] = i; variable_reordered[*it] = i;
} }
for (jacob_map::const_iterator it = static_jacobian_arg.begin(); it != static_jacobian_arg.end(); it++) for (jacob_map_t::const_iterator it = static_jacobian_arg.begin(); it != static_jacobian_arg.end(); it++)
IM[it->first.first * n + endo2eq[it->first.second]] = true; IM[it->first.first * n + endo2eq[it->first.second]] = true;
bool something_has_been_done = true; bool something_has_been_done = true;
prologue = 0; prologue = 0;
@ -410,13 +410,13 @@ ModelTree::computePrologueAndEpilogue(const jacob_map &static_jacobian_arg, vect
free(IM); free(IM);
} }
t_equation_type_and_normalized_equation equation_type_and_normalized_equation_t
ModelTree::equationTypeDetermination(const map<pair<int, pair<int, int> >, NodeID> &first_order_endo_derivatives, const vector<int> &Index_Var_IM, const vector<int> &Index_Equ_IM, int mfs) const ModelTree::equationTypeDetermination(const map<pair<int, pair<int, int> >, NodeID> &first_order_endo_derivatives, const vector<int> &Index_Var_IM, const vector<int> &Index_Equ_IM, int mfs) const
{ {
NodeID lhs, rhs; NodeID lhs, rhs;
BinaryOpNode *eq_node; BinaryOpNode *eq_node;
EquationType Equation_Simulation_Type; EquationType Equation_Simulation_Type;
t_equation_type_and_normalized_equation V_Equation_Simulation_Type(equations.size()); equation_type_and_normalized_equation_t V_Equation_Simulation_Type(equations.size());
for (unsigned int i = 0; i < equations.size(); i++) for (unsigned int i = 0; i < equations.size(); i++)
{ {
int eq = Index_Equ_IM[i]; int eq = Index_Equ_IM[i];
@ -459,11 +459,11 @@ ModelTree::equationTypeDetermination(const map<pair<int, pair<int, int> >, NodeI
} }
void void
ModelTree::getVariableLeadLagByBlock(const dynamic_jacob_map &dynamic_jacobian, const vector<int> &components_set, int nb_blck_sim, t_lag_lead_vector &equation_lead_lag, t_lag_lead_vector &variable_lead_lag, const vector<int> &equation_reordered, const vector<int> &variable_reordered) const ModelTree::getVariableLeadLagByBlock(const dynamic_jacob_map_t &dynamic_jacobian, const vector<int> &components_set, int nb_blck_sim, lag_lead_vector_t &equation_lead_lag, lag_lead_vector_t &variable_lead_lag, const vector<int> &equation_reordered, const vector<int> &variable_reordered) const
{ {
int nb_endo = symbol_table.endo_nbr(); int nb_endo = symbol_table.endo_nbr();
variable_lead_lag = t_lag_lead_vector(nb_endo, make_pair(0, 0)); variable_lead_lag = lag_lead_vector_t(nb_endo, make_pair(0, 0));
equation_lead_lag = t_lag_lead_vector(nb_endo, make_pair(0, 0)); equation_lead_lag = lag_lead_vector_t(nb_endo, make_pair(0, 0));
vector<int> variable_blck(nb_endo), equation_blck(nb_endo); vector<int> variable_blck(nb_endo), equation_blck(nb_endo);
for (int i = 0; i < nb_endo; i++) for (int i = 0; i < nb_endo; i++)
{ {
@ -483,7 +483,7 @@ ModelTree::getVariableLeadLagByBlock(const dynamic_jacob_map &dynamic_jacobian,
equation_blck[equation_reordered[i]] = i- (nb_endo - nb_blck_sim - prologue - epilogue); equation_blck[equation_reordered[i]] = i- (nb_endo - nb_blck_sim - prologue - epilogue);
} }
} }
for (dynamic_jacob_map::const_iterator it = dynamic_jacobian.begin(); it != dynamic_jacobian.end(); it++) for (dynamic_jacob_map_t::const_iterator it = dynamic_jacobian.begin(); it != dynamic_jacobian.end(); it++)
{ {
int lag = it->first.first; int lag = it->first.first;
int j_1 = it->first.second.second; int j_1 = it->first.second.second;
@ -503,7 +503,7 @@ ModelTree::getVariableLeadLagByBlock(const dynamic_jacob_map &dynamic_jacobian,
} }
void void
ModelTree::computeBlockDecompositionAndFeedbackVariablesForEachBlock(const jacob_map &static_jacobian, const dynamic_jacob_map &dynamic_jacobian, vector<int> &equation_reordered, vector<int> &variable_reordered, vector<pair<int, int> > &blocks, const t_equation_type_and_normalized_equation &Equation_Type, bool verbose_, bool select_feedback_variable, int mfs, vector<int> &inv_equation_reordered, vector<int> &inv_variable_reordered) const ModelTree::computeBlockDecompositionAndFeedbackVariablesForEachBlock(const jacob_map_t &static_jacobian, const dynamic_jacob_map_t &dynamic_jacobian, vector<int> &equation_reordered, vector<int> &variable_reordered, vector<pair<int, int> > &blocks, const equation_type_and_normalized_equation_t &Equation_Type, bool verbose_, bool select_feedback_variable, int mfs, vector<int> &inv_equation_reordered, vector<int> &inv_variable_reordered) const
{ {
int nb_var = variable_reordered.size(); int nb_var = variable_reordered.size();
int n = nb_var - prologue - epilogue; int n = nb_var - prologue - epilogue;
@ -519,7 +519,7 @@ ModelTree::computeBlockDecompositionAndFeedbackVariablesForEachBlock(const jacob
reverse_variable_reordered[variable_reordered[i]] = i; reverse_variable_reordered[variable_reordered[i]] = i;
} }
for (jacob_map::const_iterator it = static_jacobian.begin(); it != static_jacobian.end(); it++) for (jacob_map_t::const_iterator it = static_jacobian.begin(); it != static_jacobian.end(); it++)
if (reverse_equation_reordered[it->first.first] >= prologue && reverse_equation_reordered[it->first.first] < nb_var - epilogue if (reverse_equation_reordered[it->first.first] >= prologue && reverse_equation_reordered[it->first.first] < nb_var - epilogue
&& reverse_variable_reordered[it->first.second] >= prologue && reverse_variable_reordered[it->first.second] < nb_var - epilogue && reverse_variable_reordered[it->first.second] >= prologue && reverse_variable_reordered[it->first.second] < nb_var - epilogue
&& it->first.first != endo2eq[it->first.second]) && it->first.first != endo2eq[it->first.second])
@ -570,7 +570,7 @@ ModelTree::computeBlockDecompositionAndFeedbackVariablesForEachBlock(const jacob
components_set[endo2block[i]].first.insert(i); components_set[endo2block[i]].first.insert(i);
} }
t_lag_lead_vector equation_lag_lead, variable_lag_lead; lag_lead_vector_t equation_lag_lead, variable_lag_lead;
getVariableLeadLagByBlock(dynamic_jacobian, endo2block, num, equation_lag_lead, variable_lag_lead, equation_reordered, variable_reordered); getVariableLeadLagByBlock(dynamic_jacobian, endo2block, num, equation_lag_lead, variable_lag_lead, equation_reordered, variable_reordered);
@ -600,11 +600,11 @@ ModelTree::computeBlockDecompositionAndFeedbackVariablesForEachBlock(const jacob
for (int i = 0; i < num; i++) for (int i = 0; i < num; i++)
{ {
AdjacencyList_type G = GraphvizDigraph_2_AdjacencyList(G2, components_set[i].first); AdjacencyList_t G = GraphvizDigraph_2_AdjacencyList(G2, components_set[i].first);
set<int> feed_back_vertices; set<int> feed_back_vertices;
//Print(G); //Print(G);
AdjacencyList_type G1 = Minimal_set_of_feedback_vertex(feed_back_vertices, G); AdjacencyList_t G1 = Minimal_set_of_feedback_vertex(feed_back_vertices, G);
property_map<AdjacencyList_type, vertex_index_t>::type v_index = get(vertex_index, G); property_map<AdjacencyList_t, vertex_index_t>::type v_index = get(vertex_index, G);
components_set[i].second.first = feed_back_vertices; components_set[i].second.first = feed_back_vertices;
blocks[i].second = feed_back_vertices.size(); blocks[i].second = feed_back_vertices.size();
vector<int> Reordered_Vertice; vector<int> Reordered_Vertice;
@ -664,14 +664,14 @@ ModelTree::printBlockDecomposition(const vector<pair<int, int> > &blocks) const
<< " and " << Nb_feedback_variable << " feedback variable(s)." << endl; << " and " << Nb_feedback_variable << " feedback variable(s)." << endl;
} }
t_block_type_firstequation_size_mfs block_type_firstequation_size_mfs_t
ModelTree::reduceBlocksAndTypeDetermination(const dynamic_jacob_map &dynamic_jacobian, const vector<pair<int, int> > &blocks, const t_equation_type_and_normalized_equation &Equation_Type, const vector<int> &variable_reordered, const vector<int> &equation_reordered) ModelTree::reduceBlocksAndTypeDetermination(const dynamic_jacob_map_t &dynamic_jacobian, const vector<pair<int, int> > &blocks, const equation_type_and_normalized_equation_t &Equation_Type, const vector<int> &variable_reordered, const vector<int> &equation_reordered)
{ {
int i = 0; int i = 0;
int count_equ = 0, blck_count_simult = 0; int count_equ = 0, blck_count_simult = 0;
int Blck_Size, MFS_Size; int Blck_Size, MFS_Size;
int Lead, Lag; int Lead, Lag;
t_block_type_firstequation_size_mfs block_type_size_mfs; block_type_firstequation_size_mfs_t block_type_size_mfs;
BlockSimulationType Simulation_Type, prev_Type = UNKNOWN; BlockSimulationType Simulation_Type, prev_Type = UNKNOWN;
int eq = 0; int eq = 0;
for (i = 0; i < prologue+(int) blocks.size()+epilogue; i++) for (i = 0; i < prologue+(int) blocks.size()+epilogue; i++)
@ -785,7 +785,7 @@ ModelTree::reduceBlocksAndTypeDetermination(const dynamic_jacob_map &dynamic_jac
} }
vector<bool> vector<bool>
ModelTree::BlockLinear(const t_blocks_derivatives &blocks_derivatives, const vector<int> &variable_reordered) const ModelTree::BlockLinear(const blocks_derivatives_t &blocks_derivatives, const vector<int> &variable_reordered) const
{ {
unsigned int nb_blocks = getNbBlocks(); unsigned int nb_blocks = getNbBlocks();
vector<bool> blocks_linear(nb_blocks, true); vector<bool> blocks_linear(nb_blocks, true);
@ -793,11 +793,11 @@ ModelTree::BlockLinear(const t_blocks_derivatives &blocks_derivatives, const vec
{ {
BlockSimulationType simulation_type = getBlockSimulationType(block); BlockSimulationType simulation_type = getBlockSimulationType(block);
int block_size = getBlockSize(block); int block_size = getBlockSize(block);
t_block_derivatives_equation_variable_laglead_nodeid derivatives_block = blocks_derivatives[block]; block_derivatives_equation_variable_laglead_nodeid_t derivatives_block = blocks_derivatives[block];
int first_variable_position = getBlockFirstEquation(block); int first_variable_position = getBlockFirstEquation(block);
if (simulation_type == SOLVE_BACKWARD_COMPLETE || simulation_type == SOLVE_FORWARD_COMPLETE) if (simulation_type == SOLVE_BACKWARD_COMPLETE || simulation_type == SOLVE_FORWARD_COMPLETE)
{ {
for (t_block_derivatives_equation_variable_laglead_nodeid::const_iterator it = derivatives_block.begin(); it != derivatives_block.end(); it++) for (block_derivatives_equation_variable_laglead_nodeid_t::const_iterator it = derivatives_block.begin(); it != derivatives_block.end(); it++)
{ {
int lag = it->second.first; int lag = it->second.first;
if (lag == 0) if (lag == 0)
@ -821,7 +821,7 @@ ModelTree::BlockLinear(const t_blocks_derivatives &blocks_derivatives, const vec
} }
else if (simulation_type == SOLVE_TWO_BOUNDARIES_COMPLETE || simulation_type == SOLVE_TWO_BOUNDARIES_SIMPLE) else if (simulation_type == SOLVE_TWO_BOUNDARIES_COMPLETE || simulation_type == SOLVE_TWO_BOUNDARIES_SIMPLE)
{ {
for (t_block_derivatives_equation_variable_laglead_nodeid::const_iterator it = derivatives_block.begin(); it != derivatives_block.end(); it++) for (block_derivatives_equation_variable_laglead_nodeid_t::const_iterator it = derivatives_block.begin(); it != derivatives_block.end(); it++)
{ {
int lag = it->second.first; int lag = it->second.first;
NodeID Id = it->second.second; // NodeID Id = it->second.second; //
@ -864,9 +864,9 @@ ModelTree::equation_number() const
void void
ModelTree::writeDerivative(ostream &output, int eq, int symb_id, int lag, ModelTree::writeDerivative(ostream &output, int eq, int symb_id, int lag,
ExprNodeOutputType output_type, ExprNodeOutputType output_type,
const temporary_terms_type &temporary_terms) const const temporary_terms_t &temporary_terms) const
{ {
first_derivatives_type::const_iterator it = first_derivatives.find(make_pair(eq, getDerivID(symb_id, lag))); first_derivatives_t::const_iterator it = first_derivatives.find(make_pair(eq, getDerivID(symb_id, lag)));
if (it != first_derivatives.end()) if (it != first_derivatives.end())
(it->second)->writeOutput(output, output_type, temporary_terms); (it->second)->writeOutput(output, output_type, temporary_terms);
else else
@ -891,7 +891,7 @@ ModelTree::computeJacobian(const set<int> &vars)
void void
ModelTree::computeHessian(const set<int> &vars) ModelTree::computeHessian(const set<int> &vars)
{ {
for (first_derivatives_type::const_iterator it = first_derivatives.begin(); for (first_derivatives_t::const_iterator it = first_derivatives.begin();
it != first_derivatives.end(); it++) it != first_derivatives.end(); it++)
{ {
int eq = it->first.first; int eq = it->first.first;
@ -921,7 +921,7 @@ ModelTree::computeHessian(const set<int> &vars)
void void
ModelTree::computeThirdDerivatives(const set<int> &vars) ModelTree::computeThirdDerivatives(const set<int> &vars)
{ {
for (second_derivatives_type::const_iterator it = second_derivatives.begin(); for (second_derivatives_t::const_iterator it = second_derivatives.begin();
it != second_derivatives.end(); it++) it != second_derivatives.end(); it++)
{ {
int eq = it->first.first; int eq = it->first.first;
@ -964,33 +964,33 @@ ModelTree::computeTemporaryTerms(bool is_matlab)
it != equations.end(); it++) it != equations.end(); it++)
(*it)->computeTemporaryTerms(reference_count, temporary_terms, is_matlab); (*it)->computeTemporaryTerms(reference_count, temporary_terms, is_matlab);
for (first_derivatives_type::iterator it = first_derivatives.begin(); for (first_derivatives_t::iterator it = first_derivatives.begin();
it != first_derivatives.end(); it++) it != first_derivatives.end(); it++)
it->second->computeTemporaryTerms(reference_count, temporary_terms, is_matlab); it->second->computeTemporaryTerms(reference_count, temporary_terms, is_matlab);
for (second_derivatives_type::iterator it = second_derivatives.begin(); for (second_derivatives_t::iterator it = second_derivatives.begin();
it != second_derivatives.end(); it++) it != second_derivatives.end(); it++)
it->second->computeTemporaryTerms(reference_count, temporary_terms, is_matlab); it->second->computeTemporaryTerms(reference_count, temporary_terms, is_matlab);
for (third_derivatives_type::iterator it = third_derivatives.begin(); for (third_derivatives_t::iterator it = third_derivatives.begin();
it != third_derivatives.end(); it++) it != third_derivatives.end(); it++)
it->second->computeTemporaryTerms(reference_count, temporary_terms, is_matlab); it->second->computeTemporaryTerms(reference_count, temporary_terms, is_matlab);
} }
void void
ModelTree::writeTemporaryTerms(const temporary_terms_type &tt, ostream &output, ModelTree::writeTemporaryTerms(const temporary_terms_t &tt, ostream &output,
ExprNodeOutputType output_type) const ExprNodeOutputType output_type) const
{ {
// Local var used to keep track of temp nodes already written // Local var used to keep track of temp nodes already written
temporary_terms_type tt2; temporary_terms_t tt2;
// To store the functions that have already been written in the form TEF* = ext_fun(); // To store the functions that have already been written in the form TEF* = ext_fun();
deriv_node_temp_terms_type tef_terms; deriv_node_temp_terms_t tef_terms;
if (tt.size() > 0 && (IS_C(output_type))) if (tt.size() > 0 && (IS_C(output_type)))
output << "double" << endl; output << "double" << endl;
for (temporary_terms_type::const_iterator it = tt.begin(); for (temporary_terms_t::const_iterator it = tt.begin();
it != tt.end(); it++) it != tt.end(); it++)
{ {
if (IS_C(output_type) && it != tt.begin()) if (IS_C(output_type) && it != tt.begin())
@ -1015,11 +1015,11 @@ ModelTree::writeTemporaryTerms(const temporary_terms_type &tt, ostream &output,
} }
void void
ModelTree::compileTemporaryTerms(ostream &code_file, const temporary_terms_type &tt, map_idx_type map_idx, bool dynamic, bool steady_dynamic) const ModelTree::compileTemporaryTerms(ostream &code_file, const temporary_terms_t &tt, map_idx_t map_idx, bool dynamic, bool steady_dynamic) const
{ {
// Local var used to keep track of temp nodes already written // Local var used to keep track of temp nodes already written
temporary_terms_type tt2; temporary_terms_t tt2;
for (temporary_terms_type::const_iterator it = tt.begin(); for (temporary_terms_t::const_iterator it = tt.begin();
it != tt.end(); it++) it != tt.end(); it++)
{ {
FNUMEXPR_ fnumexpr(TemporaryTerm, (int)(map_idx.find((*it)->idx)->second)); FNUMEXPR_ fnumexpr(TemporaryTerm, (int)(map_idx.find((*it)->idx)->second));
@ -1074,7 +1074,7 @@ ModelTree::writeModelEquations(ostream &output, ExprNodeOutputType output_type)
double vrhs = 1.0; double vrhs = 1.0;
try try
{ {
vrhs = rhs->eval(eval_context_type()); vrhs = rhs->eval(eval_context_t());
} }
catch (ExprNode::EvalException &e) catch (ExprNode::EvalException &e)
{ {
@ -1108,7 +1108,7 @@ ModelTree::writeModelEquations(ostream &output, ExprNodeOutputType output_type)
} }
void void
ModelTree::compileModelEquations(ostream &code_file, const temporary_terms_type &tt, const map_idx_type &map_idx, bool dynamic, bool steady_dynamic) const ModelTree::compileModelEquations(ostream &code_file, const temporary_terms_t &tt, const map_idx_t &map_idx, bool dynamic, bool steady_dynamic) const
{ {
for (int eq = 0; eq < (int) equations.size(); eq++) for (int eq = 0; eq < (int) equations.size(); eq++)
{ {
@ -1121,7 +1121,7 @@ ModelTree::compileModelEquations(ostream &code_file, const temporary_terms_type
double vrhs = 1.0; double vrhs = 1.0;
try try
{ {
vrhs = rhs->eval(eval_context_type()); vrhs = rhs->eval(eval_context_t());
} }
catch (ExprNode::EvalException &e) catch (ExprNode::EvalException &e)
{ {
@ -1164,7 +1164,7 @@ ModelTree::Write_Inf_To_Bin_File(const string &basename,
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
u_count_int = 0; u_count_int = 0;
for (first_derivatives_type::const_iterator it = first_derivatives.begin();it != first_derivatives.end(); it++) for (first_derivatives_t::const_iterator it = first_derivatives.begin();it != first_derivatives.end(); it++)
{ {
int deriv_id = it->first.second; int deriv_id = it->first.second;
if (getTypeByDerivID(deriv_id) == eEndogenous) if (getTypeByDerivID(deriv_id) == eEndogenous)

View File

@ -31,19 +31,19 @@ using namespace std;
#include "DataTree.hh" #include "DataTree.hh"
//! Vector describing equations: BlockSimulationType, if BlockSimulationType == EVALUATE_s then a NodeID on the new normalized equation //! Vector describing equations: BlockSimulationType, if BlockSimulationType == EVALUATE_s then a NodeID on the new normalized equation
typedef vector<pair<EquationType, NodeID > > t_equation_type_and_normalized_equation; typedef vector<pair<EquationType, NodeID > > equation_type_and_normalized_equation_t;
//! Vector describing variables: max_lag in the block, max_lead in the block //! Vector describing variables: max_lag in the block, max_lead in the block
typedef vector<pair< int, int> > t_lag_lead_vector; typedef vector<pair< int, int> > lag_lead_vector_t;
//! for each block contains pair< pair<Simulation_Type, first_equation>, pair < Block_Size, Recursive_part_Size > > //! for each block contains pair< pair<Simulation_Type, first_equation>, pair < Block_Size, Recursive_part_Size > >
typedef vector<pair< pair< BlockSimulationType, int>, pair<int, int> > > t_block_type_firstequation_size_mfs; typedef vector<pair< pair< BlockSimulationType, int>, pair<int, int> > > block_type_firstequation_size_mfs_t;
//! for a block contains derivatives pair< pair<block_equation_number, block_variable_number> , pair<lead_lag, NodeID> > //! for a block contains derivatives pair< pair<block_equation_number, block_variable_number> , pair<lead_lag, NodeID> >
typedef vector< pair<pair<int, int>, pair< int, NodeID > > > t_block_derivatives_equation_variable_laglead_nodeid; typedef vector< pair<pair<int, int>, pair< int, NodeID > > > block_derivatives_equation_variable_laglead_nodeid_t;
//! for all blocks derivatives description //! for all blocks derivatives description
typedef vector<t_block_derivatives_equation_variable_laglead_nodeid> t_blocks_derivatives; typedef vector<block_derivatives_equation_variable_laglead_nodeid_t> blocks_derivatives_t;
//! Shared code for static and dynamic models //! Shared code for static and dynamic models
class ModelTree : public DataTree class ModelTree : public DataTree
@ -64,34 +64,34 @@ protected:
//! Number of non-zero derivatives //! Number of non-zero derivatives
int NNZDerivatives[3]; int NNZDerivatives[3];
typedef map<pair<int, int>, NodeID> first_derivatives_type; typedef map<pair<int, int>, NodeID> first_derivatives_t;
//! First order derivatives //! First order derivatives
/*! First index is equation number, second is variable w.r. to which is computed the derivative. /*! First index is equation number, second is variable w.r. to which is computed the derivative.
Only non-null derivatives are stored in the map. Only non-null derivatives are stored in the map.
Variable indices are those of the getDerivID() method. Variable indices are those of the getDerivID() method.
*/ */
first_derivatives_type first_derivatives; first_derivatives_t first_derivatives;
typedef map<pair<int, pair<int, int> >, NodeID> second_derivatives_type; typedef map<pair<int, pair<int, int> >, NodeID> second_derivatives_t;
//! Second order derivatives //! Second order derivatives
/*! First index is equation number, second and third are variables w.r. to which is computed the derivative. /*! First index is equation number, second and third are variables w.r. to which is computed the derivative.
Only non-null derivatives are stored in the map. Only non-null derivatives are stored in the map.
Contains only second order derivatives where var1 >= var2 (for obvious symmetry reasons). Contains only second order derivatives where var1 >= var2 (for obvious symmetry reasons).
Variable indices are those of the getDerivID() method. Variable indices are those of the getDerivID() method.
*/ */
second_derivatives_type second_derivatives; second_derivatives_t second_derivatives;
typedef map<pair<int, pair<int, pair<int, int> > >, NodeID> third_derivatives_type; typedef map<pair<int, pair<int, pair<int, int> > >, NodeID> third_derivatives_t;
//! Third order derivatives //! Third order derivatives
/*! First index is equation number, second, third and fourth are variables w.r. to which is computed the derivative. /*! First index is equation number, second, third and fourth are variables w.r. to which is computed the derivative.
Only non-null derivatives are stored in the map. Only non-null derivatives are stored in the map.
Contains only third order derivatives where var1 >= var2 >= var3 (for obvious symmetry reasons). Contains only third order derivatives where var1 >= var2 >= var3 (for obvious symmetry reasons).
Variable indices are those of the getDerivID() method. Variable indices are those of the getDerivID() method.
*/ */
third_derivatives_type third_derivatives; third_derivatives_t third_derivatives;
//! Temporary terms (those which will be noted Txxxx) //! Temporary terms (those which will be noted Txxxx)
temporary_terms_type temporary_terms; temporary_terms_t temporary_terms;
//! Computes 1st derivatives //! Computes 1st derivatives
/*! \param vars the derivation IDs w.r. to which compute the derivatives */ /*! \param vars the derivation IDs w.r. to which compute the derivatives */
@ -104,13 +104,13 @@ protected:
void computeThirdDerivatives(const set<int> &vars); void computeThirdDerivatives(const set<int> &vars);
//! Write derivative of an equation w.r. to a variable //! Write derivative of an equation w.r. to a variable
void writeDerivative(ostream &output, int eq, int symb_id, int lag, ExprNodeOutputType output_type, const temporary_terms_type &temporary_terms) const; void writeDerivative(ostream &output, int eq, int symb_id, int lag, ExprNodeOutputType output_type, const temporary_terms_t &temporary_terms) const;
//! Computes temporary terms (for all equations and derivatives) //! Computes temporary terms (for all equations and derivatives)
void computeTemporaryTerms(bool is_matlab); void computeTemporaryTerms(bool is_matlab);
//! Writes temporary terms //! Writes temporary terms
void writeTemporaryTerms(const temporary_terms_type &tt, ostream &output, ExprNodeOutputType output_type) const; void writeTemporaryTerms(const temporary_terms_t &tt, ostream &output, ExprNodeOutputType output_type) const;
//! Compiles temporary terms //! Compiles temporary terms
void compileTemporaryTerms(ostream &code_file, const temporary_terms_type &tt, map_idx_type map_idx, bool dynamic, bool steady_dynamic) const; void compileTemporaryTerms(ostream &code_file, const temporary_terms_t &tt, map_idx_t map_idx, bool dynamic, bool steady_dynamic) const;
//! Adds informations for simulation in a binary file //! Adds informations for simulation in a binary file
void Write_Inf_To_Bin_File(const string &basename, int &u_count_int, bool &file_open, bool is_two_boundaries, int block_mfs) const; void Write_Inf_To_Bin_File(const string &basename, int &u_count_int, bool &file_open, bool is_two_boundaries, int block_mfs) const;
@ -120,18 +120,18 @@ protected:
//! Writes model equations //! Writes model equations
void writeModelEquations(ostream &output, ExprNodeOutputType output_type) const; void writeModelEquations(ostream &output, ExprNodeOutputType output_type) const;
//! Compiles model equations //! Compiles model equations
void compileModelEquations(ostream &code_file, const temporary_terms_type &tt, const map_idx_type &map_idx, bool dynamic, bool steady_dynamic) const; void compileModelEquations(ostream &code_file, const temporary_terms_t &tt, const map_idx_t &map_idx, bool dynamic, bool steady_dynamic) const;
//! Writes LaTeX model file //! Writes LaTeX model file
void writeLatexModelFile(const string &filename, ExprNodeOutputType output_type) const; void writeLatexModelFile(const string &filename, ExprNodeOutputType output_type) const;
//! Sparse matrix of double to store the values of the Jacobian //! Sparse matrix of double to store the values of the Jacobian
/*! First index is equation number, second index is endogenous type specific ID */ /*! First index is equation number, second index is endogenous type specific ID */
typedef map<pair<int, int>, double> jacob_map; typedef map<pair<int, int>, double> jacob_map_t;
//! Sparse matrix of double to store the values of the Jacobian //! Sparse matrix of double to store the values of the Jacobian
/*! First index is lag, second index is equation number, third index is endogenous type specific ID */ /*! First index is lag, second index is equation number, third index is endogenous type specific ID */
typedef map<pair<int, pair<int, int> >, NodeID> dynamic_jacob_map; typedef map<pair<int, pair<int, int> >, NodeID> dynamic_jacob_map_t;
//! Normalization of equations //! Normalization of equations
/*! Maps endogenous type specific IDs to equation numbers */ /*! Maps endogenous type specific IDs to equation numbers */
@ -141,14 +141,14 @@ protected:
unsigned int epilogue, prologue; unsigned int epilogue, prologue;
//! for each block contains pair< max_lag, max_lead> //! for each block contains pair< max_lag, max_lead>
t_lag_lead_vector block_lag_lead; lag_lead_vector_t block_lag_lead;
//! Compute the matching between endogenous and variable using the jacobian contemporaneous_jacobian //! Compute the matching between endogenous and variable using the jacobian contemporaneous_jacobian
/*! /*!
\param contemporaneous_jacobian Jacobian used as an incidence matrix: all elements declared in the map (even if they are zero), are used as vertices of the incidence matrix \param contemporaneous_jacobian Jacobian used as an incidence matrix: all elements declared in the map (even if they are zero), are used as vertices of the incidence matrix
\return True if a complete normalization has been achieved \return True if a complete normalization has been achieved
*/ */
bool computeNormalization(const jacob_map &contemporaneous_jacobian, bool verbose); bool computeNormalization(const jacob_map_t &contemporaneous_jacobian, bool verbose);
//! Try to compute the matching between endogenous and variable using a decreasing cutoff //! Try to compute the matching between endogenous and variable using a decreasing cutoff
/*! /*!
@ -156,26 +156,26 @@ protected:
If no matching is found using a strictly positive cutoff, then a zero cutoff is applied (i.e. use a symbolic normalization); in that case, the method adds zeros in the jacobian matrices to reflect all the edges in the symbolic incidence matrix. If no matching is found using a strictly positive cutoff, then a zero cutoff is applied (i.e. use a symbolic normalization); in that case, the method adds zeros in the jacobian matrices to reflect all the edges in the symbolic incidence matrix.
If no matching is found with a zero cutoff close to zero an error message is printout. If no matching is found with a zero cutoff close to zero an error message is printout.
*/ */
void computeNonSingularNormalization(jacob_map &contemporaneous_jacobian, double cutoff, jacob_map &static_jacobian, dynamic_jacob_map &dynamic_jacobian); void computeNonSingularNormalization(jacob_map_t &contemporaneous_jacobian, double cutoff, jacob_map_t &static_jacobian, dynamic_jacob_map_t &dynamic_jacobian);
//! Try to normalized each unnormalized equation (matched endogenous variable only on the LHS) //! Try to normalized each unnormalized equation (matched endogenous variable only on the LHS)
void computeNormalizedEquations(multimap<int, int> &endo2eqs) const; void computeNormalizedEquations(multimap<int, int> &endo2eqs) const;
//! Evaluate the jacobian and suppress all the elements below the cutoff //! Evaluate the jacobian and suppress all the elements below the cutoff
void evaluateAndReduceJacobian(const eval_context_type &eval_context, jacob_map &contemporaneous_jacobian, jacob_map &static_jacobian, dynamic_jacob_map &dynamic_jacobian, double cutoff, bool verbose); void evaluateAndReduceJacobian(const eval_context_t &eval_context, jacob_map_t &contemporaneous_jacobian, jacob_map_t &static_jacobian, dynamic_jacob_map_t &dynamic_jacobian, double cutoff, bool verbose);
//! Search the equations and variables belonging to the prologue and the epilogue of the model //! Search the equations and variables belonging to the prologue and the epilogue of the model
void computePrologueAndEpilogue(const jacob_map &static_jacobian, vector<int> &equation_reordered, vector<int> &variable_reordered); void computePrologueAndEpilogue(const jacob_map_t &static_jacobian, vector<int> &equation_reordered, vector<int> &variable_reordered);
//! Determine the type of each equation of model and try to normalized the unnormalized equation using computeNormalizedEquations //! Determine the type of each equation of model and try to normalized the unnormalized equation using computeNormalizedEquations
t_equation_type_and_normalized_equation equationTypeDetermination(const map<pair<int, pair<int, int> >, NodeID> &first_order_endo_derivatives, const vector<int> &Index_Var_IM, const vector<int> &Index_Equ_IM, int mfs) const; equation_type_and_normalized_equation_t equationTypeDetermination(const map<pair<int, pair<int, int> >, NodeID> &first_order_endo_derivatives, const vector<int> &Index_Var_IM, const vector<int> &Index_Equ_IM, int mfs) const;
//! Compute the block decomposition and for a non-recusive block find the minimum feedback set //! Compute the block decomposition and for a non-recusive block find the minimum feedback set
void computeBlockDecompositionAndFeedbackVariablesForEachBlock(const jacob_map &static_jacobian, const dynamic_jacob_map &dynamic_jacobian, vector<int> &equation_reordered, vector<int> &variable_reordered, vector<pair<int, int> > &blocks, const t_equation_type_and_normalized_equation &Equation_Type, bool verbose_, bool select_feedback_variable, int mfs, vector<int> &inv_equation_reordered, vector<int> &inv_variable_reordered) const; void computeBlockDecompositionAndFeedbackVariablesForEachBlock(const jacob_map_t &static_jacobian, const dynamic_jacob_map_t &dynamic_jacobian, vector<int> &equation_reordered, vector<int> &variable_reordered, vector<pair<int, int> > &blocks, const equation_type_and_normalized_equation_t &Equation_Type, bool verbose_, bool select_feedback_variable, int mfs, vector<int> &inv_equation_reordered, vector<int> &inv_variable_reordered) const;
//! Reduce the number of block merging the same type equation in the prologue and the epilogue and determine the type of each block //! Reduce the number of block merging the same type equation in the prologue and the epilogue and determine the type of each block
t_block_type_firstequation_size_mfs reduceBlocksAndTypeDetermination(const dynamic_jacob_map &dynamic_jacobian, const vector<pair<int, int> > &blocks, const t_equation_type_and_normalized_equation &Equation_Type, const vector<int> &variable_reordered, const vector<int> &equation_reordered); block_type_firstequation_size_mfs_t reduceBlocksAndTypeDetermination(const dynamic_jacob_map_t &dynamic_jacobian, const vector<pair<int, int> > &blocks, const equation_type_and_normalized_equation_t &Equation_Type, const vector<int> &variable_reordered, const vector<int> &equation_reordered);
//! Determine the maximum number of lead and lag for the endogenous variable in a bloc //! Determine the maximum number of lead and lag for the endogenous variable in a bloc
void getVariableLeadLagByBlock(const dynamic_jacob_map &dynamic_jacobian, const vector<int> &components_set, int nb_blck_sim, t_lag_lead_vector &equation_lead_lag, t_lag_lead_vector &variable_lead_lag, const vector<int> &equation_reordered, const vector<int> &variable_reordered) const; void getVariableLeadLagByBlock(const dynamic_jacob_map_t &dynamic_jacobian, const vector<int> &components_set, int nb_blck_sim, lag_lead_vector_t &equation_lead_lag, lag_lead_vector_t &variable_lead_lag, const vector<int> &equation_reordered, const vector<int> &variable_reordered) const;
//! Print an abstract of the block structure of the model //! Print an abstract of the block structure of the model
void printBlockDecomposition(const vector<pair<int, int> > &blocks) const; void printBlockDecomposition(const vector<pair<int, int> > &blocks) const;
//! Determine for each block if it is linear or not //! Determine for each block if it is linear or not
vector<bool> BlockLinear(const t_blocks_derivatives &blocks_derivatives, const vector<int> &variable_reordered) const; vector<bool> BlockLinear(const blocks_derivatives_t &blocks_derivatives, const vector<int> &variable_reordered) const;
virtual SymbolType getTypeByDerivID(int deriv_id) const throw (UnknownDerivIDException) = 0; virtual SymbolType getTypeByDerivID(int deriv_id) const throw (UnknownDerivIDException) = 0;
virtual int getLagByDerivID(int deriv_id) const throw (UnknownDerivIDException) = 0; virtual int getLagByDerivID(int deriv_id) const throw (UnknownDerivIDException) = 0;

View File

@ -50,7 +50,7 @@ InitParamStatement::writeOutput(ostream &output, const string &basename) const
} }
void void
InitParamStatement::fillEvalContext(eval_context_type &eval_context) const InitParamStatement::fillEvalContext(eval_context_t &eval_context) const
{ {
try try
{ {
@ -62,7 +62,7 @@ InitParamStatement::fillEvalContext(eval_context_type &eval_context) const
} }
} }
InitOrEndValStatement::InitOrEndValStatement(const init_values_type &init_values_arg, InitOrEndValStatement::InitOrEndValStatement(const init_values_t &init_values_arg,
const SymbolTable &symbol_table_arg) : const SymbolTable &symbol_table_arg) :
init_values(init_values_arg), init_values(init_values_arg),
symbol_table(symbol_table_arg) symbol_table(symbol_table_arg)
@ -70,9 +70,9 @@ InitOrEndValStatement::InitOrEndValStatement(const init_values_type &init_values
} }
void void
InitOrEndValStatement::fillEvalContext(eval_context_type &eval_context) const InitOrEndValStatement::fillEvalContext(eval_context_t &eval_context) const
{ {
for (init_values_type::const_iterator it = init_values.begin(); for (init_values_t::const_iterator it = init_values.begin();
it != init_values.end(); it++) it != init_values.end(); it++)
{ {
try try
@ -89,7 +89,7 @@ InitOrEndValStatement::fillEvalContext(eval_context_type &eval_context) const
void void
InitOrEndValStatement::writeInitValues(ostream &output) const InitOrEndValStatement::writeInitValues(ostream &output) const
{ {
for (init_values_type::const_iterator it = init_values.begin(); for (init_values_t::const_iterator it = init_values.begin();
it != init_values.end(); it++) it != init_values.end(); it++)
{ {
const int symb_id = it->first; const int symb_id = it->first;
@ -111,7 +111,7 @@ InitOrEndValStatement::writeInitValues(ostream &output) const
} }
} }
InitValStatement::InitValStatement(const init_values_type &init_values_arg, InitValStatement::InitValStatement(const init_values_t &init_values_arg,
const SymbolTable &symbol_table_arg) : const SymbolTable &symbol_table_arg) :
InitOrEndValStatement(init_values_arg, symbol_table_arg) InitOrEndValStatement(init_values_arg, symbol_table_arg)
{ {
@ -141,7 +141,7 @@ InitValStatement::writeOutputPostInit(ostream &output) const
<<"end;" << endl; <<"end;" << endl;
} }
EndValStatement::EndValStatement(const init_values_type &init_values_arg, EndValStatement::EndValStatement(const init_values_t &init_values_arg,
const SymbolTable &symbol_table_arg) : const SymbolTable &symbol_table_arg) :
InitOrEndValStatement(init_values_arg, symbol_table_arg) InitOrEndValStatement(init_values_arg, symbol_table_arg)
{ {
@ -170,7 +170,7 @@ EndValStatement::writeOutput(ostream &output, const string &basename) const
writeInitValues(output); writeInitValues(output);
} }
HistValStatement::HistValStatement(const hist_values_type &hist_values_arg, HistValStatement::HistValStatement(const hist_values_t &hist_values_arg,
const SymbolTable &symbol_table_arg) : const SymbolTable &symbol_table_arg) :
hist_values(hist_values_arg), hist_values(hist_values_arg),
symbol_table(symbol_table_arg) symbol_table(symbol_table_arg)
@ -185,7 +185,7 @@ HistValStatement::writeOutput(ostream &output, const string &basename) const
<< "%" << endl << "%" << endl
<< "oo_.endo_simul = zeros(M_.endo_nbr,M_.maximum_lag);" << endl; << "oo_.endo_simul = zeros(M_.endo_nbr,M_.maximum_lag);" << endl;
for (hist_values_type::const_iterator it = hist_values.begin(); for (hist_values_t::const_iterator it = hist_values.begin();
it != hist_values.end(); it++) it != hist_values.end(); it++)
{ {
int symb_id = it->first.first; int symb_id = it->first.first;
@ -237,7 +237,7 @@ InitvalFileStatement::writeOutput(ostream &output, const string &basename) const
<< "initvalf('" << filename << "');" << endl; << "initvalf('" << filename << "');" << endl;
} }
HomotopyStatement::HomotopyStatement(const homotopy_values_type &homotopy_values_arg, HomotopyStatement::HomotopyStatement(const homotopy_values_t &homotopy_values_arg,
const SymbolTable &symbol_table_arg) : const SymbolTable &symbol_table_arg) :
homotopy_values(homotopy_values_arg), homotopy_values(homotopy_values_arg),
symbol_table(symbol_table_arg) symbol_table(symbol_table_arg)
@ -252,7 +252,7 @@ HomotopyStatement::writeOutput(ostream &output, const string &basename) const
<< "%" << endl << "%" << endl
<< "options_.homotopy_values = [];" << endl; << "options_.homotopy_values = [];" << endl;
for (homotopy_values_type::const_iterator it = homotopy_values.begin(); for (homotopy_values_t::const_iterator it = homotopy_values.begin();
it != homotopy_values.end(); it++) it != homotopy_values.end(); it++)
{ {
const int &symb_id = it->first; const int &symb_id = it->first;
@ -348,7 +348,7 @@ LoadParamsAndSteadyStateStatement::writeOutput(ostream &output, const string &ba
} }
void void
LoadParamsAndSteadyStateStatement::fillEvalContext(eval_context_type &eval_context) const LoadParamsAndSteadyStateStatement::fillEvalContext(eval_context_t &eval_context) const
{ {
for (map<int, string>::const_iterator it = content.begin(); for (map<int, string>::const_iterator it = content.begin();
it != content.end(); it++) it != content.end(); it++)

View File

@ -42,7 +42,7 @@ public:
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;
//! Fill eval context with parameter value //! Fill eval context with parameter value
void fillEvalContext(eval_context_type &eval_context) const; void fillEvalContext(eval_context_t &eval_context) const;
}; };
class InitOrEndValStatement : public Statement class InitOrEndValStatement : public Statement
@ -52,15 +52,15 @@ public:
We use a vector instead of a map, since the order of declaration matters: We use a vector instead of a map, since the order of declaration matters:
an initialization can depend on a previously initialized variable inside the block an initialization can depend on a previously initialized variable inside the block
*/ */
typedef vector<pair<int, NodeID> > init_values_type; typedef vector<pair<int, NodeID> > init_values_t;
protected: protected:
const init_values_type init_values; const init_values_t init_values;
const SymbolTable &symbol_table; const SymbolTable &symbol_table;
public: public:
InitOrEndValStatement(const init_values_type &init_values_arg, InitOrEndValStatement(const init_values_t &init_values_arg,
const SymbolTable &symbol_table_arg); const SymbolTable &symbol_table_arg);
//! Fill eval context with variables values //! Fill eval context with variables values
void fillEvalContext(eval_context_type &eval_context) const; void fillEvalContext(eval_context_t &eval_context) const;
protected: protected:
void writeInitValues(ostream &output) const; void writeInitValues(ostream &output) const;
}; };
@ -68,7 +68,7 @@ protected:
class InitValStatement : public InitOrEndValStatement class InitValStatement : public InitOrEndValStatement
{ {
public: public:
InitValStatement(const init_values_type &init_values_arg, InitValStatement(const init_values_t &init_values_arg,
const SymbolTable &symbol_table_arg); const SymbolTable &symbol_table_arg);
virtual void writeOutput(ostream &output, const string &basename) const; virtual void writeOutput(ostream &output, const string &basename) const;
//! Writes initializations for oo_.endo_simul, oo_.exo_simul and oo_.exo_det_simul //! Writes initializations for oo_.endo_simul, oo_.exo_simul and oo_.exo_det_simul
@ -78,7 +78,7 @@ public:
class EndValStatement : public InitOrEndValStatement class EndValStatement : public InitOrEndValStatement
{ {
public: public:
EndValStatement(const init_values_type &init_values_arg, EndValStatement(const init_values_t &init_values_arg,
const SymbolTable &symbol_table_arg); const SymbolTable &symbol_table_arg);
//! Workaround for trac ticket #35 //! Workaround for trac ticket #35
virtual void checkPass(ModFileStructure &mod_file_struct); virtual void checkPass(ModFileStructure &mod_file_struct);
@ -93,12 +93,12 @@ public:
a given initialization value in a second initialization inside the block. a given initialization value in a second initialization inside the block.
Maps pairs (symbol_id, lag) to NodeID Maps pairs (symbol_id, lag) to NodeID
*/ */
typedef map<pair<int, int>, NodeID> hist_values_type; typedef map<pair<int, int>, NodeID> hist_values_t;
private: private:
const hist_values_type hist_values; const hist_values_t hist_values;
const SymbolTable &symbol_table; const SymbolTable &symbol_table;
public: public:
HistValStatement(const hist_values_type &hist_values_arg, HistValStatement(const hist_values_t &hist_values_arg,
const SymbolTable &symbol_table_arg); const SymbolTable &symbol_table_arg);
virtual void writeOutput(ostream &output, const string &basename) const; virtual void writeOutput(ostream &output, const string &basename) const;
}; };
@ -117,12 +117,12 @@ class HomotopyStatement : public Statement
public: public:
//! Stores the declarations of homotopy_setup //! Stores the declarations of homotopy_setup
/*! Order matter so we use a vector. First NodeID can be NULL if no initial value given. */ /*! Order matter so we use a vector. First NodeID can be NULL if no initial value given. */
typedef vector<pair<int, pair<NodeID, NodeID> > > homotopy_values_type; typedef vector<pair<int, pair<NodeID, NodeID> > > homotopy_values_t;
private: private:
const homotopy_values_type homotopy_values; const homotopy_values_t homotopy_values;
const SymbolTable &symbol_table; const SymbolTable &symbol_table;
public: public:
HomotopyStatement(const homotopy_values_type &homotopy_values_arg, HomotopyStatement(const homotopy_values_t &homotopy_values_arg,
const SymbolTable &symbol_table_arg); const SymbolTable &symbol_table_arg);
virtual void writeOutput(ostream &output, const string &basename) const; virtual void writeOutput(ostream &output, const string &basename) const;
}; };
@ -148,7 +148,7 @@ public:
const SymbolTable &symbol_table_arg); const SymbolTable &symbol_table_arg);
virtual void writeOutput(ostream &output, const string &basename) const; virtual void writeOutput(ostream &output, const string &basename) const;
//! Fill eval context with parameters/variables values //! Fill eval context with parameters/variables values
void fillEvalContext(eval_context_type &eval_context) const; void fillEvalContext(eval_context_t &eval_context) const;
}; };
#endif #endif

View File

@ -656,7 +656,7 @@ ParsingDriver::combine_lag_and_restriction(string *lag)
{ {
int current_lag = atoi(lag->c_str()); int current_lag = atoi(lag->c_str());
for (SvarIdentificationStatement::svar_identification_exclusion_type::const_iterator it = svar_ident_exclusion_values.begin(); for (SvarIdentificationStatement::svar_identification_exclusion_t::const_iterator it = svar_ident_exclusion_values.begin();
it != svar_ident_exclusion_values.end(); it++) it != svar_ident_exclusion_values.end(); it++)
if (it->first.first == current_lag) if (it->first.first == current_lag)
error("lag " + *lag + " used more than once."); error("lag " + *lag + " used more than once.");
@ -1175,7 +1175,7 @@ ParsingDriver::run_identification()
void void
ParsingDriver::add_mc_filename(string *filename, string *prior) ParsingDriver::add_mc_filename(string *filename, string *prior)
{ {
for (ModelComparisonStatement::filename_list_type::iterator it = filename_list.begin(); for (ModelComparisonStatement::filename_list_t::iterator it = filename_list.begin();
it != filename_list.end(); it++) it != filename_list.end(); it++)
if ((*it).first == *filename) if ((*it).first == *filename)
error("model_comparison: filename " + *filename + " declared twice"); error("model_comparison: filename " + *filename + " declared twice");
@ -1263,8 +1263,8 @@ ParsingDriver::ms_sbvar()
void void
ParsingDriver::svar() ParsingDriver::svar()
{ {
OptionsList::num_options_type::const_iterator it0, it1, it2; OptionsList::num_options_t::const_iterator it0, it1, it2;
OptionsList::vec_int_options_type::const_iterator itv; OptionsList::vec_int_options_t::const_iterator itv;
it0 = options_list.string_options.find("ms.coefficients"); it0 = options_list.string_options.find("ms.coefficients");
it1 = options_list.string_options.find("ms.variances"); it1 = options_list.string_options.find("ms.variances");
@ -1301,7 +1301,7 @@ ParsingDriver::svar()
void void
ParsingDriver::markov_switching() ParsingDriver::markov_switching()
{ {
OptionsList::num_options_type::const_iterator it0, it1; OptionsList::num_options_t::const_iterator it0, it1;
it0 = options_list.num_options.find("ms.chain"); it0 = options_list.num_options.find("ms.chain");
if (it0 == options_list.num_options.end()) if (it0 == options_list.num_options.end())
@ -1780,7 +1780,7 @@ ParsingDriver::add_model_var_or_external_function(string *function_name, bool in
if (numNode == NULL && unaryNode == NULL) if (numNode == NULL && unaryNode == NULL)
error("A model variable is being treated as if it were a function (i.e., takes an argument that is not an integer)."); error("A model variable is being treated as if it were a function (i.e., takes an argument that is not an integer).");
eval_context_type ectmp; eval_context_t ectmp;
int model_var_arg; int model_var_arg;
double model_var_arg_dbl; double model_var_arg_dbl;
if (unaryNode == NULL) if (unaryNode == NULL)

View File

@ -107,47 +107,47 @@ private:
//! Stores options lists //! Stores options lists
OptionsList options_list; OptionsList options_list;
//! Temporary storage for trend elements //! Temporary storage for trend elements
ObservationTrendsStatement::trend_elements_type trend_elements; ObservationTrendsStatement::trend_elements_t trend_elements;
//! Temporary storage for filename list of ModelComparison //! Temporary storage for filename list of ModelComparison
ModelComparisonStatement::filename_list_type filename_list; ModelComparisonStatement::filename_list_t filename_list;
//! Temporary storage for list of EstimationParams (from estimated_params* statements) //! Temporary storage for list of EstimationParams (from estimated_params* statements)
vector<EstimationParams> estim_params_list; vector<EstimationParams> estim_params_list;
//! Temporary storage of variances from optim_weights //! Temporary storage of variances from optim_weights
OptimWeightsStatement::var_weights_type var_weights; OptimWeightsStatement::var_weights_t var_weights;
//! Temporary storage of covariances from optim_weights //! Temporary storage of covariances from optim_weights
OptimWeightsStatement::covar_weights_type covar_weights; OptimWeightsStatement::covar_weights_t covar_weights;
//! Temporary storage of variances from calib_var //! Temporary storage of variances from calib_var
CalibVarStatement::calib_var_type calib_var; CalibVarStatement::calib_var_t calib_var;
//! Temporary storage of covariances from calib_var //! Temporary storage of covariances from calib_var
CalibVarStatement::calib_covar_type calib_covar; CalibVarStatement::calib_covar_t calib_covar;
//! Temporary storage of autocorrelations from calib_var //! Temporary storage of autocorrelations from calib_var
CalibVarStatement::calib_ac_type calib_ac; CalibVarStatement::calib_ac_t calib_ac;
//! Temporary storage for deterministic shocks //! Temporary storage for deterministic shocks
ShocksStatement::det_shocks_type det_shocks; ShocksStatement::det_shocks_t det_shocks;
//! Temporary storage for periods of deterministic shocks //! Temporary storage for periods of deterministic shocks
vector<pair<int, int> > det_shocks_periods; vector<pair<int, int> > det_shocks_periods;
//! Temporary storage for values of deterministic shocks //! Temporary storage for values of deterministic shocks
vector<NodeID> det_shocks_values; vector<NodeID> det_shocks_values;
//! Temporary storage for variances of shocks //! Temporary storage for variances of shocks
ShocksStatement::var_and_std_shocks_type var_shocks; ShocksStatement::var_and_std_shocks_t var_shocks;
//! Temporary storage for standard errors of shocks //! Temporary storage for standard errors of shocks
ShocksStatement::var_and_std_shocks_type std_shocks; ShocksStatement::var_and_std_shocks_t std_shocks;
//! Temporary storage for covariances of shocks //! Temporary storage for covariances of shocks
ShocksStatement::covar_and_corr_shocks_type covar_shocks; ShocksStatement::covar_and_corr_shocks_t covar_shocks;
//! Temporary storage for correlations of shocks //! Temporary storage for correlations of shocks
ShocksStatement::covar_and_corr_shocks_type corr_shocks; ShocksStatement::covar_and_corr_shocks_t corr_shocks;
//! Temporary storage for Sigma_e rows //! Temporary storage for Sigma_e rows
SigmaeStatement::row_type sigmae_row; SigmaeStatement::row_t sigmae_row;
//! Temporary storage for Sigma_e matrix //! Temporary storage for Sigma_e matrix
SigmaeStatement::matrix_type sigmae_matrix; SigmaeStatement::matrix_t sigmae_matrix;
//! Temporary storage for initval/endval blocks //! Temporary storage for initval/endval blocks
InitOrEndValStatement::init_values_type init_values; InitOrEndValStatement::init_values_t init_values;
//! Temporary storage for histval blocks //! Temporary storage for histval blocks
HistValStatement::hist_values_type hist_values; HistValStatement::hist_values_t hist_values;
//! Temporary storage for homotopy_setup blocks //! Temporary storage for homotopy_setup blocks
HomotopyStatement::homotopy_values_type homotopy_values; HomotopyStatement::homotopy_values_t homotopy_values;
//! Temporary storage for svar_identification blocks //! Temporary storage for svar_identification blocks
SvarIdentificationStatement::svar_identification_exclusion_type svar_ident_exclusion_values; SvarIdentificationStatement::svar_identification_exclusion_t svar_ident_exclusion_values;
//! Temporary storage for mapping the equation number to the restrictions within an svar_identification bock //! Temporary storage for mapping the equation number to the restrictions within an svar_identification bock
map<int, vector<int> > svar_equation_restrictions; map<int, vector<int> > svar_equation_restrictions;
//! Temporary storage for restrictions in an equation within an svar_identification bock //! Temporary storage for restrictions in an equation within an svar_identification bock

View File

@ -26,7 +26,7 @@ using namespace std;
#include "Shocks.hh" #include "Shocks.hh"
AbstractShocksStatement::AbstractShocksStatement(bool mshocks_arg, AbstractShocksStatement::AbstractShocksStatement(bool mshocks_arg,
const det_shocks_type &det_shocks_arg, const det_shocks_t &det_shocks_arg,
const SymbolTable &symbol_table_arg) : const SymbolTable &symbol_table_arg) :
mshocks(mshocks_arg), mshocks(mshocks_arg),
det_shocks(det_shocks_arg), det_shocks(det_shocks_arg),
@ -39,7 +39,7 @@ AbstractShocksStatement::writeDetShocks(ostream &output) const
{ {
int exo_det_length = 0; int exo_det_length = 0;
for (det_shocks_type::const_iterator it = det_shocks.begin(); for (det_shocks_t::const_iterator it = det_shocks.begin();
it != det_shocks.end(); it++) it != det_shocks.end(); it++)
{ {
int id = symbol_table.getTypeSpecificID(it->first) + 1; int id = symbol_table.getTypeSpecificID(it->first) + 1;
@ -74,11 +74,11 @@ AbstractShocksStatement::writeDetShocks(ostream &output) const
output << "M_.exo_det_length = " << exo_det_length << ";\n"; output << "M_.exo_det_length = " << exo_det_length << ";\n";
} }
ShocksStatement::ShocksStatement(const det_shocks_type &det_shocks_arg, ShocksStatement::ShocksStatement(const det_shocks_t &det_shocks_arg,
const var_and_std_shocks_type &var_shocks_arg, const var_and_std_shocks_t &var_shocks_arg,
const var_and_std_shocks_type &std_shocks_arg, const var_and_std_shocks_t &std_shocks_arg,
const covar_and_corr_shocks_type &covar_shocks_arg, const covar_and_corr_shocks_t &covar_shocks_arg,
const covar_and_corr_shocks_type &corr_shocks_arg, const covar_and_corr_shocks_t &corr_shocks_arg,
const SymbolTable &symbol_table_arg) : const SymbolTable &symbol_table_arg) :
AbstractShocksStatement(false, det_shocks_arg, symbol_table_arg), AbstractShocksStatement(false, det_shocks_arg, symbol_table_arg),
var_shocks(var_shocks_arg), var_shocks(var_shocks_arg),
@ -108,7 +108,7 @@ ShocksStatement::writeOutput(ostream &output, const string &basename) const
} }
void void
ShocksStatement::writeVarOrStdShock(ostream &output, var_and_std_shocks_type::const_iterator &it, ShocksStatement::writeVarOrStdShock(ostream &output, var_and_std_shocks_t::const_iterator &it,
bool stddev) const bool stddev) const
{ {
SymbolType type = symbol_table.getType(it->first); SymbolType type = symbol_table.getType(it->first);
@ -138,7 +138,7 @@ ShocksStatement::writeVarOrStdShock(ostream &output, var_and_std_shocks_type::co
void void
ShocksStatement::writeVarAndStdShocks(ostream &output) const ShocksStatement::writeVarAndStdShocks(ostream &output) const
{ {
var_and_std_shocks_type::const_iterator it; var_and_std_shocks_t::const_iterator it;
for (it = var_shocks.begin(); it != var_shocks.end(); it++) for (it = var_shocks.begin(); it != var_shocks.end(); it++)
writeVarOrStdShock(output, it, false); writeVarOrStdShock(output, it, false);
@ -148,7 +148,7 @@ ShocksStatement::writeVarAndStdShocks(ostream &output) const
} }
void void
ShocksStatement::writeCovarOrCorrShock(ostream &output, covar_and_corr_shocks_type::const_iterator &it, ShocksStatement::writeCovarOrCorrShock(ostream &output, covar_and_corr_shocks_t::const_iterator &it,
bool corr) const bool corr) const
{ {
SymbolType type1 = symbol_table.getType(it->first.first); SymbolType type1 = symbol_table.getType(it->first.first);
@ -183,7 +183,7 @@ ShocksStatement::writeCovarOrCorrShock(ostream &output, covar_and_corr_shocks_ty
void void
ShocksStatement::writeCovarAndCorrShocks(ostream &output) const ShocksStatement::writeCovarAndCorrShocks(ostream &output) const
{ {
covar_and_corr_shocks_type::const_iterator it; covar_and_corr_shocks_t::const_iterator it;
for (it = covar_shocks.begin(); it != covar_shocks.end(); it++) for (it = covar_shocks.begin(); it != covar_shocks.end(); it++)
writeCovarOrCorrShock(output, it, false); writeCovarOrCorrShock(output, it, false);
@ -199,30 +199,30 @@ ShocksStatement::checkPass(ModFileStructure &mod_file_struct)
mod_file_struct.shocks_present = true; mod_file_struct.shocks_present = true;
// Determine if there is a calibrated measurement error // Determine if there is a calibrated measurement error
for (var_and_std_shocks_type::const_iterator it = var_shocks.begin(); for (var_and_std_shocks_t::const_iterator it = var_shocks.begin();
it != var_shocks.end(); it++) it != var_shocks.end(); it++)
if (symbol_table.isObservedVariable(it->first)) if (symbol_table.isObservedVariable(it->first))
mod_file_struct.calibrated_measurement_errors = true; mod_file_struct.calibrated_measurement_errors = true;
for (var_and_std_shocks_type::const_iterator it = std_shocks.begin(); for (var_and_std_shocks_t::const_iterator it = std_shocks.begin();
it != std_shocks.end(); it++) it != std_shocks.end(); it++)
if (symbol_table.isObservedVariable(it->first)) if (symbol_table.isObservedVariable(it->first))
mod_file_struct.calibrated_measurement_errors = true; mod_file_struct.calibrated_measurement_errors = true;
for (covar_and_corr_shocks_type::const_iterator it = covar_shocks.begin(); for (covar_and_corr_shocks_t::const_iterator it = covar_shocks.begin();
it != covar_shocks.end(); it++) it != covar_shocks.end(); it++)
if (symbol_table.isObservedVariable(it->first.first) if (symbol_table.isObservedVariable(it->first.first)
|| symbol_table.isObservedVariable(it->first.second)) || symbol_table.isObservedVariable(it->first.second))
mod_file_struct.calibrated_measurement_errors = true; mod_file_struct.calibrated_measurement_errors = true;
for (covar_and_corr_shocks_type::const_iterator it = corr_shocks.begin(); for (covar_and_corr_shocks_t::const_iterator it = corr_shocks.begin();
it != corr_shocks.end(); it++) it != corr_shocks.end(); it++)
if (symbol_table.isObservedVariable(it->first.first) if (symbol_table.isObservedVariable(it->first.first)
|| symbol_table.isObservedVariable(it->first.second)) || symbol_table.isObservedVariable(it->first.second))
mod_file_struct.calibrated_measurement_errors = true; mod_file_struct.calibrated_measurement_errors = true;
} }
MShocksStatement::MShocksStatement(const det_shocks_type &det_shocks_arg, MShocksStatement::MShocksStatement(const det_shocks_t &det_shocks_arg,
const SymbolTable &symbol_table_arg) : const SymbolTable &symbol_table_arg) :
AbstractShocksStatement(true, det_shocks_arg, symbol_table_arg) AbstractShocksStatement(true, det_shocks_arg, symbol_table_arg)
{ {
@ -248,7 +248,7 @@ MShocksStatement::checkPass(ModFileStructure &mod_file_struct)
mod_file_struct.shocks_present = true; mod_file_struct.shocks_present = true;
} }
ConditionalForecastPathsStatement::ConditionalForecastPathsStatement(const AbstractShocksStatement::det_shocks_type &paths_arg, const SymbolTable &symbol_table_arg) : ConditionalForecastPathsStatement::ConditionalForecastPathsStatement(const AbstractShocksStatement::det_shocks_t &paths_arg, const SymbolTable &symbol_table_arg) :
paths(paths_arg), paths(paths_arg),
symbol_table(symbol_table_arg), symbol_table(symbol_table_arg),
path_length(-1) path_length(-1)
@ -258,7 +258,7 @@ ConditionalForecastPathsStatement::ConditionalForecastPathsStatement(const Abstr
void void
ConditionalForecastPathsStatement::checkPass(ModFileStructure &mod_file_struct) ConditionalForecastPathsStatement::checkPass(ModFileStructure &mod_file_struct)
{ {
for (AbstractShocksStatement::det_shocks_type::const_iterator it = paths.begin(); for (AbstractShocksStatement::det_shocks_t::const_iterator it = paths.begin();
it != paths.end(); it++) it != paths.end(); it++)
{ {
int this_path_length = 0; int this_path_length = 0;
@ -285,7 +285,7 @@ ConditionalForecastPathsStatement::writeOutput(ostream &output, const string &ba
int k = 1; int k = 1;
for (AbstractShocksStatement::det_shocks_type::const_iterator it = paths.begin(); for (AbstractShocksStatement::det_shocks_t::const_iterator it = paths.begin();
it != paths.end(); it++) it != paths.end(); it++)
{ {
output << "constrained_vars_ = strvcat(constrained_vars_, '" << it->first << "');" << endl; output << "constrained_vars_ = strvcat(constrained_vars_, '" << it->first << "');" << endl;

View File

@ -39,37 +39,37 @@ public:
int period2; int period2;
NodeID value; NodeID value;
}; };
typedef map<int, vector<DetShockElement> > det_shocks_type; typedef map<int, vector<DetShockElement> > det_shocks_t;
protected: protected:
//! Is this statement a "mshocks" statement ? (instead of a "shocks" statement) //! Is this statement a "mshocks" statement ? (instead of a "shocks" statement)
const bool mshocks; const bool mshocks;
const det_shocks_type det_shocks; const det_shocks_t det_shocks;
const SymbolTable &symbol_table; const SymbolTable &symbol_table;
void writeDetShocks(ostream &output) const; void writeDetShocks(ostream &output) const;
AbstractShocksStatement(bool mshocks_arg, AbstractShocksStatement(bool mshocks_arg,
const det_shocks_type &det_shocks_arg, const det_shocks_t &det_shocks_arg,
const SymbolTable &symbol_table_arg); const SymbolTable &symbol_table_arg);
}; };
class ShocksStatement : public AbstractShocksStatement class ShocksStatement : public AbstractShocksStatement
{ {
public: public:
typedef map<int, NodeID> var_and_std_shocks_type; typedef map<int, NodeID> var_and_std_shocks_t;
typedef map<pair<int, int>, NodeID> covar_and_corr_shocks_type; typedef map<pair<int, int>, NodeID> covar_and_corr_shocks_t;
private: private:
const var_and_std_shocks_type var_shocks, std_shocks; const var_and_std_shocks_t var_shocks, std_shocks;
const covar_and_corr_shocks_type covar_shocks, corr_shocks; const covar_and_corr_shocks_t covar_shocks, corr_shocks;
void writeVarOrStdShock(ostream &output, var_and_std_shocks_type::const_iterator &it, bool stddev) const; void writeVarOrStdShock(ostream &output, var_and_std_shocks_t::const_iterator &it, bool stddev) const;
void writeVarAndStdShocks(ostream &output) const; void writeVarAndStdShocks(ostream &output) const;
void writeCovarOrCorrShock(ostream &output, covar_and_corr_shocks_type::const_iterator &it, bool corr) const; void writeCovarOrCorrShock(ostream &output, covar_and_corr_shocks_t::const_iterator &it, bool corr) const;
void writeCovarAndCorrShocks(ostream &output) const; void writeCovarAndCorrShocks(ostream &output) const;
public: public:
ShocksStatement(const det_shocks_type &det_shocks_arg, ShocksStatement(const det_shocks_t &det_shocks_arg,
const var_and_std_shocks_type &var_shocks_arg, const var_and_std_shocks_t &var_shocks_arg,
const var_and_std_shocks_type &std_shocks_arg, const var_and_std_shocks_t &std_shocks_arg,
const covar_and_corr_shocks_type &covar_shocks_arg, const covar_and_corr_shocks_t &covar_shocks_arg,
const covar_and_corr_shocks_type &corr_shocks_arg, const covar_and_corr_shocks_t &corr_shocks_arg,
const SymbolTable &symbol_table_arg); const SymbolTable &symbol_table_arg);
virtual void writeOutput(ostream &output, const string &basename) const; virtual void writeOutput(ostream &output, const string &basename) const;
virtual void checkPass(ModFileStructure &mod_file_struct); virtual void checkPass(ModFileStructure &mod_file_struct);
@ -78,7 +78,7 @@ public:
class MShocksStatement : public AbstractShocksStatement class MShocksStatement : public AbstractShocksStatement
{ {
public: public:
MShocksStatement(const det_shocks_type &det_shocks_arg, MShocksStatement(const det_shocks_t &det_shocks_arg,
const SymbolTable &symbol_table_arg); const SymbolTable &symbol_table_arg);
virtual void writeOutput(ostream &output, const string &basename) const; virtual void writeOutput(ostream &output, const string &basename) const;
virtual void checkPass(ModFileStructure &mod_file_struct); virtual void checkPass(ModFileStructure &mod_file_struct);
@ -87,11 +87,11 @@ public:
class ConditionalForecastPathsStatement : public Statement class ConditionalForecastPathsStatement : public Statement
{ {
private: private:
const AbstractShocksStatement::det_shocks_type paths; const AbstractShocksStatement::det_shocks_t paths;
const SymbolTable &symbol_table; const SymbolTable &symbol_table;
int path_length; int path_length;
public: public:
ConditionalForecastPathsStatement(const AbstractShocksStatement::det_shocks_type &paths_arg, ConditionalForecastPathsStatement(const AbstractShocksStatement::det_shocks_t &paths_arg,
const SymbolTable &symbol_table_arg); const SymbolTable &symbol_table_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;

View File

@ -19,18 +19,18 @@
#include "SigmaeInitialization.hh" #include "SigmaeInitialization.hh"
SigmaeStatement::SigmaeStatement(const matrix_type &matrix_arg) throw (MatrixFormException) : SigmaeStatement::SigmaeStatement(const matrix_t &matrix_arg) throw (MatrixFormException) :
matrix(matrix_arg), matrix(matrix_arg),
matrix_form(determineMatrixForm(matrix)) matrix_form(determineMatrixForm(matrix))
{ {
} }
SigmaeStatement::matrix_form_type SigmaeStatement::matrix_form_t
SigmaeStatement::determineMatrixForm(const matrix_type &matrix) throw (MatrixFormException) SigmaeStatement::determineMatrixForm(const matrix_t &matrix) throw (MatrixFormException)
{ {
size_t nbe; size_t nbe;
int inc; int inc;
matrix_form_type type; matrix_form_t type;
// Checking if first or last row has one element. // Checking if first or last row has one element.
if (matrix.front().size() == 1) if (matrix.front().size() == 1)
{ {
@ -50,7 +50,7 @@ SigmaeStatement::determineMatrixForm(const matrix_type &matrix) throw (MatrixFor
// Checking if matrix is triangular (upper or lower): // Checking if matrix is triangular (upper or lower):
// each row has one element more or less than the previous one // each row has one element more or less than the previous one
// and first or last one has one element. // and first or last one has one element.
matrix_type::const_iterator ir; matrix_t::const_iterator ir;
for (ir = matrix.begin(), ir++; ir != matrix.end(); ir++, nbe += inc) for (ir = matrix.begin(), ir++; ir != matrix.end(); ir++, nbe += inc)
if (ir->size() != nbe) if (ir->size() != nbe)
throw MatrixFormException(); throw MatrixFormException();

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2003-2008 Dynare Team * Copyright (C) 2003-2010 Dynare Team
* *
* This file is part of Dynare. * This file is part of Dynare.
* *
@ -33,15 +33,15 @@ class SigmaeStatement : public Statement
{ {
public: public:
//! Matrix form (lower or upper triangular) enum //! Matrix form (lower or upper triangular) enum
enum matrix_form_type enum matrix_form_t
{ {
eLower = 0, //!< Lower triangular matrix eLower = 0, //!< Lower triangular matrix
eUpper = 1 //!< Upper triangular matrix eUpper = 1 //!< Upper triangular matrix
}; };
//! Type of a matrix row //! Type of a matrix row
typedef vector<NodeID> row_type; typedef vector<NodeID> row_t;
//! Type of a complete matrix //! Type of a complete matrix
typedef vector<row_type> matrix_type; typedef vector<row_t> matrix_t;
//! An exception indicating that a matrix is neither upper triangular nor lower triangular //! An exception indicating that a matrix is neither upper triangular nor lower triangular
class MatrixFormException class MatrixFormException
@ -49,16 +49,16 @@ public:
}; };
private: private:
//! The matrix //! The matrix
const matrix_type matrix; const matrix_t matrix;
//! Matrix form (lower or upper) //! Matrix form (lower or upper)
const matrix_form_type matrix_form; const matrix_form_t matrix_form;
//! Returns the type (upper or lower triangular) of a given matrix //! Returns the type (upper or lower triangular) of a given matrix
/*! Throws an exception if it is neither upper triangular nor lower triangular */ /*! Throws an exception if it is neither upper triangular nor lower triangular */
static matrix_form_type determineMatrixForm(const matrix_type &matrix) throw (MatrixFormException); static matrix_form_t determineMatrixForm(const matrix_t &matrix) throw (MatrixFormException);
public: public:
SigmaeStatement(const matrix_type &matrix_arg) throw (MatrixFormException); SigmaeStatement(const matrix_t &matrix_arg) throw (MatrixFormException);
virtual void writeOutput(ostream &output, const string &basename) const; virtual void writeOutput(ostream &output, const string &basename) const;
}; };

View File

@ -70,24 +70,24 @@ NativeStatement::writeOutput(ostream &output, const string &basename) const
void void
OptionsList::writeOutput(ostream &output) const OptionsList::writeOutput(ostream &output) const
{ {
for (num_options_type::const_iterator it = num_options.begin(); for (num_options_t::const_iterator it = num_options.begin();
it != num_options.end(); it++) it != num_options.end(); it++)
output << "options_." << it->first << " = " << it->second << ";" << endl; output << "options_." << it->first << " = " << it->second << ";" << endl;
for (paired_num_options_type::const_iterator it = paired_num_options.begin(); for (paired_num_options_t::const_iterator it = paired_num_options.begin();
it != paired_num_options.end(); it++) it != paired_num_options.end(); it++)
output << "options_." << it->first << " = [" << it->second.first << "; " output << "options_." << it->first << " = [" << it->second.first << "; "
<< it->second.second << "];" << endl; << it->second.second << "];" << endl;
for (string_options_type::const_iterator it = string_options.begin(); for (string_options_t::const_iterator it = string_options.begin();
it != string_options.end(); it++) it != string_options.end(); it++)
output << "options_." << it->first << " = '" << it->second << "';" << endl; output << "options_." << it->first << " = '" << it->second << "';" << endl;
for (symbol_list_options_type::const_iterator it = symbol_list_options.begin(); for (symbol_list_options_t::const_iterator it = symbol_list_options.begin();
it != symbol_list_options.end(); it++) it != symbol_list_options.end(); it++)
it->second.writeOutput("options_." + it->first, output); it->second.writeOutput("options_." + it->first, output);
for (vec_int_options_type::const_iterator it = vector_int_options.begin(); for (vec_int_options_t::const_iterator it = vector_int_options.begin();
it != vector_int_options.end(); it++) it != vector_int_options.end(); it++)
{ {
output << "options_." << it->first << " = "; output << "options_." << it->first << " = ";
@ -109,24 +109,24 @@ OptionsList::writeOutput(ostream &output, const string &option_group) const
{ {
output << option_group << " = struct();" << endl; output << option_group << " = struct();" << endl;
for (num_options_type::const_iterator it = num_options.begin(); for (num_options_t::const_iterator it = num_options.begin();
it != num_options.end(); it++) it != num_options.end(); it++)
output << option_group << "." << it->first << " = " << it->second << ";" << endl; output << option_group << "." << it->first << " = " << it->second << ";" << endl;
for (paired_num_options_type::const_iterator it = paired_num_options.begin(); for (paired_num_options_t::const_iterator it = paired_num_options.begin();
it != paired_num_options.end(); it++) it != paired_num_options.end(); it++)
output << option_group << "." << it->first << " = [" << it->second.first << "; " output << option_group << "." << it->first << " = [" << it->second.first << "; "
<< it->second.second << "];" << endl; << it->second.second << "];" << endl;
for (string_options_type::const_iterator it = string_options.begin(); for (string_options_t::const_iterator it = string_options.begin();
it != string_options.end(); it++) it != string_options.end(); it++)
output << option_group << "." << it->first << " = '" << it->second << "';" << endl; output << option_group << "." << it->first << " = '" << it->second << "';" << endl;
for (symbol_list_options_type::const_iterator it = symbol_list_options.begin(); for (symbol_list_options_t::const_iterator it = symbol_list_options.begin();
it != symbol_list_options.end(); it++) it != symbol_list_options.end(); it++)
it->second.writeOutput(option_group + "." + it->first, output); it->second.writeOutput(option_group + "." + it->first, output);
for (vec_int_options_type::const_iterator it = vector_int_options.begin(); for (vec_int_options_t::const_iterator it = vector_int_options.begin();
it != vector_int_options.end(); it++) it != vector_int_options.end(); it++)
{ {
output << option_group << "." << it->first << " = "; output << option_group << "." << it->first << " = ";

View File

@ -104,16 +104,16 @@ public:
class OptionsList class OptionsList
{ {
public: public:
typedef map<string, string> num_options_type; typedef map<string, string> num_options_t;
typedef map<string, pair<string, string> > paired_num_options_type; typedef map<string, pair<string, string> > paired_num_options_t;
typedef map<string, string> string_options_type; typedef map<string, string> string_options_t;
typedef map<string, SymbolList> symbol_list_options_type; typedef map<string, SymbolList> symbol_list_options_t;
typedef map<string, vector<int> > vec_int_options_type; typedef map<string, vector<int> > vec_int_options_t;
num_options_type num_options; num_options_t num_options;
paired_num_options_type paired_num_options; paired_num_options_t paired_num_options;
string_options_type string_options; string_options_t string_options;
symbol_list_options_type symbol_list_options; symbol_list_options_t symbol_list_options;
vec_int_options_type vector_int_options; vec_int_options_t vector_int_options;
void writeOutput(ostream &output) const; void writeOutput(ostream &output) const;
void writeOutput(ostream &output, const string &option_group) const; void writeOutput(ostream &output, const string &option_group) const;
void clear(); void clear();

View File

@ -46,9 +46,9 @@ StaticModel::StaticModel(SymbolTable &symbol_table_arg,
} }
void void
StaticModel::compileDerivative(ofstream &code_file, int eq, int symb_id, map_idx_type &map_idx) const StaticModel::compileDerivative(ofstream &code_file, int eq, int symb_id, map_idx_t &map_idx) const
{ {
first_derivatives_type::const_iterator it = first_derivatives.find(make_pair(eq, symbol_table.getID(eEndogenous, symb_id))); first_derivatives_t::const_iterator it = first_derivatives.find(make_pair(eq, symbol_table.getID(eEndogenous, symb_id)));
if (it != first_derivatives.end()) if (it != first_derivatives.end())
(it->second)->compile(code_file, false, temporary_terms, map_idx, false, false); (it->second)->compile(code_file, false, temporary_terms, map_idx, false, false);
else else
@ -59,7 +59,7 @@ StaticModel::compileDerivative(ofstream &code_file, int eq, int symb_id, map_idx
} }
void void
StaticModel::compileChainRuleDerivative(ofstream &code_file, int eqr, int varr, int lag, map_idx_type &map_idx) const StaticModel::compileChainRuleDerivative(ofstream &code_file, int eqr, int varr, int lag, map_idx_t &map_idx) const
{ {
map<pair<int, pair<int, int> >, NodeID>::const_iterator it = first_chain_rule_derivatives.find(make_pair(eqr, make_pair(varr, lag))); map<pair<int, pair<int, int> >, NodeID>::const_iterator it = first_chain_rule_derivatives.find(make_pair(eqr, make_pair(varr, lag)));
if (it != first_chain_rule_derivatives.end()) if (it != first_chain_rule_derivatives.end())
@ -87,16 +87,16 @@ StaticModel::computeTemporaryTermsOrdered()
map<NodeID, pair<int, int> > first_occurence; map<NodeID, pair<int, int> > first_occurence;
map<NodeID, int> reference_count; map<NodeID, int> reference_count;
BinaryOpNode *eq_node; BinaryOpNode *eq_node;
first_derivatives_type::const_iterator it; first_derivatives_t::const_iterator it;
first_chain_rule_derivatives_type::const_iterator it_chr; first_chain_rule_derivatives_t::const_iterator it_chr;
ostringstream tmp_s; ostringstream tmp_s;
v_temporary_terms.clear(); v_temporary_terms.clear();
map_idx.clear(); map_idx.clear();
unsigned int nb_blocks = getNbBlocks(); unsigned int nb_blocks = getNbBlocks();
v_temporary_terms = vector< vector<temporary_terms_type> >(nb_blocks); v_temporary_terms = vector< vector<temporary_terms_t> >(nb_blocks);
v_temporary_terms_inuse = vector<temporary_terms_inuse_type>(nb_blocks); v_temporary_terms_inuse = vector<temporary_terms_inuse_t>(nb_blocks);
temporary_terms.clear(); temporary_terms.clear();
if (!global_temporary_terms) if (!global_temporary_terms)
@ -109,7 +109,7 @@ StaticModel::computeTemporaryTermsOrdered()
unsigned int block_size = getBlockSize(block); unsigned int block_size = getBlockSize(block);
unsigned int block_nb_mfs = getBlockMfs(block); unsigned int block_nb_mfs = getBlockMfs(block);
unsigned int block_nb_recursives = block_size - block_nb_mfs; unsigned int block_nb_recursives = block_size - block_nb_mfs;
v_temporary_terms[block] = vector<temporary_terms_type>(block_size); v_temporary_terms[block] = vector<temporary_terms_t>(block_size);
for (unsigned int i = 0; i < block_size; i++) for (unsigned int i = 0; i < block_size; i++)
{ {
if (i < block_nb_recursives && isBlockEquationRenormalized(block, i)) if (i < block_nb_recursives && isBlockEquationRenormalized(block, i))
@ -120,7 +120,7 @@ StaticModel::computeTemporaryTermsOrdered()
eq_node->computeTemporaryTerms(reference_count, temporary_terms, first_occurence, block, v_temporary_terms, i); eq_node->computeTemporaryTerms(reference_count, temporary_terms, first_occurence, block, v_temporary_terms, i);
} }
} }
for (t_block_derivatives_equation_variable_laglead_nodeid::const_iterator it = blocks_derivatives[block].begin(); it != (blocks_derivatives[block]).end(); it++) for (block_derivatives_equation_variable_laglead_nodeid_t::const_iterator it = blocks_derivatives[block].begin(); it != (blocks_derivatives[block]).end(); it++)
{ {
NodeID id = it->second.second; NodeID id = it->second.second;
id->computeTemporaryTerms(reference_count, temporary_terms, first_occurence, block, v_temporary_terms, block_size-1); id->computeTemporaryTerms(reference_count, temporary_terms, first_occurence, block, v_temporary_terms, block_size-1);
@ -138,7 +138,7 @@ StaticModel::computeTemporaryTermsOrdered()
unsigned int block_size = getBlockSize(block); unsigned int block_size = getBlockSize(block);
unsigned int block_nb_mfs = getBlockMfs(block); unsigned int block_nb_mfs = getBlockMfs(block);
unsigned int block_nb_recursives = block_size - block_nb_mfs; unsigned int block_nb_recursives = block_size - block_nb_mfs;
v_temporary_terms[block] = vector<temporary_terms_type>(block_size); v_temporary_terms[block] = vector<temporary_terms_t>(block_size);
for (unsigned int i = 0; i < block_size; i++) for (unsigned int i = 0; i < block_size; i++)
{ {
if (i < block_nb_recursives && isBlockEquationRenormalized(block, i)) if (i < block_nb_recursives && isBlockEquationRenormalized(block, i))
@ -149,7 +149,7 @@ StaticModel::computeTemporaryTermsOrdered()
eq_node->computeTemporaryTerms(reference_count, temporary_terms, first_occurence, block, v_temporary_terms, i); eq_node->computeTemporaryTerms(reference_count, temporary_terms, first_occurence, block, v_temporary_terms, i);
} }
} }
for (t_block_derivatives_equation_variable_laglead_nodeid::const_iterator it = blocks_derivatives[block].begin(); it != (blocks_derivatives[block]).end(); it++) for (block_derivatives_equation_variable_laglead_nodeid_t::const_iterator it = blocks_derivatives[block].begin(); it != (blocks_derivatives[block]).end(); it++)
{ {
NodeID id = it->second.second; NodeID id = it->second.second;
id->computeTemporaryTerms(reference_count, temporary_terms, first_occurence, block, v_temporary_terms, block_size-1); id->computeTemporaryTerms(reference_count, temporary_terms, first_occurence, block, v_temporary_terms, block_size-1);
@ -173,13 +173,13 @@ StaticModel::computeTemporaryTermsOrdered()
eq_node->collectTemporary_terms(temporary_terms, temporary_terms_in_use, block); eq_node->collectTemporary_terms(temporary_terms, temporary_terms_in_use, block);
} }
} }
for (t_block_derivatives_equation_variable_laglead_nodeid::const_iterator it = blocks_derivatives[block].begin(); it != (blocks_derivatives[block]).end(); it++) for (block_derivatives_equation_variable_laglead_nodeid_t::const_iterator it = blocks_derivatives[block].begin(); it != (blocks_derivatives[block]).end(); it++)
{ {
NodeID id = it->second.second; NodeID id = it->second.second;
id->collectTemporary_terms(temporary_terms, temporary_terms_in_use, block); id->collectTemporary_terms(temporary_terms, temporary_terms_in_use, block);
} }
for (int i = 0; i < (int) getBlockSize(block); i++) for (int i = 0; i < (int) getBlockSize(block); i++)
for (temporary_terms_type::const_iterator it = v_temporary_terms[block][i].begin(); for (temporary_terms_t::const_iterator it = v_temporary_terms[block][i].begin();
it != v_temporary_terms[block][i].end(); it++) it != v_temporary_terms[block][i].end(); it++)
(*it)->collectTemporary_terms(temporary_terms, temporary_terms_in_use, block); (*it)->collectTemporary_terms(temporary_terms, temporary_terms_in_use, block);
v_temporary_terms_inuse[block] = temporary_terms_in_use; v_temporary_terms_inuse[block] = temporary_terms_in_use;
@ -193,7 +193,7 @@ StaticModel::computeTemporaryTermsMapping()
{ {
// Add a mapping form node ID to temporary terms order // Add a mapping form node ID to temporary terms order
int j = 0; int j = 0;
for (temporary_terms_type::const_iterator it = temporary_terms.begin(); for (temporary_terms_t::const_iterator it = temporary_terms.begin();
it != temporary_terms.end(); it++) it != temporary_terms.end(); it++)
map_idx[(*it)->idx] = j++; map_idx[(*it)->idx] = j++;
} }
@ -206,7 +206,7 @@ StaticModel::writeModelEquationsOrdered_M(const string &static_basename) const
NodeID lhs = NULL, rhs = NULL; NodeID lhs = NULL, rhs = NULL;
BinaryOpNode *eq_node; BinaryOpNode *eq_node;
map<NodeID, int> reference_count; map<NodeID, int> reference_count;
temporary_terms_type local_temporary_terms; temporary_terms_t local_temporary_terms;
ofstream output; ofstream output;
int nze; int nze;
vector<int> feedback_variables; vector<int> feedback_variables;
@ -270,7 +270,7 @@ StaticModel::writeModelEquationsOrdered_M(const string &static_basename) const
if (v_temporary_terms_inuse[block].size()) if (v_temporary_terms_inuse[block].size())
{ {
tmp_output.str(""); tmp_output.str("");
for (temporary_terms_inuse_type::const_iterator it = v_temporary_terms_inuse[block].begin(); for (temporary_terms_inuse_t::const_iterator it = v_temporary_terms_inuse[block].begin();
it != v_temporary_terms_inuse[block].end(); it++) it != v_temporary_terms_inuse[block].end(); it++)
tmp_output << " T" << *it; tmp_output << " T" << *it;
output << " global" << tmp_output.str() << ";\n"; output << " global" << tmp_output.str() << ";\n";
@ -284,12 +284,12 @@ StaticModel::writeModelEquationsOrdered_M(const string &static_basename) const
{ {
if (!global_temporary_terms) if (!global_temporary_terms)
local_temporary_terms = v_temporary_terms[block][i]; local_temporary_terms = v_temporary_terms[block][i];
temporary_terms_type tt2; temporary_terms_t tt2;
tt2.clear(); tt2.clear();
if (v_temporary_terms[block].size()) if (v_temporary_terms[block].size())
{ {
output << " " << "% //Temporary variables" << endl; output << " " << "% //Temporary variables" << endl;
for (temporary_terms_type::const_iterator it = v_temporary_terms[block][i].begin(); for (temporary_terms_t::const_iterator it = v_temporary_terms[block][i].begin();
it != v_temporary_terms[block][i].end(); it++) it != v_temporary_terms[block][i].end(); it++)
{ {
output << " " << sps; output << " " << sps;
@ -378,7 +378,7 @@ StaticModel::writeModelEquationsOrdered_M(const string &static_basename) const
case SOLVE_FORWARD_SIMPLE: case SOLVE_FORWARD_SIMPLE:
case SOLVE_BACKWARD_COMPLETE: case SOLVE_BACKWARD_COMPLETE:
case SOLVE_FORWARD_COMPLETE: case SOLVE_FORWARD_COMPLETE:
for (t_block_derivatives_equation_variable_laglead_nodeid::const_iterator it = blocks_derivatives[block].begin(); it != (blocks_derivatives[block]).end(); it++) for (block_derivatives_equation_variable_laglead_nodeid_t::const_iterator it = blocks_derivatives[block].begin(); it != (blocks_derivatives[block]).end(); it++)
{ {
unsigned int eq = it->first.first; unsigned int eq = it->first.first;
unsigned int var = it->first.second; unsigned int var = it->first.second;
@ -401,7 +401,7 @@ StaticModel::writeModelEquationsOrdered_M(const string &static_basename) const
} }
void void
StaticModel::writeModelEquationsCode(const string file_name, const string bin_basename, map_idx_type map_idx) const StaticModel::writeModelEquationsCode(const string file_name, const string bin_basename, map_idx_t map_idx) const
{ {
ostringstream tmp_output; ostringstream tmp_output;
@ -443,7 +443,7 @@ StaticModel::writeModelEquationsCode(const string file_name, const string bin_ba
// Add a mapping form node ID to temporary terms order // Add a mapping form node ID to temporary terms order
int j = 0; int j = 0;
for (temporary_terms_type::const_iterator it = temporary_terms.begin(); for (temporary_terms_t::const_iterator it = temporary_terms.begin();
it != temporary_terms.end(); it++) it != temporary_terms.end(); it++)
map_idx[(*it)->idx] = j++; map_idx[(*it)->idx] = j++;
compileTemporaryTerms(code_file, temporary_terms, map_idx, false, false); compileTemporaryTerms(code_file, temporary_terms, map_idx, false, false);
@ -456,7 +456,7 @@ StaticModel::writeModelEquationsCode(const string file_name, const string bin_ba
vector<vector<pair<int, int> > > derivatives; vector<vector<pair<int, int> > > derivatives;
derivatives.resize(symbol_table.endo_nbr()); derivatives.resize(symbol_table.endo_nbr());
count_u = symbol_table.endo_nbr(); count_u = symbol_table.endo_nbr();
for (first_derivatives_type::const_iterator it = first_derivatives.begin(); for (first_derivatives_t::const_iterator it = first_derivatives.begin();
it != first_derivatives.end(); it++) it != first_derivatives.end(); it++)
{ {
int deriv_id = it->first.second; int deriv_id = it->first.second;
@ -511,7 +511,7 @@ StaticModel::writeModelEquationsCode(const string file_name, const string bin_ba
} }
void void
StaticModel::writeModelEquationsCode_Block(const string file_name, const string bin_basename, map_idx_type map_idx) const StaticModel::writeModelEquationsCode_Block(const string file_name, const string bin_basename, map_idx_t map_idx) const
{ {
struct Uff_l struct Uff_l
{ {
@ -588,11 +588,11 @@ StaticModel::writeModelEquationsCode_Block(const string file_name, const string
for (i = 0; i < (int) block_size; i++) for (i = 0; i < (int) block_size; i++)
{ {
//The Temporary terms //The Temporary terms
temporary_terms_type tt2; temporary_terms_t tt2;
tt2.clear(); tt2.clear();
if (v_temporary_terms[block].size()) if (v_temporary_terms[block].size())
{ {
for (temporary_terms_type::const_iterator it = v_temporary_terms[block][i].begin(); for (temporary_terms_t::const_iterator it = v_temporary_terms[block][i].begin();
it != v_temporary_terms[block][i].end(); it++) it != v_temporary_terms[block][i].end(); it++)
{ {
FNUMEXPR_ fnumexpr(TemporaryTerm, (int)(map_idx.find((*it)->idx)->second)); FNUMEXPR_ fnumexpr(TemporaryTerm, (int)(map_idx.find((*it)->idx)->second));
@ -684,7 +684,7 @@ StaticModel::writeModelEquationsCode_Block(const string file_name, const string
case SOLVE_BACKWARD_COMPLETE: case SOLVE_BACKWARD_COMPLETE:
case SOLVE_FORWARD_COMPLETE: case SOLVE_FORWARD_COMPLETE:
count_u = feedback_variables.size(); count_u = feedback_variables.size();
for (t_block_derivatives_equation_variable_laglead_nodeid::const_iterator it = blocks_derivatives[block].begin(); it != (blocks_derivatives[block]).end(); it++) for (block_derivatives_equation_variable_laglead_nodeid_t::const_iterator it = blocks_derivatives[block].begin(); it != (blocks_derivatives[block]).end(); it++)
{ {
unsigned int eq = it->first.first; unsigned int eq = it->first.first;
unsigned int var = it->first.second; unsigned int var = it->first.second;
@ -784,7 +784,7 @@ StaticModel::Write_Inf_To_Bin_File_Block(const string &static_basename, const st
unsigned int block_size = getBlockSize(num); unsigned int block_size = getBlockSize(num);
unsigned int block_mfs = getBlockMfs(num); unsigned int block_mfs = getBlockMfs(num);
unsigned int block_recursive = block_size - block_mfs; unsigned int block_recursive = block_size - block_mfs;
for (t_block_derivatives_equation_variable_laglead_nodeid::const_iterator it = blocks_derivatives[num].begin(); it != (blocks_derivatives[num]).end(); it++) for (block_derivatives_equation_variable_laglead_nodeid_t::const_iterator it = blocks_derivatives[num].begin(); it != (blocks_derivatives[num]).end(); it++)
{ {
unsigned int eq = it->first.first; unsigned int eq = it->first.first;
unsigned int var = it->first.second; unsigned int var = it->first.second;
@ -819,7 +819,7 @@ map<pair<int, pair<int, int > >, NodeID>
StaticModel::collect_first_order_derivatives_endogenous() StaticModel::collect_first_order_derivatives_endogenous()
{ {
map<pair<int, pair<int, int > >, NodeID> endo_derivatives; map<pair<int, pair<int, int > >, NodeID> endo_derivatives;
for (first_derivatives_type::iterator it2 = first_derivatives.begin(); for (first_derivatives_t::iterator it2 = first_derivatives.begin();
it2 != first_derivatives.end(); it2++) it2 != first_derivatives.end(); it2++)
{ {
if (getTypeByDerivID(it2->first.second) == eEndogenous) if (getTypeByDerivID(it2->first.second) == eEndogenous)
@ -834,7 +834,7 @@ StaticModel::collect_first_order_derivatives_endogenous()
} }
void void
StaticModel::computingPass(const eval_context_type &eval_context, bool no_tmp_terms, bool hessian, bool block, bool bytecode) StaticModel::computingPass(const eval_context_t &eval_context, bool no_tmp_terms, bool hessian, bool block, bool bytecode)
{ {
// Compute derivatives w.r. to all endogenous, and possibly exogenous and exogenous deterministic // Compute derivatives w.r. to all endogenous, and possibly exogenous and exogenous deterministic
set<int> vars; set<int> vars;
@ -857,7 +857,7 @@ StaticModel::computingPass(const eval_context_type &eval_context, bool no_tmp_te
if (block) if (block)
{ {
jacob_map contemporaneous_jacobian, static_jacobian; jacob_map_t contemporaneous_jacobian, static_jacobian;
// for each block contains pair<Size, Feddback_variable> // for each block contains pair<Size, Feddback_variable>
vector<pair<int, int> > blocks; vector<pair<int, int> > blocks;
@ -948,7 +948,7 @@ StaticModel::writeStaticMFile(const string &func_name) const
<< endl; << endl;
// Write Jacobian w.r. to endogenous only // Write Jacobian w.r. to endogenous only
for (first_derivatives_type::const_iterator it = first_derivatives.begin(); for (first_derivatives_t::const_iterator it = first_derivatives.begin();
it != first_derivatives.end(); it++) it != first_derivatives.end(); it++)
{ {
int eq = it->first.first; int eq = it->first.first;
@ -977,7 +977,7 @@ StaticModel::writeStaticMFile(const string &func_name) const
// Write Hessian w.r. to endogenous only (only if 2nd order derivatives have been computed) // Write Hessian w.r. to endogenous only (only if 2nd order derivatives have been computed)
int k = 0; // Keep the line of a 2nd derivative in v2 int k = 0; // Keep the line of a 2nd derivative in v2
for (second_derivatives_type::const_iterator it = second_derivatives.begin(); for (second_derivatives_t::const_iterator it = second_derivatives.begin();
it != second_derivatives.end(); it++) it != second_derivatives.end(); it++)
{ {
int eq = it->first.first; int eq = it->first.first;
@ -1195,14 +1195,14 @@ StaticModel::get_Derivatives(int block)
} }
void void
StaticModel::computeChainRuleJacobian(t_blocks_derivatives &blocks_derivatives) StaticModel::computeChainRuleJacobian(blocks_derivatives_t &blocks_derivatives)
{ {
map<int, NodeID> recursive_variables; map<int, NodeID> recursive_variables;
unsigned int nb_blocks = getNbBlocks(); unsigned int nb_blocks = getNbBlocks();
blocks_derivatives = t_blocks_derivatives(nb_blocks); blocks_derivatives = blocks_derivatives_t(nb_blocks);
for (unsigned int block = 0; block < nb_blocks; block++) for (unsigned int block = 0; block < nb_blocks; block++)
{ {
t_block_derivatives_equation_variable_laglead_nodeid tmp_derivatives; block_derivatives_equation_variable_laglead_nodeid_t tmp_derivatives;
recursive_variables.clear(); recursive_variables.clear();
BlockSimulationType simulation_type = getBlockSimulationType(block); BlockSimulationType simulation_type = getBlockSimulationType(block);
int block_size = getBlockSize(block); int block_size = getBlockSize(block);
@ -1210,7 +1210,7 @@ StaticModel::computeChainRuleJacobian(t_blocks_derivatives &blocks_derivatives)
int block_nb_recursives = block_size - block_nb_mfs; int block_nb_recursives = block_size - block_nb_mfs;
if (simulation_type == SOLVE_TWO_BOUNDARIES_COMPLETE || simulation_type == SOLVE_TWO_BOUNDARIES_SIMPLE) if (simulation_type == SOLVE_TWO_BOUNDARIES_COMPLETE || simulation_type == SOLVE_TWO_BOUNDARIES_SIMPLE)
{ {
blocks_derivatives.push_back(t_block_derivatives_equation_variable_laglead_nodeid(0)); blocks_derivatives.push_back(block_derivatives_equation_variable_laglead_nodeid_t(0));
for (int i = 0; i < block_nb_recursives; i++) for (int i = 0; i < block_nb_recursives; i++)
{ {
if (getBlockEquationType(block, i) == E_EVALUATE_S) if (getBlockEquationType(block, i) == E_EVALUATE_S)
@ -1247,7 +1247,7 @@ StaticModel::computeChainRuleJacobian(t_blocks_derivatives &blocks_derivatives)
else if (simulation_type == SOLVE_BACKWARD_SIMPLE || simulation_type == SOLVE_FORWARD_SIMPLE else if (simulation_type == SOLVE_BACKWARD_SIMPLE || simulation_type == SOLVE_FORWARD_SIMPLE
|| simulation_type == SOLVE_BACKWARD_COMPLETE || simulation_type == SOLVE_FORWARD_COMPLETE) || simulation_type == SOLVE_BACKWARD_COMPLETE || simulation_type == SOLVE_FORWARD_COMPLETE)
{ {
blocks_derivatives.push_back(t_block_derivatives_equation_variable_laglead_nodeid(0)); blocks_derivatives.push_back(block_derivatives_equation_variable_laglead_nodeid_t(0));
for (int i = 0; i < block_nb_recursives; i++) for (int i = 0; i < block_nb_recursives; i++)
{ {
if (getBlockEquationType(block, i) == E_EVALUATE_S) if (getBlockEquationType(block, i) == E_EVALUATE_S)
@ -1291,10 +1291,10 @@ StaticModel::collect_block_first_order_derivatives()
variable_2_block[getBlockVariableID(block, i)] = block; variable_2_block[getBlockVariableID(block, i)] = block;
} }
} }
derivative_endo = vector<t_derivative>(nb_blocks); derivative_endo = vector<derivative_t>(nb_blocks);
endo_max_leadlag_block = vector<pair<int, int> >(nb_blocks, make_pair(0, 0)); endo_max_leadlag_block = vector<pair<int, int> >(nb_blocks, make_pair(0, 0));
max_leadlag_block = vector<pair<int, int> >(nb_blocks, make_pair(0, 0)); max_leadlag_block = vector<pair<int, int> >(nb_blocks, make_pair(0, 0));
for (first_derivatives_type::iterator it2 = first_derivatives.begin(); for (first_derivatives_t::iterator it2 = first_derivatives.begin();
it2 != first_derivatives.end(); it2++) it2 != first_derivatives.end(); it2++)
{ {
int eq = it2->first.first; int eq = it2->first.first;
@ -1306,8 +1306,8 @@ StaticModel::collect_block_first_order_derivatives()
max_leadlag_block[block_eq] = make_pair(0, 0); max_leadlag_block[block_eq] = make_pair(0, 0);
endo_max_leadlag_block[block_eq] = make_pair(0, 0); endo_max_leadlag_block[block_eq] = make_pair(0, 0);
endo_max_leadlag_block[block_eq] = make_pair(0, 0); endo_max_leadlag_block[block_eq] = make_pair(0, 0);
t_derivative tmp_derivative; derivative_t tmp_derivative;
t_lag_var lag_var; lag_var_t lag_var;
if (getTypeByDerivID(it2->first.second) == eEndogenous && block_eq == block_var) if (getTypeByDerivID(it2->first.second) == eEndogenous && block_eq == block_var)
{ {
tmp_derivative = derivative_endo[block_eq]; tmp_derivative = derivative_endo[block_eq];
@ -1320,7 +1320,7 @@ StaticModel::collect_block_first_order_derivatives()
void void
StaticModel::writeChainRuleDerivative(ostream &output, int eqr, int varr, int lag, StaticModel::writeChainRuleDerivative(ostream &output, int eqr, int varr, int lag,
ExprNodeOutputType output_type, ExprNodeOutputType output_type,
const temporary_terms_type &temporary_terms) const const temporary_terms_t &temporary_terms) const
{ {
map<pair<int, pair<int, int> >, NodeID>::const_iterator it = first_chain_rule_derivatives.find(make_pair(eqr, make_pair(varr, lag))); map<pair<int, pair<int, int> >, NodeID>::const_iterator it = first_chain_rule_derivatives.find(make_pair(eqr, make_pair(varr, lag)));
if (it != first_chain_rule_derivatives.end()) if (it != first_chain_rule_derivatives.end())

View File

@ -37,15 +37,15 @@ private:
vector<pair<int, int> > inv_deriv_id_table; vector<pair<int, int> > inv_deriv_id_table;
//! Temporary terms for the file containing parameters dervicatives //! Temporary terms for the file containing parameters dervicatives
temporary_terms_type params_derivs_temporary_terms; temporary_terms_t params_derivs_temporary_terms;
//! Temporary terms for block decomposed models //! Temporary terms for block decomposed models
vector<vector<temporary_terms_type> > v_temporary_terms; vector<vector<temporary_terms_t> > v_temporary_terms;
vector<temporary_terms_inuse_type> v_temporary_terms_inuse; vector<temporary_terms_inuse_t> v_temporary_terms_inuse;
typedef map< pair< int, pair< int, int> >, NodeID> first_chain_rule_derivatives_type; typedef map< pair< int, pair< int, int> >, NodeID> first_chain_rule_derivatives_t;
first_chain_rule_derivatives_type first_chain_rule_derivatives; first_chain_rule_derivatives_t first_chain_rule_derivatives;
//! Writes static model file (standard Matlab version) //! Writes static model file (standard Matlab version)
void writeStaticMFile(const string &static_basename) const; void writeStaticMFile(const string &static_basename) const;
@ -61,10 +61,10 @@ private:
void writeModelEquationsOrdered_M(const string &dynamic_basename) const; void writeModelEquationsOrdered_M(const string &dynamic_basename) const;
//! Writes the code of the Block reordred structure of the model in virtual machine bytecode //! Writes the code of the Block reordred structure of the model in virtual machine bytecode
void writeModelEquationsCode_Block(const string file_name, const string bin_basename, map_idx_type map_idx) const; void writeModelEquationsCode_Block(const string file_name, const string bin_basename, map_idx_t map_idx) const;
//! Writes the code of the model in virtual machine bytecode //! Writes the code of the model in virtual machine bytecode
void writeModelEquationsCode(const string file_name, const string bin_basename, map_idx_type map_idx) const; void writeModelEquationsCode(const string file_name, const string bin_basename, map_idx_t map_idx) const;
//! Computes jacobian and prepares for equation normalization //! Computes jacobian and prepares for equation normalization
@ -72,9 +72,9 @@ private:
- computes the jacobian for the model w.r. to contemporaneous variables - computes the jacobian for the model w.r. to contemporaneous variables
- removes edges of the incidence matrix when derivative w.r. to the corresponding variable is too close to zero (below the cutoff) - removes edges of the incidence matrix when derivative w.r. to the corresponding variable is too close to zero (below the cutoff)
*/ */
void evaluateJacobian(const eval_context_type &eval_context, jacob_map *j_m, bool dynamic); void evaluateJacobian(const eval_context_t &eval_context, jacob_map_t *j_m, bool dynamic);
map_idx_type map_idx; map_idx_t map_idx;
//! sorts the temporary terms in the blocks order //! sorts the temporary terms in the blocks order
void computeTemporaryTermsOrdered(); void computeTemporaryTermsOrdered();
@ -82,9 +82,9 @@ private:
void computeTemporaryTermsMapping(); void computeTemporaryTermsMapping();
//! Write derivative code of an equation w.r. to a variable //! Write derivative code of an equation w.r. to a variable
void compileDerivative(ofstream &code_file, int eq, int symb_id, map_idx_type &map_idx) const; void compileDerivative(ofstream &code_file, int eq, int symb_id, map_idx_t &map_idx) const;
//! Write chain rule derivative code of an equation w.r. to a variable //! Write chain rule derivative code of an equation w.r. to a variable
void compileChainRuleDerivative(ofstream &code_file, int eq, int var, int lag, map_idx_type &map_idx) const; void compileChainRuleDerivative(ofstream &code_file, int eq, int var, int lag, map_idx_t &map_idx) const;
//! Get the type corresponding to a derivation ID //! Get the type corresponding to a derivation ID
virtual SymbolType getTypeByDerivID(int deriv_id) const throw (UnknownDerivIDException); virtual SymbolType getTypeByDerivID(int deriv_id) const throw (UnknownDerivIDException);
@ -97,7 +97,7 @@ private:
//! return a map on the block jacobian //! return a map on the block jacobian
map<pair<pair<int, pair<int, int> >, pair<int, int> >, int> get_Derivatives(int block); map<pair<pair<int, pair<int, int> >, pair<int, int> >, int> get_Derivatives(int block);
//! Computes chain rule derivatives of the Jacobian w.r. to endogenous variables //! Computes chain rule derivatives of the Jacobian w.r. to endogenous variables
void computeChainRuleJacobian(t_blocks_derivatives &blocks_derivatives); void computeChainRuleJacobian(blocks_derivatives_t &blocks_derivatives);
//! Collect only the first derivatives //! Collect only the first derivatives
map<pair<int, pair<int, int> >, NodeID> collect_first_order_derivatives_endogenous(); map<pair<int, pair<int, int> >, NodeID> collect_first_order_derivatives_endogenous();
@ -110,7 +110,7 @@ private:
void hessianHelper(ostream &output, int row_nb, int col_nb, ExprNodeOutputType output_type) const; void hessianHelper(ostream &output, int row_nb, int col_nb, ExprNodeOutputType output_type) const;
//! Write chain rule derivative of a recursive equation w.r. to a variable //! Write chain rule derivative of a recursive equation w.r. to a variable
void writeChainRuleDerivative(ostream &output, int eq, int var, int lag, ExprNodeOutputType output_type, const temporary_terms_type &temporary_terms) const; void writeChainRuleDerivative(ostream &output, int eq, int var, int lag, ExprNodeOutputType output_type, const temporary_terms_t &temporary_terms) const;
//! Collecte the derivatives w.r. to endogenous of the block, to endogenous of previouys blocks and to exogenous //! Collecte the derivatives w.r. to endogenous of the block, to endogenous of previouys blocks and to exogenous
void collect_block_first_order_derivatives(); void collect_block_first_order_derivatives();
@ -123,29 +123,29 @@ protected:
vector<int> equation_reordered, variable_reordered, inv_equation_reordered, inv_variable_reordered; vector<int> equation_reordered, variable_reordered, inv_equation_reordered, inv_variable_reordered;
//! Vector describing equations: BlockSimulationType, if BlockSimulationType == EVALUATE_s then a NodeID on the new normalized equation //! Vector describing equations: BlockSimulationType, if BlockSimulationType == EVALUATE_s then a NodeID on the new normalized equation
t_equation_type_and_normalized_equation equation_type_and_normalized_equation; equation_type_and_normalized_equation_t equation_type_and_normalized_equation;
//! for each block contains pair< Simulation_Type, pair < Block_Size, Recursive_part_Size > > //! for each block contains pair< Simulation_Type, pair < Block_Size, Recursive_part_Size > >
t_block_type_firstequation_size_mfs block_type_firstequation_size_mfs; block_type_firstequation_size_mfs_t block_type_firstequation_size_mfs;
//! for all blocks derivatives description //! for all blocks derivatives description
t_blocks_derivatives blocks_derivatives; blocks_derivatives_t blocks_derivatives;
//! The jacobian without the elements below the cutoff //! The jacobian without the elements below the cutoff
dynamic_jacob_map dynamic_jacobian; dynamic_jacob_map_t dynamic_jacobian;
//! Vector indicating if the block is linear in endogenous variable (true) or not (false) //! Vector indicating if the block is linear in endogenous variable (true) or not (false)
vector<bool> blocks_linear; vector<bool> blocks_linear;
//! Map the derivatives for a block pair<lag, make_pair(make_pair(eq, var)), NodeID> //! Map the derivatives for a block pair<lag, make_pair(make_pair(eq, var)), NodeID>
typedef map<pair< int, pair<int, int> >, NodeID> t_derivative; typedef map<pair< int, pair<int, int> >, NodeID> derivative_t;
//! Vector of derivative for each blocks //! Vector of derivative for each blocks
vector<t_derivative> derivative_endo, derivative_other_endo, derivative_exo, derivative_exo_det; vector<derivative_t> derivative_endo, derivative_other_endo, derivative_exo, derivative_exo_det;
//!List for each block and for each lag-leag all the other endogenous variables and exogenous variables //!List for each block and for each lag-leag all the other endogenous variables and exogenous variables
typedef set<int> t_var; typedef set<int> var_t;
typedef map<int, t_var> t_lag_var; typedef map<int, var_t> lag_var_t;
vector<t_lag_var> other_endo_block, exo_block, exo_det_block; vector<lag_var_t> other_endo_block, exo_block, exo_det_block;
//!Maximum lead and lag for each block on endogenous of the block, endogenous of the previous blocks, exogenous and deterministic exogenous //!Maximum lead and lag for each block on endogenous of the block, endogenous of the previous blocks, exogenous and deterministic exogenous
vector<pair<int, int> > endo_max_leadlag_block, other_endo_max_leadlag_block, exo_max_leadlag_block, exo_det_max_leadlag_block, max_leadlag_block; vector<pair<int, int> > endo_max_leadlag_block, other_endo_max_leadlag_block, exo_max_leadlag_block, exo_det_max_leadlag_block, max_leadlag_block;
@ -175,7 +175,7 @@ public:
\param eval_context evaluation context for normalization \param eval_context evaluation context for normalization
\param no_tmp_terms if true, no temporary terms will be computed in the static files \param no_tmp_terms if true, no temporary terms will be computed in the static files
*/ */
void computingPass(const eval_context_type &eval_context, bool no_tmp_terms, bool hessian, bool block, bool bytecode); void computingPass(const eval_context_t &eval_context, bool no_tmp_terms, bool hessian, bool block, bool bytecode);
//! Adds informations for simulation in a binary file for a block decomposed model //! Adds informations for simulation in a binary file for a block decomposed model
void Write_Inf_To_Bin_File_Block(const string &static_basename, const string &bin_basename, const int &num, void Write_Inf_To_Bin_File_Block(const string &static_basename, const string &bin_basename, const int &num,