@reicek/neataptic-ts 0.1.25 → 0.1.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/copilot-instructions.md +11 -0
- package/.github/skills/trace-analyzer-extension/SKILL.md +3 -3
- package/.github/skills/trace-analyzer-extension/assets/extension-checklist.md +1 -1
- package/.github/skills/trace-analyzer-extension/references/analyzer-extension-workflow.md +1 -1
- package/.github/skills/trace-audit-reporting/SKILL.md +3 -3
- package/.github/skills/trace-audit-reporting/references/trace-analysis-workflow.md +1 -1
- package/package.json +19 -13
- package/plans/Flappy_Bird_Folder_Documentation_Pass.md +4 -4
- package/plans/README.md +24 -0
- package/plans/Roadmap.md +62 -40
- package/plans/analyze-trace-solid-split.plans.md +66 -0
- package/plans/architecture-solid-split.plans.md +9 -15
- package/plans/asciiMaze-typescript-repair.plans.md +1 -1
- package/plans/generate-docs-solid-split.plans.md +87 -0
- package/plans/methods-docs.plans.md +25 -1
- package/plans/methods-solid-split.plans.md +14 -14
- package/plans/neat-docs.plans.md +9 -1
- package/plans/neat-test-surface-repair.plans.md +1 -1
- package/plans/render-docs-html-solid-split.plans.md +68 -0
- package/plans/src-no-explicit-any-cleanup.plans.md +1 -1
- package/plans/utils-docs.plans.md +6 -1
- package/scripts/analyze-trace/analyze-trace.analysis.ts +479 -0
- package/scripts/analyze-trace/analyze-trace.constants.ts +35 -0
- package/scripts/analyze-trace/analyze-trace.io.ts +69 -0
- package/scripts/analyze-trace/analyze-trace.report.ts +100 -0
- package/scripts/analyze-trace/analyze-trace.shared.ts +116 -0
- package/scripts/analyze-trace/analyze-trace.ts +45 -0
- package/scripts/analyze-trace/analyze-trace.types.ts +72 -0
- package/scripts/assets/theme.css +80 -23
- package/scripts/copy-examples.ts +239 -0
- package/scripts/export-onnx.ts +223 -0
- package/scripts/generate-bench-tables.ts +378 -37
- package/scripts/generate-docs/generate-docs.constants.ts +107 -0
- package/scripts/generate-docs/generate-docs.order.ts +355 -0
- package/scripts/generate-docs/generate-docs.state.ts +31 -0
- package/scripts/generate-docs/generate-docs.targets.ts +165 -0
- package/scripts/generate-docs/generate-docs.ts +63 -0
- package/scripts/generate-docs/generate-docs.types.ts +112 -0
- package/scripts/generate-docs/output/generate-docs.output.folder-index.utils.ts +167 -0
- package/scripts/generate-docs/output/generate-docs.output.ordering.utils.ts +353 -0
- package/scripts/generate-docs/output/generate-docs.output.readme.utils.ts +420 -0
- package/scripts/generate-docs/output/generate-docs.output.ts +123 -0
- package/scripts/generate-docs/output/generate-docs.output.warnings.utils.ts +219 -0
- package/scripts/generate-docs/symbols/generate-docs.symbols.collection.utils.ts +365 -0
- package/scripts/generate-docs/symbols/generate-docs.symbols.jsdoc.utils.ts +373 -0
- package/scripts/generate-docs/symbols/generate-docs.symbols.normalize.utils.ts +155 -0
- package/scripts/generate-docs/symbols/generate-docs.symbols.render.utils.ts +149 -0
- package/scripts/generate-docs/symbols/generate-docs.symbols.signature.utils.ts +289 -0
- package/scripts/generate-docs/symbols/generate-docs.symbols.ts +11 -0
- package/scripts/mermaid-cli.mjs +102 -22
- package/scripts/mermaid-cli.ts +736 -0
- package/scripts/render-docs-html/render-docs-html.assets.ts +54 -0
- package/scripts/render-docs-html/render-docs-html.mermaid.ts +245 -0
- package/scripts/{render-docs-html.sidebar.ts → render-docs-html/render-docs-html.navigation.ts} +141 -144
- package/scripts/render-docs-html/render-docs-html.pages.ts +333 -0
- package/scripts/render-docs-html/render-docs-html.shared.ts +333 -0
- package/scripts/render-docs-html/render-docs-html.types.ts +42 -0
- package/scripts/render-docs-html.ts +23 -587
- package/scripts/run-docs.ts +238 -0
- package/scripts/write-dist-docs-pkg.ts +40 -0
- package/src/README.md +75 -75
- package/src/architecture/connection/README.md +5 -5
- package/src/architecture/layer/README.md +508 -508
- package/src/architecture/network/README.md +1458 -1458
- package/src/architecture/network/activate/README.md +694 -694
- package/src/architecture/network/bootstrap/README.md +77 -77
- package/src/architecture/network/connect/README.md +74 -74
- package/src/architecture/network/deterministic/README.md +135 -135
- package/src/architecture/network/evolve/README.md +364 -364
- package/src/architecture/network/gating/README.md +130 -130
- package/src/architecture/network/genetic/README.md +399 -399
- package/src/architecture/network/mutate/README.md +897 -897
- package/src/architecture/network/onnx/README.md +720 -720
- package/src/architecture/network/onnx/export/README.md +728 -728
- package/src/architecture/network/onnx/export/layers/README.md +450 -450
- package/src/architecture/network/onnx/import/README.md +618 -618
- package/src/architecture/network/onnx/schema/README.md +32 -32
- package/src/architecture/network/prune/README.md +245 -245
- package/src/architecture/network/remove/README.md +135 -135
- package/src/architecture/network/runtime/README.md +106 -106
- package/src/architecture/network/serialize/README.md +542 -542
- package/src/architecture/network/slab/README.md +608 -608
- package/src/architecture/network/standalone/README.md +212 -212
- package/src/architecture/network/stats/README.md +84 -84
- package/src/architecture/network/topology/README.md +465 -465
- package/src/architecture/network/training/README.md +200 -200
- package/src/architecture/node/README.md +5 -5
- package/src/architecture/nodePool/README.md +14 -14
- package/src/methods/README.md +99 -99
- package/src/methods/activation/README.md +189 -189
- package/src/methods/cost/README.md +131 -131
- package/src/methods/rate/README.md +86 -86
- package/src/multithreading/README.md +77 -77
- package/src/multithreading/workers/browser/README.md +8 -8
- package/src/multithreading/workers/node/README.md +8 -8
- package/src/neat/README.md +148 -148
- package/src/neat/adaptive/README.md +120 -120
- package/src/neat/adaptive/acceptance/README.md +40 -40
- package/src/neat/adaptive/complexity/README.md +137 -137
- package/src/neat/adaptive/core/README.md +197 -197
- package/src/neat/adaptive/lineage/README.md +90 -90
- package/src/neat/adaptive/mutation/README.md +284 -284
- package/src/neat/compat/README.md +43 -43
- package/src/neat/compat/core/README.md +90 -90
- package/src/neat/diversity/README.md +35 -35
- package/src/neat/diversity/core/README.md +88 -88
- package/src/neat/evaluate/README.md +85 -85
- package/src/neat/evaluate/auto-distance/README.md +75 -75
- package/src/neat/evaluate/entropy-compat/README.md +37 -37
- package/src/neat/evaluate/entropy-sharing/README.md +43 -43
- package/src/neat/evaluate/fitness/README.md +23 -23
- package/src/neat/evaluate/novelty/README.md +120 -120
- package/src/neat/evaluate/objectives/README.md +17 -17
- package/src/neat/evaluate/shared/README.md +94 -94
- package/src/neat/evolve/README.md +96 -96
- package/src/neat/evolve/adaptive/README.md +60 -60
- package/src/neat/evolve/objectives/README.md +63 -63
- package/src/neat/evolve/offspring/README.md +56 -56
- package/src/neat/evolve/population/README.md +171 -171
- package/src/neat/evolve/runtime/README.md +79 -79
- package/src/neat/evolve/speciation/README.md +74 -74
- package/src/neat/evolve/warnings/README.md +10 -10
- package/src/neat/export/README.md +114 -114
- package/src/neat/helpers/README.md +50 -50
- package/src/neat/init/README.md +9 -9
- package/src/neat/lineage/core/README.md +101 -101
- package/src/neat/multiobjective/category/README.md +74 -74
- package/src/neat/multiobjective/crowding/README.md +272 -272
- package/src/neat/multiobjective/dominance/README.md +171 -171
- package/src/neat/multiobjective/fronts/README.md +68 -68
- package/src/neat/multiobjective/metrics/README.md +43 -43
- package/src/neat/multiobjective/objectives/README.md +31 -31
- package/src/neat/multiobjective/shared/README.md +27 -27
- package/src/neat/mutation/README.md +97 -97
- package/src/neat/mutation/add-conn/README.md +115 -115
- package/src/neat/mutation/add-node/README.md +126 -126
- package/src/neat/mutation/flow/README.md +149 -149
- package/src/neat/mutation/repair/README.md +185 -185
- package/src/neat/mutation/select/README.md +117 -117
- package/src/neat/mutation/shared/README.md +32 -32
- package/src/neat/objectives/README.md +25 -25
- package/src/neat/objectives/core/README.md +67 -67
- package/src/neat/pruning/README.md +40 -40
- package/src/neat/pruning/core/README.md +171 -171
- package/src/neat/pruning/facade/README.md +32 -32
- package/src/neat/rng/README.md +104 -104
- package/src/neat/rng/core/README.md +137 -137
- package/src/neat/rng/facade/README.md +50 -50
- package/src/neat/selection/README.md +111 -111
- package/src/neat/selection/core/README.md +227 -227
- package/src/neat/selection/facade/README.md +61 -61
- package/src/neat/shared/README.md +163 -163
- package/src/neat/speciation/README.md +31 -31
- package/src/neat/speciation/threshold/README.md +35 -35
- package/src/neat/species/README.md +25 -25
- package/src/neat/species/core/README.md +20 -20
- package/src/neat/species/core/shared/README.md +18 -18
- package/src/neat/species/history/context/README.md +22 -22
- package/src/neat/telemetry/accessors/README.md +58 -58
- package/src/neat/telemetry/exports/README.md +233 -233
- package/src/neat/telemetry/facade/README.md +252 -252
- package/src/neat/telemetry/facade/archive/README.md +57 -57
- package/src/neat/telemetry/facade/buffer/README.md +43 -43
- package/src/neat/telemetry/facade/lineage/README.md +12 -12
- package/src/neat/telemetry/facade/objectives/README.md +44 -44
- package/src/neat/telemetry/facade/runtime/README.md +26 -26
- package/src/neat/telemetry/facade/species/README.md +27 -27
- package/src/neat/telemetry/metrics/README.md +696 -696
- package/src/neat/telemetry/recorder/README.md +57 -57
- package/src/neat/telemetry/types/README.md +32 -32
- package/src/neat/topology-intent/README.md +75 -75
- package/src/utils/README.md +193 -193
- package/test/examples/asciiMaze/browser-entry/README.md +92 -92
- package/test/examples/asciiMaze/dashboardManager/README.md +109 -109
- package/test/examples/asciiMaze/dashboardManager/telemetry/README.md +28 -28
- package/test/examples/asciiMaze/evolutionEngine/README.md +1527 -1527
- package/test/examples/asciiMaze/mazeMovement/README.md +105 -105
- package/test/examples/asciiMaze/mazeMovement/finalization/README.md +16 -16
- package/test/examples/asciiMaze/mazeMovement/policy/README.md +57 -57
- package/test/examples/asciiMaze/mazeMovement/runtime/README.md +52 -52
- package/test/examples/asciiMaze/mazeMovement/shaping/README.md +46 -46
- package/test/examples/flappy_bird/browser-entry/README.md +508 -508
- package/test/examples/flappy_bird/browser-entry/host/README.md +101 -101
- package/test/examples/flappy_bird/browser-entry/host/resize/README.md +144 -144
- package/test/examples/flappy_bird/browser-entry/network-view/README.md +194 -194
- package/test/examples/flappy_bird/browser-entry/playback/README.md +278 -278
- package/test/examples/flappy_bird/browser-entry/playback/background/README.md +129 -129
- package/test/examples/flappy_bird/browser-entry/playback/background/ground-grid/README.md +502 -502
- package/test/examples/flappy_bird/browser-entry/playback/frame-render/README.md +139 -139
- package/test/examples/flappy_bird/browser-entry/playback/snapshot/README.md +10 -10
- package/test/examples/flappy_bird/browser-entry/playback/trail/README.md +43 -43
- package/test/examples/flappy_bird/browser-entry/playback/worker-channel/README.md +30 -30
- package/test/examples/flappy_bird/browser-entry/runtime/README.md +59 -59
- package/test/examples/flappy_bird/browser-entry/visualization/README.md +276 -276
- package/test/examples/flappy_bird/browser-entry/worker-channel/README.md +16 -16
- package/test/examples/flappy_bird/constants/README.md +1070 -1070
- package/test/examples/flappy_bird/environment/README.md +22 -22
- package/test/examples/flappy_bird/evaluation/README.md +32 -32
- package/test/examples/flappy_bird/evaluation/rollout/README.md +141 -141
- package/test/examples/flappy_bird/flappy-evolution-worker/README.md +425 -425
- package/test/examples/flappy_bird/simulation-shared/README.md +170 -170
- package/test/examples/flappy_bird/simulation-shared/observation/README.md +109 -109
- package/test/examples/flappy_bird/trainer/README.md +325 -325
- package/test/examples/flappy_bird/trainer/evaluation/README.md +74 -74
- package/scripts/analyze-trace.ts +0 -590
- package/scripts/copy-examples.mjs +0 -114
- package/scripts/export-onnx.mjs +0 -86
- package/scripts/generate-bench-tables.mjs +0 -182
- package/scripts/generate-docs.ts +0 -2900
- package/scripts/write-dist-docs-pkg.mjs +0 -16
|
@@ -37,46 +37,6 @@ flowchart TD
|
|
|
37
37
|
|
|
38
38
|
## neat/pruning/pruning.ts
|
|
39
39
|
|
|
40
|
-
### applyEvolutionPruning
|
|
41
|
-
|
|
42
|
-
```ts
|
|
43
|
-
applyEvolutionPruning(): void
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
Apply evolution-time pruning to the current population.
|
|
47
|
-
|
|
48
|
-
Use this path when pruning should follow the generation schedule rather than
|
|
49
|
-
a live feedback loop. The evolve orchestration calls into this entrypoint to
|
|
50
|
-
ask a simple controller question: "for this generation, should pruning run,
|
|
51
|
-
and if so, how sparse should genomes become right now?"
|
|
52
|
-
|
|
53
|
-
This function does not maintain long-lived adaptive controller state. Instead
|
|
54
|
-
it reads the configured `evolutionPruning` schedule, checks whether the
|
|
55
|
-
current generation is inside the active window, computes the ramped target
|
|
56
|
-
sparsity for that moment in the run, and forwards the result to the genomes.
|
|
57
|
-
The host generation counter is read but not mutated here.
|
|
58
|
-
|
|
59
|
-
Choose this entrypoint when you want pruning to be predictable and tied to
|
|
60
|
-
generation timing. Use `applyAdaptivePruning()` instead when pruning should
|
|
61
|
-
react to observed population size or complexity metrics at runtime.
|
|
62
|
-
|
|
63
|
-
Returns: Nothing. Compatible genomes may be pruned in place when the schedule is active, but no adaptive controller fields are updated.
|
|
64
|
-
|
|
65
|
-
Example:
|
|
66
|
-
|
|
67
|
-
```ts
|
|
68
|
-
host.generation = 40;
|
|
69
|
-
host.options.evolutionPruning = {
|
|
70
|
-
startGeneration: 20,
|
|
71
|
-
interval: 5,
|
|
72
|
-
rampGenerations: 10,
|
|
73
|
-
targetSparsity: 0.3,
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
applyEvolutionPruning.call(host);
|
|
77
|
-
// Compatible genomes prune themselves using the schedule-derived sparsity.
|
|
78
|
-
```
|
|
79
|
-
|
|
80
40
|
### applyAdaptivePruning
|
|
81
41
|
|
|
82
42
|
```ts
|
|
@@ -118,3 +78,43 @@ applyAdaptivePruning.call(host);
|
|
|
118
78
|
// The host may initialize its baseline, update _adaptivePruneLevel,
|
|
119
79
|
// and prune compatible genomes if the metric drift is large enough.
|
|
120
80
|
```
|
|
81
|
+
|
|
82
|
+
### applyEvolutionPruning
|
|
83
|
+
|
|
84
|
+
```ts
|
|
85
|
+
applyEvolutionPruning(): void
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Apply evolution-time pruning to the current population.
|
|
89
|
+
|
|
90
|
+
Use this path when pruning should follow the generation schedule rather than
|
|
91
|
+
a live feedback loop. The evolve orchestration calls into this entrypoint to
|
|
92
|
+
ask a simple controller question: "for this generation, should pruning run,
|
|
93
|
+
and if so, how sparse should genomes become right now?"
|
|
94
|
+
|
|
95
|
+
This function does not maintain long-lived adaptive controller state. Instead
|
|
96
|
+
it reads the configured `evolutionPruning` schedule, checks whether the
|
|
97
|
+
current generation is inside the active window, computes the ramped target
|
|
98
|
+
sparsity for that moment in the run, and forwards the result to the genomes.
|
|
99
|
+
The host generation counter is read but not mutated here.
|
|
100
|
+
|
|
101
|
+
Choose this entrypoint when you want pruning to be predictable and tied to
|
|
102
|
+
generation timing. Use `applyAdaptivePruning()` instead when pruning should
|
|
103
|
+
react to observed population size or complexity metrics at runtime.
|
|
104
|
+
|
|
105
|
+
Returns: Nothing. Compatible genomes may be pruned in place when the schedule is active, but no adaptive controller fields are updated.
|
|
106
|
+
|
|
107
|
+
Example:
|
|
108
|
+
|
|
109
|
+
```ts
|
|
110
|
+
host.generation = 40;
|
|
111
|
+
host.options.evolutionPruning = {
|
|
112
|
+
startGeneration: 20,
|
|
113
|
+
interval: 5,
|
|
114
|
+
rampGenerations: 10,
|
|
115
|
+
targetSparsity: 0.3,
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
applyEvolutionPruning.call(host);
|
|
119
|
+
// Compatible genomes prune themselves using the schedule-derived sparsity.
|
|
120
|
+
```
|
|
@@ -22,6 +22,22 @@ which configuration knobs belong to scheduled versus adaptive control.
|
|
|
22
22
|
|
|
23
23
|
## neat/pruning/core/pruning.types.ts
|
|
24
24
|
|
|
25
|
+
### AdaptivePruningOptions
|
|
26
|
+
|
|
27
|
+
Adaptive pruning options extracted from the NEAT host.
|
|
28
|
+
|
|
29
|
+
These options drive the feedback-controller path: which population metric is
|
|
30
|
+
observed, what sparsity target should remain, how large a drift is tolerated,
|
|
31
|
+
and how quickly the shared prune level is allowed to move.
|
|
32
|
+
|
|
33
|
+
### EvolutionPruningOptions
|
|
34
|
+
|
|
35
|
+
Evolution pruning options extracted from the NEAT host.
|
|
36
|
+
|
|
37
|
+
These options drive the calendar-like pruning path: when pruning starts, how
|
|
38
|
+
often it repeats, how quickly the target sparsity ramps in, and which pruning
|
|
39
|
+
method is forwarded to compatible genomes.
|
|
40
|
+
|
|
25
41
|
### NeatLikeForPruning
|
|
26
42
|
|
|
27
43
|
Minimal NEAT host contract required by pruning helpers.
|
|
@@ -44,22 +60,6 @@ Read this chapter before `pruning.core.ts` when you need to know which state
|
|
|
44
60
|
the pruning helpers are allowed to read, which state they may write back, and
|
|
45
61
|
which configuration knobs belong to scheduled versus adaptive control.
|
|
46
62
|
|
|
47
|
-
### EvolutionPruningOptions
|
|
48
|
-
|
|
49
|
-
Evolution pruning options extracted from the NEAT host.
|
|
50
|
-
|
|
51
|
-
These options drive the calendar-like pruning path: when pruning starts, how
|
|
52
|
-
often it repeats, how quickly the target sparsity ramps in, and which pruning
|
|
53
|
-
method is forwarded to compatible genomes.
|
|
54
|
-
|
|
55
|
-
### AdaptivePruningOptions
|
|
56
|
-
|
|
57
|
-
Adaptive pruning options extracted from the NEAT host.
|
|
58
|
-
|
|
59
|
-
These options drive the feedback-controller path: which population metric is
|
|
60
|
-
observed, what sparsity target should remain, how large a drift is tolerated,
|
|
61
|
-
and how quickly the shared prune level is allowed to move.
|
|
62
|
-
|
|
63
63
|
### PopulationMetrics
|
|
64
64
|
|
|
65
65
|
Summary of population metrics used by adaptive pruning.
|
|
@@ -102,66 +102,26 @@ flowchart TD
|
|
|
102
102
|
Hold --> ApplyAdaptive
|
|
103
103
|
```
|
|
104
104
|
|
|
105
|
-
###
|
|
106
|
-
|
|
107
|
-
```ts
|
|
108
|
-
resolveActiveEvolutionPruningOptions(
|
|
109
|
-
host: NeatLikeForPruning,
|
|
110
|
-
): { startGeneration?: number | undefined; interval?: number | undefined; rampGenerations?: number | undefined; targetSparsity?: number | undefined; method?: string | undefined; } | null
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
Resolve scheduled pruning options when they are active for the current generation.
|
|
114
|
-
|
|
115
|
-
This helper is the gatekeeper for the calendar-driven pruning path. It keeps
|
|
116
|
-
the public pruning wrapper simple by answering one precise question: does the
|
|
117
|
-
current generation actually belong to the configured pruning schedule?
|
|
118
|
-
|
|
119
|
-
Parameters:
|
|
120
|
-
- `host` - - NEAT host exposing generation and pruning options.
|
|
121
|
-
|
|
122
|
-
Returns: Evolution pruning options when active, otherwise `null`.
|
|
123
|
-
|
|
124
|
-
### computeTargetSparsityNow
|
|
125
|
-
|
|
126
|
-
```ts
|
|
127
|
-
computeTargetSparsityNow(
|
|
128
|
-
host: NeatLikeForPruning,
|
|
129
|
-
options: { startGeneration?: number | undefined; interval?: number | undefined; rampGenerations?: number | undefined; targetSparsity?: number | undefined; method?: string | undefined; },
|
|
130
|
-
): number
|
|
131
|
-
```
|
|
132
|
-
|
|
133
|
-
Compute the target sparsity for the current generation.
|
|
134
|
-
|
|
135
|
-
Scheduled pruning ramps toward its configured sparsity target instead of
|
|
136
|
-
snapping there immediately. This helper converts the current ramp progress
|
|
137
|
-
into the exact target sparsity the active generation should use.
|
|
138
|
-
|
|
139
|
-
Parameters:
|
|
140
|
-
- `host` - - NEAT host exposing generation state.
|
|
141
|
-
- `options` - - Active scheduled pruning options.
|
|
142
|
-
|
|
143
|
-
Returns: Target sparsity for the current generation.
|
|
144
|
-
|
|
145
|
-
### computeRampFraction
|
|
105
|
+
### applyAdaptivePruneLevelToPopulation
|
|
146
106
|
|
|
147
107
|
```ts
|
|
148
|
-
|
|
108
|
+
applyAdaptivePruneLevelToPopulation(
|
|
149
109
|
host: NeatLikeForPruning,
|
|
150
|
-
|
|
151
|
-
):
|
|
110
|
+
pruneLevel: number,
|
|
111
|
+
): void
|
|
152
112
|
```
|
|
153
113
|
|
|
154
|
-
|
|
114
|
+
Apply the shared adaptive prune level to every compatible genome.
|
|
155
115
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
116
|
+
This is the final fan-out step for adaptive pruning. The host maintains one
|
|
117
|
+
shared prune level, and this helper applies that single controller decision
|
|
118
|
+
uniformly across genomes that support sparsity pruning.
|
|
159
119
|
|
|
160
120
|
Parameters:
|
|
161
|
-
- `host` - - NEAT host exposing
|
|
162
|
-
- `
|
|
121
|
+
- `host` - - NEAT host exposing the population.
|
|
122
|
+
- `pruneLevel` - - Prune level to apply.
|
|
163
123
|
|
|
164
|
-
Returns:
|
|
124
|
+
Returns: Nothing. Compatible genomes are pruned in place.
|
|
165
125
|
|
|
166
126
|
### applyPruningToPopulation
|
|
167
127
|
|
|
@@ -186,44 +146,69 @@ Parameters:
|
|
|
186
146
|
|
|
187
147
|
Returns: Nothing. Genomes are pruned in place when supported.
|
|
188
148
|
|
|
189
|
-
###
|
|
149
|
+
### computeMeanConnectionCount
|
|
190
150
|
|
|
191
151
|
```ts
|
|
192
|
-
|
|
152
|
+
computeMeanConnectionCount(
|
|
193
153
|
host: NeatLikeForPruning,
|
|
194
|
-
):
|
|
154
|
+
): number
|
|
195
155
|
```
|
|
196
156
|
|
|
197
|
-
|
|
157
|
+
Compute the average connection count per genome.
|
|
198
158
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
159
|
+
Connection count is the denser complexity signal commonly used for sparsity
|
|
160
|
+
control. Like node count, it is reduced to a population mean so the adaptive
|
|
161
|
+
controller reacts to trend rather than to one outlier genome.
|
|
202
162
|
|
|
203
163
|
Parameters:
|
|
204
|
-
- `host` - - NEAT host exposing
|
|
164
|
+
- `host` - - NEAT host exposing the population.
|
|
205
165
|
|
|
206
|
-
Returns:
|
|
166
|
+
Returns: Average number of connections per genome.
|
|
207
167
|
|
|
208
|
-
###
|
|
168
|
+
### computeMeanNodeCount
|
|
209
169
|
|
|
210
170
|
```ts
|
|
211
|
-
|
|
171
|
+
computeMeanNodeCount(
|
|
212
172
|
host: NeatLikeForPruning,
|
|
213
|
-
):
|
|
173
|
+
): number
|
|
214
174
|
```
|
|
215
175
|
|
|
216
|
-
|
|
176
|
+
Compute the average node count per genome.
|
|
217
177
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
initialization guard.
|
|
178
|
+
Node count is one of the two complexity signals the adaptive controller can
|
|
179
|
+
watch. It is intentionally averaged so population size changes do not by
|
|
180
|
+
themselves distort the pruning signal.
|
|
222
181
|
|
|
223
182
|
Parameters:
|
|
224
|
-
- `host` - - NEAT host exposing
|
|
183
|
+
- `host` - - NEAT host exposing the population.
|
|
225
184
|
|
|
226
|
-
Returns:
|
|
185
|
+
Returns: Average number of nodes per genome.
|
|
186
|
+
|
|
187
|
+
### computeNextAdaptivePruneLevel
|
|
188
|
+
|
|
189
|
+
```ts
|
|
190
|
+
computeNextAdaptivePruneLevel(
|
|
191
|
+
options: { enabled?: boolean | undefined; metric?: string | undefined; targetSparsity?: number | undefined; learningRate?: number | undefined; tolerance?: number | undefined; adjustRate?: number | undefined; },
|
|
192
|
+
currentPruneLevel: number,
|
|
193
|
+
currentMetricValue: number,
|
|
194
|
+
targetRemainingMetric: number,
|
|
195
|
+
): number
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
Compute the next adaptive prune level.
|
|
199
|
+
|
|
200
|
+
Once the controller decides that drift is large enough, this helper turns the
|
|
201
|
+
direction of that drift into a bounded update of the shared prune level.
|
|
202
|
+
Higher-than-target complexity tightens pruning; lower-than-target complexity
|
|
203
|
+
relaxes it.
|
|
204
|
+
|
|
205
|
+
Parameters:
|
|
206
|
+
- `options` - - Adaptive pruning options.
|
|
207
|
+
- `currentPruneLevel` - - Current shared prune level.
|
|
208
|
+
- `currentMetricValue` - - Current observed metric value.
|
|
209
|
+
- `targetRemainingMetric` - - Target remaining metric value.
|
|
210
|
+
|
|
211
|
+
Returns: Updated prune level clamped into the valid sparsity range.
|
|
227
212
|
|
|
228
213
|
### computePopulationMetrics
|
|
229
214
|
|
|
@@ -245,64 +230,127 @@ Parameters:
|
|
|
245
230
|
|
|
246
231
|
Returns: Summary of mean node and connection counts.
|
|
247
232
|
|
|
248
|
-
###
|
|
233
|
+
### computeRampFraction
|
|
249
234
|
|
|
250
235
|
```ts
|
|
251
|
-
|
|
236
|
+
computeRampFraction(
|
|
252
237
|
host: NeatLikeForPruning,
|
|
238
|
+
options: { startGeneration?: number | undefined; interval?: number | undefined; rampGenerations?: number | undefined; targetSparsity?: number | undefined; method?: string | undefined; },
|
|
253
239
|
): number
|
|
254
240
|
```
|
|
255
241
|
|
|
256
|
-
Compute the
|
|
242
|
+
Compute the ramp completion fraction for scheduled pruning.
|
|
257
243
|
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
244
|
+
The ramp fraction is the soft-start mechanism for scheduled pruning. It lets
|
|
245
|
+
the controller phase sparsity in gradually over several generations so the
|
|
246
|
+
population does not experience one abrupt structural shock.
|
|
261
247
|
|
|
262
248
|
Parameters:
|
|
263
|
-
- `host` - - NEAT host exposing
|
|
249
|
+
- `host` - - NEAT host exposing generation state.
|
|
250
|
+
- `options` - - Active scheduled pruning options.
|
|
264
251
|
|
|
265
|
-
Returns:
|
|
252
|
+
Returns: Fraction in `[0, 1]` indicating ramp completion.
|
|
266
253
|
|
|
267
|
-
###
|
|
254
|
+
### computeTargetRemainingMetric
|
|
268
255
|
|
|
269
256
|
```ts
|
|
270
|
-
|
|
271
|
-
|
|
257
|
+
computeTargetRemainingMetric(
|
|
258
|
+
options: { enabled?: boolean | undefined; metric?: string | undefined; targetSparsity?: number | undefined; learningRate?: number | undefined; tolerance?: number | undefined; adjustRate?: number | undefined; },
|
|
259
|
+
adaptivePruneBaseline: number,
|
|
272
260
|
): number
|
|
273
261
|
```
|
|
274
262
|
|
|
275
|
-
Compute the
|
|
263
|
+
Compute the target remaining metric implied by the desired sparsity.
|
|
276
264
|
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
265
|
+
Adaptive pruning expresses its goal as desired sparsity, but the feedback loop
|
|
266
|
+
compares live complexity metrics. This helper bridges those two views by
|
|
267
|
+
translating the baseline metric into the remaining amount of structure the
|
|
268
|
+
controller wants to keep.
|
|
280
269
|
|
|
281
270
|
Parameters:
|
|
282
|
-
- `
|
|
271
|
+
- `options` - - Adaptive pruning options.
|
|
272
|
+
- `adaptivePruneBaseline` - - Baseline metric value.
|
|
283
273
|
|
|
284
|
-
Returns:
|
|
274
|
+
Returns: Target remaining metric value.
|
|
285
275
|
|
|
286
|
-
###
|
|
276
|
+
### computeTargetSparsityNow
|
|
287
277
|
|
|
288
278
|
```ts
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
279
|
+
computeTargetSparsityNow(
|
|
280
|
+
host: NeatLikeForPruning,
|
|
281
|
+
options: { startGeneration?: number | undefined; interval?: number | undefined; rampGenerations?: number | undefined; targetSparsity?: number | undefined; method?: string | undefined; },
|
|
292
282
|
): number
|
|
293
283
|
```
|
|
294
284
|
|
|
295
|
-
|
|
285
|
+
Compute the target sparsity for the current generation.
|
|
296
286
|
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
287
|
+
Scheduled pruning ramps toward its configured sparsity target instead of
|
|
288
|
+
snapping there immediately. This helper converts the current ramp progress
|
|
289
|
+
into the exact target sparsity the active generation should use.
|
|
300
290
|
|
|
301
291
|
Parameters:
|
|
302
|
-
- `
|
|
303
|
-
- `
|
|
292
|
+
- `host` - - NEAT host exposing generation state.
|
|
293
|
+
- `options` - - Active scheduled pruning options.
|
|
304
294
|
|
|
305
|
-
Returns:
|
|
295
|
+
Returns: Target sparsity for the current generation.
|
|
296
|
+
|
|
297
|
+
### initializeAdaptivePruningState
|
|
298
|
+
|
|
299
|
+
```ts
|
|
300
|
+
initializeAdaptivePruningState(
|
|
301
|
+
host: NeatLikeForPruning,
|
|
302
|
+
): void
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
Ensure the adaptive pruning state exists on the host.
|
|
306
|
+
|
|
307
|
+
Adaptive pruning keeps one shared prune level on the host so the whole
|
|
308
|
+
population can react coherently across generations. This helper bootstraps
|
|
309
|
+
that state once, rather than making every downstream helper repeat the same
|
|
310
|
+
initialization guard.
|
|
311
|
+
|
|
312
|
+
Parameters:
|
|
313
|
+
- `host` - - NEAT host exposing adaptive pruning state.
|
|
314
|
+
|
|
315
|
+
Returns: Nothing. The shared prune level is initialized when missing.
|
|
316
|
+
|
|
317
|
+
### resolveActiveAdaptivePruningOptions
|
|
318
|
+
|
|
319
|
+
```ts
|
|
320
|
+
resolveActiveAdaptivePruningOptions(
|
|
321
|
+
host: NeatLikeForPruning,
|
|
322
|
+
): { enabled?: boolean | undefined; metric?: string | undefined; targetSparsity?: number | undefined; learningRate?: number | undefined; tolerance?: number | undefined; adjustRate?: number | undefined; } | null
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
Resolve adaptive pruning options when enabled.
|
|
326
|
+
|
|
327
|
+
This is the narrow on-ramp to the feedback-controller branch. It makes the
|
|
328
|
+
rest of the adaptive helpers read linearly by collapsing disabled or missing
|
|
329
|
+
configuration into one `null` check.
|
|
330
|
+
|
|
331
|
+
Parameters:
|
|
332
|
+
- `host` - - NEAT host exposing adaptive pruning options.
|
|
333
|
+
|
|
334
|
+
Returns: Adaptive pruning options when enabled, otherwise `null`.
|
|
335
|
+
|
|
336
|
+
### resolveActiveEvolutionPruningOptions
|
|
337
|
+
|
|
338
|
+
```ts
|
|
339
|
+
resolveActiveEvolutionPruningOptions(
|
|
340
|
+
host: NeatLikeForPruning,
|
|
341
|
+
): { startGeneration?: number | undefined; interval?: number | undefined; rampGenerations?: number | undefined; targetSparsity?: number | undefined; method?: string | undefined; } | null
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
Resolve scheduled pruning options when they are active for the current generation.
|
|
345
|
+
|
|
346
|
+
This helper is the gatekeeper for the calendar-driven pruning path. It keeps
|
|
347
|
+
the public pruning wrapper simple by answering one precise question: does the
|
|
348
|
+
current generation actually belong to the configured pruning schedule?
|
|
349
|
+
|
|
350
|
+
Parameters:
|
|
351
|
+
- `host` - - NEAT host exposing generation and pruning options.
|
|
352
|
+
|
|
353
|
+
Returns: Evolution pruning options when active, otherwise `null`.
|
|
306
354
|
|
|
307
355
|
### resolveAdaptivePruneBaseline
|
|
308
356
|
|
|
@@ -325,27 +373,26 @@ Parameters:
|
|
|
325
373
|
|
|
326
374
|
Returns: Baseline metric value used for adaptation.
|
|
327
375
|
|
|
328
|
-
###
|
|
376
|
+
### resolveObservedMetricValue
|
|
329
377
|
|
|
330
378
|
```ts
|
|
331
|
-
|
|
379
|
+
resolveObservedMetricValue(
|
|
332
380
|
options: { enabled?: boolean | undefined; metric?: string | undefined; targetSparsity?: number | undefined; learningRate?: number | undefined; tolerance?: number | undefined; adjustRate?: number | undefined; },
|
|
333
|
-
|
|
381
|
+
metrics: PopulationMetrics,
|
|
334
382
|
): number
|
|
335
383
|
```
|
|
336
384
|
|
|
337
|
-
|
|
385
|
+
Resolve the currently observed population metric for adaptive pruning.
|
|
338
386
|
|
|
339
|
-
Adaptive pruning
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
controller wants to keep.
|
|
387
|
+
Adaptive pruning can watch either node count or connection count. This helper
|
|
388
|
+
turns the configured metric name into the actual observed value that the rest
|
|
389
|
+
of the controller math will compare with the target remaining complexity.
|
|
343
390
|
|
|
344
391
|
Parameters:
|
|
345
392
|
- `options` - - Adaptive pruning options.
|
|
346
|
-
- `
|
|
393
|
+
- `metrics` - - Population metric summary.
|
|
347
394
|
|
|
348
|
-
Returns:
|
|
395
|
+
Returns: Current observed metric value used for adaptation.
|
|
349
396
|
|
|
350
397
|
### shouldAdjustAdaptivePruning
|
|
351
398
|
|
|
@@ -371,50 +418,3 @@ Parameters:
|
|
|
371
418
|
- `adaptivePruneBaseline` - - Baseline metric value.
|
|
372
419
|
|
|
373
420
|
Returns: `true` when the normalized drift exceeds the configured tolerance.
|
|
374
|
-
|
|
375
|
-
### computeNextAdaptivePruneLevel
|
|
376
|
-
|
|
377
|
-
```ts
|
|
378
|
-
computeNextAdaptivePruneLevel(
|
|
379
|
-
options: { enabled?: boolean | undefined; metric?: string | undefined; targetSparsity?: number | undefined; learningRate?: number | undefined; tolerance?: number | undefined; adjustRate?: number | undefined; },
|
|
380
|
-
currentPruneLevel: number,
|
|
381
|
-
currentMetricValue: number,
|
|
382
|
-
targetRemainingMetric: number,
|
|
383
|
-
): number
|
|
384
|
-
```
|
|
385
|
-
|
|
386
|
-
Compute the next adaptive prune level.
|
|
387
|
-
|
|
388
|
-
Once the controller decides that drift is large enough, this helper turns the
|
|
389
|
-
direction of that drift into a bounded update of the shared prune level.
|
|
390
|
-
Higher-than-target complexity tightens pruning; lower-than-target complexity
|
|
391
|
-
relaxes it.
|
|
392
|
-
|
|
393
|
-
Parameters:
|
|
394
|
-
- `options` - - Adaptive pruning options.
|
|
395
|
-
- `currentPruneLevel` - - Current shared prune level.
|
|
396
|
-
- `currentMetricValue` - - Current observed metric value.
|
|
397
|
-
- `targetRemainingMetric` - - Target remaining metric value.
|
|
398
|
-
|
|
399
|
-
Returns: Updated prune level clamped into the valid sparsity range.
|
|
400
|
-
|
|
401
|
-
### applyAdaptivePruneLevelToPopulation
|
|
402
|
-
|
|
403
|
-
```ts
|
|
404
|
-
applyAdaptivePruneLevelToPopulation(
|
|
405
|
-
host: NeatLikeForPruning,
|
|
406
|
-
pruneLevel: number,
|
|
407
|
-
): void
|
|
408
|
-
```
|
|
409
|
-
|
|
410
|
-
Apply the shared adaptive prune level to every compatible genome.
|
|
411
|
-
|
|
412
|
-
This is the final fan-out step for adaptive pruning. The host maintains one
|
|
413
|
-
shared prune level, and this helper applies that single controller decision
|
|
414
|
-
uniformly across genomes that support sparsity pruning.
|
|
415
|
-
|
|
416
|
-
Parameters:
|
|
417
|
-
- `host` - - NEAT host exposing the population.
|
|
418
|
-
- `pruneLevel` - - Prune level to apply.
|
|
419
|
-
|
|
420
|
-
Returns: Nothing. Compatible genomes are pruned in place.
|
|
@@ -38,72 +38,72 @@ its own.
|
|
|
38
38
|
|
|
39
39
|
## neat/pruning/facade/pruning.facade.ts
|
|
40
40
|
|
|
41
|
-
###
|
|
41
|
+
### applyAdaptivePruning
|
|
42
42
|
|
|
43
43
|
```ts
|
|
44
|
-
|
|
44
|
+
applyAdaptivePruning(
|
|
45
45
|
host: NeatLikeForPruning,
|
|
46
46
|
): Promise<void>
|
|
47
47
|
```
|
|
48
48
|
|
|
49
|
-
|
|
49
|
+
Run adaptive pruning through the stable public `Neat` facade.
|
|
50
50
|
|
|
51
|
-
This is the public wrapper for
|
|
52
|
-
|
|
53
|
-
|
|
51
|
+
This is the public wrapper for metric-driven pruning. Use it when pruning
|
|
52
|
+
should react to live population complexity signals rather than a fixed
|
|
53
|
+
generation schedule.
|
|
54
54
|
|
|
55
|
-
The
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
The facade keeps the same lazy optional-loading behavior so callers can
|
|
56
|
+
continue to treat adaptive pruning as an additive maintenance feature rather
|
|
57
|
+
than a required runtime dependency.
|
|
58
58
|
|
|
59
|
-
This wrapper is the
|
|
60
|
-
|
|
61
|
-
That makes it the better fit for
|
|
62
|
-
|
|
59
|
+
This wrapper is the reactive pruning entrypoint: it says "inspect the live
|
|
60
|
+
population metrics and adjust the shared prune level only if the drift is big
|
|
61
|
+
enough to matter." That makes it the better fit for maintenance-style runs
|
|
62
|
+
where pruning should respond to observed complexity rather than the calendar.
|
|
63
63
|
|
|
64
64
|
Parameters:
|
|
65
|
-
- `host` - - `Neat` instance exposing pruning
|
|
65
|
+
- `host` - - `Neat` instance exposing adaptive pruning state and population metrics.
|
|
66
66
|
|
|
67
|
-
Returns: Promise that resolves after the best-effort pruning attempt finishes.
|
|
67
|
+
Returns: Promise that resolves after the best-effort adaptive pruning attempt finishes.
|
|
68
68
|
|
|
69
69
|
Example:
|
|
70
70
|
|
|
71
71
|
```ts
|
|
72
|
-
await neat.
|
|
72
|
+
await neat.applyAdaptivePruning();
|
|
73
73
|
```
|
|
74
74
|
|
|
75
|
-
###
|
|
75
|
+
### applyEvolutionPruning
|
|
76
76
|
|
|
77
77
|
```ts
|
|
78
|
-
|
|
78
|
+
applyEvolutionPruning(
|
|
79
79
|
host: NeatLikeForPruning,
|
|
80
80
|
): Promise<void>
|
|
81
81
|
```
|
|
82
82
|
|
|
83
|
-
|
|
83
|
+
Apply evolution-time pruning through the stable public `Neat` facade.
|
|
84
84
|
|
|
85
|
-
This is the public wrapper for
|
|
86
|
-
|
|
87
|
-
|
|
85
|
+
This is the public wrapper for schedule-driven pruning. Use it when the
|
|
86
|
+
caller wants the root pruning chapter to inspect generation timing and apply
|
|
87
|
+
pruning only when the configured evolution schedule says it is active.
|
|
88
88
|
|
|
89
|
-
The
|
|
90
|
-
|
|
91
|
-
|
|
89
|
+
The underlying pruning module is loaded lazily so pruning remains optional,
|
|
90
|
+
and the facade preserves the same best-effort behavior as before the pruning
|
|
91
|
+
logic was extracted out of the main `Neat` class.
|
|
92
92
|
|
|
93
|
-
This wrapper is the
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
where pruning should
|
|
93
|
+
This wrapper is the predictable pruning entrypoint: it says "consult the
|
|
94
|
+
generation schedule and prune if the current run state says it is time."
|
|
95
|
+
That makes it the better fit for orchestrated evolve loops and deterministic
|
|
96
|
+
experiments where pruning should follow a known calendar.
|
|
97
97
|
|
|
98
98
|
Parameters:
|
|
99
|
-
- `host` - - `Neat` instance exposing
|
|
99
|
+
- `host` - - `Neat` instance exposing pruning options, generation state, and population.
|
|
100
100
|
|
|
101
|
-
Returns: Promise that resolves after the best-effort
|
|
101
|
+
Returns: Promise that resolves after the best-effort pruning attempt finishes.
|
|
102
102
|
|
|
103
103
|
Example:
|
|
104
104
|
|
|
105
105
|
```ts
|
|
106
|
-
await neat.
|
|
106
|
+
await neat.applyEvolutionPruning();
|
|
107
107
|
```
|
|
108
108
|
|
|
109
109
|
### NeatPruningFacadeHost
|