Chain-Load: implement graph statistic computation

- iterate over all nodes and classify them
- group per level
- book in per level statistics into the Indicator records
- close global averages

...just coded, not yet tested...
This commit is contained in:
Fischlurch 2023-11-28 03:03:55 +01:00
parent d968da989e
commit c3bef6d344
2 changed files with 101 additions and 16 deletions

View file

@ -245,10 +245,19 @@ namespace test {
friend bool isStart (Node const& n) { return isnil (n.pred); };
friend bool isExit (Node const& n) { return isnil (n.succ); };
friend bool isInner (Node const& n) { return not (isStart(n) or isExit(n)); }
friend bool isFork (Node const& n) { return 1 < n.succ.size(); }
friend bool isJoin (Node const& n) { return 1 < n.pred.size(); }
friend bool isLink (Node const& n) { return 1 == n.pred.size() and 1 == n.succ.size(); }
friend bool isKnot (Node const& n) { return isFork(n) and isJoin(n); }
friend bool isStart (Node const* n) { return n and isStart (*n); };
friend bool isExit (Node const* n) { return n and isExit (*n); };
friend bool isInner (Node const* n) { return n and isInner (*n); };
friend bool isStart (Node const* n) { return n and isStart(*n); };
friend bool isExit (Node const* n) { return n and isExit (*n); };
friend bool isInner (Node const* n) { return n and isInner(*n); };
friend bool isFork (Node const* n) { return n and isFork (*n); };
friend bool isJoin (Node const* n) { return n and isJoin (*n); };
friend bool isLink (Node const* n) { return n and isLink (*n); };
friend bool isKnot (Node const* n) { return n and isKnot (*n); };
};
@ -533,6 +542,9 @@ namespace test {
return move(*this);
}
Statistic computeGraphStatistics();
private:
};
@ -647,6 +659,23 @@ namespace test {
const std::array KEYS = {STAT_SEED,STAT_EXIT,STAT_INNR,STAT_FORK,STAT_JOIN,STAT_LINK,STAT_KNOT};
const uint CAT = KEYS.size();
namespace {
template<class NOD>
inline auto
buildEvaluations()
{
return std::array<std::function<uint(NOD&)>, CAT>
{ [](NOD& n){ return isStart(n);}
, [](NOD& n){ return isExit(n); }
, [](NOD& n){ return isInner(n);}
, [](NOD& n){ return isFork(n); }
, [](NOD& n){ return isJoin(n); }
, [](NOD& n){ return isLink(n); }
, [](NOD& n){ return isKnot(n); }
};
}
}
using VecU = std::vector<uint>;
using LevelSums = std::array<uint, CAT>;
@ -693,7 +722,7 @@ namespace test {
/**
* Statistic data calculated for a given chain-load topology
*/
struct Staticstic
struct Statistic
{
uint nodes{0};
uint levels{0};
@ -702,7 +731,7 @@ namespace test {
std::map<const string, Indicator> indicators;
explicit
Staticstic (uint lvls)
Statistic (uint lvls)
: nodes{0}
, levels{lvls}
{
@ -742,5 +771,41 @@ namespace test {
template<size_t numNodes, size_t maxFan>
inline Statistic
TestChainLoad<numNodes,maxFan>::computeGraphStatistics()
{
auto totalLevels = uint(topLevel());
auto classify = buildEvaluations<Node>();
Statistic stat(totalLevels);
LevelSums particulars{0};
size_t level{0};
uint width{0};
for (Node& node : allNodes())
{
++width;
for (uint i=0; i<CAT; ++i)
particulars[i] += classify[i](node);
if (level != node.level)
{ // record statistics for previous level
stat.addPoint (width, particulars);
// switch to next time-level
++level;
ENSURE (level == node.level);
particulars = LevelSums{0};
width = 0;
}
}
ENSURE (level = topLevel());
stat.addPoint (width, particulars);
stat.closeAverages();
return stat;
}
}}} // namespace vault::gear::test
#endif /*VAULT_GEAR_TEST_TEST_CHAIN_LOAD_H*/

View file

@ -99410,8 +99410,8 @@ Date:&#160;&#160;&#160;Thu Apr 20 18:53:17 2023 +0200<br/>
<node CREATED="1701015081865" ID="ID_1426934946" MODIFIED="1701015088816" TEXT="average"/>
</node>
</node>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1701016789541" ID="ID_677587050" MODIFIED="1701016798574" TEXT="Berechnung">
<icon BUILTIN="flag-yellow"/>
<node BACKGROUND_COLOR="#eef0c5" COLOR="#990000" CREATED="1701016789541" ID="ID_677587050" MODIFIED="1701140137686" TEXT="Berechnung">
<icon BUILTIN="pencil"/>
<node CREATED="1701016800527" ID="ID_465492261" MODIFIED="1701125333044" TEXT="auf Erweiterbarkeit abzielen">
<richcontent TYPE="NOTE"><html>
<head/>
@ -99423,8 +99423,8 @@ Date:&#160;&#160;&#160;Thu Apr 20 18:53:17 2023 +0200<br/>
</html></richcontent>
<icon BUILTIN="yes"/>
</node>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1701125376983" ID="ID_1738324890" MODIFIED="1701125382060" TEXT="Daten-Record">
<icon BUILTIN="flag-yellow"/>
<node BACKGROUND_COLOR="#eef0c5" COLOR="#990000" CREATED="1701125376983" ID="ID_1738324890" MODIFIED="1701140134675" TEXT="Daten-Record">
<icon BUILTIN="pencil"/>
<node CREATED="1701125441964" ID="ID_418000988" MODIFIED="1701125470010" TEXT="feste Datenfelder als uint und double"/>
<node CREATED="1701125474136" ID="ID_774880220" MODIFIED="1701125477483" TEXT="Benennungs-Schema">
<node CREATED="1701126033651" ID="ID_1862774018" MODIFIED="1701126080812" TEXT="forks[lev]">
@ -99546,6 +99546,7 @@ Date:&#160;&#160;&#160;Thu Apr 20 18:53:17 2023 +0200<br/>
</node>
</node>
<node CREATED="1701127574637" ID="ID_923332375" MODIFIED="1701127579225" TEXT="Struktur">
<node CREATED="1701129033182" ID="ID_480359437" MODIFIED="1701129047234" TEXT="als eigenst&#xe4;ndiger Typ im Namespace"/>
<node CREATED="1701127580038" ID="ID_856358485" MODIFIED="1701127646988" TEXT="globals">
<node CREATED="1701127588184" ID="ID_1819109646" MODIFIED="1701127599814" TEXT="Node-Z&#xe4;hler"/>
<node CREATED="1701127600974" ID="ID_173189022" MODIFIED="1701127612041" TEXT="Vector der Level-Breiten"/>
@ -99556,11 +99557,12 @@ Date:&#160;&#160;&#160;Thu Apr 20 18:53:17 2023 +0200<br/>
</node>
</node>
</node>
<node CREATED="1701126784469" ID="ID_1887920945" MODIFIED="1701126788192" TEXT="Rechenweg">
<node BACKGROUND_COLOR="#eef0c5" COLOR="#990000" CREATED="1701126784469" ID="ID_1887920945" MODIFIED="1701140211229" TEXT="Rechenweg">
<icon BUILTIN="pencil"/>
<node BACKGROUND_COLOR="#e0ceaa" COLOR="#690f14" CREATED="1701126789108" ID="ID_1733334637" MODIFIED="1701126799986" TEXT="das wird verdammt repetitiv">
<icon BUILTIN="stop-sign"/>
</node>
<node CREATED="1701126885253" ID="ID_988227984" MODIFIED="1701126891770" TEXT="Sub-Objekte einf&#xfc;hren">
<node COLOR="#435e98" CREATED="1701126885253" ID="ID_988227984" MODIFIED="1701140161284" TEXT="Sub-Objekte einf&#xfc;hren">
<icon BUILTIN="yes"/>
<node CREATED="1701126896342" ID="ID_628957116" MODIFIED="1701126910351" TEXT="da der Rechenweg stets gleich ist"/>
<node COLOR="#435e98" CREATED="1701126911196" ID="ID_609498555" MODIFIED="1701127120136" TEXT="Frage: Ablage und Zugriff?">
@ -99576,11 +99578,17 @@ Date:&#160;&#160;&#160;Thu Apr 20 18:53:17 2023 +0200<br/>
<node CREATED="1701127280727" ID="ID_211987609" MODIFIED="1701127280727" TEXT="enth&#xe4;lt einen data-Vector"/>
<node CREATED="1701127286949" ID="ID_113578279" MODIFIED="1701127312993" TEXT="ggfs sp&#xe4;ter weitere Tabellen (MA, lokaler Trend)"/>
<node CREATED="1701127339746" ID="ID_552079211" MODIFIED="1701127349436" TEXT="sowie feste Datenfelder f&#xfc;r die Kennzahlen"/>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1701127401298" ID="ID_1356798063" MODIFIED="1701127564540" TEXT="Berechnung-1">
<icon BUILTIN="flag-yellow"/>
<node CREATED="1701127405705" ID="ID_1717640247" MODIFIED="1701127444776" TEXT="ein Datenpunkt + Breite"/>
<node CREATED="1701127445812" ID="ID_1308319193" MODIFIED="1701127519477" TEXT="legt Daten ab und akkumuliert Integrale"/>
<node CREATED="1701127520281" ID="ID_327297411" MODIFIED="1701127537417" TEXT="Abschlu&#xdf;: Gesamtzahl &#x27fc; &#x2205;"/>
<node BACKGROUND_COLOR="#eef0c5" COLOR="#990000" CREATED="1701127401298" ID="ID_1356798063" MODIFIED="1701140125631" TEXT="Berechnung-1">
<icon BUILTIN="pencil"/>
<node COLOR="#338800" CREATED="1701127405705" ID="ID_1717640247" MODIFIED="1701140156044" TEXT="ein Datenpunkt + Breite">
<icon BUILTIN="button_ok"/>
</node>
<node COLOR="#338800" CREATED="1701127445812" ID="ID_1308319193" MODIFIED="1701140157348" TEXT="legt Daten ab und akkumuliert Integrale">
<icon BUILTIN="button_ok"/>
</node>
<node COLOR="#338800" CREATED="1701127520281" ID="ID_327297411" MODIFIED="1701140158553" TEXT="Abschlu&#xdf;: Gesamtzahl &#x27fc; &#x2205;">
<icon BUILTIN="button_ok"/>
</node>
</node>
<node BACKGROUND_COLOR="#d2beaf" COLOR="#5c4d6e" CREATED="1701127540653" ID="ID_838754026" MODIFIED="1701127562922" TEXT="Berechnung-2">
<icon BUILTIN="hourglass"/>
@ -99590,6 +99598,18 @@ Date:&#160;&#160;&#160;Thu Apr 20 18:53:17 2023 +0200<br/>
</node>
</node>
</node>
<node COLOR="#338800" CREATED="1701140164859" ID="ID_1147492015" MODIFIED="1701140208443" TEXT="&#xfc;ber alle Nodes mit &#xbb;schleppendem Level&#xab;">
<icon BUILTIN="button_ok"/>
<node COLOR="#338800" CREATED="1701140177177" ID="ID_1196764346" MODIFIED="1701140205823" TEXT="Array mit Auswertungs-Pr&#xe4;dikaten">
<icon BUILTIN="button_ok"/>
</node>
<node COLOR="#338800" CREATED="1701140186704" ID="ID_1137018850" MODIFIED="1701140205824" TEXT="daraus Partikular-Statistiken">
<icon BUILTIN="button_ok"/>
</node>
<node COLOR="#338800" CREATED="1701140196422" ID="ID_183954619" MODIFIED="1701140205824" TEXT="in Statistic-Record einbuchen">
<icon BUILTIN="button_ok"/>
</node>
</node>
</node>
</node>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1701016792372" ID="ID_1251453714" MODIFIED="1701016798575" TEXT="Darstellung">