diff --git a/preprocessor/ExprNode.hh b/preprocessor/ExprNode.hh
index 1a4274001c33f290af0978af6c77f045ced071e7..0383272a475a2fdbb07b80d2fe6696b4527c1427 100644
--- a/preprocessor/ExprNode.hh
+++ b/preprocessor/ExprNode.hh
@@ -140,10 +140,19 @@ public:
void writeOutput(ostream &output);
//! Computes the set of endogenous variables in the expression
- /*! Endogenous are stored as integer pairs of the form (symb_id, lag)
- They are added to the set given in argument */
+ /*!
+ Endogenous are stored as integer pairs of the form (symb_id, lag).
+ They are added to the set given in argument.
+ */
virtual void collectEndogenous(set<pair<int, int> > &result) const = 0;
+
+ //! Computes the set of exogenous variables in the expression
+ /*!
+ Exogenous are stored as integer pairs of the form (symb_id, lag).
+ They are added to the set given in argument.
+ */
virtual void collectExogenous(set<pair<int, int> > &result) const = 0;
+
virtual void collectTemporary_terms(const temporary_terms_type &temporary_terms, Model_Block *ModelBlock, int Curr_Block) const = 0;
virtual void computeTemporaryTerms(map<NodeID, int> &reference_count,
temporary_terms_type &temporary_terms,
diff --git a/preprocessor/StaticModel.cc b/preprocessor/StaticModel.cc
index 838d7a0ad5586c09fb0ba4fb8cde27a22ab4a49b..f125d56d52008aba161660ac96c1e07e2645cecf 100644
--- a/preprocessor/StaticModel.cc
+++ b/preprocessor/StaticModel.cc
@@ -18,9 +18,15 @@
*/
#include <cstdlib>
+#include <cassert>
+
+#include <boost/graph/adjacency_list.hpp>
+#include <boost/graph/max_cardinality_matching.hpp>
#include "StaticModel.hh"
+using namespace boost;
+
StaticModel::StaticModel(SymbolTable &symbol_table_arg,
NumericalConstants &num_constants_arg) :
ModelTree(symbol_table_arg, num_constants_arg)
@@ -305,3 +311,41 @@ StaticModel::getDerivID(int symb_id, int lag) const throw (UnknownDerivIDExcepti
else
throw UnknownDerivIDException();
}
+
+void
+StaticModel::computeNormalization()
+{
+ int n = equation_number();
+
+ assert(n == symbol_table.endo_nbr());
+
+ typedef adjacency_list<vecS, vecS, undirectedS> BipartiteGraph;
+
+ /*
+ Vertices 0 to n-1 are for endogenous (using type specific ID)
+ Vertices n to 2*n-1 are for equations (using equation no.)
+ */
+ BipartiteGraph g(2 * n);
+
+ // Fill in the graph
+ set<pair<int, int> > endo;
+ for(int i = 0; i < n; i++)
+ {
+ endo.clear();
+ equations[i]->collectEndogenous(endo);
+ for(set<pair<int, int> >::const_iterator it = endo.begin();
+ it != endo.end(); it++)
+ add_edge(i + n, symbol_table.getTypeSpecificID(it->first), g);
+ }
+
+ // Compute maximum cardinality matching
+ vector<graph_traits<BipartiteGraph>::vertex_descriptor> mate_map(2*n);
+
+ bool check = checked_edmonds_maximum_cardinality_matching(g, &mate_map[0]);
+
+ assert(check);
+
+ for(int i = 0; i < n; i++)
+ cout << "Endogenous " << symbol_table.getName(symbol_table.getID(eEndogenous, i)) << " matched with equation "
+ << (mate_map[i]-n+1) << endl;
+}
diff --git a/preprocessor/StaticModel.hh b/preprocessor/StaticModel.hh
index 8c6dd119037c02cb6c760205721ddfdebb56a6dd..5c7beb5b256627cd7f25e12ad8b580f99c50fee0 100644
--- a/preprocessor/StaticModel.hh
+++ b/preprocessor/StaticModel.hh
@@ -39,6 +39,9 @@ private:
virtual int computeDerivID(int symb_id, int lag);
+ //! Computes normalization of the static model
+ void computeNormalization();
+
public:
StaticModel(SymbolTable &symbol_table_arg, NumericalConstants &num_constants);
//! Execute computations (derivation)