@reicek/neataptic-ts 0.1.24 → 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/.github/workflows/ci.yml +3 -3
- package/.github/workflows/deploy-pages.yml +6 -6
- package/.github/workflows/manual_release_pipeline.yml +3 -3
- package/.github/workflows/publish.yml +18 -19
- package/.github/workflows/release_dispatch.yml +3 -3
- package/package.json +26 -20
- 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
|
@@ -48,264 +48,265 @@ flowchart TD
|
|
|
48
48
|
|
|
49
49
|
## neat/mutation/flow/mutation.flow.ts
|
|
50
50
|
|
|
51
|
-
###
|
|
51
|
+
### applyAddConnMutation
|
|
52
52
|
|
|
53
53
|
```ts
|
|
54
|
-
|
|
54
|
+
applyAddConnMutation(
|
|
55
55
|
genome: GenomeWithMetadata,
|
|
56
56
|
internal: NeatControllerForMutation,
|
|
57
57
|
methods: { mutation: unknown; },
|
|
58
|
-
):
|
|
58
|
+
): void
|
|
59
59
|
```
|
|
60
60
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
This is the orchestration entry point for the `flow/` chapter. It keeps the
|
|
64
|
-
per-genome lifecycle linear: adaptive settings are prepared first, then one
|
|
65
|
-
probability gate decides whether work happens at all, and only then does the
|
|
66
|
-
helper loop ask `select/` for concrete operators.
|
|
67
|
-
|
|
68
|
-
The important design choice is that mutation amount is resolved after the
|
|
69
|
-
mutate-or-skip gate passes. That keeps genomes with low effective rates from
|
|
70
|
-
paying the full operator-selection cost every generation while still letting
|
|
71
|
-
successful genomes perform multiple edits once they have been admitted into
|
|
72
|
-
the flow.
|
|
61
|
+
Apply an ADD_CONN mutation with reuse and weight nudging.
|
|
73
62
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
of merely consuming attempts.
|
|
63
|
+
This is the connection-growth companion to `applyAddNodeMutation()`. The
|
|
64
|
+
structural edit itself is delegated to the reuse-aware connection helper so
|
|
65
|
+
identical edge discoveries can still share innovation identity across the
|
|
66
|
+
population.
|
|
79
67
|
|
|
80
68
|
Parameters:
|
|
81
69
|
- `genome` - - genome to mutate
|
|
82
70
|
- `internal` - - neat controller context
|
|
83
71
|
- `methods` - - mutation methods module
|
|
84
72
|
|
|
85
|
-
Returns:
|
|
73
|
+
Returns: void
|
|
86
74
|
|
|
87
|
-
###
|
|
75
|
+
### applyAddNodeMutation
|
|
88
76
|
|
|
89
77
|
```ts
|
|
90
|
-
|
|
78
|
+
applyAddNodeMutation(
|
|
91
79
|
genome: GenomeWithMetadata,
|
|
92
80
|
internal: NeatControllerForMutation,
|
|
81
|
+
methods: { mutation: unknown; },
|
|
93
82
|
): void
|
|
94
83
|
```
|
|
95
84
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
Adaptive mutation is stateful at the genome level, not just a controller
|
|
99
|
-
default. This helper assigns the first persistent rate and optional amount so
|
|
100
|
-
later generations can treat the genome as carrying its own mutation budget.
|
|
85
|
+
Apply an ADD_NODE mutation with reuse and weight nudging.
|
|
101
86
|
|
|
102
|
-
The
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
87
|
+
The add-node path is special because it needs both innovation-aware
|
|
88
|
+
structural growth and a post-split weight nudge that makes the topology
|
|
89
|
+
change observable immediately in downstream behavior and tests. The helper
|
|
90
|
+
intentionally treats cache invalidation as part of the operation rather than
|
|
91
|
+
leaving it to callers.
|
|
106
92
|
|
|
107
93
|
Parameters:
|
|
108
|
-
- `genome` - - genome to
|
|
94
|
+
- `genome` - - genome to mutate
|
|
109
95
|
- `internal` - - neat controller context
|
|
96
|
+
- `methods` - - mutation methods module
|
|
110
97
|
|
|
111
98
|
Returns: void
|
|
112
99
|
|
|
113
|
-
###
|
|
100
|
+
### applyMutationOperator
|
|
114
101
|
|
|
115
102
|
```ts
|
|
116
|
-
|
|
103
|
+
applyMutationOperator(
|
|
117
104
|
genome: GenomeWithMetadata,
|
|
105
|
+
mutationMethod: MutationMethod,
|
|
118
106
|
internal: NeatControllerForMutation,
|
|
119
|
-
|
|
107
|
+
methods: { mutation: unknown; },
|
|
108
|
+
): void
|
|
120
109
|
```
|
|
121
110
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
This helper explains the precedence order for rate policy:
|
|
111
|
+
Apply a mutation operator to a genome and invalidate caches as needed.
|
|
125
112
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
113
|
+
This helper is the dispatch hinge between policy and topology. Structural
|
|
114
|
+
growth operators such as `ADD_NODE` and `ADD_CONN` are routed through the
|
|
115
|
+
innovation-reuse helpers because the controller cares about more than local
|
|
116
|
+
graph edits; it also needs stable innovation history for later crossover and
|
|
117
|
+
speciation.
|
|
130
118
|
|
|
131
|
-
|
|
132
|
-
|
|
119
|
+
Non-structural operators stay delegated to the genome's own `mutate()`
|
|
120
|
+
implementation. Cache invalidation is then handled separately so the flow can
|
|
121
|
+
keep the expensive cleanup targeted to methods that plausibly changed the
|
|
122
|
+
structural view of the genome.
|
|
133
123
|
|
|
134
124
|
Parameters:
|
|
135
|
-
- `genome` - - genome to
|
|
125
|
+
- `genome` - - genome to mutate
|
|
126
|
+
- `mutationMethod` - - mutation operator to apply
|
|
136
127
|
- `internal` - - neat controller context
|
|
128
|
+
- `methods` - - mutation methods module
|
|
137
129
|
|
|
138
|
-
Returns:
|
|
130
|
+
Returns: void
|
|
139
131
|
|
|
140
|
-
###
|
|
132
|
+
### captureStructuralSizes
|
|
141
133
|
|
|
142
134
|
```ts
|
|
143
|
-
|
|
135
|
+
captureStructuralSizes(
|
|
144
136
|
genome: GenomeWithMetadata,
|
|
145
|
-
|
|
146
|
-
): number
|
|
137
|
+
): { beforeNodes: number; beforeConns: number; }
|
|
147
138
|
```
|
|
148
139
|
|
|
149
|
-
|
|
140
|
+
Capture structural sizes used to evaluate operator success.
|
|
150
141
|
|
|
151
|
-
|
|
152
|
-
whether
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
amount stays authoritative.
|
|
142
|
+
Operator adaptation in this subtree is intentionally coarse-grained: it asks
|
|
143
|
+
whether an attempted mutation increased structural size, not whether the
|
|
144
|
+
resulting genome later scored better. This helper records the pre-mutation
|
|
145
|
+
node and connection counts that make that local success signal possible.
|
|
156
146
|
|
|
157
147
|
Parameters:
|
|
158
|
-
- `genome` - - genome to
|
|
159
|
-
- `internal` - - neat controller context
|
|
148
|
+
- `genome` - - genome to inspect
|
|
160
149
|
|
|
161
|
-
Returns:
|
|
150
|
+
Returns: structural size snapshot
|
|
162
151
|
|
|
163
|
-
###
|
|
152
|
+
### initializeAdaptiveMutation
|
|
164
153
|
|
|
165
154
|
```ts
|
|
166
|
-
|
|
167
|
-
|
|
155
|
+
initializeAdaptiveMutation(
|
|
156
|
+
genome: GenomeWithMetadata,
|
|
168
157
|
internal: NeatControllerForMutation,
|
|
169
|
-
):
|
|
158
|
+
): void
|
|
170
159
|
```
|
|
171
160
|
|
|
172
|
-
|
|
161
|
+
Initialize per-genome adaptive mutation parameters if configured.
|
|
173
162
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
163
|
+
Adaptive mutation is stateful at the genome level, not just a controller
|
|
164
|
+
default. This helper assigns the first persistent rate and optional amount so
|
|
165
|
+
later generations can treat the genome as carrying its own mutation budget.
|
|
166
|
+
|
|
167
|
+
The helper only writes when the genome has not yet been initialized. That is
|
|
168
|
+
why it runs at the top of `mutateGenome()` on every pass: it behaves like a
|
|
169
|
+
cheap bootstrap check rather than a repeated reset of evolved mutation
|
|
170
|
+
behavior.
|
|
177
171
|
|
|
178
172
|
Parameters:
|
|
179
|
-
- `
|
|
173
|
+
- `genome` - - genome to initialize
|
|
180
174
|
- `internal` - - neat controller context
|
|
181
175
|
|
|
182
|
-
Returns:
|
|
176
|
+
Returns: void
|
|
183
177
|
|
|
184
|
-
###
|
|
178
|
+
### maybeAddExtraConnection
|
|
185
179
|
|
|
186
180
|
```ts
|
|
187
|
-
|
|
181
|
+
maybeAddExtraConnection(
|
|
188
182
|
genome: GenomeWithMetadata,
|
|
189
183
|
internal: NeatControllerForMutation,
|
|
190
|
-
):
|
|
184
|
+
): void
|
|
191
185
|
```
|
|
192
186
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
The selection boundary may already return one final operator, or it may
|
|
196
|
-
return a legacy array-like pool for backward-compatible paths. This helper is
|
|
197
|
-
the bridge between that policy layer and the execution layer in `flow/`: it
|
|
198
|
-
guarantees the rest of the loop sees either one concrete operator or `null`.
|
|
187
|
+
Optionally add an extra connection to increase exploration.
|
|
199
188
|
|
|
200
|
-
|
|
201
|
-
|
|
189
|
+
This small post-operator hook gives the controller one extra chance to add
|
|
190
|
+
connectivity after the main mutation has landed. It is intentionally
|
|
191
|
+
probabilistic and lightweight: the flow uses it as a gentle exploration bump,
|
|
192
|
+
not as a second full operator-selection phase.
|
|
202
193
|
|
|
203
194
|
Parameters:
|
|
204
|
-
- `genome` - - genome to
|
|
195
|
+
- `genome` - - genome to mutate
|
|
205
196
|
- `internal` - - neat controller context
|
|
206
197
|
|
|
207
|
-
Returns:
|
|
198
|
+
Returns: void
|
|
208
199
|
|
|
209
|
-
###
|
|
200
|
+
### mutateGenome
|
|
210
201
|
|
|
211
202
|
```ts
|
|
212
|
-
|
|
203
|
+
mutateGenome(
|
|
213
204
|
genome: GenomeWithMetadata,
|
|
214
|
-
|
|
205
|
+
internal: NeatControllerForMutation,
|
|
206
|
+
methods: { mutation: unknown; },
|
|
207
|
+
): Promise<void>
|
|
215
208
|
```
|
|
216
209
|
|
|
217
|
-
|
|
210
|
+
Mutate a single genome based on configured mutation policies.
|
|
218
211
|
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
212
|
+
This is the orchestration entry point for the `flow/` chapter. It keeps the
|
|
213
|
+
per-genome lifecycle linear: adaptive settings are prepared first, then one
|
|
214
|
+
probability gate decides whether work happens at all, and only then does the
|
|
215
|
+
helper loop ask `select/` for concrete operators.
|
|
216
|
+
|
|
217
|
+
The important design choice is that mutation amount is resolved after the
|
|
218
|
+
mutate-or-skip gate passes. That keeps genomes with low effective rates from
|
|
219
|
+
paying the full operator-selection cost every generation while still letting
|
|
220
|
+
successful genomes perform multiple edits once they have been admitted into
|
|
221
|
+
the flow.
|
|
222
|
+
|
|
223
|
+
Each loop iteration captures a before-snapshot, applies one operator,
|
|
224
|
+
performs an extra exploration edge when configured, and finally records whether the genome
|
|
225
|
+
actually grew. That final feedback is what later allows operator adaptation
|
|
226
|
+
and bandit-style policies to reward operators that change structure instead
|
|
227
|
+
of merely consuming attempts.
|
|
223
228
|
|
|
224
229
|
Parameters:
|
|
225
|
-
- `genome` - - genome to
|
|
230
|
+
- `genome` - - genome to mutate
|
|
231
|
+
- `internal` - - neat controller context
|
|
232
|
+
- `methods` - - mutation methods module
|
|
226
233
|
|
|
227
|
-
Returns:
|
|
234
|
+
Returns: Promise resolving after mutation attempts complete
|
|
228
235
|
|
|
229
|
-
###
|
|
236
|
+
### resolveEffectiveAmount
|
|
230
237
|
|
|
231
238
|
```ts
|
|
232
|
-
|
|
239
|
+
resolveEffectiveAmount(
|
|
233
240
|
genome: GenomeWithMetadata,
|
|
234
|
-
mutationMethod: MutationMethod,
|
|
235
241
|
internal: NeatControllerForMutation,
|
|
236
|
-
|
|
237
|
-
): void
|
|
242
|
+
): number
|
|
238
243
|
```
|
|
239
244
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
This helper is the dispatch hinge between policy and topology. Structural
|
|
243
|
-
growth operators such as `ADD_NODE` and `ADD_CONN` are routed through the
|
|
244
|
-
innovation-reuse helpers because the controller cares about more than local
|
|
245
|
-
graph edits; it also needs stable innovation history for later crossover and
|
|
246
|
-
speciation.
|
|
245
|
+
Resolve the effective mutation amount for a genome.
|
|
247
246
|
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
247
|
+
Mutation amount answers a different question from mutation rate. Rate decides
|
|
248
|
+
whether the genome enters the flow. Amount decides how many operator draws it
|
|
249
|
+
receives once admitted. When adaptive mutation amount is enabled, the genome
|
|
250
|
+
may carry its own evolving attempt budget; otherwise the controller-wide
|
|
251
|
+
amount stays authoritative.
|
|
252
252
|
|
|
253
253
|
Parameters:
|
|
254
|
-
- `genome` - - genome to
|
|
255
|
-
- `mutationMethod` - - mutation operator to apply
|
|
254
|
+
- `genome` - - genome to resolve for
|
|
256
255
|
- `internal` - - neat controller context
|
|
257
|
-
- `methods` - - mutation methods module
|
|
258
256
|
|
|
259
|
-
Returns:
|
|
257
|
+
Returns: effective mutation amount
|
|
260
258
|
|
|
261
|
-
###
|
|
259
|
+
### resolveEffectiveRate
|
|
262
260
|
|
|
263
261
|
```ts
|
|
264
|
-
|
|
262
|
+
resolveEffectiveRate(
|
|
265
263
|
genome: GenomeWithMetadata,
|
|
266
264
|
internal: NeatControllerForMutation,
|
|
267
|
-
|
|
268
|
-
): void
|
|
265
|
+
): number
|
|
269
266
|
```
|
|
270
267
|
|
|
271
|
-
|
|
268
|
+
Resolve the effective mutation rate for a genome.
|
|
272
269
|
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
270
|
+
This helper explains the precedence order for rate policy:
|
|
271
|
+
|
|
272
|
+
1. an explicit controller-level `mutationRate` wins,
|
|
273
|
+
2. otherwise an adaptive per-genome `_mutRate` is used when adaptive
|
|
274
|
+
mutation is enabled,
|
|
275
|
+
3. otherwise the flow falls back to the local default.
|
|
276
|
+
|
|
277
|
+
Keeping that precedence isolated here makes the rest of the mutation flow
|
|
278
|
+
read as orchestration instead of configuration branching.
|
|
278
279
|
|
|
279
280
|
Parameters:
|
|
280
|
-
- `genome` - - genome to
|
|
281
|
+
- `genome` - - genome to resolve for
|
|
281
282
|
- `internal` - - neat controller context
|
|
282
|
-
- `methods` - - mutation methods module
|
|
283
283
|
|
|
284
|
-
Returns:
|
|
284
|
+
Returns: effective mutation rate
|
|
285
285
|
|
|
286
|
-
###
|
|
286
|
+
### selectConcreteMutationMethod
|
|
287
287
|
|
|
288
288
|
```ts
|
|
289
|
-
|
|
289
|
+
selectConcreteMutationMethod(
|
|
290
290
|
genome: GenomeWithMetadata,
|
|
291
291
|
internal: NeatControllerForMutation,
|
|
292
|
-
|
|
293
|
-
): void
|
|
292
|
+
): Promise<MutationMethod | null>
|
|
294
293
|
```
|
|
295
294
|
|
|
296
|
-
|
|
295
|
+
Select a concrete mutation method, resolving legacy arrays when present.
|
|
297
296
|
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
297
|
+
The selection boundary may already return one final operator, or it may
|
|
298
|
+
return a legacy array-like pool for backward-compatible paths. This helper is
|
|
299
|
+
the bridge between that policy layer and the execution layer in `flow/`: it
|
|
300
|
+
guarantees the rest of the loop sees either one concrete operator or `null`.
|
|
301
|
+
|
|
302
|
+
That normalization keeps `mutateGenome()` focused on lifecycle sequencing
|
|
303
|
+
rather than on legacy selection-shape quirks.
|
|
302
304
|
|
|
303
305
|
Parameters:
|
|
304
|
-
- `genome` - - genome to
|
|
306
|
+
- `genome` - - genome to select for
|
|
305
307
|
- `internal` - - neat controller context
|
|
306
|
-
- `methods` - - mutation methods module
|
|
307
308
|
|
|
308
|
-
Returns:
|
|
309
|
+
Returns: resolved mutation method or null
|
|
309
310
|
|
|
310
311
|
### shouldInvalidateCaches
|
|
311
312
|
|
|
@@ -329,27 +330,26 @@ Parameters:
|
|
|
329
330
|
|
|
330
331
|
Returns: true when caches should be invalidated
|
|
331
332
|
|
|
332
|
-
###
|
|
333
|
+
### shouldMutateGenome
|
|
333
334
|
|
|
334
335
|
```ts
|
|
335
|
-
|
|
336
|
-
|
|
336
|
+
shouldMutateGenome(
|
|
337
|
+
effectiveRate: number,
|
|
337
338
|
internal: NeatControllerForMutation,
|
|
338
|
-
):
|
|
339
|
+
): boolean
|
|
339
340
|
```
|
|
340
341
|
|
|
341
|
-
|
|
342
|
+
Decide whether a genome should be mutated based on probability.
|
|
342
343
|
|
|
343
|
-
This
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
not as a second full operator-selection phase.
|
|
344
|
+
This is the narrow admission gate for the per-genome flow. Keeping the RNG
|
|
345
|
+
comparison in one helper makes the orchestration read clearly and gives tests
|
|
346
|
+
one stable seam for deterministic gating behavior.
|
|
347
347
|
|
|
348
348
|
Parameters:
|
|
349
|
-
- `
|
|
349
|
+
- `effectiveRate` - - effective mutation probability
|
|
350
350
|
- `internal` - - neat controller context
|
|
351
351
|
|
|
352
|
-
Returns:
|
|
352
|
+
Returns: true when the genome should be mutated
|
|
353
353
|
|
|
354
354
|
### updateOperatorStatsIfNeeded
|
|
355
355
|
|