Chain-Load: generate statistics report
...test and fix the statistics computation...
This commit is contained in:
parent
c3bef6d344
commit
852a86bbda
3 changed files with 110 additions and 35 deletions
|
|
@ -239,7 +239,8 @@ namespace test {
|
||||||
graph.expansionRule(graph.rule().probability(0.8).maxVal(1))
|
graph.expansionRule(graph.rule().probability(0.8).maxVal(1))
|
||||||
.pruningRule(graph.rule().probability(0.6))
|
.pruningRule(graph.rule().probability(0.6))
|
||||||
.buildToplolgy()
|
.buildToplolgy()
|
||||||
.printTopologyDOT();
|
.printTopologyDOT()
|
||||||
|
.printTopologyStatistics();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -90,6 +90,7 @@
|
||||||
//#include "lib/meta/function.hpp"
|
//#include "lib/meta/function.hpp"
|
||||||
//#include "lib/wrapper.hpp"
|
//#include "lib/wrapper.hpp"
|
||||||
#include "lib/iter-explorer.hpp"
|
#include "lib/iter-explorer.hpp"
|
||||||
|
#include "lib/format-string.hpp"
|
||||||
#include "lib/format-cout.hpp"
|
#include "lib/format-cout.hpp"
|
||||||
#include "lib/random-draw.hpp"
|
#include "lib/random-draw.hpp"
|
||||||
#include "lib/dot-gen.hpp"
|
#include "lib/dot-gen.hpp"
|
||||||
|
|
@ -104,7 +105,6 @@
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <map>
|
|
||||||
|
|
||||||
|
|
||||||
namespace vault{
|
namespace vault{
|
||||||
|
|
@ -118,6 +118,7 @@ namespace test {
|
||||||
// using lib::time::FSecs;
|
// using lib::time::FSecs;
|
||||||
// using lib::time::Offset;
|
// using lib::time::Offset;
|
||||||
// using lib::meta::RebindVariadic;
|
// using lib::meta::RebindVariadic;
|
||||||
|
using util::_Fmt;
|
||||||
using util::min;
|
using util::min;
|
||||||
using util::max;
|
using util::max;
|
||||||
using util::isnil;
|
using util::isnil;
|
||||||
|
|
@ -544,6 +545,7 @@ namespace test {
|
||||||
|
|
||||||
|
|
||||||
Statistic computeGraphStatistics();
|
Statistic computeGraphStatistics();
|
||||||
|
TestChainLoad&& printTopologyStatistics();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
};
|
};
|
||||||
|
|
@ -648,6 +650,8 @@ namespace test {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* ========= Graph Statistics Evaluation ========= */
|
||||||
|
|
||||||
const string STAT_SEED{"seed"}; ///< seed node
|
const string STAT_SEED{"seed"}; ///< seed node
|
||||||
const string STAT_EXIT{"exit"}; ///< exit node
|
const string STAT_EXIT{"exit"}; ///< exit node
|
||||||
const string STAT_INNR{"innr"}; ///< inner node
|
const string STAT_INNR{"innr"}; ///< inner node
|
||||||
|
|
@ -662,7 +666,7 @@ namespace test {
|
||||||
namespace {
|
namespace {
|
||||||
template<class NOD>
|
template<class NOD>
|
||||||
inline auto
|
inline auto
|
||||||
buildEvaluations()
|
prepareEvaluaions()
|
||||||
{
|
{
|
||||||
return std::array<std::function<uint(NOD&)>, CAT>
|
return std::array<std::function<uint(NOD&)>, CAT>
|
||||||
{ [](NOD& n){ return isStart(n);}
|
{ [](NOD& n){ return isStart(n);}
|
||||||
|
|
@ -676,7 +680,7 @@ namespace test {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
using VecU = std::vector<uint>;
|
using VecU = std::vector<uint>;
|
||||||
using LevelSums = std::array<uint, CAT>;
|
using LevelSums = std::array<uint, CAT>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -689,21 +693,22 @@ namespace test {
|
||||||
VecU data{};
|
VecU data{};
|
||||||
uint cnt{0}; ///< global sum over all levels
|
uint cnt{0}; ///< global sum over all levels
|
||||||
double frac{0}; ///< fraction of all nodes
|
double frac{0}; ///< fraction of all nodes
|
||||||
double pL{0}; ///< average per level
|
double pL {0}; ///< average per level
|
||||||
double pLW{0}; ///< average per level and level-width
|
double pLW{0}; ///< average per level and level-width
|
||||||
double cL{0}; ///< weight centre level for this indicator
|
double cL {0}; ///< weight centre level for this indicator
|
||||||
double cLW{0}; ///< weight centre level width-reduced
|
double cLW{0}; ///< weight centre level width-reduced
|
||||||
|
|
||||||
void
|
void
|
||||||
addPoint (uint level, uint width, uint items)
|
addPoint (uint levelID, uint width, uint items)
|
||||||
{
|
{
|
||||||
REQUIRE (level == data.size());
|
REQUIRE (levelID == data.size()); // ID is zero based
|
||||||
|
REQUIRE (width > 0);
|
||||||
data.push_back (items);
|
data.push_back (items);
|
||||||
cnt += items;
|
cnt += items;
|
||||||
pL += items;
|
pL += items;
|
||||||
pLW += items / double(width);
|
pLW += items / double(width);
|
||||||
cL += level * items;
|
cL += levelID * items;
|
||||||
cLW += level * items/double(width);
|
cLW += levelID * items/double(width);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
@ -712,8 +717,8 @@ namespace test {
|
||||||
uint levels = data.size();
|
uint levels = data.size();
|
||||||
REQUIRE (levels > 0);
|
REQUIRE (levels > 0);
|
||||||
frac = cnt / double(nodes);
|
frac = cnt / double(nodes);
|
||||||
cL /= pL; // weighted averages: normalise to weight sum
|
cL = pL? cL/pL :0; // weighted averages: normalise to weight sum
|
||||||
cLW /= pLW;
|
cLW = pLW? cLW/pLW :0;
|
||||||
pL /= levels; // simple averages : normalise to number of levels
|
pL /= levels; // simple averages : normalise to number of levels
|
||||||
pLW /= levels;
|
pLW /= levels;
|
||||||
}
|
}
|
||||||
|
|
@ -728,14 +733,14 @@ namespace test {
|
||||||
uint levels{0};
|
uint levels{0};
|
||||||
VecU width{};
|
VecU width{};
|
||||||
|
|
||||||
std::map<const string, Indicator> indicators;
|
std::array<Indicator, CAT> indicators;
|
||||||
|
|
||||||
explicit
|
explicit
|
||||||
Statistic (uint lvls)
|
Statistic (uint lvls)
|
||||||
: nodes{0}
|
: nodes{0}
|
||||||
, levels{lvls}
|
, levels{0}
|
||||||
{
|
{
|
||||||
reserve (levels);
|
reserve (lvls);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
@ -745,38 +750,52 @@ namespace test {
|
||||||
nodes += levelWidth;
|
nodes += levelWidth;
|
||||||
width.push_back (levelWidth);
|
width.push_back (levelWidth);
|
||||||
ASSERT (levels == width.size());
|
ASSERT (levels == width.size());
|
||||||
|
ASSERT (0 < levels);
|
||||||
|
ASSERT (0 < levelWidth);
|
||||||
for (uint i=0; i< CAT; ++i)
|
for (uint i=0; i< CAT; ++i)
|
||||||
indicators[KEYS[i]].addPoint (levels, levelWidth, particulars[i]);
|
indicators[i].addPoint (levels-1, levelWidth, particulars[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
closeAverages()
|
closeAverages()
|
||||||
{
|
{
|
||||||
for (auto& KEY : KEYS)
|
for (uint i=0; i< CAT; ++i)
|
||||||
indicators[KEY].closeAverages (nodes);
|
indicators[i].closeAverages (nodes);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void
|
void
|
||||||
reserve (uint levels)
|
reserve (uint lvls)
|
||||||
{
|
{
|
||||||
width.reserve (levels);
|
width.reserve (lvls);
|
||||||
for (auto& KEY : KEYS)
|
for (uint i=0; i< CAT; ++i)
|
||||||
{
|
{
|
||||||
indicators[KEY] = Indicator{};
|
indicators[i] = Indicator{};
|
||||||
indicators[KEY].data.reserve(levels);
|
indicators[i].data.reserve(lvls);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Operator on TestChainLoad to evaluate current graph connectivity.
|
||||||
|
* In a pass over the internal storage, all nodes are classified
|
||||||
|
* and accounted into a set of categories, thereby evaluating
|
||||||
|
* - the overall number of nodes and levels generated
|
||||||
|
* - the number of nodes in each level (termed _level width_)
|
||||||
|
* - the fraction of overall nodes falling into each category
|
||||||
|
* - the average number of category members over the levels
|
||||||
|
* - the density of members, normalised over level width
|
||||||
|
* - the weight centre of this category members
|
||||||
|
* - the weight centre of according to density
|
||||||
|
*/
|
||||||
template<size_t numNodes, size_t maxFan>
|
template<size_t numNodes, size_t maxFan>
|
||||||
inline Statistic
|
inline Statistic
|
||||||
TestChainLoad<numNodes,maxFan>::computeGraphStatistics()
|
TestChainLoad<numNodes,maxFan>::computeGraphStatistics()
|
||||||
{
|
{
|
||||||
auto totalLevels = uint(topLevel());
|
auto totalLevels = uint(topLevel());
|
||||||
auto classify = buildEvaluations<Node>();
|
auto classify = prepareEvaluaions<Node>();
|
||||||
Statistic stat(totalLevels);
|
Statistic stat(totalLevels);
|
||||||
LevelSums particulars{0};
|
LevelSums particulars{0};
|
||||||
size_t level{0};
|
size_t level{0};
|
||||||
|
|
@ -784,10 +803,6 @@ namespace test {
|
||||||
|
|
||||||
for (Node& node : allNodes())
|
for (Node& node : allNodes())
|
||||||
{
|
{
|
||||||
++width;
|
|
||||||
for (uint i=0; i<CAT; ++i)
|
|
||||||
particulars[i] += classify[i](node);
|
|
||||||
|
|
||||||
if (level != node.level)
|
if (level != node.level)
|
||||||
{ // record statistics for previous level
|
{ // record statistics for previous level
|
||||||
stat.addPoint (width, particulars);
|
stat.addPoint (width, particulars);
|
||||||
|
|
@ -797,13 +812,42 @@ namespace test {
|
||||||
particulars = LevelSums{0};
|
particulars = LevelSums{0};
|
||||||
width = 0;
|
width = 0;
|
||||||
}
|
}
|
||||||
|
// classify and account..
|
||||||
|
++width;
|
||||||
|
for (uint i=0; i<CAT; ++i)
|
||||||
|
particulars[i] += classify[i](node);
|
||||||
}
|
}
|
||||||
ENSURE (level = topLevel());
|
ENSURE (level = topLevel());
|
||||||
stat.addPoint (width, particulars);
|
stat.addPoint (width, particulars);
|
||||||
stat.closeAverages();
|
stat.closeAverages();
|
||||||
return stat;
|
return stat;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
template<size_t numNodes, size_t maxFan>
|
||||||
|
inline TestChainLoad<numNodes,maxFan>&&
|
||||||
|
TestChainLoad<numNodes,maxFan>::printTopologyStatistics()
|
||||||
|
{
|
||||||
|
cout << "INDI cnt frac ∅pL ∅pLW γL γLW\n";
|
||||||
|
_Fmt line{"%s %3d %3.0f%% %4.2f %4.2f %5.1f %5.1f\n"};
|
||||||
|
Statistic stat = computeGraphStatistics();
|
||||||
|
for (uint i=0; i< CAT; ++i)
|
||||||
|
{
|
||||||
|
Indicator& indi = stat.indicators[i];
|
||||||
|
cout << line % KEYS[i]
|
||||||
|
% indi.cnt
|
||||||
|
% (indi.frac*100)
|
||||||
|
% indi.pL
|
||||||
|
% indi.pLW
|
||||||
|
% indi.cL
|
||||||
|
% indi.cLW
|
||||||
|
;
|
||||||
|
}
|
||||||
|
cout << "───═══───═══───═══───═══───═══───═══───═══───═══───═══───═══───"
|
||||||
|
<< endl;
|
||||||
|
return move(*this);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -99570,16 +99570,32 @@ Date:   Thu Apr 20 18:53:17 2023 +0200<br/>
|
||||||
<node CREATED="1701126927102" ID="ID_1692039562" MODIFIED="1701127026960" TEXT="Map mit String-Key"/>
|
<node CREATED="1701126927102" ID="ID_1692039562" MODIFIED="1701127026960" TEXT="Map mit String-Key"/>
|
||||||
<node CREATED="1701127027572" ID="ID_554934189" MODIFIED="1701127035511" TEXT="Vector mit ENUM-index"/>
|
<node CREATED="1701127027572" ID="ID_554934189" MODIFIED="1701127035511" TEXT="Vector mit ENUM-index"/>
|
||||||
<node CREATED="1701127055028" ID="ID_544320843" MODIFIED="1701127068922" TEXT="Sub-Objekte mit member-ptr"/>
|
<node CREATED="1701127055028" ID="ID_544320843" MODIFIED="1701127068922" TEXT="Sub-Objekte mit member-ptr"/>
|
||||||
<node CREATED="1701127099690" ID="ID_1150088226" MODIFIED="1701127117708" TEXT="ist im Grunde egal ⟹ Map mit String-Key">
|
<node COLOR="#5b280f" CREATED="1701127099690" ID="ID_1150088226" MODIFIED="1701181195395" TEXT="ist im Grunde egal ⟹ Map mit String-Key">
|
||||||
|
<icon BUILTIN="button_cancel"/>
|
||||||
|
<node COLOR="#5b280f" CREATED="1701181099023" ID="ID_655755151" MODIFIED="1701181120346" TEXT="immer noch zu komplisiert">
|
||||||
|
<icon BUILTIN="stop-sign"/>
|
||||||
|
</node>
|
||||||
|
<node COLOR="#435e98" CREATED="1701181139849" ID="ID_138263114" MODIFIED="1701181151504" TEXT="geht noch KISSiger">
|
||||||
|
<font NAME="SansSerif" SIZE="11"/>
|
||||||
|
<icon BUILTIN="ksmiletris"/>
|
||||||
|
</node>
|
||||||
|
</node>
|
||||||
|
<node CREATED="1701181154476" ID="ID_1678400125" MODIFIED="1701181190273" TEXT="feste Index-Folge und alles in std::array">
|
||||||
<icon BUILTIN="yes"/>
|
<icon BUILTIN="yes"/>
|
||||||
|
<node CREATED="1701181210002" ID="ID_1679700560" MODIFIED="1701181218067" TEXT="und zwar als im Header definierte Konstanten"/>
|
||||||
|
<node CREATED="1701181262856" ID="ID_793524141" MODIFIED="1701181284833" TEXT="STAT_* : Kategorie-Bezeichner (human-readable)"/>
|
||||||
|
<node CREATED="1701181225838" ID="ID_704708703" MODIFIED="1701181290625" TEXT="KEYS : ein array mit den Kategorie-Bezeichnern"/>
|
||||||
|
<node CREATED="1701181298668" ID="ID_1143111821" MODIFIED="1701181305790" TEXT="CAT = KEYS.size()"/>
|
||||||
|
<node CREATED="1701181311114" ID="ID_1052500553" MODIFIED="1701181371657" TEXT="evaluations: ein array mit Klassifikations-λ"/>
|
||||||
|
<node CREATED="1701181338943" ID="ID_1835182207" MODIFIED="1701181366087" TEXT="Statistic::indicators : ein array mit den Indicator-records für jede Kategorie"/>
|
||||||
</node>
|
</node>
|
||||||
</node>
|
</node>
|
||||||
<node CREATED="1701127237104" ID="ID_627445638" MODIFIED="1701127280398" TEXT="Sub-Objekt...">
|
<node CREATED="1701127237104" ID="ID_627445638" MODIFIED="1701127280398" TEXT="Sub-Objekt...">
|
||||||
<node CREATED="1701127280727" ID="ID_211987609" MODIFIED="1701127280727" TEXT="enthält einen data-Vector"/>
|
<node CREATED="1701127280727" ID="ID_211987609" MODIFIED="1701127280727" TEXT="enthält einen data-Vector"/>
|
||||||
<node CREATED="1701127286949" ID="ID_113578279" MODIFIED="1701127312993" TEXT="ggfs später weitere Tabellen (MA, lokaler Trend)"/>
|
<node CREATED="1701127286949" ID="ID_113578279" MODIFIED="1701127312993" TEXT="ggfs später weitere Tabellen (MA, lokaler Trend)"/>
|
||||||
<node CREATED="1701127339746" ID="ID_552079211" MODIFIED="1701127349436" TEXT="sowie feste Datenfelder für die Kennzahlen"/>
|
<node CREATED="1701127339746" ID="ID_552079211" MODIFIED="1701127349436" TEXT="sowie feste Datenfelder für die Kennzahlen"/>
|
||||||
<node BACKGROUND_COLOR="#eef0c5" COLOR="#990000" CREATED="1701127401298" ID="ID_1356798063" MODIFIED="1701140125631" TEXT="Berechnung-1">
|
<node COLOR="#338800" CREATED="1701127401298" ID="ID_1356798063" MODIFIED="1701184821866" TEXT="Berechnung-1">
|
||||||
<icon BUILTIN="pencil"/>
|
<icon BUILTIN="button_ok"/>
|
||||||
<node COLOR="#338800" CREATED="1701127405705" ID="ID_1717640247" MODIFIED="1701140156044" TEXT="ein Datenpunkt + Breite">
|
<node COLOR="#338800" CREATED="1701127405705" ID="ID_1717640247" MODIFIED="1701140156044" TEXT="ein Datenpunkt + Breite">
|
||||||
<icon BUILTIN="button_ok"/>
|
<icon BUILTIN="button_ok"/>
|
||||||
</node>
|
</node>
|
||||||
|
|
@ -99589,6 +99605,10 @@ Date:   Thu Apr 20 18:53:17 2023 +0200<br/>
|
||||||
<node COLOR="#338800" CREATED="1701127520281" ID="ID_327297411" MODIFIED="1701140158553" TEXT="Abschluß: Gesamtzahl ⟼ ∅">
|
<node COLOR="#338800" CREATED="1701127520281" ID="ID_327297411" MODIFIED="1701140158553" TEXT="Abschluß: Gesamtzahl ⟼ ∅">
|
||||||
<icon BUILTIN="button_ok"/>
|
<icon BUILTIN="button_ok"/>
|
||||||
</node>
|
</node>
|
||||||
|
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1701184912655" ID="ID_283973311" MODIFIED="1701184946768" TEXT="Zerlegung in Teilgraphen berücksichtigen">
|
||||||
|
<linktarget COLOR="#7327b4" DESTINATION="ID_283973311" ENDARROW="Default" ENDINCLINATION="-138;8;" ID="Arrow_ID_468448911" SOURCE="ID_1190320888" STARTARROW="None" STARTINCLINATION="124;-10;"/>
|
||||||
|
<icon BUILTIN="flag-yellow"/>
|
||||||
|
</node>
|
||||||
</node>
|
</node>
|
||||||
<node BACKGROUND_COLOR="#d2beaf" COLOR="#5c4d6e" CREATED="1701127540653" ID="ID_838754026" MODIFIED="1701127562922" TEXT="Berechnung-2">
|
<node BACKGROUND_COLOR="#d2beaf" COLOR="#5c4d6e" CREATED="1701127540653" ID="ID_838754026" MODIFIED="1701127562922" TEXT="Berechnung-2">
|
||||||
<icon BUILTIN="hourglass"/>
|
<icon BUILTIN="hourglass"/>
|
||||||
|
|
@ -99612,11 +99632,21 @@ Date:   Thu Apr 20 18:53:17 2023 +0200<br/>
|
||||||
</node>
|
</node>
|
||||||
</node>
|
</node>
|
||||||
</node>
|
</node>
|
||||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1701016792372" ID="ID_1251453714" MODIFIED="1701016798575" TEXT="Darstellung">
|
<node BACKGROUND_COLOR="#eef0c5" COLOR="#990000" CREATED="1701016792372" ID="ID_1251453714" MODIFIED="1701184833970" TEXT="Darstellung">
|
||||||
<icon BUILTIN="flag-yellow"/>
|
<icon BUILTIN="pencil"/>
|
||||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1701125319870" ID="ID_1457245227" MODIFIED="1701125329516" TEXT="Statistik-Report bereitstellen">
|
<node BACKGROUND_COLOR="#eef0c5" COLOR="#990000" CREATED="1701125319870" ID="ID_1457245227" MODIFIED="1701184853119" TEXT="Statistik-Report bereitstellen">
|
||||||
|
<icon BUILTIN="pencil"/>
|
||||||
|
<node COLOR="#338800" CREATED="1701184854447" ID="ID_1823077805" MODIFIED="1701184862006" TEXT="Auswertungen pro Kategorie">
|
||||||
|
<icon BUILTIN="button_ok"/>
|
||||||
|
</node>
|
||||||
|
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1701184862856" ID="ID_85653289" MODIFIED="1701184866502" TEXT="Gesamtsummen">
|
||||||
<icon BUILTIN="flag-yellow"/>
|
<icon BUILTIN="flag-yellow"/>
|
||||||
</node>
|
</node>
|
||||||
|
<node BACKGROUND_COLOR="#fdfdcf" COLOR="#ff0000" CREATED="1701184867453" ID="ID_1190320888" MODIFIED="1701184954043" TEXT="Teilgraphen berücksichtigen">
|
||||||
|
<arrowlink COLOR="#7327b4" DESTINATION="ID_283973311" ENDARROW="Default" ENDINCLINATION="-138;8;" ID="Arrow_ID_468448911" STARTARROW="None" STARTINCLINATION="124;-10;"/>
|
||||||
|
<icon BUILTIN="flag-pink"/>
|
||||||
|
</node>
|
||||||
|
</node>
|
||||||
</node>
|
</node>
|
||||||
</node>
|
</node>
|
||||||
</node>
|
</node>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue