Commit 0a816a4e authored by ferhat's avatar ferhat

New options for block decomposition and bytecode (see http://www.dynare.org/DynareWiki/ByteCode):

- the options "sparse_dll" and "sparse" are no more available. They are replaced by combinations of block (for block decomposition) and bytecode (for model stored in a binary file)
- markowitz is now an option of simul and steady commands


git-svn-id: https://www.dynare.org/svn/dynare/trunk@2873 ac1d8469-bf42-47a9-8791-bf33cf982152
parent a693b831
...@@ -129,7 +129,10 @@ BlockTriangular::Compute_Normalization(bool *IM, int equation_number, int prolog ...@@ -129,7 +129,10 @@ BlockTriangular::Compute_Normalization(bool *IM, int equation_number, int prolog
for (int i = 0; i < n; i++) for (int i = 0; i < n; i++)
for (int j = 0; j < n; j++) for (int j = 0; j < n; j++)
if (IM0[(i+prologue) * equation_number+j+prologue]) if (IM0[(i+prologue) * equation_number+j+prologue])
add_edge(i + n, j, g); {
//printf("equation=%3d variable=%3d\n",i,j);
add_edge(i + n, j, g);
}
// Compute maximum cardinality matching // Compute maximum cardinality matching
typedef vector<graph_traits<BipartiteGraph>::vertex_descriptor> mate_map_t; typedef vector<graph_traits<BipartiteGraph>::vertex_descriptor> mate_map_t;
...@@ -931,10 +934,7 @@ BlockTriangular::Normalize_and_BlockDecompose(bool *IM, Model_Block *ModelBlock, ...@@ -931,10 +934,7 @@ BlockTriangular::Normalize_and_BlockDecompose(bool *IM, Model_Block *ModelBlock,
int count_Block, count_Equ; int count_Block, count_Equ;
bool *SIM0, *SIM00; bool *SIM0, *SIM00;
SIM0 = (bool *) malloc(n * n * sizeof(bool));
memcpy(SIM0, IM_0, n*n*sizeof(bool));
Prologue_Epilogue(IM, prologue, epilogue, n, Index_Var_IM, Index_Equ_IM, SIM0);
free(SIM0);
int counted = 0; int counted = 0;
if (prologue+epilogue < n) if (prologue+epilogue < n)
...@@ -963,8 +963,10 @@ BlockTriangular::Normalize_and_BlockDecompose(bool *IM, Model_Block *ModelBlock, ...@@ -963,8 +963,10 @@ BlockTriangular::Normalize_and_BlockDecompose(bool *IM, Model_Block *ModelBlock,
memset(SIM0, 0, n*n*sizeof(bool)); memset(SIM0, 0, n*n*sizeof(bool));
SIM00 = (bool *) malloc(n * n * sizeof(bool)); SIM00 = (bool *) malloc(n * n * sizeof(bool));
memset(SIM00, 0, n*n*sizeof(bool)); memset(SIM00, 0, n*n*sizeof(bool));
//cout << "---------------------------------\n";
for (map< pair< int, int >, double >::iterator iter = j_m.begin(); iter != j_m.end(); iter++) for (map< pair< int, int >, double >::iterator iter = j_m.begin(); iter != j_m.end(); iter++)
{ {
//printf("iter->second=% 1.10f iter->first.first=%3d iter->first.second=%3d bi=%f\n", iter->second, iter->first.first, iter->first.second, bi);
if (fabs(iter->second) > max(bi, cutoff)) if (fabs(iter->second) > max(bi, cutoff))
{ {
SIM0[iter->first.first*n+iter->first.second] = 1; SIM0[iter->first.first*n+iter->first.second] = 1;
...@@ -999,6 +1001,11 @@ BlockTriangular::Normalize_and_BlockDecompose(bool *IM, Model_Block *ModelBlock, ...@@ -999,6 +1001,11 @@ BlockTriangular::Normalize_and_BlockDecompose(bool *IM, Model_Block *ModelBlock,
} }
} }
SIM0 = (bool *) malloc(n * n * sizeof(bool));
memcpy(SIM0, IM_0, n*n*sizeof(bool));
Prologue_Epilogue(IM, prologue, epilogue, n, Index_Var_IM, Index_Equ_IM, SIM0);
free(SIM0);
V_Equation_Type = Equation_Type_determination(equations, first_order_endo_derivatives, Index_Var_IM, Index_Equ_IM, mfs); V_Equation_Type = Equation_Type_determination(equations, first_order_endo_derivatives, Index_Var_IM, Index_Equ_IM, mfs);
cout << "Finding the optimal block decomposition of the model ...\n"; cout << "Finding the optimal block decomposition of the model ...\n";
......
...@@ -35,10 +35,6 @@ SteadyStatement::SteadyStatement(const OptionsList &options_list_arg, StaticDllM ...@@ -35,10 +35,6 @@ SteadyStatement::SteadyStatement(const OptionsList &options_list_arg, StaticDllM
void void
SteadyStatement::checkPass(ModFileStructure &mod_file_struct) SteadyStatement::checkPass(ModFileStructure &mod_file_struct)
{ {
if (options_list.num_options.find("block_mfs") != options_list.num_options.end())
mod_file_struct.steady_block_mfs_option = true;
else if (options_list.num_options.find("block_mfs_dll") != options_list.num_options.end())
mod_file_struct.steady_block_mfs_dll_option = true;
} }
void void
...@@ -86,8 +82,8 @@ void ModelInfoStatement::writeOutput(ostream &output, const string &basename) co ...@@ -86,8 +82,8 @@ void ModelInfoStatement::writeOutput(ostream &output, const string &basename) co
} }
SimulStatement::SimulStatement(const OptionsList &options_list_arg, DynamicModel::mode_t mode_arg) : SimulStatement::SimulStatement(const OptionsList &options_list_arg, DynamicModel::mode_t mode_arg, bool block_arg, bool byte_code_arg) :
options_list(options_list_arg), mode(mode_arg) options_list(options_list_arg), mode(mode_arg), byte_code(byte_code_arg), block(block_arg)
{ {
} }
...@@ -101,7 +97,7 @@ void ...@@ -101,7 +97,7 @@ void
SimulStatement::writeOutput(ostream &output, const string &basename) const SimulStatement::writeOutput(ostream &output, const string &basename) const
{ {
options_list.writeOutput(output); options_list.writeOutput(output);
if (mode == DynamicModel::eStandardMode || mode == DynamicModel::eDLLMode) if ((mode == DynamicModel::eStandardMode || mode == DynamicModel::eDLLMode) && !block)
output << "simul(oo_.dr);\n"; output << "simul(oo_.dr);\n";
else else
{ {
...@@ -113,7 +109,7 @@ SimulStatement::writeOutput(ostream &output, const string &basename) const ...@@ -113,7 +109,7 @@ SimulStatement::writeOutput(ostream &output, const string &basename) const
<< " read_data_;" << endl << " read_data_;" << endl
<< " end" << endl << " end" << endl
<< "end" << endl; << "end" << endl;
if (mode == DynamicModel::eSparseDLLMode) if (byte_code)
output << "oo_.endo_simul=simulate;" << endl; output << "oo_.endo_simul=simulate;" << endl;
else else
output << basename << "_dynamic;" << endl; output << basename << "_dynamic;" << endl;
...@@ -922,7 +918,7 @@ PlannerObjectiveStatement::computingPass() ...@@ -922,7 +918,7 @@ PlannerObjectiveStatement::computingPass()
void void
PlannerObjectiveStatement::writeOutput(ostream &output, const string &basename) const PlannerObjectiveStatement::writeOutput(ostream &output, const string &basename) const
{ {
model_tree->writeStaticFile(basename + "_objective"); model_tree->writeStaticFile(basename + "_objective", false);
} }
BVARDensityStatement::BVARDensityStatement(int maxnlags_arg, const OptionsList &options_list_arg) : BVARDensityStatement::BVARDensityStatement(int maxnlags_arg, const OptionsList &options_list_arg) :
......
...@@ -54,8 +54,10 @@ class SimulStatement : public Statement ...@@ -54,8 +54,10 @@ class SimulStatement : public Statement
private: private:
const OptionsList options_list; const OptionsList options_list;
const DynamicModel::mode_t mode; const DynamicModel::mode_t mode;
const bool byte_code;
const bool block;
public: public:
SimulStatement(const OptionsList &options_list_arg, DynamicModel::mode_t mode_arg); SimulStatement(const OptionsList &options_list_arg, DynamicModel::mode_t mode_arg, bool block_arg, bool byte_code_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;
}; };
......
...@@ -337,6 +337,7 @@ DynamicModel::writeModelEquationsOrdered_M( Model_Block *ModelBlock, const strin ...@@ -337,6 +337,7 @@ DynamicModel::writeModelEquationsOrdered_M( Model_Block *ModelBlock, const strin
<< " % // Simulation type " << " % // Simulation type "
<< BlockTriangular::BlockSim(ModelBlock->Block_List[j].Simulation_Type) << " //" << endl << BlockTriangular::BlockSim(ModelBlock->Block_List[j].Simulation_Type) << " //" << endl
<< " % ////////////////////////////////////////////////////////////////////////" << endl; << " % ////////////////////////////////////////////////////////////////////////" << endl;
output << " global options_;" << endl;
//The Temporary terms //The Temporary terms
//output << " relax = 1;\n"; //output << " relax = 1;\n";
if (ModelBlock->Block_List[j].Simulation_Type==EVALUATE_BACKWARD if (ModelBlock->Block_List[j].Simulation_Type==EVALUATE_BACKWARD
...@@ -359,9 +360,9 @@ DynamicModel::writeModelEquationsOrdered_M( Model_Block *ModelBlock, const strin ...@@ -359,9 +360,9 @@ DynamicModel::writeModelEquationsOrdered_M( Model_Block *ModelBlock, const strin
output << " else\n"; output << " else\n";
if (ModelBlock->Block_List[j].Simulation_Type==SOLVE_TWO_BOUNDARIES_COMPLETE || ModelBlock->Block_List[j].Simulation_Type==SOLVE_TWO_BOUNDARIES_SIMPLE) if (ModelBlock->Block_List[j].Simulation_Type==SOLVE_TWO_BOUNDARIES_COMPLETE || ModelBlock->Block_List[j].Simulation_Type==SOLVE_TWO_BOUNDARIES_SIMPLE)
{ {
output << " g1 = spalloc(" << (ModelBlock->Block_List[j].Size-ModelBlock->Block_List[j].Nb_Recursives)*ModelBlock->Periods output << " g1 = spalloc(" << (ModelBlock->Block_List[j].Size-ModelBlock->Block_List[j].Nb_Recursives) << "*options_.periods, "
<< ", " << (ModelBlock->Block_List[j].Size-ModelBlock->Block_List[j].Nb_Recursives)*(ModelBlock->Periods+ModelBlock->Block_List[j].Max_Lag+ModelBlock->Block_List[j].Max_Lead+1) << (ModelBlock->Block_List[j].Size-ModelBlock->Block_List[j].Nb_Recursives) << "*(options_.periods+" << ModelBlock->Block_List[j].Max_Lag+ModelBlock->Block_List[j].Max_Lead+1 << ")"
<< ", " << nze*ModelBlock->Periods << ");\n"; << ", " << nze << "*options_.periods);\n";
/*output << " g1_tmp_r = spalloc(" << (ModelBlock->Block_List[j].Nb_Recursives) /*output << " g1_tmp_r = spalloc(" << (ModelBlock->Block_List[j].Nb_Recursives)
<< ", " << (ModelBlock->Block_List[j].Size)*(ModelBlock->Block_List[j].Max_Lag+ModelBlock->Block_List[j].Max_Lead+1) << ", " << (ModelBlock->Block_List[j].Size)*(ModelBlock->Block_List[j].Max_Lag+ModelBlock->Block_List[j].Max_Lead+1)
<< ", " << nze << ");\n"; << ", " << nze << ");\n";
...@@ -1278,7 +1279,6 @@ DynamicModel::Write_Inf_To_Bin_File(const string &dynamic_basename, const string ...@@ -1278,7 +1279,6 @@ DynamicModel::Write_Inf_To_Bin_File(const string &dynamic_basename, const string
} }
/*for (int m=0;m<=block_triangular.ModelBlock->Block_List[num].Max_Lead+block_triangular.ModelBlock->Block_List[num].Max_Lag;m++) /*for (int m=0;m<=block_triangular.ModelBlock->Block_List[num].Max_Lead+block_triangular.ModelBlock->Block_List[num].Max_Lag;m++)
{ {
int k1=m-block_triangular.ModelBlock->Block_List[num].Max_Lag; int k1=m-block_triangular.ModelBlock->Block_List[num].Max_Lag;
...@@ -1296,10 +1296,10 @@ DynamicModel::Write_Inf_To_Bin_File(const string &dynamic_basename, const string ...@@ -1296,10 +1296,10 @@ DynamicModel::Write_Inf_To_Bin_File(const string &dynamic_basename, const string
}*/ }*/
if (is_two_boundaries) if (is_two_boundaries)
{ {
for (j=0;j<Size;j++) /*for (j=0;j<Size;j++)
{ {
int eqr1=j; int eqr1=j;
int varr=/*block_triangular.ModelBlock->Block_List[num].Size*/Size*(block_triangular.periods int varr=Size*(block_triangular.periods
+block_triangular.incidencematrix.Model_Max_Lead_Endo); +block_triangular.incidencematrix.Model_Max_Lead_Endo);
int k1=0; int k1=0;
SaveCode.write(reinterpret_cast<char *>(&eqr1), sizeof(eqr1)); SaveCode.write(reinterpret_cast<char *>(&eqr1), sizeof(eqr1));
...@@ -1307,7 +1307,8 @@ DynamicModel::Write_Inf_To_Bin_File(const string &dynamic_basename, const string ...@@ -1307,7 +1307,8 @@ DynamicModel::Write_Inf_To_Bin_File(const string &dynamic_basename, const string
SaveCode.write(reinterpret_cast<char *>(&k1), sizeof(k1)); SaveCode.write(reinterpret_cast<char *>(&k1), sizeof(k1));
SaveCode.write(reinterpret_cast<char *>(&eqr1), sizeof(eqr1)); SaveCode.write(reinterpret_cast<char *>(&eqr1), sizeof(eqr1));
u_count_int++; u_count_int++;
} }*/
u_count_int+=Size;
} }
//cout << "u_count_int=" << u_count_int << "\n"; //cout << "u_count_int=" << u_count_int << "\n";
for (j=block_triangular.ModelBlock->Block_List[num].Nb_Recursives;j<block_triangular.ModelBlock->Block_List[num].Size;j++) for (j=block_triangular.ModelBlock->Block_List[num].Nb_Recursives;j<block_triangular.ModelBlock->Block_List[num].Size;j++)
...@@ -1687,7 +1688,7 @@ DynamicModel::writeDynamicModel(ostream &DynamicOutput) const ...@@ -1687,7 +1688,7 @@ DynamicModel::writeDynamicModel(ostream &DynamicOutput) const
ostringstream hessian_output; // Used for storing Hessian equations ostringstream hessian_output; // Used for storing Hessian equations
ostringstream third_derivatives_output; ostringstream third_derivatives_output;
ExprNodeOutputType output_type = (mode == eStandardMode || mode==eSparseMode ? oMatlabDynamicModel : oCDynamicModel); ExprNodeOutputType output_type = (mode != eDLLMode ? oMatlabDynamicModel : oCDynamicModel);
writeModelLocalVariables(model_output, output_type); writeModelLocalVariables(model_output, output_type);
...@@ -1889,12 +1890,12 @@ DynamicModel::writeDynamicModel(ostream &DynamicOutput) const ...@@ -1889,12 +1890,12 @@ DynamicModel::writeDynamicModel(ostream &DynamicOutput) const
} }
void void
DynamicModel::writeOutput(ostream &output, const string &basename) const DynamicModel::writeOutput(ostream &output, const string &basename, bool block) const
{ {
output << "options_.model_mode = " << mode << ";" << endl; output << "options_.model_mode = " << mode << ";" << endl;
// Erase possible remnants of previous runs // Erase possible remnants of previous runs
if (mode != eStandardMode) if (mode != eStandardMode || block)
output << "delete('" << basename << "_dynamic.m');" << endl; output << "delete('" << basename << "_dynamic.m');" << endl;
if (mode != eDLLMode) if (mode != eDLLMode)
output << "erase_compiled_function('" + basename + "_dynamic');" << endl; output << "erase_compiled_function('" + basename + "_dynamic');" << endl;
...@@ -1902,7 +1903,7 @@ DynamicModel::writeOutput(ostream &output, const string &basename) const ...@@ -1902,7 +1903,7 @@ DynamicModel::writeOutput(ostream &output, const string &basename) const
// Special setup for DLL or Sparse modes // Special setup for DLL or Sparse modes
if (mode == eDLLMode) if (mode == eDLLMode)
output << "mex -O LDFLAGS='-pthread -shared -Wl,--no-undefined' " << basename << "_dynamic.c" << endl; output << "mex -O LDFLAGS='-pthread -shared -Wl,--no-undefined' " << basename << "_dynamic.c" << endl;
if (mode == eSparseMode || mode == eSparseDLLMode) if (block)
output << "addpath " << basename << ";" << endl; output << "addpath " << basename << ";" << endl;
/* Writing initialisation for M_.lead_lag_incidence matrix /* Writing initialisation for M_.lead_lag_incidence matrix
...@@ -1938,7 +1939,7 @@ DynamicModel::writeOutput(ostream &output, const string &basename) const ...@@ -1938,7 +1939,7 @@ DynamicModel::writeOutput(ostream &output, const string &basename) const
output << "]';" << endl; output << "]';" << endl;
//In case of sparse model, writes the block structure of the model //In case of sparse model, writes the block structure of the model
if (mode==eSparseMode || mode==eSparseDLLMode) if (block)
{ {
//int prev_Simulation_Type=-1; //int prev_Simulation_Type=-1;
//bool skip_the_head; //bool skip_the_head;
...@@ -2137,9 +2138,9 @@ DynamicModel::writeOutput(ostream &output, const string &basename) const ...@@ -2137,9 +2138,9 @@ DynamicModel::writeOutput(ostream &output, const string &basename) const
} }
void void
DynamicModel::writeOutputPostComputing(ostream &output, const string &basename) const DynamicModel::writeOutputPostComputing(ostream &output, const string &basename, bool block) const
{ {
if (mode == eSparseMode || mode == eSparseDLLMode) if (block)
output << "rmpath " << basename << ";" << endl; output << "rmpath " << basename << ";" << endl;
} }
...@@ -2300,7 +2301,7 @@ DynamicModel::collect_first_order_derivatives_endogenous() ...@@ -2300,7 +2301,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) const eval_context_type &eval_context, bool no_tmp_terms, bool block)
{ {
assert(jacobianExo || !(hessian || thirdDerivatives || paramsDerivatives)); assert(jacobianExo || !(hessian || thirdDerivatives || paramsDerivatives));
...@@ -2343,7 +2344,7 @@ DynamicModel::computingPass(bool jacobianExo, bool hessian, bool thirdDerivative ...@@ -2343,7 +2344,7 @@ DynamicModel::computingPass(bool jacobianExo, bool hessian, bool thirdDerivative
computeThirdDerivatives(vars); computeThirdDerivatives(vars);
} }
if (mode == eSparseDLLMode || mode == eSparseMode) if (block)
{ {
BuildIncidenceMatrix(); BuildIncidenceMatrix();
...@@ -2375,10 +2376,48 @@ DynamicModel::computingPass(bool jacobianExo, bool hessian, bool thirdDerivative ...@@ -2375,10 +2376,48 @@ DynamicModel::computingPass(bool jacobianExo, bool hessian, bool thirdDerivative
} }
void void
DynamicModel::writeDynamicFile(const string &basename) const DynamicModel::writeDynamicFile(const string &basename, bool block, bool bytecode) const
{ {
int r; int r;
switch (mode) if(block && bytecode)
{
#ifdef _WIN32
r = mkdir(basename.c_str());
#else
r = mkdir(basename.c_str(), 0777);
#endif
if (r < 0 && errno != EEXIST)
{
perror("ERROR");
exit(EXIT_FAILURE);
}
writeModelEquationsCodeOrdered(basename + "_dynamic", block_triangular.ModelBlock, basename, map_idx);
block_triangular.Free_Block(block_triangular.ModelBlock);
block_triangular.incidencematrix.Free_IM();
//block_triangular.Free_IM_X(block_triangular.First_IM_X);
}
else if(block && !bytecode)
{
#ifdef _WIN32
r = mkdir(basename.c_str());
#else
r = mkdir(basename.c_str(), 0777);
#endif
if (r < 0 && errno != EEXIST)
{
perror("ERROR");
exit(EXIT_FAILURE);
}
writeSparseDynamicMFile(basename + "_dynamic", basename, mode);
block_triangular.Free_Block(block_triangular.ModelBlock);
block_triangular.incidencematrix.Free_IM();
//block_triangular.Free_IM_X(block_triangular.First_IM_X);
}
else if (mode == eDLLMode)
writeDynamicCFile(basename + "_dynamic");
else if (mode == eStandardMode)
writeDynamicMFile(basename + "_dynamic");
/*switch (mode)
{ {
case eStandardMode: case eStandardMode:
writeDynamicMFile(basename + "_dynamic"); writeDynamicMFile(basename + "_dynamic");
...@@ -2419,7 +2458,7 @@ DynamicModel::writeDynamicFile(const string &basename) const ...@@ -2419,7 +2458,7 @@ DynamicModel::writeDynamicFile(const string &basename) const
block_triangular.incidencematrix.Free_IM(); block_triangular.incidencematrix.Free_IM();
//block_triangular.Free_IM_X(block_triangular.First_IM_X); //block_triangular.Free_IM_X(block_triangular.First_IM_X);
break; break;
} }*/
} }
void void
......
...@@ -36,9 +36,9 @@ public: ...@@ -36,9 +36,9 @@ public:
enum mode_t enum mode_t
{ {
eStandardMode, //!< Standard mode (dynamic file in Matlab) eStandardMode, //!< Standard mode (dynamic file in Matlab)
eSparseMode, //!< Sparse mode (dynamic file in Matlab with block decomposition) //eSparseMode, //!< Sparse mode (dynamic file in Matlab with block decomposition)
eDLLMode, //!< DLL mode (dynamic file in C) eDLLMode //!< DLL mode (dynamic file in C)
eSparseDLLMode //!< Sparse DLL mode (dynamic file in C with block decomposition plus a binary file) //eSparseDLLMode //!< Sparse DLL mode (dynamic file in C with block decomposition plus a binary file)
}; };
private: private:
typedef map<pair<int, int>, int> deriv_id_table_t; typedef map<pair<int, int>, int> deriv_id_table_t;
...@@ -174,18 +174,18 @@ public: ...@@ -174,18 +174,18 @@ 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); const eval_context_type &eval_context, bool no_tmp_terms, bool block);
//! 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) const; void writeOutput(ostream &output, const string &basename, bool block) const;
//! Write statements to be added to the main M-file, after computational tasks //! Write statements to be added to the main M-file, after computational tasks
void writeOutputPostComputing(ostream &output, const string &basename) const; void writeOutputPostComputing(ostream &output, const string &basename, bool block) const;
//! Complete set to block decompose the model //! Complete set to block decompose the model
BlockTriangular block_triangular; BlockTriangular block_triangular;
//! Adds informations for simulation in a binary file //! Adds informations for simulation in a binary file
void Write_Inf_To_Bin_File(const string &dynamic_basename, const string &bin_basename, void Write_Inf_To_Bin_File(const string &dynamic_basename, const string &bin_basename,
const int &num, int &u_count_int, bool &file_open, bool is_two_boundaries) const; const int &num, int &u_count_int, bool &file_open, bool is_two_boundaries) const;
//! Writes dynamic model file //! Writes dynamic model file
void writeDynamicFile(const string &basename) const; void writeDynamicFile(const string &basename, bool block, bool bytecode) const;
//! Writes file containing parameters derivatives //! Writes file containing parameters derivatives
void writeParamsDerivativesFile(const string &basename) const; void writeParamsDerivativesFile(const string &basename) const;
//! Converts to static model (only the equations) //! Converts to static model (only the equations)
......
...@@ -87,11 +87,11 @@ class ParsingDriver; ...@@ -87,11 +87,11 @@ class ParsingDriver;
%} %}
%token AR AUTOCORR %token AR AUTOCORR
%token BAYESIAN_IRF BETA_PDF BICGSTAB BLOCK_MFS BLOCK_MFS_DLL %token BAYESIAN_IRF BETA_PDF BICGSTAB BLOCK
%token BVAR_DENSITY BVAR_FORECAST %token BVAR_DENSITY BVAR_FORECAST
%token BVAR_PRIOR_DECAY BVAR_PRIOR_FLAT BVAR_PRIOR_LAMBDA %token BVAR_PRIOR_DECAY BVAR_PRIOR_FLAT BVAR_PRIOR_LAMBDA
%token BVAR_PRIOR_MU BVAR_PRIOR_OMEGA BVAR_PRIOR_TAU BVAR_PRIOR_TRAIN %token BVAR_PRIOR_MU BVAR_PRIOR_OMEGA BVAR_PRIOR_TAU BVAR_PRIOR_TRAIN
%token BVAR_REPLIC %token BVAR_REPLIC BYTECODE
%token CALIB CALIB_VAR CHANGE_TYPE CHECK CONF_SIG CONSTANT CORR COVAR CUTOFF %token CALIB CALIB_VAR CHANGE_TYPE CHECK CONF_SIG CONSTANT CORR COVAR CUTOFF
%token DATAFILE DR_ALGO DROP DSAMPLE DYNASAVE DYNATYPE %token DATAFILE DR_ALGO DROP DSAMPLE DYNASAVE DYNATYPE
%token END ENDVAL EQUAL ESTIMATION ESTIMATED_PARAMS ESTIMATED_PARAMS_BOUNDS ESTIMATED_PARAMS_INIT %token END ENDVAL EQUAL ESTIMATION ESTIMATED_PARAMS ESTIMATED_PARAMS_BOUNDS ESTIMATED_PARAMS_INIT
...@@ -119,7 +119,7 @@ class ParsingDriver; ...@@ -119,7 +119,7 @@ class ParsingDriver;
%token QZ_CRITERIUM %token QZ_CRITERIUM
%token RELATIVE_IRF REPLIC RPLOT SAVE_PARAMS_AND_STEADY_STATE %token RELATIVE_IRF REPLIC RPLOT SAVE_PARAMS_AND_STEADY_STATE
%token SHOCKS SIGMA_E SIMUL SIMUL_ALGO SIMUL_SEED SMOOTHER SOLVE_ALGO %token SHOCKS SIGMA_E SIMUL SIMUL_ALGO SIMUL_SEED SMOOTHER SOLVE_ALGO
%token SPARSE SPARSE_DLL STDERR STEADY STOCH_SIMUL %token STDERR STEADY STOCH_SIMUL
%token TEX RAMSEY_POLICY PLANNER_DISCOUNT %token TEX RAMSEY_POLICY PLANNER_DISCOUNT
%token <string_val> TEX_NAME %token <string_val> TEX_NAME
%token UNIFORM_PDF UNIT_ROOT_VARS USE_DLL SHOCK_DECOMPOSITION LABELS %token UNIFORM_PDF UNIT_ROOT_VARS USE_DLL SHOCK_DECOMPOSITION LABELS
...@@ -143,8 +143,8 @@ class ParsingDriver; ...@@ -143,8 +143,8 @@ class ParsingDriver;
%token FREQ INITIAL_YEAR INITIAL_SUBPERIOD FINAL_YEAR FINAL_SUBPERIOD DATA VLIST VARLIST VLISTLOG VLISTPER %token FREQ INITIAL_YEAR INITIAL_SUBPERIOD FINAL_YEAR FINAL_SUBPERIOD DATA VLIST VARLIST VLISTLOG VLISTPER
%token RESTRICTION_FNAME NLAGS CROSS_RESTRICTIONS CONTEMP_REDUCED_FORM REAL_PSEUDO_FORECAST BAYESIAN_PRIOR %token RESTRICTION_FNAME NLAGS CROSS_RESTRICTIONS CONTEMP_REDUCED_FORM REAL_PSEUDO_FORECAST BAYESIAN_PRIOR
%token DUMMY_OBS NSTATES INDXSCALESSTATES ALPHA BETA GSIG2_LMD GSIG2_LMDM Q_DIAG FLAT_PRIOR NCSK NSTD NINV %token DUMMY_OBS NSTATES INDXSCALESSTATES ALPHA BETA GSIG2_LMD GSIG2_LMDM Q_DIAG FLAT_PRIOR NCSK NSTD NINV
%token INDXPARR INDXOVR ABAND INDXAP APBAND INDXIMF IMFBAND INDXFORE FOREBAND INDXGFOREHAT INDXGIMFHAT %token INDXPARR INDXOVR ABAND INDXAP APBAND INDXIMF IMFBAND INDXFORE FOREBAND INDXGFOREHAT INDXGIMFHAT
%token INDXESTIMA INDXGDLS EQ_MS CMS NCMS EQ_CMS TLINDX TLNUMBER CNUM BANACT %token INDXESTIMA INDXGDLS EQ_MS CMS NCMS EQ_CMS TLINDX TLNUMBER CNUM BANACT
%token SBVAR MS_SBVAR %token SBVAR MS_SBVAR
%type <node_val> expression expression_or_empty %type <node_val> expression expression_or_empty
...@@ -155,7 +155,7 @@ class ParsingDriver; ...@@ -155,7 +155,7 @@ class ParsingDriver;
%type <string_val> vec_value_1 vec_value %type <string_val> vec_value_1 vec_value
%type <string_val> calib_arg2 range number %type <string_val> calib_arg2 range number
%type <symbol_type_val> change_type_arg %type <symbol_type_val> change_type_arg
%type <vector_string_val> change_type_var_list %type <vector_string_val> change_type_var_list
%% %%
...@@ -443,14 +443,24 @@ histval_list : histval_list histval_elem ...@@ -443,14 +443,24 @@ histval_list : histval_list histval_elem
histval_elem : symbol '(' signed_integer ')' EQUAL expression ';' { driver.hist_val($1, $3, $6); }; histval_elem : symbol '(' signed_integer ')' EQUAL expression ';' { driver.hist_val($1, $3, $6); };
model_sparse_options_list : model_sparse_options_list COMMA model_sparse_options /*model_block_options_list : model_block_options_list COMMA model_block_options
| model_sparse_options | model_block_options
; ;
model_sparse_options : o_cutoff model_block_options : o_cutoff
| o_markowitz | o_mfs
| o_mfs
; ;
*/
model_options : BLOCK {driver.block(); }
| o_cutoff
| o_mfs
| BYTECODE {driver.byte_code();}
;
model_options_list : model_options_list COMMA model_options
| model_options
;
model : MODEL ';' { driver.begin_model(); } model : MODEL ';' { driver.begin_model(); }
equation_list END { driver.reset_data_tree(); } equation_list END { driver.reset_data_tree(); }
...@@ -458,15 +468,7 @@ model : MODEL ';' { driver.begin_model(); } ...@@ -458,15 +468,7 @@ model : MODEL ';' { driver.begin_model(); }
equation_list END { driver.reset_data_tree(); } equation_list END { driver.reset_data_tree(); }
| MODEL '(' USE_DLL ')' ';' { driver.begin_model(); driver.use_dll(); } | MODEL '(' USE_DLL ')' ';' { driver.begin_model(); driver.use_dll(); }
equation_list END { driver.reset_data_tree(); } equation_list END { driver.reset_data_tree(); }
| MODEL '(' SPARSE_DLL COMMA model_sparse_options_list ')' | MODEL '(' model_options_list ')' ';' { driver.begin_model(); }
{ driver.begin_model(); driver.sparse_dll(); } ';'
equation_list END { driver.reset_data_tree(); }
| MODEL '(' SPARSE_DLL ')' { driver.begin_model(); driver.sparse_dll(); } ';'
equation_list END { driver.reset_data_tree(); }
| MODEL '(' SPARSE COMMA model_sparse_options_list ')'
{ driver.begin_model(); driver.sparse(); } ';'
equation_list END { driver.reset_data_tree(); }
| MODEL '(' SPARSE ')' { driver.begin_model(); driver.sparse(); } ';'
equation_list END { driver.reset_data_tree(); } equation_list END { driver.reset_data_tree(); }
; ;
...@@ -641,11 +643,7 @@ steady_options_list : steady_options_list COMMA steady_options ...@@ -641,11 +643,7 @@ steady_options_list : steady_options_list COMMA steady_options
steady_options : o_solve_algo steady_options : o_solve_algo
| o_homotopy_mode | o_homotopy_mode
| o_homotopy_steps | o_homotopy_steps
| o_block_mfs
| o_block_mfs_dll
| o_cutoff
| o_markowitz | o_markowitz
| o_mfs
; ;
check : CHECK ';' check : CHECK ';'
...@@ -677,6 +675,7 @@ simul_options_list : simul_options_list COMMA simul_options ...@@ -677,6 +675,7 @@ simul_options_list : simul_options_list COMMA simul_options
simul_options : o_periods simul_options : o_periods
| o_datafile | o_datafile
| o_method | o_method
| o_markowitz
; ;
stoch_simul : STOCH_SIMUL ';' stoch_simul : STOCH_SIMUL ';'
...@@ -733,7 +732,7 @@ symbol_list_ext : symbol_list ...@@ -733,7 +732,7 @@ symbol_list_ext : symbol_list
driver.add_in_symbol_list(colon); driver.add_in_symbol_list(colon);
} }
; ;