@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
|
@@ -42,78 +42,60 @@ flowchart TD
|
|
|
42
42
|
|
|
43
43
|
## neat/mutation/select/mutation.select.ts
|
|
44
44
|
|
|
45
|
-
###
|
|
45
|
+
### applyOperatorAdaptationForSelect
|
|
46
46
|
|
|
47
47
|
```ts
|
|
48
|
-
|
|
48
|
+
applyOperatorAdaptationForSelect(
|
|
49
|
+
pool: MutationMethod[],
|
|
49
50
|
internal: NeatControllerForMutation,
|
|
50
|
-
|
|
51
|
-
rawReturnForTest: boolean,
|
|
52
|
-
): MutationMethod | MutationMethod[] | null
|
|
51
|
+
): MutationMethod[]
|
|
53
52
|
```
|
|
54
53
|
|
|
55
|
-
|
|
54
|
+
Apply operator adaptation weighting to the pool when enabled.
|
|
56
55
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
56
|
+
Operator adaptation uses recent structural success as a lightweight teaching
|
|
57
|
+
signal. Operators that have enough attempts and a sufficiently high success
|
|
58
|
+
ratio are duplicated into the candidate pool, increasing their sampling
|
|
59
|
+
probability without changing the operator interface itself.
|
|
61
60
|
|
|
62
|
-
The
|
|
63
|
-
|
|
64
|
-
|
|
61
|
+
The helper intentionally does not compute a fancy score. It just reshapes the
|
|
62
|
+
pool, which keeps the later selection steps simple and preserves compatibility
|
|
63
|
+
with random sampling and bandit-based final choice.
|
|
65
64
|
|
|
66
65
|
Parameters:
|
|
66
|
+
- `pool` - - base pool
|
|
67
67
|
- `internal` - - neat controller context
|
|
68
|
-
- `methods` - - methods module
|
|
69
|
-
- `rawReturnForTest` - - whether to return raw FFW array for tests
|
|
70
68
|
|
|
71
|
-
Returns:
|
|
69
|
+
Returns: augmented pool
|
|
72
70
|
|
|
73
|
-
###
|
|
71
|
+
### applyOperatorBanditForSelect
|
|
74
72
|
|
|
75
73
|
```ts
|
|
76
|
-
|
|
74
|
+
applyOperatorBanditForSelect(
|
|
75
|
+
pool: MutationMethod[],
|
|
76
|
+
fallbackMethod: MutationMethod,
|
|
77
77
|
internal: NeatControllerForMutation,
|
|
78
|
-
|
|
79
|
-
rawReturnForTest: boolean,
|
|
80
|
-
): MutationMethod[]
|
|
78
|
+
): MutationMethod
|
|
81
79
|
```
|
|
82
80
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
This helper is the bridge from loose policy configuration to a concrete
|
|
86
|
-
candidate shelf. It flattens nested legacy arrays and preserves the special
|
|
87
|
-
FFW path when tests explicitly need the historical representation.
|
|
88
|
-
|
|
89
|
-
Parameters:
|
|
90
|
-
- `internal` - - neat controller context
|
|
91
|
-
- `methods` - - methods module
|
|
92
|
-
- `rawReturnForTest` - - whether to return raw FFW for tests
|
|
93
|
-
|
|
94
|
-
Returns: normalized mutation pool
|
|
95
|
-
|
|
96
|
-
### isLegacyFFWPoolForSelect
|
|
97
|
-
|
|
98
|
-
```ts
|
|
99
|
-
isLegacyFFWPoolForSelect(
|
|
100
|
-
configuredPool: MutationMethod[],
|
|
101
|
-
methods: { mutation: unknown; },
|
|
102
|
-
): boolean
|
|
103
|
-
```
|
|
81
|
+
Apply operator bandit selection if enabled.
|
|
104
82
|
|
|
105
|
-
|
|
83
|
+
The operator bandit is the strongest opinionated selector in this chapter.
|
|
84
|
+
Instead of drawing randomly from the shaped pool, it ranks candidate
|
|
85
|
+
operators with a UCB-style score that balances observed success and
|
|
86
|
+
exploration.
|
|
106
87
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
88
|
+
Early in a run, under-sampled operators receive effectively unbounded
|
|
89
|
+
exploration pressure. Later, the choice shifts toward operators with better
|
|
90
|
+
observed structural payoff. That makes this helper the bridge between simple
|
|
91
|
+
mutation policy configuration and online operator learning.
|
|
111
92
|
|
|
112
93
|
Parameters:
|
|
113
|
-
- `
|
|
114
|
-
- `
|
|
94
|
+
- `pool` - - operator pool
|
|
95
|
+
- `fallbackMethod` - - method used when bandit is disabled
|
|
96
|
+
- `internal` - - neat controller context
|
|
115
97
|
|
|
116
|
-
Returns:
|
|
98
|
+
Returns: selected method
|
|
117
99
|
|
|
118
100
|
### applyPhasedComplexityForSelect
|
|
119
101
|
|
|
@@ -138,52 +120,76 @@ Parameters:
|
|
|
138
120
|
|
|
139
121
|
Returns: pool with phased complexity adjustments
|
|
140
122
|
|
|
141
|
-
###
|
|
123
|
+
### isBlockedByRecurrentPolicyForSelect
|
|
142
124
|
|
|
143
125
|
```ts
|
|
144
|
-
|
|
145
|
-
|
|
126
|
+
isBlockedByRecurrentPolicyForSelect(
|
|
127
|
+
mutationMethod: MutationMethod,
|
|
146
128
|
internal: NeatControllerForMutation,
|
|
147
|
-
|
|
129
|
+
methods: { mutation: unknown; },
|
|
130
|
+
): boolean
|
|
148
131
|
```
|
|
149
132
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
Operator adaptation uses recent structural success as a lightweight teaching
|
|
153
|
-
signal. Operators that have enough attempts and a sufficiently high success
|
|
154
|
-
ratio are duplicated into the candidate pool, increasing their sampling
|
|
155
|
-
probability without changing the operator interface itself.
|
|
133
|
+
Check whether a mutation is blocked by recurrent connection policy.
|
|
156
134
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
135
|
+
Structural capacity limits are not the only hard guard. Some runs prohibit
|
|
136
|
+
recurrent structure entirely, and this helper keeps that policy localized so
|
|
137
|
+
the rest of the selection code can stay focused on scoring and weighting.
|
|
160
138
|
|
|
161
139
|
Parameters:
|
|
162
|
-
- `
|
|
140
|
+
- `mutationMethod` - - mutation operator to check
|
|
163
141
|
- `internal` - - neat controller context
|
|
142
|
+
- `methods` - - methods module
|
|
164
143
|
|
|
165
|
-
Returns:
|
|
144
|
+
Returns: true when the mutation should be blocked
|
|
166
145
|
|
|
167
|
-
###
|
|
146
|
+
### isBlockedByStructuralLimitsForSelect
|
|
168
147
|
|
|
169
148
|
```ts
|
|
170
|
-
|
|
171
|
-
|
|
149
|
+
isBlockedByStructuralLimitsForSelect(
|
|
150
|
+
mutationMethod: MutationMethod,
|
|
151
|
+
genome: GenomeWithMetadata,
|
|
172
152
|
internal: NeatControllerForMutation,
|
|
173
|
-
|
|
153
|
+
methods: { mutation: unknown; },
|
|
154
|
+
): boolean
|
|
174
155
|
```
|
|
175
156
|
|
|
176
|
-
|
|
157
|
+
Check whether a mutation is blocked by structural limits.
|
|
177
158
|
|
|
178
|
-
This is the
|
|
179
|
-
|
|
180
|
-
|
|
159
|
+
This helper is one of the hard guard rails after softer policy shaping has
|
|
160
|
+
already happened. Even if an operator is favored by phase bias or adaptation,
|
|
161
|
+
it must still respect controller-wide caps such as maximum nodes,
|
|
162
|
+
connections, or gates.
|
|
181
163
|
|
|
182
164
|
Parameters:
|
|
183
|
-
- `
|
|
165
|
+
- `mutationMethod` - - mutation operator to check
|
|
166
|
+
- `genome` - - genome to inspect
|
|
184
167
|
- `internal` - - neat controller context
|
|
168
|
+
- `methods` - - methods module
|
|
185
169
|
|
|
186
|
-
Returns:
|
|
170
|
+
Returns: true when the mutation should be blocked
|
|
171
|
+
|
|
172
|
+
### isLegacyFFWPoolForSelect
|
|
173
|
+
|
|
174
|
+
```ts
|
|
175
|
+
isLegacyFFWPoolForSelect(
|
|
176
|
+
configuredPool: MutationMethod[],
|
|
177
|
+
methods: { mutation: unknown; },
|
|
178
|
+
): boolean
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
Check whether a pool matches the legacy FFW operator ordering.
|
|
182
|
+
|
|
183
|
+
The selection boundary uses this check as a compatibility detector, not as a
|
|
184
|
+
generic equality helper. Matching the canonical FFW ordering tells the caller
|
|
185
|
+
that the configured pool is really a feed-forward preset that may deserve
|
|
186
|
+
special handling.
|
|
187
|
+
|
|
188
|
+
Parameters:
|
|
189
|
+
- `configuredPool` - - configured operator pool
|
|
190
|
+
- `methods` - - methods module
|
|
191
|
+
|
|
192
|
+
Returns: true when the pool matches FFW
|
|
187
193
|
|
|
188
194
|
### isOperatorNamePrefixedForSelect
|
|
189
195
|
|
|
@@ -206,80 +212,74 @@ Parameters:
|
|
|
206
212
|
|
|
207
213
|
Returns: true when the operator name matches the prefix
|
|
208
214
|
|
|
209
|
-
###
|
|
215
|
+
### normalizeMutationPoolForSelect
|
|
210
216
|
|
|
211
217
|
```ts
|
|
212
|
-
|
|
213
|
-
mutationMethod: MutationMethod,
|
|
214
|
-
genome: GenomeWithMetadata,
|
|
218
|
+
normalizeMutationPoolForSelect(
|
|
215
219
|
internal: NeatControllerForMutation,
|
|
216
220
|
methods: { mutation: unknown; },
|
|
217
|
-
|
|
221
|
+
rawReturnForTest: boolean,
|
|
222
|
+
): MutationMethod[]
|
|
218
223
|
```
|
|
219
224
|
|
|
220
|
-
|
|
225
|
+
Normalize the configured mutation pool to a flat operator list.
|
|
221
226
|
|
|
222
|
-
This helper is
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
connections, or gates.
|
|
227
|
+
This helper is the bridge from loose policy configuration to a concrete
|
|
228
|
+
candidate shelf. It flattens nested legacy arrays and preserves the special
|
|
229
|
+
FFW path when tests explicitly need the historical representation.
|
|
226
230
|
|
|
227
231
|
Parameters:
|
|
228
|
-
- `mutationMethod` - - mutation operator to check
|
|
229
|
-
- `genome` - - genome to inspect
|
|
230
232
|
- `internal` - - neat controller context
|
|
231
233
|
- `methods` - - methods module
|
|
234
|
+
- `rawReturnForTest` - - whether to return raw FFW for tests
|
|
232
235
|
|
|
233
|
-
Returns:
|
|
236
|
+
Returns: normalized mutation pool
|
|
234
237
|
|
|
235
|
-
###
|
|
238
|
+
### resolveFFWPolicyForSelect
|
|
236
239
|
|
|
237
240
|
```ts
|
|
238
|
-
|
|
239
|
-
pool: MutationMethod[],
|
|
240
|
-
fallbackMethod: MutationMethod,
|
|
241
|
+
resolveFFWPolicyForSelect(
|
|
241
242
|
internal: NeatControllerForMutation,
|
|
242
|
-
|
|
243
|
+
methods: { mutation: unknown; },
|
|
244
|
+
rawReturnForTest: boolean,
|
|
245
|
+
): MutationMethod | MutationMethod[] | null
|
|
243
246
|
```
|
|
244
247
|
|
|
245
|
-
|
|
248
|
+
Resolve legacy FFW policy behavior, including test-specific returns.
|
|
246
249
|
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
250
|
+
Older feed-forward configuration paths can encode mutation policy in shapes
|
|
251
|
+
that do not look like the newer flat operator pool. This helper isolates that
|
|
252
|
+
compatibility layer so the rest of selection can operate on a predictable
|
|
253
|
+
surface.
|
|
251
254
|
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
mutation policy configuration and online operator learning.
|
|
255
|
+
The `rawReturnForTest` flag exists because some tests assert the preserved
|
|
256
|
+
legacy pool shape rather than one sampled method. Production mutation flow,
|
|
257
|
+
by contrast, normally wants one concrete operator.
|
|
256
258
|
|
|
257
259
|
Parameters:
|
|
258
|
-
- `pool` - - operator pool
|
|
259
|
-
- `fallbackMethod` - - method used when bandit is disabled
|
|
260
260
|
- `internal` - - neat controller context
|
|
261
|
+
- `methods` - - methods module
|
|
262
|
+
- `rawReturnForTest` - - whether to return raw FFW array for tests
|
|
261
263
|
|
|
262
|
-
Returns:
|
|
264
|
+
Returns: mutation method or null when not handled
|
|
263
265
|
|
|
264
|
-
###
|
|
266
|
+
### sampleFromPoolForSelect
|
|
265
267
|
|
|
266
268
|
```ts
|
|
267
|
-
|
|
268
|
-
|
|
269
|
+
sampleFromPoolForSelect(
|
|
270
|
+
pool: MutationMethod[],
|
|
269
271
|
internal: NeatControllerForMutation,
|
|
270
|
-
|
|
271
|
-
): boolean
|
|
272
|
+
): MutationMethod | null
|
|
272
273
|
```
|
|
273
274
|
|
|
274
|
-
|
|
275
|
+
Sample a random method from the pool.
|
|
275
276
|
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
277
|
+
This is the uncomplicated fallback selector. It is useful both for direct
|
|
278
|
+
legacy sampling paths and for each configuration that wants weighted random
|
|
279
|
+
choice without the stronger opinion of the operator bandit.
|
|
279
280
|
|
|
280
281
|
Parameters:
|
|
281
|
-
- `
|
|
282
|
+
- `pool` - - operator pool
|
|
282
283
|
- `internal` - - neat controller context
|
|
283
|
-
- `methods` - - methods module
|
|
284
284
|
|
|
285
|
-
Returns:
|
|
285
|
+
Returns: sampled method or null
|
|
@@ -37,6 +37,15 @@ flowchart TD
|
|
|
37
37
|
|
|
38
38
|
## neat/mutation/shared/mutation.types.ts
|
|
39
39
|
|
|
40
|
+
### ConnectionWithMetadata
|
|
41
|
+
|
|
42
|
+
Runtime interface for a connection within a genome.
|
|
43
|
+
|
|
44
|
+
This is the minimum edge metadata required by the structural mutation paths.
|
|
45
|
+
The add-node and add-conn chapters use it to preserve weights, inspect edge
|
|
46
|
+
activation, and attach innovation ids that later support alignment-based
|
|
47
|
+
crossover and speciation.
|
|
48
|
+
|
|
40
49
|
### GenomeWithMetadata
|
|
41
50
|
|
|
42
51
|
Runtime interface for a genome with mutation-related metadata.
|
|
@@ -51,24 +60,6 @@ state such as `_mutRate` and `_mutAmount` travels with the genome itself,
|
|
|
51
60
|
while global innovation tables and policy controls stay on the controller
|
|
52
61
|
host contract.
|
|
53
62
|
|
|
54
|
-
### NodeWithMetadata
|
|
55
|
-
|
|
56
|
-
Runtime interface for a node within a genome.
|
|
57
|
-
|
|
58
|
-
Mutation helpers only need a narrow node view: topology category, optional
|
|
59
|
-
gene identity, adjacency lists, and one projection check. That narrowness is
|
|
60
|
-
what lets the structural chapters reason about connection growth and cycle
|
|
61
|
-
checks without depending on the whole node implementation.
|
|
62
|
-
|
|
63
|
-
### ConnectionWithMetadata
|
|
64
|
-
|
|
65
|
-
Runtime interface for a connection within a genome.
|
|
66
|
-
|
|
67
|
-
This is the minimum edge metadata required by the structural mutation paths.
|
|
68
|
-
The add-node and add-conn chapters use it to preserve weights, inspect edge
|
|
69
|
-
activation, and attach innovation ids that later support alignment-based
|
|
70
|
-
crossover and speciation.
|
|
71
|
-
|
|
72
63
|
### MutationMethod
|
|
73
64
|
|
|
74
65
|
Runtime interface for a mutation method descriptor.
|
|
@@ -78,14 +69,17 @@ as enum literals alone. That gives selection helpers room to reason about
|
|
|
78
69
|
operator families, sample-count hints, and output-mutation behavior without
|
|
79
70
|
having to know the concrete implementation of each operator.
|
|
80
71
|
|
|
81
|
-
###
|
|
72
|
+
### NeatControllerForMutation
|
|
82
73
|
|
|
83
|
-
Runtime interface for
|
|
74
|
+
Runtime interface for the NEAT controller used in mutation operations.
|
|
84
75
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
76
|
+
This host contract is the bridge between local genome edits and global NEAT
|
|
77
|
+
state. It exposes configuration, RNG access, innovation stores, operator
|
|
78
|
+
statistics, and the narrow controller callbacks that the mutation helpers need.
|
|
79
|
+
|
|
80
|
+
The important boundary is that mutation chapters can mutate controller-owned
|
|
81
|
+
bookkeeping through this interface, but they do not need the entire `Neat`
|
|
82
|
+
class surface to do their work.
|
|
89
83
|
|
|
90
84
|
### NodeSplitRecord
|
|
91
85
|
|
|
@@ -96,14 +90,20 @@ A node-split record is the durable memory that tells the add-node path,
|
|
|
96
90
|
paired edge innovations is how separate genomes can independently perform the
|
|
97
91
|
same split and still remain historically alignable.
|
|
98
92
|
|
|
99
|
-
###
|
|
93
|
+
### NodeWithMetadata
|
|
100
94
|
|
|
101
|
-
Runtime interface for
|
|
95
|
+
Runtime interface for a node within a genome.
|
|
102
96
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
97
|
+
Mutation helpers only need a narrow node view: topology category, optional
|
|
98
|
+
gene identity, adjacency lists, and one projection check. That narrowness is
|
|
99
|
+
what lets the structural chapters reason about connection growth and cycle
|
|
100
|
+
checks without depending on the whole node implementation.
|
|
106
101
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
102
|
+
### OperatorStats
|
|
103
|
+
|
|
104
|
+
Runtime interface for operator statistics tracking.
|
|
105
|
+
|
|
106
|
+
These counters support the adaptive side of mutation policy. They do not try
|
|
107
|
+
to capture full fitness impact; instead they record a cheap local proxy for
|
|
108
|
+
whether an attempted operator actually produced structure often enough to be
|
|
109
|
+
favored later by adaptation or bandit logic.
|
|
@@ -81,6 +81,31 @@ const objectives = neat._getObjectives();
|
|
|
81
81
|
console.log(objectives.map((objective) => objective.key));
|
|
82
82
|
```
|
|
83
83
|
|
|
84
|
+
### clearObjectives
|
|
85
|
+
|
|
86
|
+
```ts
|
|
87
|
+
clearObjectives(): void
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Clear all registered multi-objectives.
|
|
91
|
+
|
|
92
|
+
Use this when a run should fall back to its default objective behavior or
|
|
93
|
+
when a test needs a clean objective slate before registering a new set. This
|
|
94
|
+
clears the user-defined objective layer and invalidates the cached resolved
|
|
95
|
+
list so the next read rebuilds it from the remaining controller defaults.
|
|
96
|
+
|
|
97
|
+
Parameters:
|
|
98
|
+
- `this` - - NEAT host exposing multi-objective options and the cached objective list.
|
|
99
|
+
|
|
100
|
+
Returns: Nothing. Registered user objectives and the cached objective list are cleared.
|
|
101
|
+
|
|
102
|
+
Example:
|
|
103
|
+
|
|
104
|
+
```ts
|
|
105
|
+
neat.clearObjectives();
|
|
106
|
+
const objectives = neat._getObjectives();
|
|
107
|
+
```
|
|
108
|
+
|
|
84
109
|
### registerObjective
|
|
85
110
|
|
|
86
111
|
```ts
|
|
@@ -115,28 +140,3 @@ Example:
|
|
|
115
140
|
```ts
|
|
116
141
|
neat.registerObjective('energy', 'min', (genome) => genome.cost ?? 0);
|
|
117
142
|
```
|
|
118
|
-
|
|
119
|
-
### clearObjectives
|
|
120
|
-
|
|
121
|
-
```ts
|
|
122
|
-
clearObjectives(): void
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
Clear all registered multi-objectives.
|
|
126
|
-
|
|
127
|
-
Use this when a run should fall back to its default objective behavior or
|
|
128
|
-
when a test needs a clean objective slate before registering a new set. This
|
|
129
|
-
clears the user-defined objective layer and invalidates the cached resolved
|
|
130
|
-
list so the next read rebuilds it from the remaining controller defaults.
|
|
131
|
-
|
|
132
|
-
Parameters:
|
|
133
|
-
- `this` - - NEAT host exposing multi-objective options and the cached objective list.
|
|
134
|
-
|
|
135
|
-
Returns: Nothing. Registered user objectives and the cached objective list are cleared.
|
|
136
|
-
|
|
137
|
-
Example:
|
|
138
|
-
|
|
139
|
-
```ts
|
|
140
|
-
neat.clearObjectives();
|
|
141
|
-
const objectives = neat._getObjectives();
|
|
142
|
-
```
|
|
@@ -84,6 +84,25 @@ must exist by default, middle helpers gather and validate user intent, and
|
|
|
84
84
|
later helpers hydrate missing containers or replace one objective without
|
|
85
85
|
mutating an older list in place.
|
|
86
86
|
|
|
87
|
+
### buildDefaultFitnessObjective
|
|
88
|
+
|
|
89
|
+
```ts
|
|
90
|
+
buildDefaultFitnessObjective(): ObjectiveDescriptor
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Build the default fitness objective descriptor.
|
|
94
|
+
|
|
95
|
+
The default fitness objective is the anchor that keeps ordinary NEAT runs
|
|
96
|
+
meaningful even when no richer objective policy has been configured yet.
|
|
97
|
+
Core resolution builds it on demand so callers do not need a special
|
|
98
|
+
bootstrap path elsewhere.
|
|
99
|
+
|
|
100
|
+
Keeping this builder separate from the collection logic also makes the core
|
|
101
|
+
flow easier to teach: one helper decides *whether* the default should exist,
|
|
102
|
+
this helper decides *what* that default descriptor looks like.
|
|
103
|
+
|
|
104
|
+
Returns: Default fitness objective descriptor.
|
|
105
|
+
|
|
87
106
|
### collectDefaultObjectives
|
|
88
107
|
|
|
89
108
|
```ts
|
|
@@ -130,46 +149,49 @@ Parameters:
|
|
|
130
149
|
|
|
131
150
|
Returns: Valid user objective descriptors.
|
|
132
151
|
|
|
133
|
-
###
|
|
152
|
+
### ensureMultiObjectiveOptions
|
|
134
153
|
|
|
135
154
|
```ts
|
|
136
|
-
|
|
155
|
+
ensureMultiObjectiveOptions(
|
|
156
|
+
neatInstance: NeatLikeWithObjectives,
|
|
157
|
+
): { enabled?: boolean | undefined; objectives?: ObjectiveDescriptor[] | undefined; }
|
|
137
158
|
```
|
|
138
159
|
|
|
139
|
-
|
|
160
|
+
Ensure the multi-objective options container exists.
|
|
140
161
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
bootstrap path elsewhere.
|
|
162
|
+
Objective registration and resolution are allowed to hydrate this container
|
|
163
|
+
lazily so controller construction does not need to eagerly materialize every
|
|
164
|
+
optional configuration branch.
|
|
145
165
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
166
|
+
This is one of the small helpers that keeps the core chapter mutation-safe:
|
|
167
|
+
later logic can assume the container exists without scattering defensive
|
|
168
|
+
object creation throughout the file.
|
|
149
169
|
|
|
150
|
-
|
|
170
|
+
Parameters:
|
|
171
|
+
- `neatInstance` - - NEAT host receiving the multi-objective container.
|
|
151
172
|
|
|
152
|
-
|
|
173
|
+
Returns: Initialized multi-objective options.
|
|
174
|
+
|
|
175
|
+
### ensureObjectivesList
|
|
153
176
|
|
|
154
177
|
```ts
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
):
|
|
178
|
+
ensureObjectivesList(
|
|
179
|
+
multiObjectiveOptions: { enabled?: boolean | undefined; objectives?: ObjectiveDescriptor[] | undefined; },
|
|
180
|
+
): ObjectiveDescriptor[]
|
|
158
181
|
```
|
|
159
182
|
|
|
160
|
-
|
|
183
|
+
Ensure the objectives list exists on the multi-objective container.
|
|
161
184
|
|
|
162
|
-
This
|
|
163
|
-
|
|
164
|
-
can avoid reasoning about half-hydrated state.
|
|
185
|
+
This helper complements container hydration by guaranteeing a writable list
|
|
186
|
+
surface for later non-destructive replacement logic.
|
|
165
187
|
|
|
166
|
-
|
|
167
|
-
|
|
188
|
+
It exists so registration code can talk about replacing objectives by key
|
|
189
|
+
instead of repeatedly guarding against `undefined` lists.
|
|
168
190
|
|
|
169
191
|
Parameters:
|
|
170
|
-
- `
|
|
192
|
+
- `multiObjectiveOptions` - - Multi-objective container to hydrate.
|
|
171
193
|
|
|
172
|
-
Returns:
|
|
194
|
+
Returns: Objectives list ready for non-destructive operations.
|
|
173
195
|
|
|
174
196
|
### getObjectiveCandidates
|
|
175
197
|
|
|
@@ -191,6 +213,28 @@ Parameters:
|
|
|
191
213
|
|
|
192
214
|
Returns: Objective candidates from configuration.
|
|
193
215
|
|
|
216
|
+
### isMultiObjectiveEnabled
|
|
217
|
+
|
|
218
|
+
```ts
|
|
219
|
+
isMultiObjectiveEnabled(
|
|
220
|
+
neatInstance: NeatLikeWithObjectives,
|
|
221
|
+
): boolean
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
Check whether multi-objective mode is enabled with a candidate list.
|
|
225
|
+
|
|
226
|
+
This guard is intentionally strict: enabling multi-objective mode without an
|
|
227
|
+
objective array is treated as incomplete configuration, so downstream helpers
|
|
228
|
+
can avoid reasoning about half-hydrated state.
|
|
229
|
+
|
|
230
|
+
That strictness keeps later helpers simpler because they can assume that a
|
|
231
|
+
`true` result means both the mode and the candidate container are present.
|
|
232
|
+
|
|
233
|
+
Parameters:
|
|
234
|
+
- `neatInstance` - - NEAT host exposing objective settings.
|
|
235
|
+
|
|
236
|
+
Returns: `true` when multi-objective mode is enabled and an objective list exists.
|
|
237
|
+
|
|
194
238
|
### isValidObjective
|
|
195
239
|
|
|
196
240
|
```ts
|
|
@@ -214,50 +258,6 @@ Parameters:
|
|
|
214
258
|
|
|
215
259
|
Returns: `true` when the descriptor can be used safely.
|
|
216
260
|
|
|
217
|
-
### ensureMultiObjectiveOptions
|
|
218
|
-
|
|
219
|
-
```ts
|
|
220
|
-
ensureMultiObjectiveOptions(
|
|
221
|
-
neatInstance: NeatLikeWithObjectives,
|
|
222
|
-
): { enabled?: boolean | undefined; objectives?: ObjectiveDescriptor[] | undefined; }
|
|
223
|
-
```
|
|
224
|
-
|
|
225
|
-
Ensure the multi-objective options container exists.
|
|
226
|
-
|
|
227
|
-
Objective registration and resolution are allowed to hydrate this container
|
|
228
|
-
lazily so controller construction does not need to eagerly materialize every
|
|
229
|
-
optional configuration branch.
|
|
230
|
-
|
|
231
|
-
This is one of the small helpers that keeps the core chapter mutation-safe:
|
|
232
|
-
later logic can assume the container exists without scattering defensive
|
|
233
|
-
object creation throughout the file.
|
|
234
|
-
|
|
235
|
-
Parameters:
|
|
236
|
-
- `neatInstance` - - NEAT host receiving the multi-objective container.
|
|
237
|
-
|
|
238
|
-
Returns: Initialized multi-objective options.
|
|
239
|
-
|
|
240
|
-
### ensureObjectivesList
|
|
241
|
-
|
|
242
|
-
```ts
|
|
243
|
-
ensureObjectivesList(
|
|
244
|
-
multiObjectiveOptions: { enabled?: boolean | undefined; objectives?: ObjectiveDescriptor[] | undefined; },
|
|
245
|
-
): ObjectiveDescriptor[]
|
|
246
|
-
```
|
|
247
|
-
|
|
248
|
-
Ensure the objectives list exists on the multi-objective container.
|
|
249
|
-
|
|
250
|
-
This helper complements container hydration by guaranteeing a writable list
|
|
251
|
-
surface for later non-destructive replacement logic.
|
|
252
|
-
|
|
253
|
-
It exists so registration code can talk about replacing objectives by key
|
|
254
|
-
instead of repeatedly guarding against `undefined` lists.
|
|
255
|
-
|
|
256
|
-
Parameters:
|
|
257
|
-
- `multiObjectiveOptions` - - Multi-objective container to hydrate.
|
|
258
|
-
|
|
259
|
-
Returns: Objectives list ready for non-destructive operations.
|
|
260
|
-
|
|
261
261
|
### replaceObjectiveByKey
|
|
262
262
|
|
|
263
263
|
```ts
|