...
 
Commits (4)
This diff is collapsed.
......@@ -556,7 +556,7 @@ public:
};
//! Return the number of blocks
unsigned int
int
getNbBlocks() const override
{
return block_type_firstequation_size_mfs.size();
......@@ -568,43 +568,43 @@ public:
return get<0>(block_type_firstequation_size_mfs[block_number]);
};
//! Return the first equation number of a block
unsigned int
int
getBlockFirstEquation(int block_number) const override
{
return get<1>(block_type_firstequation_size_mfs[block_number]);
};
//! Return the size of the block block_number
unsigned int
int
getBlockSize(int block_number) const override
{
return get<2>(block_type_firstequation_size_mfs[block_number]);
};
//! Return the number of exogenous variable in the block block_number
unsigned int
int
getBlockExoSize(int block_number) const override
{
return block_var_exo[block_number].first.size();
};
//! Return the number of colums in the jacobian matrix for exogenous variable in the block block_number
unsigned int
int
getBlockExoColSize(int block_number) const override
{
return block_var_exo[block_number].second;
};
//! Return the number of feedback variable of the block block_number
unsigned int
int
getBlockMfs(int block_number) const override
{
return get<3>(block_type_firstequation_size_mfs[block_number]);
};
//! Return the maximum lag in a block
unsigned int
int
getBlockMaxLag(int block_number) const override
{
return block_lag_lead[block_number].first;
};
//! Return the maximum lead in a block
unsigned int
int
getBlockMaxLead(int block_number) const override
{
return block_lag_lead[block_number].second;
......@@ -655,13 +655,13 @@ public:
int
getBlockInitialEquationID(int block_number, int equation_number) const override
{
return static_cast<int>(inv_equation_reordered[equation_number]) - static_cast<int>(get<1>(block_type_firstequation_size_mfs[block_number]));
return inv_equation_reordered[equation_number] - get<1>(block_type_firstequation_size_mfs[block_number]);
};
//! Return the position of variable_number in the block number belonging to the block block_number
int
getBlockInitialVariableID(int block_number, int variable_number) const override
{
return static_cast<int>(inv_variable_reordered[variable_number]) - static_cast<int>(get<1>(block_type_firstequation_size_mfs[block_number]));
return inv_variable_reordered[variable_number] - get<1>(block_type_firstequation_size_mfs[block_number]);
};
//! Return the block number containing the endogenous variable variable_number
int
......@@ -724,28 +724,4 @@ public:
bool isChecksumMatching(const string &basename, bool block) const;
};
//! Classes to re-order derivatives for various sparse storage formats
class derivative
{
public:
long unsigned int linear_address;
long unsigned int col_nbr;
unsigned int row_nbr;
expr_t value;
derivative(long unsigned int arg1, long unsigned int arg2, int arg3, expr_t arg4) :
linear_address(arg1), col_nbr(arg2), row_nbr(arg3), value(arg4)
{
};
};
class derivative_less_than
{
public:
bool
operator()(const derivative &d1, const derivative &d2) const
{
return d1.linear_address < d2.linear_address;
}
};
#endif
......@@ -8163,7 +8163,7 @@ FirstDerivExternalFunctionNode::compileExternalFunctionOutput(ostream &CompileCo
{
unsigned int nb_input_arguments = 0;
unsigned int nb_output_arguments = 1;
unsigned int indx = getIndxInTefTerms(symb_id, tef_terms);
int indx = getIndxInTefTerms(symb_id, tef_terms);
FCALL_ fcall(nb_output_arguments, nb_input_arguments, "jacob_element", indx);
fcall.set_arg_func_name(datatree.symbol_table.getName(symb_id));
fcall.set_row(inputIndex);
......
......@@ -123,18 +123,18 @@ namespace MFS
}
AdjacencyList_t
AM_2_AdjacencyList(bool *AM, unsigned int n)
AM_2_AdjacencyList(bool *AM, int n)
{
AdjacencyList_t G(n);
auto v_index = get(vertex_index, G);
auto v_index1 = get(vertex_index1, G);
for (unsigned int i = 0; i < n; i++)
for (int i = 0; i < n; i++)
{
put(v_index, vertex(i, G), i);
put(v_index1, vertex(i, G), i);
}
for (unsigned int i = 0; i < n; i++)
for (unsigned int j = 0; j < n; j++)
for (int i = 0; i < n; i++)
for (int j = 0; j < n; j++)
if (AM[i*n+j])
add_edge(vertex(j, G), vertex(i, G), G);
return G;
......@@ -143,14 +143,14 @@ namespace MFS
AdjacencyList_t
extract_subgraph(AdjacencyList_t &G1, set<int> select_index)
{
unsigned int n = select_index.size();
int n = select_index.size();
AdjacencyList_t G(n);
auto v_index = get(vertex_index, G);
auto v_index1 = get(vertex_index1, G);
auto v1_index = get(vertex_index, G1);
map<int, int> reverse_index;
set<int>::iterator it;
unsigned int i;
int i;
for (it = select_index.begin(), i = 0; i < n; i++, ++it)
{
reverse_index[get(v1_index, vertex(*it, G1))] = i;
......@@ -205,11 +205,11 @@ namespace MFS
{
if (it_in != in_end || it_out != out_end)
agree = false;
unsigned int i = 1;
while (i < liste.size() && agree)
int i = 1;
while (i < static_cast<int>(liste.size()) && agree)
{
unsigned int j = i + 1;
while (j < liste.size() && agree)
int j = i + 1;
while (j < static_cast<int>(liste.size()) && agree)
{
AdjacencyList_t::edge_descriptor ed;
bool exist1, exist2;
......@@ -379,10 +379,10 @@ namespace MFS
if (num_vertices(G) > 0)
{
/*if nothing has been done in the five previous rule then cut the vertex with the maximum in_degree+out_degree*/
unsigned int max_degree = 0, num = 0;
int max_degree = 0, num = 0;
AdjacencyList_t::vertex_iterator it, it_end, max_degree_index;
for (tie(it, it_end) = vertices(G); it != it_end; ++it, num++)
if (in_degree(*it, G) + out_degree(*it, G) > max_degree)
if (static_cast<int>(in_degree(*it, G) + out_degree(*it, G)) > max_degree)
{
max_degree = in_degree(*it, G) + out_degree(*it, G);
max_degree_index = it;
......
This diff is collapsed.
......@@ -256,12 +256,12 @@ protected:
/*! First index is equation number, second index is endogenous type specific ID */
using jacob_map_t = map<pair<int, int>, double>;
//! Normalization of equations
//! Normalization of equations, as computed by computeNonSingularNormalization()
/*! Maps endogenous type specific IDs to equation numbers */
vector<int> endo2eq;
//! number of equation in the prologue and in the epilogue
unsigned int epilogue, prologue;
int epilogue, prologue;
//! for each block contains pair< max_lag, max_lead>
lag_lead_vector_t block_lag_lead;
......@@ -277,19 +277,20 @@ protected:
/*!
Applied to the jacobian contemporaneous_jacobian and stop when a matching is found.
If no matching is found using a strictly positive cutoff, then a zero cutoff is applied (i.e. use a symbolic normalization); in that case, the method adds zeros in the jacobian matrices to reflect all the edges in the symbolic incidence matrix.
If no matching is found with a zero cutoff close to zero an error message is printout.
If no matching is found with a zero cutoff, an error message is printed.
The resulting normalization is stored in endo2eq.
*/
void computeNonSingularNormalization(jacob_map_t &contemporaneous_jacobian, double cutoff, jacob_map_t &static_jacobian);
//! Try to find a natural normalization if all equations are matched to an endogenous variable on the LHS
bool computeNaturalNormalization();
//! Evaluate the jacobian (w.r.t. endogenous) and suppress all the elements below the cutoff
/*! Returns a pair (contemporaneous_jacobian, static_jacobian). Also fills
dynamic_jacobian. External functions are evaluated to 1. */
dynamic_jacobian. Elements below the cutoff are discarded. External functions are evaluated to 1. */
pair<jacob_map_t, jacob_map_t> evaluateAndReduceJacobian(const eval_context_t &eval_context, double cutoff, bool verbose);
//! Select and reorder the non linear equations of the model
/*! Returns a tuple (blocks, equation_lag_lead, variable_lag_lead, n_static,
n_forward, n_backward, n_mixed) */
tuple<vector<pair<int, int>>, lag_lead_vector_t, lag_lead_vector_t, vector<unsigned int>, vector<unsigned int>, vector<unsigned int>, vector<unsigned int>> select_non_linear_equations_and_variables(const vector<bool> &is_equation_linear);
tuple<vector<pair<int, int>>, lag_lead_vector_t, lag_lead_vector_t, vector<int>, vector<int>, vector<int>, vector<int>> select_non_linear_equations_and_variables(const vector<bool> &is_equation_linear);
//! Search the equations and variables belonging to the prologue and the epilogue of the model
void computePrologueAndEpilogue(const jacob_map_t &static_jacobian);
//! Determine the type of each equation of model and try to normalize the unnormalized equation
......@@ -297,9 +298,9 @@ protected:
//! Compute the block decomposition and for a non-recusive block find the minimum feedback set
/*! Returns a tuple (blocks, equation_lag_lead, variable_lag_lead, n_static,
n_forward, n_backward, n_mixed) */
tuple<vector<pair<int, int>>, lag_lead_vector_t, lag_lead_vector_t, vector<unsigned int>, vector<unsigned int>, vector<unsigned int>, vector<unsigned int>> computeBlockDecompositionAndFeedbackVariablesForEachBlock(const jacob_map_t &static_jacobian, const equation_type_and_normalized_equation_t &Equation_Type, bool verbose_, bool select_feedback_variable);
tuple<vector<pair<int, int>>, lag_lead_vector_t, lag_lead_vector_t, vector<int>, vector<int>, vector<int>, vector<int>> computeBlockDecompositionAndFeedbackVariablesForEachBlock(const jacob_map_t &static_jacobian, const equation_type_and_normalized_equation_t &Equation_Type, bool verbose_, bool select_feedback_variable);
//! Reduce the number of block merging the same type equation in the prologue and the epilogue and determine the type of each block
void reduceBlocksAndTypeDetermination(const vector<pair<int, int>> &blocks, const equation_type_and_normalized_equation_t &Equation_Type, const vector<unsigned int> &n_static, const vector<unsigned int> &n_forward, const vector<unsigned int> &n_backward, const vector<unsigned int> &n_mixed, bool linear_decomposition);
void reduceBlocksAndTypeDetermination(const vector<pair<int, int>> &blocks, const equation_type_and_normalized_equation_t &Equation_Type, const vector<int> &n_static, const vector<int> &n_forward, const vector<int> &n_backward, const vector<int> &n_mixed, bool linear_decomposition);
//! Determine the maximum number of lead and lag for the endogenous variable in a bloc
/*! Returns a pair { equation_lead,lag, variable_lead_lag } */
pair<lag_lead_vector_t, lag_lead_vector_t> getVariableLeadLagByBlock(const vector<int> &components_set, int nb_blck_sim) const;
......@@ -317,21 +318,21 @@ protected:
//! Determine the simulation type of each block
virtual BlockSimulationType getBlockSimulationType(int block_number) const = 0;
//! Return the number of blocks
virtual unsigned int getNbBlocks() const = 0;
virtual int getNbBlocks() const = 0;
//! Return the first equation number of a block
virtual unsigned int getBlockFirstEquation(int block_number) const = 0;
virtual int getBlockFirstEquation(int block_number) const = 0;
//! Return the size of the block block_number
virtual unsigned int getBlockSize(int block_number) const = 0;
virtual int getBlockSize(int block_number) const = 0;
//! Return the number of exogenous variable in the block block_number
virtual unsigned int getBlockExoSize(int block_number) const = 0;
virtual int getBlockExoSize(int block_number) const = 0;
//! Return the number of colums in the jacobian matrix for exogenous variable in the block block_number
virtual unsigned int getBlockExoColSize(int block_number) const = 0;
virtual int getBlockExoColSize(int block_number) const = 0;
//! Return the number of feedback variable of the block block_number
virtual unsigned int getBlockMfs(int block_number) const = 0;
virtual int getBlockMfs(int block_number) const = 0;
//! Return the maximum lag in a block
virtual unsigned int getBlockMaxLag(int block_number) const = 0;
virtual int getBlockMaxLag(int block_number) const = 0;
//! Return the maximum lead in a block
virtual unsigned int getBlockMaxLead(int block_number) const = 0;
virtual int getBlockMaxLead(int block_number) const = 0;
inline void
setBlockLeadLag(int block, int max_lag, int max_lead)
{
......
This diff is collapsed.
......@@ -193,7 +193,7 @@ public:
void addAllParamDerivId(set<int> &deriv_id_set) override;
//! Return the number of blocks
unsigned int
int
getNbBlocks() const override
{
return (block_type_firstequation_size_mfs.size());
......@@ -205,43 +205,43 @@ public:
return (get<0>(block_type_firstequation_size_mfs[block_number]));
};
//! Return the first equation number of a block
unsigned int
int
getBlockFirstEquation(int block_number) const override
{
return (get<1>(block_type_firstequation_size_mfs[block_number]));
};
//! Return the size of the block block_number
unsigned int
int
getBlockSize(int block_number) const override
{
return (get<2>(block_type_firstequation_size_mfs[block_number]));
};
//! Return the number of exogenous variable in the block block_number
unsigned int
int
getBlockExoSize(int block_number) const override
{
return 0;
};
//! Return the number of colums in the jacobian matrix for exogenous variable in the block block_number
unsigned int
int
getBlockExoColSize(int block_number) const override
{
return 0;
}
//! Return the number of feedback variable of the block block_number
unsigned int
int
getBlockMfs(int block_number) const override
{
return (get<3>(block_type_firstequation_size_mfs[block_number]));
};
//! Return the maximum lag in a block
unsigned int
int
getBlockMaxLag(int block_number) const override
{
return (block_lag_lead[block_number].first);
};
//! Return the maximum lead in a block
unsigned int
int
getBlockMaxLead(int block_number) const override
{
return (block_lag_lead[block_number].second);
......@@ -292,13 +292,13 @@ public:
int
getBlockInitialEquationID(int block_number, int equation_number) const override
{
return (static_cast<int>(inv_equation_reordered[equation_number]) - static_cast<int>(get<1>(block_type_firstequation_size_mfs[block_number])));
return inv_equation_reordered[equation_number] - get<1>(block_type_firstequation_size_mfs[block_number]);
};
//! Return the position of variable_number in the block number belonging to the block block_number
int
getBlockInitialVariableID(int block_number, int variable_number) const override
{
return (static_cast<int>(inv_variable_reordered[variable_number]) - static_cast<int>(get<1>(block_type_firstequation_size_mfs[block_number])));
return inv_variable_reordered[variable_number] - get<1>(block_type_firstequation_size_mfs[block_number]);
};
//! Return the position of variable_number in the block number belonging to the block block_number
int
......