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-bf33cf982152time-shift
parent
3f924cc1de
commit
ed6cda0ca1
|
@ -223,8 +223,7 @@ function global_initialization()
|
||||||
options_.prior_analysis_endo_var_list = [];
|
options_.prior_analysis_endo_var_list = [];
|
||||||
|
|
||||||
% block decomposition + minimum feedback set for steady state computation
|
% block decomposition + minimum feedback set for steady state computation
|
||||||
options_.block_mfs = 0;
|
options_.block = 0;
|
||||||
|
|
||||||
% block decomposition + minimum feedback set for steady state computation
|
% model evaluated using simulate.dll
|
||||||
% using simulate.dll
|
options_.bytecode = 0;
|
||||||
options_.block_mfs_dll = 0;
|
|
||||||
|
|
|
@ -73,7 +73,6 @@ function y = solve_two_boundaries(fname, y, x, params, y_index, nze, periods, y_
|
||||||
reduced = 0;
|
reduced = 0;
|
||||||
while ~(cvg==1 | iter>maxit_),
|
while ~(cvg==1 | iter>maxit_),
|
||||||
[r, y, g1, g2, g3, b]=feval(fname, y, x, params, periods, 0, y_kmin, Blck_size);
|
[r, y, g1, g2, g3, b]=feval(fname, y, x, params, periods, 0, y_kmin, Blck_size);
|
||||||
|
|
||||||
% fjac = zeros(Blck_size, Blck_size*(y_kmin_l+1+y_kmax_l));
|
% fjac = zeros(Blck_size, Blck_size*(y_kmin_l+1+y_kmax_l));
|
||||||
% disp(['Blck_size=' int2str(Blck_size) ' size(y_index)=' int2str(size(y_index,2))]);
|
% disp(['Blck_size=' int2str(Blck_size) ' size(y_index)=' int2str(size(y_index,2))]);
|
||||||
% dh = max(abs(y(y_kmin+1-y_kmin_l:y_kmin+1+y_kmax_l, y_index)),options_.gstep*ones(y_kmin_l+1+y_kmax_l, Blck_size))*eps^(1/3);
|
% dh = max(abs(y(y_kmin+1-y_kmin_l:y_kmin+1+y_kmax_l, y_index)),options_.gstep*ones(y_kmin_l+1+y_kmax_l, Blck_size))*eps^(1/3);
|
||||||
|
|
|
@ -62,7 +62,7 @@ function steady_()
|
||||||
options_.jacobian_flag, ...
|
options_.jacobian_flag, ...
|
||||||
[oo_.exo_steady_state;oo_.exo_det_steady_state],indv);
|
[oo_.exo_steady_state;oo_.exo_det_steady_state],indv);
|
||||||
end
|
end
|
||||||
elseif options_.block_mfs
|
elseif options_.block && ~options_.bytecode
|
||||||
for b = 1:size(M_.blocksMFS,1)
|
for b = 1:size(M_.blocksMFS,1)
|
||||||
n = size(M_.blocksMFS{b}, 1);
|
n = size(M_.blocksMFS{b}, 1);
|
||||||
ss = oo_.steady_state;
|
ss = oo_.steady_state;
|
||||||
|
@ -79,7 +79,7 @@ function steady_()
|
||||||
[oo_.exo_steady_state; ...
|
[oo_.exo_steady_state; ...
|
||||||
oo_.exo_det_steady_state], M_.params);
|
oo_.exo_det_steady_state], M_.params);
|
||||||
end
|
end
|
||||||
elseif options_.block_mfs_dll
|
elseif options_.block && options_.bytecode
|
||||||
[oo_.steady_state,check] = simulate('steady_state');
|
[oo_.steady_state,check] = simulate('steady_state');
|
||||||
else
|
else
|
||||||
[oo_.steady_state,check] = dynare_solve([M_.fname '_static'],...
|
[oo_.steady_state,check] = dynare_solve([M_.fname '_static'],...
|
||||||
|
|
|
@ -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,
|
||||||
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,
|
||||||
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,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
||||||
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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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
|
||||||
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
|
||||||
<< " 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()
|
||||||
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
|
||||||
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
|
||||||
<< " % // 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
|
||||||
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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*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
|
||||||
}*/
|
}*/
|
||||||
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
|
||||||
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
|
||||||
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
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
||||||
// 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
|
||||||
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
|
||||||
}
|
}
|
||||||
|
|
||||||
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()
|
||||||
|
|
||||||
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
|
||||||
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
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
||||||
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:
|
||||||
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:
|
||||||
\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;
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%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;
|
||||||
%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
|
||||||
|
@ -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(); }
|
||||||
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
|
||||||
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
|
||||||
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 ';'
|
||||||
|
@ -1607,8 +1606,7 @@ o_gsa_trans_ident : TRANS_IDENT EQUAL INT_NUMBER { driver.option_num("trans_iden
|
||||||
|
|
||||||
o_homotopy_mode : HOMOTOPY_MODE EQUAL INT_NUMBER {driver.option_num("homotopy_mode",$3); };
|
o_homotopy_mode : HOMOTOPY_MODE EQUAL INT_NUMBER {driver.option_num("homotopy_mode",$3); };
|
||||||
o_homotopy_steps : HOMOTOPY_STEPS EQUAL INT_NUMBER {driver.option_num("homotopy_steps",$3); };
|
o_homotopy_steps : HOMOTOPY_STEPS EQUAL INT_NUMBER {driver.option_num("homotopy_steps",$3); };
|
||||||
o_block_mfs : BLOCK_MFS { driver.option_num("block_mfs", "1"); }
|
|
||||||
o_block_mfs_dll : BLOCK_MFS_DLL { driver.option_num("block_mfs_dll", "1"); }
|
|
||||||
|
|
||||||
o_parameters : PARAMETERS EQUAL symbol {driver.option_str("parameters",$3);};
|
o_parameters : PARAMETERS EQUAL symbol {driver.option_str("parameters",$3);};
|
||||||
o_shocks : SHOCKS EQUAL '(' list_of_symbol_lists ')' { driver.option_symbol_list("shocks"); };
|
o_shocks : SHOCKS EQUAL '(' list_of_symbol_lists ')' { driver.option_symbol_list("shocks"); };
|
||||||
|
@ -1624,7 +1622,7 @@ o_vlist : VLIST EQUAL INT_NUMBER {driver.option_num("ms.vlist",$3); };
|
||||||
o_vlistlog : VLISTLOG EQUAL INT_NUMBER {driver.option_num("ms.vlistlog",$3); };
|
o_vlistlog : VLISTLOG EQUAL INT_NUMBER {driver.option_num("ms.vlistlog",$3); };
|
||||||
o_vlistper : VLISTPER EQUAL INT_NUMBER {driver.option_num("ms.vlistper",$3); };
|
o_vlistper : VLISTPER EQUAL INT_NUMBER {driver.option_num("ms.vlistper",$3); };
|
||||||
o_varlist : VARLIST EQUAL '(' symbol_list ')' {driver.option_symbol_list("ms.varlist"); };
|
o_varlist : VARLIST EQUAL '(' symbol_list ')' {driver.option_symbol_list("ms.varlist"); };
|
||||||
o_restriction_fname : RESTRICTION_FNAME EQUAL symbol {driver.option_str("ms.restriction_fname",$3); };
|
o_restriction_fname : RESTRICTION_FNAME EQUAL '(' symbol_list ')' {driver.option_symbol_list("ms.restriction_fname"); };
|
||||||
o_nlags : NLAGS EQUAL INT_NUMBER {driver.option_num("ms.nlags",$3); };
|
o_nlags : NLAGS EQUAL INT_NUMBER {driver.option_num("ms.nlags",$3); };
|
||||||
o_cross_restrictions : CROSS_RESTRICTIONS EQUAL INT_NUMBER {driver.option_num("ms.cross_restrictions",$3); };
|
o_cross_restrictions : CROSS_RESTRICTIONS EQUAL INT_NUMBER {driver.option_num("ms.cross_restrictions",$3); };
|
||||||
o_contemp_reduced_form : CONTEMP_REDUCED_FORM EQUAL INT_NUMBER {driver.option_num("ms.contemp_reduced_form",$3); };
|
o_contemp_reduced_form : CONTEMP_REDUCED_FORM EQUAL INT_NUMBER {driver.option_num("ms.contemp_reduced_form",$3); };
|
||||||
|
|
|
@ -220,8 +220,6 @@ int sigma_e = 0;
|
||||||
<DYNARE_STATEMENT>filename {return token::FILENAME;}
|
<DYNARE_STATEMENT>filename {return token::FILENAME;}
|
||||||
<DYNARE_STATEMENT>diffuse_filter {return token::DIFFUSE_FILTER;}
|
<DYNARE_STATEMENT>diffuse_filter {return token::DIFFUSE_FILTER;}
|
||||||
<DYNARE_STATEMENT>plot_priors {return token::PLOT_PRIORS;}
|
<DYNARE_STATEMENT>plot_priors {return token::PLOT_PRIORS;}
|
||||||
<DYNARE_STATEMENT>block_mfs {return token::BLOCK_MFS;}
|
|
||||||
<DYNARE_STATEMENT>block_mfs_dll {return token::BLOCK_MFS_DLL;}
|
|
||||||
|
|
||||||
<DYNARE_STATEMENT>freq {return token::FREQ;}
|
<DYNARE_STATEMENT>freq {return token::FREQ;}
|
||||||
<DYNARE_STATEMENT>initial_year {return token::INITIAL_YEAR;}
|
<DYNARE_STATEMENT>initial_year {return token::INITIAL_YEAR;}
|
||||||
|
@ -349,8 +347,8 @@ int sigma_e = 0;
|
||||||
<DYNARE_STATEMENT,DYNARE_BLOCK>gaussian_elimination {return token::GAUSSIAN_ELIMINATION;}
|
<DYNARE_STATEMENT,DYNARE_BLOCK>gaussian_elimination {return token::GAUSSIAN_ELIMINATION;}
|
||||||
<DYNARE_STATEMENT,DYNARE_BLOCK>gmres {return token::GMRES;}
|
<DYNARE_STATEMENT,DYNARE_BLOCK>gmres {return token::GMRES;}
|
||||||
<DYNARE_STATEMENT,DYNARE_BLOCK>bicgstab {return token::BICGSTAB;}
|
<DYNARE_STATEMENT,DYNARE_BLOCK>bicgstab {return token::BICGSTAB;}
|
||||||
<DYNARE_STATEMENT,DYNARE_BLOCK>sparse {return token::SPARSE;}
|
<DYNARE_STATEMENT,DYNARE_BLOCK>block {return token::BLOCK;}
|
||||||
<DYNARE_STATEMENT,DYNARE_BLOCK>sparse_dll {return token::SPARSE_DLL;}
|
<DYNARE_STATEMENT,DYNARE_BLOCK>bytecode {return token::BYTECODE;}
|
||||||
<DYNARE_STATEMENT,DYNARE_BLOCK>linear {return token::LINEAR;}
|
<DYNARE_STATEMENT,DYNARE_BLOCK>linear {return token::LINEAR;}
|
||||||
<DYNARE_STATEMENT,DYNARE_BLOCK>[,] {return token::COMMA;}
|
<DYNARE_STATEMENT,DYNARE_BLOCK>[,] {return token::COMMA;}
|
||||||
<DYNARE_STATEMENT,DYNARE_BLOCK>[:] {return Dynare::parser::token_type (yytext[0]);}
|
<DYNARE_STATEMENT,DYNARE_BLOCK>[:] {return Dynare::parser::token_type (yytext[0]);}
|
||||||
|
|
|
@ -29,6 +29,8 @@ ModFile::ModFile() : expressions_tree(symbol_table, num_constants),
|
||||||
dynamic_model(symbol_table, num_constants),
|
dynamic_model(symbol_table, num_constants),
|
||||||
linear(false)
|
linear(false)
|
||||||
{
|
{
|
||||||
|
block = false;
|
||||||
|
byte_code = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ModFile::~ModFile()
|
ModFile::~ModFile()
|
||||||
|
@ -144,20 +146,23 @@ ModFile::computingPass(bool no_tmp_terms)
|
||||||
if (dynamic_model.equation_number() > 0)
|
if (dynamic_model.equation_number() > 0)
|
||||||
{
|
{
|
||||||
// Compute static model and its derivatives
|
// Compute static model and its derivatives
|
||||||
if(mod_file_struct.steady_block_mfs_dll_option)
|
cout << "byte_code=" << byte_code << endl;
|
||||||
|
cout << "block=" << block << endl;
|
||||||
|
if(byte_code)
|
||||||
{
|
{
|
||||||
|
cout << "go in DLL\n";
|
||||||
dynamic_model.toStaticDll(static_dll_model);
|
dynamic_model.toStaticDll(static_dll_model);
|
||||||
static_dll_model.computingPass(global_eval_context, no_tmp_terms);
|
static_dll_model.computingPass(global_eval_context, no_tmp_terms, block);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dynamic_model.toStatic(static_model);
|
dynamic_model.toStatic(static_model);
|
||||||
static_model.computingPass(mod_file_struct.steady_block_mfs_option, false, no_tmp_terms);
|
static_model.computingPass(block, false, no_tmp_terms);
|
||||||
}
|
}
|
||||||
// Set things to compute for dynamic model
|
// Set things to compute for dynamic model
|
||||||
|
|
||||||
if (mod_file_struct.simul_present)
|
if (mod_file_struct.simul_present)
|
||||||
dynamic_model.computingPass(false, false, false, false, global_eval_context, no_tmp_terms);
|
dynamic_model.computingPass(false, false, false, false, global_eval_context, no_tmp_terms, block);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (mod_file_struct.order_option < 1 || mod_file_struct.order_option > 3)
|
if (mod_file_struct.order_option < 1 || mod_file_struct.order_option > 3)
|
||||||
|
@ -168,7 +173,7 @@ ModFile::computingPass(bool no_tmp_terms)
|
||||||
bool hessian = mod_file_struct.order_option >= 2;
|
bool hessian = mod_file_struct.order_option >= 2;
|
||||||
bool thirdDerivatives = mod_file_struct.order_option == 3;
|
bool thirdDerivatives = mod_file_struct.order_option == 3;
|
||||||
bool paramsDerivatives = mod_file_struct.identification_present;
|
bool paramsDerivatives = mod_file_struct.identification_present;
|
||||||
dynamic_model.computingPass(true, hessian, thirdDerivatives, paramsDerivatives, global_eval_context, no_tmp_terms);
|
dynamic_model.computingPass(true, hessian, thirdDerivatives, paramsDerivatives, global_eval_context, no_tmp_terms, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -235,11 +240,14 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all) const
|
||||||
|
|
||||||
if (dynamic_model.equation_number() > 0)
|
if (dynamic_model.equation_number() > 0)
|
||||||
{
|
{
|
||||||
dynamic_model.writeOutput(mOutputFile, basename);
|
if (mod_file_struct.simul_present)
|
||||||
if(mod_file_struct.steady_block_mfs_dll_option)
|
dynamic_model.writeOutput(mOutputFile, basename, block);
|
||||||
static_dll_model.writeOutput(mOutputFile, basename);
|
else
|
||||||
|
dynamic_model.writeOutput(mOutputFile, basename, false);
|
||||||
|
if(byte_code)
|
||||||
|
static_dll_model.writeOutput(mOutputFile, basename, block);
|
||||||
else
|
else
|
||||||
static_model.writeOutput(mOutputFile);
|
static_model.writeOutput(mOutputFile, block);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Print statements
|
// Print statements
|
||||||
|
@ -248,7 +256,12 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all) const
|
||||||
(*it)->writeOutput(mOutputFile, basename);
|
(*it)->writeOutput(mOutputFile, basename);
|
||||||
|
|
||||||
if (dynamic_model.equation_number() > 0)
|
if (dynamic_model.equation_number() > 0)
|
||||||
dynamic_model.writeOutputPostComputing(mOutputFile, basename);
|
{
|
||||||
|
if (mod_file_struct.simul_present)
|
||||||
|
dynamic_model.writeOutputPostComputing(mOutputFile, basename, block);
|
||||||
|
else
|
||||||
|
dynamic_model.writeOutputPostComputing(mOutputFile, basename, false);
|
||||||
|
}
|
||||||
|
|
||||||
mOutputFile << "save('" << basename << "_results.mat', 'oo_', 'M_', 'options_');" << endl
|
mOutputFile << "save('" << basename << "_results.mat', 'oo_', 'M_', 'options_');" << endl
|
||||||
<< "diary off" << endl
|
<< "diary off" << endl
|
||||||
|
@ -259,11 +272,14 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all) const
|
||||||
// Create static and dynamic files
|
// Create static and dynamic files
|
||||||
if (dynamic_model.equation_number() > 0)
|
if (dynamic_model.equation_number() > 0)
|
||||||
{
|
{
|
||||||
if(mod_file_struct.steady_block_mfs_dll_option)
|
if(byte_code)
|
||||||
static_dll_model.writeStaticFile(basename);
|
static_dll_model.writeStaticFile(basename, block);
|
||||||
else
|
else
|
||||||
static_model.writeStaticFile(basename);
|
static_model.writeStaticFile(basename, block);
|
||||||
dynamic_model.writeDynamicFile(basename);
|
if (mod_file_struct.simul_present)
|
||||||
|
dynamic_model.writeDynamicFile(basename, block, byte_code);
|
||||||
|
else
|
||||||
|
dynamic_model.writeDynamicFile(basename, false, false);
|
||||||
dynamic_model.writeParamsDerivativesFile(basename);
|
dynamic_model.writeParamsDerivativesFile(basename);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,6 +53,14 @@ public:
|
||||||
DynamicModel dynamic_model;
|
DynamicModel dynamic_model;
|
||||||
//! Option linear
|
//! Option linear
|
||||||
bool linear;
|
bool linear;
|
||||||
|
|
||||||
|
//! Is the model block decomposed?
|
||||||
|
bool block;
|
||||||
|
|
||||||
|
//! Is the model stored in baytecode format (byte_code=true) or in a M-file (byte_code=false)
|
||||||
|
bool byte_code;
|
||||||
|
|
||||||
|
|
||||||
//! 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_type global_eval_context;
|
||||||
|
|
|
@ -183,7 +183,7 @@ ParsingDriver::add_model_variable(string *name, string *olag)
|
||||||
if (type == eUnknownFunction)
|
if (type == eUnknownFunction)
|
||||||
error("Symbol " + *name + " is a function name unknown to Dynare. It cannot be used inside model.");
|
error("Symbol " + *name + " is a function name unknown to Dynare. It cannot be used inside model.");
|
||||||
|
|
||||||
if (type == eExogenous && lag != 0 && (dynamic_model->mode != DynamicModel::eSparseDLLMode && dynamic_model->mode != DynamicModel::eSparseMode))
|
if (type == eExogenous && lag != 0 && !mod_file->block)
|
||||||
warning("Exogenous variable " + *name + " has lead/lag " + *olag);
|
warning("Exogenous variable " + *name + " has lead/lag " + *olag);
|
||||||
|
|
||||||
if (type == eModelLocalVariable && lag != 0)
|
if (type == eModelLocalVariable && lag != 0)
|
||||||
|
@ -351,15 +351,15 @@ ParsingDriver::use_dll()
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ParsingDriver::sparse_dll()
|
ParsingDriver::block()
|
||||||
{
|
{
|
||||||
dynamic_model->mode = DynamicModel::eSparseDLLMode;
|
mod_file->block = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ParsingDriver::sparse()
|
ParsingDriver::byte_code()
|
||||||
{
|
{
|
||||||
dynamic_model->mode = DynamicModel::eSparseMode;
|
mod_file->byte_code = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -617,7 +617,7 @@ ParsingDriver::option_num(const string &name_option, const string &opt)
|
||||||
&& (options_list.num_options.find(name_option) != options_list.num_options.end()))
|
&& (options_list.num_options.find(name_option) != options_list.num_options.end()))
|
||||||
error("option " + name_option + " declared twice");
|
error("option " + name_option + " declared twice");
|
||||||
|
|
||||||
if ((name_option == "periods") && (mod_file->dynamic_model.mode == DynamicModel::eSparseDLLMode || mod_file->dynamic_model.mode == DynamicModel::eSparseMode))
|
if ((name_option == "periods") && mod_file->block)
|
||||||
mod_file->dynamic_model.block_triangular.periods = atoi(opt.c_str());
|
mod_file->dynamic_model.block_triangular.periods = atoi(opt.c_str());
|
||||||
else if (name_option == "cutoff")
|
else if (name_option == "cutoff")
|
||||||
{
|
{
|
||||||
|
@ -629,8 +629,6 @@ ParsingDriver::option_num(const string &name_option, const string &opt)
|
||||||
mod_file->dynamic_model.mfs = atoi(opt.c_str());
|
mod_file->dynamic_model.mfs = atoi(opt.c_str());
|
||||||
mod_file->static_dll_model.mfs = atoi(opt.c_str());
|
mod_file->static_dll_model.mfs = atoi(opt.c_str());
|
||||||
}
|
}
|
||||||
else if (name_option == "block_mfs_dll")
|
|
||||||
mod_file->static_dll_model.mode = (StaticDllModel::mode_t)DynamicModel::eSparseDLLMode;
|
|
||||||
|
|
||||||
options_list.num_options[name_option] = opt;
|
options_list.num_options[name_option] = opt;
|
||||||
}
|
}
|
||||||
|
@ -695,7 +693,7 @@ void ParsingDriver::stoch_simul()
|
||||||
void
|
void
|
||||||
ParsingDriver::simul()
|
ParsingDriver::simul()
|
||||||
{
|
{
|
||||||
mod_file->addStatement(new SimulStatement(options_list, mod_file->dynamic_model.mode));
|
mod_file->addStatement(new SimulStatement(options_list, mod_file->dynamic_model.mode, mod_file->block, mod_file->byte_code));
|
||||||
options_list.clear();
|
options_list.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -175,10 +175,10 @@ public:
|
||||||
bool symbol_exists_and_is_not_modfile_local_or_unknown_function(const char *s);
|
bool symbol_exists_and_is_not_modfile_local_or_unknown_function(const char *s);
|
||||||
//! Sets mode of ModelTree class to use C output
|
//! Sets mode of ModelTree class to use C output
|
||||||
void use_dll();
|
void use_dll();
|
||||||
//! Sets mode of ModelTree class to block decompose the model and triggers the creation of the incidence matrix in a C context
|
//! the modelis block decomposed
|
||||||
void sparse_dll();
|
void block();
|
||||||
//! Sets mode of ModelTree class to block decompose the model and triggers the creation of the incidence matrix in Matlab context
|
//! the model is stored in a binary file
|
||||||
void sparse();
|
void byte_code();
|
||||||
//! Sets the FILENAME for the initial value in initval
|
//! Sets the FILENAME for the initial value in initval
|
||||||
void initval_file(string *filename);
|
void initval_file(string *filename);
|
||||||
//! Declares an endogenous variable
|
//! Declares an endogenous variable
|
||||||
|
|
|
@ -824,8 +824,10 @@ StaticDllModel::writeSparseStaticMFile(const string &static_basename, const stri
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
StaticDllModel::writeOutput(ostream &output, const string &basename) const
|
StaticDllModel::writeOutput(ostream &output, const string &basename, bool block) const
|
||||||
{
|
{
|
||||||
|
output << "options_.block=" << block << ";" << endl;
|
||||||
|
output << "options_.bytecode=1;" << endl;
|
||||||
output << "options_.model_mode = " << mode << ";" << endl;
|
output << "options_.model_mode = " << mode << ";" << endl;
|
||||||
|
|
||||||
// Erase possible remnants of previous runs
|
// Erase possible remnants of previous runs
|
||||||
|
@ -837,14 +839,14 @@ StaticDllModel::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 << "_static.c" << endl;
|
output << "mex -O LDFLAGS='-pthread -shared -Wl,--no-undefined' " << basename << "_static.c" << endl;
|
||||||
if (mode == eSparseMode || mode == eSparseDLLMode)
|
if (block)
|
||||||
output << "addpath " << basename << ";" << endl;
|
output << "addpath " << basename << ";" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
StaticDllModel::writeOutputPostComputing(ostream &output, const string &basename) const
|
StaticDllModel::writeOutputPostComputing(ostream &output, const string &basename, bool block) const
|
||||||
{
|
{
|
||||||
if (mode == eSparseMode || mode == eSparseDLLMode)
|
if (block)
|
||||||
output << "rmpath " << basename << ";" << endl;
|
output << "rmpath " << basename << ";" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1004,7 +1006,7 @@ StaticDllModel::collect_first_order_derivatives_endogenous()
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
StaticDllModel::computingPass(const eval_context_type &eval_context, bool no_tmp_terms)
|
StaticDllModel::computingPass(const eval_context_type &eval_context, bool no_tmp_terms, bool block)
|
||||||
{
|
{
|
||||||
|
|
||||||
// Computes static jacobian columns
|
// Computes static jacobian columns
|
||||||
|
@ -1025,7 +1027,7 @@ StaticDllModel::computingPass(const eval_context_type &eval_context, bool no_tmp
|
||||||
<< " - order 1" << endl;
|
<< " - order 1" << endl;
|
||||||
computeJacobian(vars);
|
computeJacobian(vars);
|
||||||
//cout << "mode=" << mode << " eSparseDLLMode=" << eSparseDLLMode << " eSparseMode=" << eSparseMode << "\n";
|
//cout << "mode=" << mode << " eSparseDLLMode=" << eSparseDLLMode << " eSparseMode=" << eSparseMode << "\n";
|
||||||
if (mode == eSparseDLLMode || mode == eSparseMode)
|
if (block)
|
||||||
{
|
{
|
||||||
BuildIncidenceMatrix();
|
BuildIncidenceMatrix();
|
||||||
|
|
||||||
|
@ -1067,10 +1069,29 @@ StaticDllModel::computingPass(const eval_context_type &eval_context, bool no_tmp
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
StaticDllModel::writeStaticFile(const string &basename) const
|
StaticDllModel::writeStaticFile(const string &basename, bool block) const
|
||||||
{
|
{
|
||||||
int r;
|
int r;
|
||||||
switch (mode)
|
if(block)
|
||||||
|
{
|
||||||
|
#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 + "_static", block_triangular.ModelBlock, basename, map_idx);
|
||||||
|
block_triangular.Free_Block(block_triangular.ModelBlock);
|
||||||
|
block_triangular.incidencematrix.Free_IM();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
}
|
||||||
|
/*switch (mode)
|
||||||
{
|
{
|
||||||
case eStandardMode:
|
case eStandardMode:
|
||||||
break;
|
break;
|
||||||
|
@ -1109,7 +1130,7 @@ StaticDllModel::writeStaticFile(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;
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -35,9 +35,9 @@ public:
|
||||||
enum mode_t
|
enum mode_t
|
||||||
{
|
{
|
||||||
eStandardMode, //!< Standard mode (static file in Matlab)
|
eStandardMode, //!< Standard mode (static file in Matlab)
|
||||||
eSparseMode, //!< Sparse mode (static file in Matlab with block decomposition)
|
//eSparseMode, //!< Sparse mode (static file in Matlab with block decomposition)
|
||||||
eDLLMode, //!< DLL mode (static file in C)
|
eDLLMode //!< DLL mode (static file in C)
|
||||||
eSparseDLLMode //!< Sparse DLL mode (static file in C with block decomposition plus a binary file)
|
//eSparseDLLMode //!< Sparse DLL mode (static 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;
|
||||||
|
@ -167,18 +167,18 @@ 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);
|
void computingPass(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 &static_basename, const string &bin_basename,
|
void Write_Inf_To_Bin_File(const string &static_basename, const string &bin_basename,
|
||||||
const int &num, int &u_count_int, bool &file_open) const;
|
const int &num, int &u_count_int, bool &file_open) const;
|
||||||
//! Writes static model file
|
//! Writes static model file
|
||||||
void writeStaticFile(const string &basename) const;
|
void writeStaticFile(const string &basename, bool block) const;
|
||||||
//! Writes file containing parameters derivatives
|
//! Writes file containing parameters derivatives
|
||||||
void writeParamsDerivativesFile(const string &basename) const;
|
void writeParamsDerivativesFile(const string &basename) const;
|
||||||
|
|
||||||
|
|
|
@ -45,8 +45,7 @@ using namespace boost;
|
||||||
|
|
||||||
StaticModel::StaticModel(SymbolTable &symbol_table_arg,
|
StaticModel::StaticModel(SymbolTable &symbol_table_arg,
|
||||||
NumericalConstants &num_constants_arg) :
|
NumericalConstants &num_constants_arg) :
|
||||||
ModelTree(symbol_table_arg, num_constants_arg),
|
ModelTree(symbol_table_arg, num_constants_arg)
|
||||||
block_mfs(false)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -158,7 +157,7 @@ StaticModel::writeStaticMFile(ostream &output, const string &func_name) const
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
StaticModel::writeStaticFile(const string &basename) const
|
StaticModel::writeStaticFile(const string &basename, bool block) const
|
||||||
{
|
{
|
||||||
string filename = basename + "_static.m";
|
string filename = basename + "_static.m";
|
||||||
|
|
||||||
|
@ -170,7 +169,7 @@ StaticModel::writeStaticFile(const string &basename) const
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (block_mfs)
|
if (block)
|
||||||
writeStaticBlockMFSFile(output, basename + "_static");
|
writeStaticBlockMFSFile(output, basename + "_static");
|
||||||
else
|
else
|
||||||
writeStaticMFile(output, basename + "_static");
|
writeStaticMFile(output, basename + "_static");
|
||||||
|
@ -179,9 +178,9 @@ StaticModel::writeStaticFile(const string &basename) const
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
StaticModel::computingPass(bool block_mfs_arg, bool hessian, bool no_tmp_terms)
|
StaticModel::computingPass(bool block, bool hessian, bool no_tmp_terms)
|
||||||
{
|
{
|
||||||
block_mfs = block_mfs_arg;
|
|
||||||
|
|
||||||
// Compute derivatives w.r. to all endogenous
|
// Compute derivatives w.r. to all endogenous
|
||||||
set<int> vars;
|
set<int> vars;
|
||||||
|
@ -199,7 +198,7 @@ StaticModel::computingPass(bool block_mfs_arg, bool hessian, bool no_tmp_terms)
|
||||||
computeHessian(vars);
|
computeHessian(vars);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (block_mfs)
|
if (block)
|
||||||
{
|
{
|
||||||
computeNormalization();
|
computeNormalization();
|
||||||
computeSortedBlockDecomposition();
|
computeSortedBlockDecomposition();
|
||||||
|
@ -555,9 +554,9 @@ StaticModel::computeBlockMFSJacobian()
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
StaticModel::writeOutput(ostream &output) const
|
StaticModel::writeOutput(ostream &output, bool block) const
|
||||||
{
|
{
|
||||||
if (!block_mfs)
|
if (!block)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
output << "M_.blocksMFS = cell(" << blocksMFS.size() << ", 1);" << endl;
|
output << "M_.blocksMFS = cell(" << blocksMFS.size() << ", 1);" << endl;
|
||||||
|
@ -574,7 +573,6 @@ StaticModel::writeLocalVars(ostream &output, NodeID expr, set<int> &local_var_wr
|
||||||
{
|
{
|
||||||
set<int> expr_local_var;
|
set<int> expr_local_var;
|
||||||
expr->collectModelLocalVariables(expr_local_var);
|
expr->collectModelLocalVariables(expr_local_var);
|
||||||
|
|
||||||
vector<int> new_local_var;
|
vector<int> new_local_var;
|
||||||
set_difference(expr_local_var.begin(), expr_local_var.end(),
|
set_difference(expr_local_var.begin(), expr_local_var.end(),
|
||||||
local_var_written.begin(), local_var_written.end(),
|
local_var_written.begin(), local_var_written.end(),
|
||||||
|
|
|
@ -27,9 +27,6 @@
|
||||||
class StaticModel : public ModelTree
|
class StaticModel : public ModelTree
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
//! Are we in block decomposition + min. feedback set mode ?
|
|
||||||
bool block_mfs;
|
|
||||||
|
|
||||||
//! Normalization of equations
|
//! Normalization of equations
|
||||||
/*! Maps endogenous type specific IDs to equation numbers */
|
/*! Maps endogenous type specific IDs to equation numbers */
|
||||||
vector<int> endo2eq;
|
vector<int> endo2eq;
|
||||||
|
@ -95,13 +92,13 @@ public:
|
||||||
\param block_mfs whether block decomposition and minimum feedback set should be computed
|
\param block_mfs whether block decomposition and minimum feedback set should be computed
|
||||||
\param hessian whether Hessian (w.r. to endogenous only) should be computed
|
\param hessian whether Hessian (w.r. to endogenous only) should be computed
|
||||||
\param no_tmp_terms if true, no temporary terms will be computed in the static and dynamic files */
|
\param no_tmp_terms if true, no temporary terms will be computed in the static and dynamic files */
|
||||||
void computingPass(bool block_mfs_arg, bool hessian, bool no_tmp_terms);
|
void computingPass(bool block, bool hessian, bool no_tmp_terms);
|
||||||
|
|
||||||
//! Writes information on block decomposition when relevant
|
//! Writes information on block decomposition when relevant
|
||||||
void writeOutput(ostream &output) const;
|
void writeOutput(ostream &output, bool block) const;
|
||||||
|
|
||||||
//! Writes static model file
|
//! Writes static model file
|
||||||
void writeStaticFile(const string &basename) const;
|
void writeStaticFile(const string &basename, bool block) const;
|
||||||
|
|
||||||
//! Writes LaTeX file with the equations of the static model
|
//! Writes LaTeX file with the equations of the static model
|
||||||
void writeLatexFile(const string &basename) const;
|
void writeLatexFile(const string &basename) const;
|
||||||
|
|
|
@ -32,7 +32,7 @@ psi = 0.787;
|
||||||
del = 0.02;
|
del = 0.02;
|
||||||
toto = [2 3];
|
toto = [2 3];
|
||||||
|
|
||||||
model(sparse_dll);
|
model(block, bytecode);
|
||||||
//model(sparse);
|
//model(sparse);
|
||||||
//model;
|
//model;
|
||||||
/*0*/ exp(gam+e_a) = dA ;
|
/*0*/ exp(gam+e_a) = dA ;
|
||||||
|
|
|
@ -23,9 +23,9 @@ scy = 0.0040;
|
||||||
shy = 0.0015;
|
shy = 0.0015;
|
||||||
shc = 0.0010;
|
shc = 0.0010;
|
||||||
|
|
||||||
//model(sparse_dll, cutoff=0);
|
//model(block, bytecode, cutoff=0);
|
||||||
model(sparse,cutoff=0);
|
model(block,cutoff=0);
|
||||||
//model(sparse);
|
//model(block);
|
||||||
//model;
|
//model;
|
||||||
exp(y) = exp(a)*exp(k(-1))^theta*exp(h)^(1-theta);
|
exp(y) = exp(a)*exp(k(-1))^theta*exp(h)^(1-theta);
|
||||||
a = (1-rho)*aa+rho*a(-1)+e;
|
a = (1-rho)*aa+rho*a(-1)+e;
|
||||||
|
|
|
@ -17,7 +17,7 @@ rho_ys = 0.9;
|
||||||
rho_pies = 0.7;
|
rho_pies = 0.7;
|
||||||
|
|
||||||
|
|
||||||
model(sparse_dll, markowitz=0, cutoff=0);
|
model(block, bytecode, cutoff=0);
|
||||||
//model(sparse);
|
//model(sparse);
|
||||||
//model;
|
//model;
|
||||||
y = y(+1) - (tau +alpha*(2-alpha)*(1-tau))*(R-pie(+1))-alpha*(tau +alpha*(2-alpha)*(1-tau))*dq(+1) + alpha*(2-alpha)*((1-tau)/tau)*(y_s-y_s(+1))-A(+1);
|
y = y(+1) - (tau +alpha*(2-alpha)*(1-tau))*(R-pie(+1))-alpha*(tau +alpha*(2-alpha)*(1-tau))*dq(+1) + alpha*(2-alpha)*((1-tau)/tau)*(y_s-y_s(+1))-A(+1);
|
||||||
|
@ -93,7 +93,7 @@ values 0.5;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
//simul(periods=200,method=bicgstab);
|
//simul(periods=200,method=bicgstab);
|
||||||
simul(periods=20);
|
simul(periods=20, markowitz=0);
|
||||||
rplot vv;
|
rplot vv;
|
||||||
rplot ww;
|
rplot ww;
|
||||||
rplot A;
|
rplot A;
|
||||||
|
|
|
@ -6,7 +6,7 @@ parameters rho_x rho_y;
|
||||||
rho_x = 0.5;
|
rho_x = 0.5;
|
||||||
rho_y = -0.3;
|
rho_y = -0.3;
|
||||||
|
|
||||||
model(sparse);
|
model(block);
|
||||||
dx = rho_x*dx(-1)+e_x;
|
dx = rho_x*dx(-1)+e_x;
|
||||||
dy = rho_y*dy(-1)+e_y;
|
dy = rho_y*dy(-1)+e_y;
|
||||||
x = x(-1)+dx;
|
x = x(-1)+dx;
|
||||||
|
|
|
@ -852,7 +852,7 @@ W0906=0.0800069594276;
|
||||||
W0907=0.147854375051;
|
W0907=0.147854375051;
|
||||||
W0908=0.206834342322;
|
W0908=0.206834342322;
|
||||||
W0909=-1;
|
W0909=-1;
|
||||||
model(SPARSE_DLL,markowitz=3, mfs = 3);
|
model(block, bytecode, mfs = 3, cutoff =0);
|
||||||
//model(SPARSE,markowitz=2.0);
|
//model(SPARSE,markowitz=2.0);
|
||||||
//model;
|
//model;
|
||||||
( log(US_CPI)-(log(US_CPI(-1)))) = US_CPI1*( log(US_PIM)-(log(US_PIM(-1))))+US_CPI2*( log(US_PGNP)-(log(US_PGNP(-1))))+(1-US_CPI1-US_CPI2)*log(US_CPI(-1)/US_CPI(-2))+RES_US_CPI ;
|
( log(US_CPI)-(log(US_CPI(-1)))) = US_CPI1*( log(US_PIM)-(log(US_PIM(-1))))+US_CPI2*( log(US_PGNP)-(log(US_PGNP(-1))))+(1-US_CPI1-US_CPI2)*log(US_CPI(-1)/US_CPI(-2))+RES_US_CPI ;
|
||||||
|
@ -2753,7 +2753,7 @@ options_.dynatol = 1e-4;
|
||||||
options_.maxit_ = 5;
|
options_.maxit_ = 5;
|
||||||
|
|
||||||
|
|
||||||
simul(periods=80,datafile=mark3);
|
simul(periods=80,datafile=mark3,markowitz=3);
|
||||||
|
|
||||||
|
|
||||||
//simul(periods=10,datafile=mark3, method=lu);
|
//simul(periods=10,datafile=mark3, method=lu);
|
||||||
|
|
|
@ -10,8 +10,8 @@ bet=0.05;
|
||||||
aa=0.5;
|
aa=0.5;
|
||||||
|
|
||||||
|
|
||||||
//model(sparse);
|
//model(block, mfs=3);
|
||||||
model(sparse_dll);
|
model(block, bytecode, mfs=3);
|
||||||
//model;
|
//model;
|
||||||
//s = aa*x*k(-1)^alph - c;
|
//s = aa*x*k(-1)^alph - c;
|
||||||
c + k - aa*x*k(-1)^alph - (1-delt)*k(-1);// + 0.00000001*s;
|
c + k - aa*x*k(-1)^alph - (1-delt)*k(-1);// + 0.00000001*s;
|
||||||
|
|
|
@ -10,7 +10,7 @@ bet=0.05;
|
||||||
aa=0.5;
|
aa=0.5;
|
||||||
|
|
||||||
|
|
||||||
model(sparse);
|
model(block);
|
||||||
c + k - aa*x*k(-1)^alph - (1-delt)*k(-1);
|
c + k - aa*x*k(-1)^alph - (1-delt)*k(-1);
|
||||||
c^(-gam) - (1+bet)^(-1)*(aa*alph*x(+1)*k^(alph-1) + 1 - delt)*c(+1)^(-gam);
|
c^(-gam) - (1+bet)^(-1)*(aa*alph*x(+1)*k^(alph-1) + 1 - delt)*c(+1)^(-gam);
|
||||||
end;
|
end;
|
||||||
|
|
Loading…
Reference in New Issue