Chain-Load: demonstrate use of reduction rule
... special rule to generate a fixed expansion on each seed ... consecutive reductions join everything back into one chain ... can counterbalance expansions and reductions
This commit is contained in:
parent
aafd277ebe
commit
229541859d
5 changed files with 150 additions and 32 deletions
|
|
@ -326,6 +326,13 @@ namespace lib {
|
|||
return move (*this);
|
||||
}
|
||||
|
||||
RandomDraw&&
|
||||
fixedVal (Tar v)
|
||||
{
|
||||
mapping ([v](size_t){ return v; });
|
||||
return move (*this);
|
||||
}
|
||||
|
||||
template<class FUN>
|
||||
RandomDraw&&
|
||||
mapping (FUN&& fun)
|
||||
|
|
|
|||
|
|
@ -588,6 +588,19 @@ namespace test{
|
|||
"val:+0 (00|50.00%)\n"
|
||||
"val:+1 (-1| 0.00%)\n"
|
||||
"val:+2 (-1| 0.00%)\n"_expect);
|
||||
|
||||
|
||||
// ═════════
|
||||
draw.fixedVal(1);
|
||||
report = "+++| fixedVal(1) \n";
|
||||
report += distribution(draw);
|
||||
CHECK (report ==
|
||||
"+++| fixedVal(1) \n"
|
||||
"val:-2 (-1| 0.00%)\n"
|
||||
"val:-1 (-1| 0.00%)\n"
|
||||
"val:+0 (-1| 0.00%)\n"
|
||||
"val:+1 (00|100.00%)\n"
|
||||
"val:+2 (-1| 0.00%)\n"_expect);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -302,34 +302,74 @@ namespace test {
|
|||
|
||||
|
||||
|
||||
/** @test TODO demonstrate shaping of generated topology
|
||||
* - TODO
|
||||
* @todo WIP 11/23 🔁 define ⟶ 🔁 implement
|
||||
/** @test demonstrate impact of reduction on graph topology
|
||||
* - after one fixed initial expansion, reduction causes
|
||||
* all chains to be joined eventually
|
||||
* - expansion and reduction can counterbalance each other,
|
||||
* leading to localised »packages« of branchings and reductions
|
||||
* @todo WIP 11/23 ✔ define ⟶ ✔ implement
|
||||
*/
|
||||
void
|
||||
verify_Reduction()
|
||||
{
|
||||
ChainLoad32 graph;
|
||||
|
||||
// moderate symmetrical expansion with 40% probability and maximal +2 links
|
||||
graph.expansionRule(graph.rule().mapping([&](Node* n)
|
||||
{
|
||||
if (isStart(n))
|
||||
return graph.rule().probability(1.0).maxVal(8).mapping([](size_t){ return 1.0; });
|
||||
else
|
||||
return graph.rule();
|
||||
}))
|
||||
// expand immediately at start and then gradually reduce / join chains
|
||||
graph.expansionRule(graph.rule_atStart(8))
|
||||
.reductionRule(graph.rule().probability(0.2).maxVal(3).shuffle(555))
|
||||
.buildToplolgy()
|
||||
.printTopologyDOT()
|
||||
.printTopologyStatistics()
|
||||
// .printTopologyDOT()
|
||||
// .printTopologyStatistics()
|
||||
;
|
||||
// CHECK (graph.getHash() == 0xAE332109116C5100);
|
||||
SHOW_EXPR(graph.getHash())
|
||||
CHECK (graph.getHash() == 0x8454196BFA40CFE1);
|
||||
|
||||
auto stat = graph.computeGraphStatistics();
|
||||
CHECK (stat.levels == 9); // This connection pattern filled 9 levels
|
||||
CHECK (stat.indicators[STAT_JOIN].cnt == 4); // we got 4 »Join« events (reductions=
|
||||
CHECK (stat.indicators[STAT_FORK].cnt == 1); // and the single expansion/fork
|
||||
CHECK (stat.indicators[STAT_FORK].cL == 0.0); // ...sitting right at the beginning
|
||||
CHECK (stat.indicators[STAT_NODE].cL == "0.37890625"_expect); // Nodes are concentrated towards the beginning
|
||||
|
||||
|
||||
|
||||
// expansion and reduction can counterbalance each other
|
||||
graph.expansionRule(graph.rule().probability(0.2).maxVal(3).shuffle(555))
|
||||
.reductionRule(graph.rule().probability(0.2).maxVal(3).shuffle(555))
|
||||
.buildToplolgy()
|
||||
// .printTopologyDOT()
|
||||
// .printTopologyStatistics()
|
||||
;
|
||||
CHECK (graph.getHash() == 0x825696EA63E579A4);
|
||||
|
||||
stat = graph.computeGraphStatistics();
|
||||
CHECK (stat.levels == 12); // This example runs a bit longer
|
||||
CHECK (stat.indicators[STAT_NODE].pL == "2.6666667"_expect); // in the middle threading 3-5 Nodes per Level
|
||||
CHECK (stat.indicators[STAT_FORK].cnt == 5); // with 5 expansions
|
||||
CHECK (stat.indicators[STAT_JOIN].cnt == 3); // and 3 reductions
|
||||
CHECK (stat.indicators[STAT_FORK].cL == "0.45454545"_expect); // forks dominating earlier
|
||||
CHECK (stat.indicators[STAT_JOIN].cL == "0.66666667"_expect); // while joins need forks as prerequisite
|
||||
|
||||
|
||||
|
||||
// expansion bursts can be balanced with a heightened reduction intensity
|
||||
graph.expansionRule(graph.rule().probability(0.3).maxVal(4).shuffle(555))
|
||||
.reductionRule(graph.rule().probability(0.9).maxVal(2).shuffle(555))
|
||||
.buildToplolgy()
|
||||
// .printTopologyDOT()
|
||||
// .printTopologyStatistics()
|
||||
;
|
||||
CHECK (graph.getHash() == 0xA850E6A4921521AB);
|
||||
|
||||
stat = graph.computeGraphStatistics();
|
||||
CHECK (stat.levels == 12); // This graph has a similar outline
|
||||
CHECK (stat.indicators[STAT_NODE].pL == "2.6666667"_expect); // in the middle threading 3-5 Nodes per Level
|
||||
CHECK (stat.indicators[STAT_FORK].cnt == 7); // ...yet with quite different internal structure
|
||||
CHECK (stat.indicators[STAT_JOIN].cnt == 9); //
|
||||
CHECK (stat.indicators[STAT_FORK].cL == "0.41558442"_expect);
|
||||
CHECK (stat.indicators[STAT_JOIN].cL == "0.62626263"_expect);
|
||||
CHECK (stat.indicators[STAT_FORK].pLW == "0.19583333"_expect); // while the densities of forks and joins almost match,
|
||||
CHECK (stat.indicators[STAT_JOIN].pLW == "0.26527778"_expect); // a slightly higher reduction density leads to convergence eventually
|
||||
}
|
||||
//SHOW_EXPR(graph.getHash())
|
||||
//SHOW_EXPR(stat.indicators[STAT_NODE].pL)
|
||||
//SHOW_EXPR(stat.indicators[STAT_JOIN].cL)
|
||||
|
||||
|
||||
|
||||
|
|
@ -342,6 +382,10 @@ SHOW_EXPR(graph.getHash())
|
|||
{
|
||||
|
||||
}
|
||||
//SHOW_EXPR(graph.getHash())
|
||||
//SHOW_EXPR(stat.indicators[STAT_NODE].pL)
|
||||
//SHOW_EXPR(stat.indicators[STAT_FORK].cL)
|
||||
//SHOW_EXPR(stat.indicators[STAT_JOIN].cL)
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -317,8 +317,6 @@ namespace test {
|
|||
|
||||
/* ===== topology control ===== */
|
||||
|
||||
static Rule rule() { return Rule(); }
|
||||
|
||||
TestChainLoad&&
|
||||
seedingRule (Rule r)
|
||||
{
|
||||
|
|
@ -348,6 +346,21 @@ namespace test {
|
|||
}
|
||||
|
||||
|
||||
/** Abbreviation for starting rules */
|
||||
static Rule rule() { return Rule(); }
|
||||
|
||||
static Rule
|
||||
rule_atStart (uint v)
|
||||
{
|
||||
return Rule().mapping([v](Node* n)
|
||||
{
|
||||
return isStart(n)? Rule().fixedVal(v)
|
||||
: Rule();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Use current configuration and seed to (re)build Node connectivity.
|
||||
* While working in-place, the wiring and thus the resulting hash values
|
||||
|
|
|
|||
|
|
@ -96231,14 +96231,17 @@ Date:   Thu Apr 20 18:53:17 2023 +0200<br/>
|
|||
<icon BUILTIN="button_ok"/>
|
||||
</node>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1700239873583" ID="ID_108514069" MODIFIED="1701226056299" TEXT="Reduction">
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
<node CREATED="1701288030605" ID="ID_1831978324" MODIFIED="1701288052215" TEXT="Reduction braucht zur Wirksamkeit bereits bestehende Expansion">
|
||||
<node CREATED="1701288078679" ID="ID_1660308998" MODIFIED="1701288100383" TEXT="das wäre dann wohl im Gegenspiel mit einer Expansion-Rule zu sehen"/>
|
||||
<node CREATED="1701288101212" ID="ID_1431953126" MODIFIED="1701288125016" TEXT="oder man injiziert punktweise eine Verbreiterung">
|
||||
<node COLOR="#338800" CREATED="1700239873583" ID="ID_108514069" MODIFIED="1701313948713" TEXT="Reduction">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
<node COLOR="#338800" CREATED="1701288030605" ID="ID_1831978324" MODIFIED="1701313917966" TEXT="Reduction braucht zur Wirksamkeit bereits bestehende Expansion">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
<node CREATED="1701288078679" ID="ID_1660308998" MODIFIED="1701313940440" TEXT="das wäre dann wohl im Gegenspiel mit einer Expansion-Rule zu sehen">
|
||||
<arrowlink COLOR="#4d8b8e" DESTINATION="ID_1407690732" ENDARROW="Default" ENDINCLINATION="310;14;" ID="Arrow_ID_146807214" STARTARROW="None" STARTINCLINATION="39;150;"/>
|
||||
</node>
|
||||
<node COLOR="#435e98" CREATED="1701288101212" ID="ID_1431953126" MODIFIED="1701310755741" TEXT="oder man injiziert punktweise eine Verbreiterung">
|
||||
<icon BUILTIN="idea"/>
|
||||
<node CREATED="1701288126724" ID="ID_760448320" MODIFIED="1701288137034" TEXT="wie ganz konkret?"/>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1701288140416" ID="ID_999842267" MODIFIED="1701288181028">
|
||||
<node COLOR="#435e98" CREATED="1701288140416" ID="ID_999842267" MODIFIED="1701309519156">
|
||||
<richcontent TYPE="NODE"><html>
|
||||
<head/>
|
||||
<body>
|
||||
|
|
@ -96265,7 +96268,23 @@ Date:   Thu Apr 20 18:53:17 2023 +0200<br/>
|
|||
<icon BUILTIN="button_ok"/>
|
||||
</node>
|
||||
</node>
|
||||
<node COLOR="#338800" CREATED="1701309520050" ID="ID_333395562" MODIFIED="1701310728681" TEXT="Schreibweise vereinfachen">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
<node COLOR="#338800" CREATED="1701309525786" ID="ID_1501828076" MODIFIED="1701309534297" TEXT="RandomDraw::fixedValue(v)">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
</node>
|
||||
<node COLOR="#338800" CREATED="1701310672056" ID="ID_1255387462" MODIFIED="1701310702449" TEXT="rule_atStart(val)">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
<node COLOR="#3835ce" CREATED="1701310695349" ID="ID_1716536616" MODIFIED="1701310725823" TEXT="isStart(n)? Rule().fixedVal(v) : Rule()">
|
||||
<font NAME="Monospaced" SIZE="12"/>
|
||||
</node>
|
||||
</node>
|
||||
</node>
|
||||
</node>
|
||||
</node>
|
||||
<node COLOR="#338800" CREATED="1701313904127" ID="ID_1407690732" MODIFIED="1701313933160" TEXT="demonstriere auch gleich das Zusammenspiel mit Expansion">
|
||||
<linktarget COLOR="#4d8b8e" DESTINATION="ID_1407690732" ENDARROW="Default" ENDINCLINATION="310;14;" ID="Arrow_ID_146807214" SOURCE="ID_1660308998" STARTARROW="None" STARTINCLINATION="39;150;"/>
|
||||
<icon BUILTIN="button_ok"/>
|
||||
</node>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1700239880388" ID="ID_897183253" MODIFIED="1701226056300" TEXT="Seed">
|
||||
|
|
@ -96274,8 +96293,9 @@ Date:   Thu Apr 20 18:53:17 2023 +0200<br/>
|
|||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1701226052691" ID="ID_929780401" MODIFIED="1701226056300" TEXT="Prune">
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1701226061434" ID="ID_1246960546" MODIFIED="1701226064800" TEXT="Gleichgewicht">
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
<node COLOR="#338800" CREATED="1701226061434" ID="ID_1246960546" MODIFIED="1701314215907" TEXT="Gleichgewicht">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
<node CREATED="1701314218952" ID="ID_959655971" MODIFIED="1701314254700" TEXT="Expansion ⟵⟶ Reduction"/>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1701226065633" ID="ID_633684852" MODIFIED="1701226072137" TEXT="Teilgraphen">
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
|
|
@ -98894,6 +98914,9 @@ Date:   Thu Apr 20 18:53:17 2023 +0200<br/>
|
|||
<arrowlink COLOR="#5a9fb2" DESTINATION="ID_388325956" ENDARROW="Default" ENDINCLINATION="-986;64;" ID="Arrow_ID_815524029" STARTARROW="None" STARTINCLINATION="840;39;"/>
|
||||
<icon BUILTIN="button_ok"/>
|
||||
</node>
|
||||
<node COLOR="#338800" CREATED="1701314067041" ID="ID_431420996" MODIFIED="1701314084426" TEXT="habe jetzt die Basis zum einfachen Definieren von Bausteinen">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
</node>
|
||||
</node>
|
||||
</node>
|
||||
</node>
|
||||
|
|
@ -99052,14 +99075,17 @@ Date:   Thu Apr 20 18:53:17 2023 +0200<br/>
|
|||
</node>
|
||||
<node BACKGROUND_COLOR="#eef0c5" COLOR="#990000" CREATED="1699805890752" ID="ID_604823204" MODIFIED="1699827731274" TEXT="Limitierungen einhalten">
|
||||
<icon BUILTIN="pencil"/>
|
||||
<node BACKGROUND_COLOR="#eef0c5" COLOR="#990000" CREATED="1700163524509" ID="ID_1054737506" MODIFIED="1700166665465" TEXT="Auswertung der CtrlRules sicher handhaben">
|
||||
<node COLOR="#338800" CREATED="1700163524509" ID="ID_1054737506" MODIFIED="1701314149767" TEXT="Auswertung der CtrlRules sicher handhaben">
|
||||
<arrowlink COLOR="#fdedce" DESTINATION="ID_310818837" ENDARROW="Default" ENDINCLINATION="174;13;" ID="Arrow_ID_184825307" STARTARROW="None" STARTINCLINATION="247;-214;"/>
|
||||
<icon BUILTIN="pencil"/>
|
||||
<icon BUILTIN="button_ok"/>
|
||||
<node CREATED="1700163554337" ID="ID_467387724" MODIFIED="1700163567392" TEXT="diverse Fallen hier">
|
||||
<icon BUILTIN="clanbomber"/>
|
||||
</node>
|
||||
<node COLOR="#435e98" CREATED="1700163568492" ID="ID_1902020306" MODIFIED="1700179577804" TEXT="unsigned-wrap-around"/>
|
||||
<node COLOR="#435e98" CREATED="1700163611881" ID="ID_1655584485" MODIFIED="1700179577805" TEXT="numerische Probleme"/>
|
||||
<node COLOR="#338800" CREATED="1701314125417" ID="ID_1070473602" LINK="#ID_1225692248" MODIFIED="1701314146089" TEXT="letztlich komplett in die RandomDraw-Komponente verlagert">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
</node>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#c8c0b6" COLOR="#a50125" CREATED="1700172965245" ID="ID_1212905228" MODIFIED="1700177181718" TEXT="Logik in Randbereichen">
|
||||
<icon BUILTIN="messagebox_warning"/>
|
||||
|
|
@ -99158,9 +99184,24 @@ Date:   Thu Apr 20 18:53:17 2023 +0200<br/>
|
|||
<node COLOR="#11660e" CREATED="1700761069915" ID="ID_557518427" MODIFIED="1700761165588" TEXT="Basis: »ziehen« von Zufallszahlen aus dem Hash ⟶ lib::RandomDraw">
|
||||
<arrowlink COLOR="#719f60" DESTINATION="ID_1225692248" ENDARROW="Default" ENDINCLINATION="-466;214;" ID="Arrow_ID_834549033" STARTARROW="None" STARTINCLINATION="241;10;"/>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1701012898916" ID="ID_1931960006" MODIFIED="1701012940106" TEXT="Regel-Baukasten aufbauen">
|
||||
<node BACKGROUND_COLOR="#eef0c5" COLOR="#990000" CREATED="1701012898916" ID="ID_1931960006" MODIFIED="1701314189673" TEXT="Regel-Baukasten aufbauen">
|
||||
<arrowlink COLOR="#5a509e" DESTINATION="ID_1092101612" ENDARROW="Default" ENDINCLINATION="8;265;" ID="Arrow_ID_362060244" STARTARROW="None" STARTINCLINATION="415;-28;"/>
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
<icon BUILTIN="pencil"/>
|
||||
<node COLOR="#435e98" CREATED="1701313975373" HGAP="49" ID="ID_1693658322" MODIFIED="1701314186518" TEXT="Bausteine" VSHIFT="14">
|
||||
<icon BUILTIN="info"/>
|
||||
<node COLOR="#338800" CREATED="1701313986968" ID="ID_332576900" MODIFIED="1701314035258" TEXT="rule_atStart">
|
||||
<richcontent TYPE="NOTE"><html>
|
||||
<head>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<p>
|
||||
stattet jede seed-Node sofort mit einem festen Branch-Faktor aus
|
||||
</p>
|
||||
</body>
|
||||
</html></richcontent>
|
||||
</node>
|
||||
</node>
|
||||
</node>
|
||||
</node>
|
||||
<node COLOR="#338800" CREATED="1701225831100" ID="ID_502326802" MODIFIED="1701225843337" TEXT="seed und shufle zur Auswahl von Varianten">
|
||||
|
|
|
|||
Loading…
Reference in a new issue