- References to ModelNormalization erased
- Use derivatives w.r. to lead and lag endogenous in BlockTriangular.cc git-svn-id: https://www.dynare.org/svn/dynare/trunk@2728 ac1d8469-bf42-47a9-8791-bf33cf982152time-shift
parent
1707d7eed9
commit
0380ae414a
|
@ -674,7 +674,7 @@ BlockTriangular::Free_Block(Model_Block *ModelBlock) const
|
|||
}
|
||||
|
||||
t_etype
|
||||
BlockTriangular::Equation_Type_determination(vector<BinaryOpNode *> &equations, map<pair<int, int >, NodeID> &first_cur_endo_derivatives, vector<int> &Index_Var_IM, vector<int> &Index_Equ_IM)
|
||||
BlockTriangular::Equation_Type_determination(vector<BinaryOpNode *> &equations, map<pair<int, pair<int, int> >, NodeID> &first_order_endo_derivatives, vector<int> &Index_Var_IM, vector<int> &Index_Equ_IM)
|
||||
{
|
||||
NodeID lhs, rhs;
|
||||
ostringstream tmp_output;
|
||||
|
@ -696,7 +696,7 @@ BlockTriangular::Equation_Type_determination(vector<BinaryOpNode *> &equations,
|
|||
tmp_output.str("");
|
||||
lhs->writeOutput(tmp_output, oMatlabDynamicModelSparse, temporary_terms);
|
||||
tmp_s << "y(it_, " << Index_Var_IM[i]+1 << ")";
|
||||
map<pair<int, int>, NodeID>::iterator derivative = first_cur_endo_derivatives.find(make_pair(eq, var));
|
||||
map<pair<int, pair<int, int> >, NodeID>::iterator derivative = first_order_endo_derivatives.find(make_pair(eq, make_pair(var, 0)));
|
||||
/*cout << "eq=" << eq << " var=" << var << "=";
|
||||
first_cur_endo_derivatives[make_pair(eq, var)]->writeOutput(cout, oMatlabDynamicModelSparse, temporary_terms);
|
||||
cout << "\n";
|
||||
|
@ -731,6 +731,9 @@ BlockTriangular::Equation_Type_determination(vector<BinaryOpNode *> &equations,
|
|||
return (V_Equation_Simulation_Type);
|
||||
}
|
||||
|
||||
/*void
|
||||
BlockTriangular::Recompute_Deriavtives_Respect_to_Feedback_Variables(
|
||||
*/
|
||||
t_type
|
||||
BlockTriangular::Reduce_Blocks_and_type_determination(int prologue, int epilogue, vector<pair<int, int> > &blocks, vector<BinaryOpNode *> &equations, t_etype &Equation_Type)
|
||||
{
|
||||
|
@ -840,7 +843,7 @@ BlockTriangular::Reduce_Blocks_and_type_determination(int prologue, int epilogue
|
|||
}
|
||||
|
||||
void
|
||||
BlockTriangular::Normalize_and_BlockDecompose(bool *IM, Model_Block *ModelBlock, int n, int &prologue, int &epilogue, vector<int> &Index_Var_IM, vector<int> &Index_Equ_IM, bool *IM_0, jacob_map &j_m, vector<BinaryOpNode *> &equations, t_etype &V_Equation_Type, map<pair<int, int >, NodeID> &first_cur_endo_derivatives)
|
||||
BlockTriangular::Normalize_and_BlockDecompose(bool *IM, Model_Block *ModelBlock, int n, int &prologue, int &epilogue, vector<int> &Index_Var_IM, vector<int> &Index_Equ_IM, bool *IM_0, jacob_map &j_m, vector<BinaryOpNode *> &equations, t_etype &V_Equation_Type, map<pair<int, pair<int, int> >, NodeID> &first_order_endo_derivatives)
|
||||
{
|
||||
int i, j, Nb_TotalBlocks, Nb_RecursBlocks, Nb_SimulBlocks;
|
||||
BlockType Btype;
|
||||
|
@ -911,7 +914,7 @@ BlockTriangular::Normalize_and_BlockDecompose(bool *IM, Model_Block *ModelBlock,
|
|||
Compute_Normalization(IM, n, prologue, epilogue, true, SIM00, Index_Equ_IM);
|
||||
}
|
||||
|
||||
V_Equation_Type = Equation_Type_determination(equations, first_cur_endo_derivatives, Index_Var_IM, Index_Equ_IM);
|
||||
V_Equation_Type = Equation_Type_determination(equations, first_order_endo_derivatives, Index_Var_IM, Index_Equ_IM);
|
||||
|
||||
cout << "Finding the optimal block decomposition of the model ...\n";
|
||||
vector<pair<int, int> > blocks;
|
||||
|
@ -969,7 +972,7 @@ BlockTriangular::Normalize_and_BlockDecompose(bool *IM, Model_Block *ModelBlock,
|
|||
// normalize each equation of the dynamic model
|
||||
// and find the optimal block triangular decomposition of the static model
|
||||
void
|
||||
BlockTriangular::Normalize_and_BlockDecompose_Static_0_Model(jacob_map &j_m, vector<BinaryOpNode *> &equations, t_etype &equation_simulation_type, map<pair<int, int >, NodeID> &first_cur_endo_derivatives)
|
||||
BlockTriangular::Normalize_and_BlockDecompose_Static_0_Model(jacob_map &j_m, vector<BinaryOpNode *> &equations, t_etype &equation_simulation_type, map<pair<int, pair<int, int> >, NodeID> &first_order_endo_derivatives)
|
||||
{
|
||||
bool *SIM, *SIM_0;
|
||||
bool *Cur_IM;
|
||||
|
@ -1011,7 +1014,7 @@ BlockTriangular::Normalize_and_BlockDecompose_Static_0_Model(jacob_map &j_m, vec
|
|||
SIM_0 = (bool *) malloc(symbol_table.endo_nbr() * symbol_table.endo_nbr() * sizeof(*SIM_0));
|
||||
for (i = 0; i < symbol_table.endo_nbr()*symbol_table.endo_nbr(); i++)
|
||||
SIM_0[i] = Cur_IM[i];
|
||||
Normalize_and_BlockDecompose(SIM, ModelBlock, symbol_table.endo_nbr(), prologue, epilogue, Index_Var_IM, Index_Equ_IM, SIM_0, j_m, equations, equation_simulation_type, first_cur_endo_derivatives);
|
||||
Normalize_and_BlockDecompose(SIM, ModelBlock, symbol_table.endo_nbr(), prologue, epilogue, Index_Var_IM, Index_Equ_IM, SIM_0, j_m, equations, equation_simulation_type, first_order_endo_derivatives);
|
||||
free(SIM_0);
|
||||
free(SIM);
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ private:
|
|||
//! Decomposes into recurive blocks the non purely recursive equations and determines for each block the minimum feedback variables
|
||||
void Compute_Block_Decomposition_and_Feedback_Variables_For_Each_Block(bool *IM, int nb_var, int prologue, int epilogue, vector<int> &Index_Equ_IM, vector<int> &Index_Var_IM, vector<pair<int, int> > &blocks, t_etype &Equation_Type, bool verbose_) const;
|
||||
//! determines the type of each equation of the model (could be evaluated or need to be solved)
|
||||
t_etype Equation_Type_determination(vector<BinaryOpNode *> &equations, map<pair<int, int >, NodeID> &first_cur_endo_derivatives, vector<int> &Index_Var_IM, vector<int> &Index_Equ_IM);
|
||||
t_etype Equation_Type_determination(vector<BinaryOpNode *> &equations, map<pair<int, pair<int, int> >, NodeID> &first_order_endo_derivatives, vector<int> &Index_Var_IM, vector<int> &Index_Equ_IM);
|
||||
//! Tries to merge the consecutive blocks in a single block and determine the type of each block: recursive, simultaneous, ...
|
||||
t_type Reduce_Blocks_and_type_determination(int prologue, int epilogue, vector<pair<int, int> > &blocks, vector<BinaryOpNode *> &equations, t_etype &Equation_Type);
|
||||
//! Compute for each variable its maximum lead and lag in its block
|
||||
|
@ -74,8 +74,8 @@ public:
|
|||
|
||||
|
||||
|
||||
void Normalize_and_BlockDecompose_Static_0_Model(jacob_map &j_m, vector<BinaryOpNode *> &equations, t_etype &V_Equation_Type, map<pair<int, int >, NodeID> &first_cur_endo_derivatives);
|
||||
void Normalize_and_BlockDecompose(bool* IM, Model_Block* ModelBlock, int n, int &prologue, int &epilogue, vector<int> &Index_Var_IM, vector<int> &Index_Equ_IM, bool* IM_0 , jacob_map &j_m, vector<BinaryOpNode *> &equations, t_etype &equation_simulation_type, map<pair<int, int >, NodeID> &first_cur_endo_derivatives);
|
||||
void Normalize_and_BlockDecompose_Static_0_Model(jacob_map &j_m, vector<BinaryOpNode *> &equations, t_etype &V_Equation_Type, map<pair<int, pair<int, int> >, NodeID> &first_order_endo_derivatives);
|
||||
void Normalize_and_BlockDecompose(bool* IM, Model_Block* ModelBlock, int n, int &prologue, int &epilogue, vector<int> &Index_Var_IM, vector<int> &Index_Equ_IM, bool* IM_0 , jacob_map &j_m, vector<BinaryOpNode *> &equations, t_etype &equation_simulation_type, map<pair<int, pair<int, int> >, NodeID> &first_order_endo_derivatives);
|
||||
vector<int> Index_Equ_IM;
|
||||
vector<int> Index_Var_IM;
|
||||
int prologue, epilogue;
|
||||
|
|
|
@ -2462,10 +2462,10 @@ follow:
|
|||
}
|
||||
|
||||
|
||||
map<pair<int, int >, NodeID>
|
||||
DynamicModel::collect_first_order_derivatives_current_endogenous()
|
||||
map<pair<int, pair<int, int > >, NodeID>
|
||||
DynamicModel::collect_first_order_derivatives_endogenous()
|
||||
{
|
||||
map<pair<int, int >, NodeID> curr_endo_derivatives;
|
||||
map<pair<int, pair<int, int > >, NodeID> endo_derivatives;
|
||||
for (first_derivatives_type::iterator it2 = first_derivatives.begin();
|
||||
it2 != first_derivatives.end(); it2++)
|
||||
{
|
||||
|
@ -2474,17 +2474,11 @@ DynamicModel::collect_first_order_derivatives_current_endogenous()
|
|||
int eq = it2->first.first;
|
||||
int var=symbol_table.getTypeSpecificID(getSymbIDByDerivID(it2->first.second));
|
||||
int lag=getLagByDerivID(it2->first.second);
|
||||
/*cout << "eq=" << eq << " var=" << symbol_table.getName(var) << " (" << var << ") lag=" << lag;
|
||||
ExprNodeOutputType output_type=oMatlabDynamicModelSparse;
|
||||
const temporary_terms_type temporary_terms;
|
||||
cout << " derivative = ";
|
||||
(it2->second)->writeOutput(cout, output_type, temporary_terms);
|
||||
cout << "\n";*/
|
||||
if (lag==0)
|
||||
curr_endo_derivatives[make_pair(eq, var)] = it2->second;
|
||||
//if (lag==0)
|
||||
endo_derivatives[make_pair(eq, make_pair(var, lag))] = it2->second;
|
||||
}
|
||||
}
|
||||
return curr_endo_derivatives;
|
||||
return endo_derivatives;
|
||||
}
|
||||
|
||||
|
||||
|
@ -2549,9 +2543,9 @@ DynamicModel::computingPass(bool jacobianExo, bool hessian, bool thirdDerivative
|
|||
block_triangular.incidencematrix.Print_IM(eEndogenous);
|
||||
}
|
||||
t_etype equation_simulation_type;
|
||||
map<pair<int, int >, NodeID> first_cur_endo_derivatives = collect_first_order_derivatives_current_endogenous();
|
||||
map<pair<int, pair<int, int> >, NodeID> first_order_endo_derivatives = collect_first_order_derivatives_endogenous();
|
||||
|
||||
block_triangular.Normalize_and_BlockDecompose_Static_0_Model(j_m, equations, equation_simulation_type, first_cur_endo_derivatives);
|
||||
block_triangular.Normalize_and_BlockDecompose_Static_0_Model(j_m, equations, equation_simulation_type, first_order_endo_derivatives);
|
||||
BlockLinear(block_triangular.ModelBlock);
|
||||
if (!no_tmp_terms)
|
||||
computeTemporaryTermsOrdered(block_triangular.ModelBlock);
|
||||
|
|
|
@ -110,7 +110,7 @@ private:
|
|||
//! Computes temporary terms for the file containing parameters derivatives
|
||||
void computeParamsDerivativesTemporaryTerms();
|
||||
//! Collect only the first derivatives
|
||||
map<pair<int, int >, NodeID> collect_first_order_derivatives_current_endogenous();
|
||||
map<pair<int, pair<int, int> >, NodeID> collect_first_order_derivatives_endogenous();
|
||||
|
||||
public:
|
||||
DynamicModel(SymbolTable &symbol_table_arg, NumericalConstants &num_constants);
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#include <map>
|
||||
#include "ExprNode.hh"
|
||||
#include "SymbolTable.hh"
|
||||
#include "ModelNormalization.hh"
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue