Skip to content
Snippets Groups Projects
Commit 19ca8624 authored by Sébastien Villemot's avatar Sébastien Villemot Committed by MichelJuillard
Browse files

Block decomposition: simplify code for ordering dynamic Jacobian columns

parent 39a1a4a1
No related branches found
No related tags found
1 merge request!19Initval histval file
......@@ -1406,9 +1406,9 @@ private:
uint8_t type;
vector<int> variable;
vector<int> equation;
vector<unsigned int> other_endogenous;
vector<unsigned int> exogenous;
vector<unsigned int> det_exogenous;
vector<int> other_endogenous;
vector<int> exogenous;
vector<int> det_exogenous;
bool is_linear;
vector<Block_contain_type> Block_Contain_;
int endo_nbr;
......@@ -1429,14 +1429,14 @@ public:
const vector<int> &variable_arg, const vector<int> &equation_arg,
bool is_linear_arg, int endo_nbr_arg, int Max_Lag_arg, int Max_Lead_arg, int &u_count_int_arg, int nb_col_jacob_arg,
unsigned int det_exo_size_arg, unsigned int nb_col_det_exo_jacob_arg, unsigned int exo_size_arg, unsigned int nb_col_exo_jacob_arg, unsigned int other_endo_size_arg, unsigned int nb_col_other_endo_jacob_arg,
const vector<unsigned int> &det_exogenous_arg, const vector<unsigned int> &exogenous_arg, const vector<unsigned int> &other_endogenous_arg) :
vector<int> det_exogenous_arg, vector<int> exogenous_arg, vector<int> other_endogenous_arg) :
size{static_cast<int>(size_arg)},
type{static_cast<uint8_t>(type_arg)},
variable{variable_arg.begin()+first_element, variable_arg.begin()+(first_element+block_size)},
equation{equation_arg.begin()+first_element, equation_arg.begin()+(first_element+block_size)},
other_endogenous{other_endogenous_arg},
exogenous{exogenous_arg},
det_exogenous{det_exogenous_arg},
other_endogenous{move(other_endogenous_arg)},
exogenous{move(exogenous_arg)},
det_exogenous{move(det_exogenous_arg)},
is_linear{is_linear_arg},
endo_nbr{endo_nbr_arg},
Max_Lag{Max_Lag_arg},
......@@ -1553,7 +1553,7 @@ public:
{
return variable;
}
inline vector<unsigned int>
inline vector<int>
get_exogenous()
{
return exogenous;
......@@ -1632,19 +1632,19 @@ public:
for (unsigned int i = 0; i < det_exo_size; i++)
{
unsigned int tmp_i;
int tmp_i;
memcpy(&tmp_i, code, sizeof(tmp_i)); code += sizeof(tmp_i);
det_exogenous.push_back(tmp_i);
}
for (unsigned int i = 0; i < exo_size; i++)
{
unsigned int tmp_i;
int tmp_i;
memcpy(&tmp_i, code, sizeof(tmp_i)); code += sizeof(tmp_i);
exogenous.push_back(tmp_i);
}
for (unsigned int i = 0; i < other_endo_size; i++)
{
unsigned int tmp_i;
int tmp_i;
memcpy(&tmp_i, code, sizeof(tmp_i)); code += sizeof(tmp_i);
other_endogenous.push_back(tmp_i);
}
......
This diff is collapsed.
......@@ -110,6 +110,15 @@ private:
vector<map<tuple<int, int, int>, expr_t>> blocks_derivatives_other_endo,
blocks_derivatives_exo, blocks_derivatives_exo_det;
// For each block, gives type-specific other endos / exo / exo det that appear in it
vector<set<int>> blocks_other_endo, blocks_exo, blocks_exo_det;
/* For each block, and for each variable type, maps (variable ID, lag) to
Jacobian column.
For the “endo” version, the variable ID is the index within the block. For
the three others, it’s the type-specific ID */
vector<map<pair<int, int>, int>> blocks_jacob_cols_endo, blocks_jacob_cols_other_endo, blocks_jacob_cols_exo, blocks_jacob_cols_exo_det;
//! Writes dynamic model file (Matlab version)
void writeDynamicMFile(const string &basename) const;
//! Writes dynamic model file (Julia version)
......@@ -177,8 +186,11 @@ private:
/*! Also computes max_{endo,exo}_{lead_lag}, and initializes dynJacobianColsNbr to the number of dynamic endos */
void computeDerivIDs();
//! Collecte the derivatives w.r. to endogenous of the block, to endogenous of previouys blocks and to exogenous
void collect_block_first_order_derivatives();
/* Compute the Jacobian column indices in the block decomposition case
(stored in blocks_jacob_cols_*).
Also fills auxiliary structures related to “other” endogenous and
exogenous: blocks{,_derivatives}_{other_endo,exo_exo_det} */
void computeBlockDynJacobianCols();
//! Factorized code for substitutions of leads/lags
/*! \param[in] type determines which type of variables is concerned
......@@ -190,11 +202,6 @@ private:
//! Indicate if the temporary terms are computed for the overall model (true) or not (false). Default value true
bool global_temporary_terms{true};
//!List for each block and for each lag-lead all the other endogenous variables and exogenous variables
using var_t = set<int>;
using lag_var_t = map<int, var_t>;
vector<lag_var_t> other_endo_block, exo_block, exo_det_block;
//! Help computeXrefs to compute the reverse references (i.e. param->eqs, endo->eqs, etc)
void computeRevXref(map<pair<int, int>, set<int>> &xrefset, const set<pair<int, int>> &eiref, int eqn);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment