5 #ifndef LODESTAR_STRONGLYCONNECTEDCOMPONENTS_HPP
6 #define LODESTAR_STRONGLYCONNECTEDCOMPONENTS_HPP
8 #include "DirectedGraph.hpp"
9 #include "Lodestar/blocks/BlockPack.hpp"
19 SCCResult() : components(0, ::std::vector<int>(0))
22 SCCResult(const ::std::vector<::std::vector<int>> &v) : components(v.begin(), v.end())
27 ::std::swap(components, other.components);
40 ::std::vector<::std::vector<int>> components{};
44 ::std::vector<FullConnection>,
45 ::std::vector<FullConnection>
48 int componentIdx = 0)
const;
51 ::std::vector<FullConnection>
53 int componentIdx = 0)
const;
55 bool isSubset(
int sup,
int sub)
const;
57 bool intersects(
int idx1,
int idx2)
const;
59 bool isAlgebraicLoop(
const BlockPack &bp,
int componentIdx = 0)
const;
61 bool containsAlgebraicLoops(
const BlockPack &bp)
const;
63 ::std::vector<const BlockProto *>
64 extractBlocks(const ::std::vector<FullConnection> &connections)
const;
66 ::std::size_t getComponentLength(
int componentIdx = 0)
const;
70 GiNaC::lst getSymbolicEquationList(
const BlockPack &bp,
int componentIdx = 0)
const;
72 GiNaC::lst getInterconnectionEquationList(
const BlockPack &bp,
int componentIdx = 0)
const;
74 GiNaC::lst getBlockEquationList(
const BlockPack &bp,
int componentIdx = 0)
const;
76 GiNaC::lst getKnownSymbolList(
const BlockPack &bp,
int componentIdx = 0)
const;
78 GiNaC::lst getUnknownSymbolList(
const BlockPack &bp,
int componentIdx = 0)
const;
80 ::std::pair<GiNaC::lst, GiNaC::lst>
81 getAlgebraicEquations(
const BlockPack &bp,
int componentIdx = 0)
const;
84 getAlgebraicEquationsJacobian(
const GiNaC::lst &eqs,
const GiNaC::lst &vars);
86 static ::std::pair<GiNaC::matrix, GiNaC::matrix>
87 solveAlgebraicEquationsNewtonRaphson(
const GiNaC::lst &eqs,
const GiNaC::matrix &jac,
88 const GiNaC::lst &vars);
90 static void expandListToSymbols(
const GiNaC::lst &l, GiNaC::lst &g);
92 static void expandListToSymbols(
const GiNaC::matrix &l, GiNaC::lst &g);
94 static void substituteExpressions(GiNaC::ex &ex, GiNaC::lst &subs);
101 bool allowSingletons =
false);
107 ::std::vector<int> &disc,
108 ::std::vector<int> &low,
109 ::std::stack<int> &stack,
110 ::std::vector<bool> &stackItem,
111 ::std::vector<::std::vector<int>> &components,
113 bool allowSingletons);
120 #endif //LODESTAR_STRONGLYCONNECTEDCOMPONENTS_HPP