@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
|
@@ -43,49 +43,35 @@ from or why descriptor order must stay fixed.
|
|
|
43
43
|
|
|
44
44
|
## neat/multiobjective/dominance/multiobjective.dominance.ts
|
|
45
45
|
|
|
46
|
-
###
|
|
46
|
+
### applyPairwiseDominance
|
|
47
47
|
|
|
48
48
|
```ts
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
applyPairwiseDominance(
|
|
50
|
+
dominanceState: DominanceState,
|
|
51
|
+
valuesMatrixInput: number[][],
|
|
52
52
|
descriptors: ObjectiveDescriptor[],
|
|
53
|
-
|
|
53
|
+
candidateIndex: number,
|
|
54
|
+
opponentIndex: number,
|
|
55
|
+
): void
|
|
54
56
|
```
|
|
55
57
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
A dominates B iff:
|
|
59
|
-
- A is **no worse** than B in every objective (respecting each objective’s
|
|
60
|
-
direction: maximize/minimize), and
|
|
61
|
-
- A is **strictly better** in at least one objective.
|
|
58
|
+
Applies a single pairwise dominance update between candidate and opponent.
|
|
62
59
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
60
|
+
If the candidate dominates the opponent, the opponent index is appended to
|
|
61
|
+
`dominatedIndicesByIndex[candidateIndex]`. If the candidate is dominated by
|
|
62
|
+
the opponent, `dominationCounts[candidateIndex]` is incremented.
|
|
66
63
|
|
|
67
|
-
|
|
68
|
-
-
|
|
69
|
-
-
|
|
70
|
-
|
|
64
|
+
That asymmetry is the key bookkeeping contract for the later frontier peel:
|
|
65
|
+
- the count answers whether the candidate can join the current front yet,
|
|
66
|
+
- the dominated-neighbor list tells later passes which counts to relax once
|
|
67
|
+
the candidate is removed as a blocker.
|
|
71
68
|
|
|
72
69
|
Parameters:
|
|
73
|
-
- `
|
|
74
|
-
- `
|
|
75
|
-
- `descriptors` - - Objective descriptors
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
Example:
|
|
80
|
-
|
|
81
|
-
```ts
|
|
82
|
-
// Maximize accuracy, minimize latency:
|
|
83
|
-
vectorDominates([0.9, 120], [0.9, 150], [
|
|
84
|
-
{ accessor: () => 0, direction: 'max' },
|
|
85
|
-
{ accessor: () => 0, direction: 'min' },
|
|
86
|
-
]);
|
|
87
|
-
// => true (equal accuracy, lower latency)
|
|
88
|
-
```
|
|
70
|
+
- `dominanceState` - - Dominance bookkeeping.
|
|
71
|
+
- `valuesMatrixInput` - - Matrix of objective values.
|
|
72
|
+
- `descriptors` - - Objective descriptors.
|
|
73
|
+
- `candidateIndex` - - Candidate genome index.
|
|
74
|
+
- `opponentIndex` - - Opponent genome index.
|
|
89
75
|
|
|
90
76
|
### buildDominanceState
|
|
91
77
|
|
|
@@ -128,41 +114,25 @@ Parameters:
|
|
|
128
114
|
|
|
129
115
|
Returns: Dominance bookkeeping structures for ranking.
|
|
130
116
|
|
|
131
|
-
###
|
|
132
|
-
|
|
133
|
-
Dominance bookkeeping structures for fast non-dominated sorting.
|
|
134
|
-
|
|
135
|
-
These structures are typically produced once per generation (from the values
|
|
136
|
-
matrix) and then consumed to build Pareto fronts.
|
|
137
|
-
|
|
138
|
-
They form the compact handoff between pairwise comparison mechanics and the
|
|
139
|
-
later frontier-construction pass:
|
|
140
|
-
- `dominationCounts` records how many opponents currently sit above each row
|
|
141
|
-
- `dominatedIndicesByIndex` records which rows should be relaxed when a
|
|
142
|
-
front is peeled away
|
|
143
|
-
- `firstFrontIndices` captures the initial non-dominated frontier without
|
|
144
|
-
re-running the full comparison loop
|
|
145
|
-
|
|
146
|
-
### resolveObjectiveDirection
|
|
117
|
+
### buildIndexRange
|
|
147
118
|
|
|
148
119
|
```ts
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
): "max" | "min"
|
|
120
|
+
buildIndexRange(
|
|
121
|
+
populationSize: number,
|
|
122
|
+
): number[]
|
|
153
123
|
```
|
|
154
124
|
|
|
155
|
-
|
|
125
|
+
Builds a stable index range for iterating the population.
|
|
156
126
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
127
|
+
The returned range becomes the shared iteration order for candidate and
|
|
128
|
+
opponent loops. Using explicit indices instead of genome references keeps the
|
|
129
|
+
dominance state compact and guarantees later frontier code can look up rows
|
|
130
|
+
and genomes with the same integer keys.
|
|
160
131
|
|
|
161
132
|
Parameters:
|
|
162
|
-
- `
|
|
163
|
-
- `objectiveIndex` - - Objective index.
|
|
133
|
+
- `populationSize` - - Number of genomes.
|
|
164
134
|
|
|
165
|
-
Returns:
|
|
135
|
+
Returns: Array of indices `0..populationSize-1`.
|
|
166
136
|
|
|
167
137
|
### compareObjectiveValues
|
|
168
138
|
|
|
@@ -190,6 +160,40 @@ Parameters:
|
|
|
190
160
|
|
|
191
161
|
Returns: Comparison flags for this objective.
|
|
192
162
|
|
|
163
|
+
### createEmptyDominanceState
|
|
164
|
+
|
|
165
|
+
```ts
|
|
166
|
+
createEmptyDominanceState(
|
|
167
|
+
populationSize: number,
|
|
168
|
+
): DominanceState
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
Creates an empty dominance state container sized to the population.
|
|
172
|
+
|
|
173
|
+
Every array slot maps directly to one matrix row and therefore one genome in
|
|
174
|
+
the ranking pass. Initializing the structure once keeps later comparison
|
|
175
|
+
helpers focused on bookkeeping updates rather than allocation details.
|
|
176
|
+
|
|
177
|
+
Parameters:
|
|
178
|
+
- `populationSize` - - Number of genomes.
|
|
179
|
+
|
|
180
|
+
Returns: An initialized dominance state with zeroed counts.
|
|
181
|
+
|
|
182
|
+
### DominanceState
|
|
183
|
+
|
|
184
|
+
Dominance bookkeeping structures for fast non-dominated sorting.
|
|
185
|
+
|
|
186
|
+
These structures are typically produced once per generation (from the values
|
|
187
|
+
matrix) and then consumed to build Pareto fronts.
|
|
188
|
+
|
|
189
|
+
They form the compact handoff between pairwise comparison mechanics and the
|
|
190
|
+
later frontier-construction pass:
|
|
191
|
+
- `dominationCounts` records how many opponents currently sit above each row
|
|
192
|
+
- `dominatedIndicesByIndex` records which rows should be relaxed when a
|
|
193
|
+
front is peeled away
|
|
194
|
+
- `firstFrontIndices` captures the initial non-dominated frontier without
|
|
195
|
+
re-running the full comparison loop
|
|
196
|
+
|
|
193
197
|
### isCandidateDominatedByObjective
|
|
194
198
|
|
|
195
199
|
```ts
|
|
@@ -235,192 +239,188 @@ Parameters:
|
|
|
235
239
|
|
|
236
240
|
Returns: `true` if the candidate is strictly better for this objective.
|
|
237
241
|
|
|
238
|
-
###
|
|
242
|
+
### isNonDominatedCandidate
|
|
239
243
|
|
|
240
244
|
```ts
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
245
|
+
isNonDominatedCandidate(
|
|
246
|
+
dominanceState: DominanceState,
|
|
247
|
+
candidateIndex: number,
|
|
244
248
|
): boolean
|
|
245
249
|
```
|
|
246
250
|
|
|
247
|
-
|
|
248
|
-
|
|
251
|
+
Determines whether a candidate has zero domination count.
|
|
252
|
+
|
|
253
|
+
A zero count means the current row survived every pairwise comparison without
|
|
254
|
+
finding a dominating opponent, which is exactly the criterion for first-front
|
|
255
|
+
membership before frontier peeling begins.
|
|
249
256
|
|
|
250
257
|
Parameters:
|
|
251
|
-
- `
|
|
252
|
-
- `
|
|
253
|
-
current objective.
|
|
258
|
+
- `dominanceState` - - Dominance bookkeeping.
|
|
259
|
+
- `candidateIndex` - - Candidate genome index.
|
|
254
260
|
|
|
255
|
-
Returns:
|
|
261
|
+
Returns: `true` if the candidate is currently non-dominated.
|
|
256
262
|
|
|
257
|
-
###
|
|
263
|
+
### resolveDominanceOutcome
|
|
258
264
|
|
|
259
265
|
```ts
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
266
|
+
resolveDominanceOutcome(
|
|
267
|
+
candidateVector: number[],
|
|
268
|
+
opponentVector: number[],
|
|
269
|
+
descriptors: ObjectiveDescriptor[],
|
|
270
|
+
): "dominates" | "dominated" | "indifferent"
|
|
263
271
|
```
|
|
264
272
|
|
|
265
|
-
|
|
273
|
+
Resolves dominance outcome between two objective vectors.
|
|
266
274
|
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
275
|
+
Outcome meanings:
|
|
276
|
+
- `'dominates'`: candidate dominates opponent.
|
|
277
|
+
- `'dominated'`: candidate is dominated by opponent.
|
|
278
|
+
- `'indifferent'`: neither dominates the other.
|
|
279
|
+
|
|
280
|
+
Pareto dominance is directional, so this helper checks both directions in a
|
|
281
|
+
fixed order. That keeps ties and tradeoffs explicit: many pairs in a
|
|
282
|
+
multi-objective population are intentionally incomparable rather than simply
|
|
283
|
+
"better" or "worse."
|
|
270
284
|
|
|
271
285
|
Parameters:
|
|
272
|
-
- `
|
|
286
|
+
- `candidateVector` - - Candidate objective values.
|
|
287
|
+
- `opponentVector` - - Opponent objective values.
|
|
288
|
+
- `descriptors` - - Objective descriptors.
|
|
273
289
|
|
|
274
|
-
Returns:
|
|
290
|
+
Returns: Dominance outcome between candidate and opponent.
|
|
275
291
|
|
|
276
|
-
###
|
|
292
|
+
### resolveObjectiveDirection
|
|
277
293
|
|
|
278
294
|
```ts
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
295
|
+
resolveObjectiveDirection(
|
|
296
|
+
descriptors: ObjectiveDescriptor[],
|
|
297
|
+
objectiveIndex: number,
|
|
298
|
+
): "max" | "min"
|
|
282
299
|
```
|
|
283
300
|
|
|
284
|
-
|
|
301
|
+
Resolves the objective direction for a given objective index.
|
|
285
302
|
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
and genomes with the same integer keys.
|
|
303
|
+
If a descriptor omits `direction`, it is treated as maximization.
|
|
304
|
+
Keeping that default here ensures every comparison helper downstream reads
|
|
305
|
+
one normalized direction rule instead of repeating fallback logic.
|
|
290
306
|
|
|
291
307
|
Parameters:
|
|
292
|
-
- `
|
|
308
|
+
- `descriptors` - - Objective descriptors.
|
|
309
|
+
- `objectiveIndex` - - Objective index.
|
|
293
310
|
|
|
294
|
-
Returns:
|
|
311
|
+
Returns: Normalized objective direction.
|
|
295
312
|
|
|
296
|
-
###
|
|
313
|
+
### shouldSkipSelfComparison
|
|
297
314
|
|
|
298
315
|
```ts
|
|
299
|
-
|
|
300
|
-
dominanceState: DominanceState,
|
|
301
|
-
valuesMatrixInput: number[][],
|
|
302
|
-
descriptors: ObjectiveDescriptor[],
|
|
316
|
+
shouldSkipSelfComparison(
|
|
303
317
|
candidateIndex: number,
|
|
304
|
-
|
|
305
|
-
):
|
|
318
|
+
opponentIndex: number,
|
|
319
|
+
): boolean
|
|
306
320
|
```
|
|
307
321
|
|
|
308
|
-
|
|
322
|
+
Determines whether a pairwise comparison should be skipped.
|
|
309
323
|
|
|
310
|
-
|
|
311
|
-
Self-comparisons are ignored.
|
|
324
|
+
Currently this skips only self-comparisons.
|
|
312
325
|
|
|
313
|
-
|
|
314
|
-
the
|
|
315
|
-
|
|
316
|
-
accumulated.
|
|
326
|
+
Keeping the skip rule isolated makes it easier to audit the pairwise loop and
|
|
327
|
+
preserves the invariant that every stored relationship refers to two distinct
|
|
328
|
+
matrix rows.
|
|
317
329
|
|
|
318
330
|
Parameters:
|
|
319
|
-
- `dominanceState` - - Dominance bookkeeping.
|
|
320
|
-
- `valuesMatrixInput` - - Matrix of objective values.
|
|
321
|
-
- `descriptors` - - Objective descriptors.
|
|
322
331
|
- `candidateIndex` - - Candidate genome index.
|
|
323
|
-
- `
|
|
332
|
+
- `opponentIndex` - - Opponent genome index.
|
|
324
333
|
|
|
325
|
-
|
|
334
|
+
Returns: `true` if the pair should be skipped.
|
|
335
|
+
|
|
336
|
+
### updateDominanceForCandidate
|
|
326
337
|
|
|
327
338
|
```ts
|
|
328
|
-
|
|
339
|
+
updateDominanceForCandidate(
|
|
329
340
|
dominanceState: DominanceState,
|
|
330
341
|
valuesMatrixInput: number[][],
|
|
331
342
|
descriptors: ObjectiveDescriptor[],
|
|
332
343
|
candidateIndex: number,
|
|
333
|
-
|
|
344
|
+
candidateIndices: number[],
|
|
334
345
|
): void
|
|
335
346
|
```
|
|
336
347
|
|
|
337
|
-
|
|
348
|
+
Updates dominance bookkeeping for a candidate against all opponents.
|
|
338
349
|
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
the opponent, `dominationCounts[candidateIndex]` is incremented.
|
|
350
|
+
This iterates every opponent index and applies a pairwise dominance update.
|
|
351
|
+
Self-comparisons are ignored.
|
|
342
352
|
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
353
|
+
The helper stays candidate-centric on purpose. Each pass answers "what does
|
|
354
|
+
the rest of the matrix imply about this row?" and leaves first-front
|
|
355
|
+
discovery to the outer orchestration once all opponent evidence has been
|
|
356
|
+
accumulated.
|
|
347
357
|
|
|
348
358
|
Parameters:
|
|
349
359
|
- `dominanceState` - - Dominance bookkeeping.
|
|
350
360
|
- `valuesMatrixInput` - - Matrix of objective values.
|
|
351
361
|
- `descriptors` - - Objective descriptors.
|
|
352
362
|
- `candidateIndex` - - Candidate genome index.
|
|
353
|
-
- `
|
|
363
|
+
- `candidateIndices` - - Indices to compare against.
|
|
354
364
|
|
|
355
|
-
###
|
|
365
|
+
### updateStrictImprovement
|
|
356
366
|
|
|
357
367
|
```ts
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
368
|
+
updateStrictImprovement(
|
|
369
|
+
hasStrictImprovement: boolean,
|
|
370
|
+
isStrictlyBetter: boolean,
|
|
361
371
|
): boolean
|
|
362
372
|
```
|
|
363
373
|
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
Currently this skips only self-comparisons.
|
|
367
|
-
|
|
368
|
-
Keeping the skip rule isolated makes it easier to audit the pairwise loop and
|
|
369
|
-
preserves the invariant that every stored relationship refers to two distinct
|
|
370
|
-
matrix rows.
|
|
374
|
+
Accumulates whether the candidate has a strict improvement across
|
|
375
|
+
objectives.
|
|
371
376
|
|
|
372
377
|
Parameters:
|
|
373
|
-
- `
|
|
374
|
-
- `
|
|
378
|
+
- `hasStrictImprovement` - - Current strict-improvement flag.
|
|
379
|
+
- `isStrictlyBetter` - - Whether the candidate strictly improves on the
|
|
380
|
+
current objective.
|
|
375
381
|
|
|
376
|
-
Returns:
|
|
382
|
+
Returns: Updated strict-improvement flag.
|
|
377
383
|
|
|
378
|
-
###
|
|
384
|
+
### vectorDominates
|
|
379
385
|
|
|
380
386
|
```ts
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
387
|
+
vectorDominates(
|
|
388
|
+
valuesA: number[],
|
|
389
|
+
valuesB: number[],
|
|
384
390
|
descriptors: ObjectiveDescriptor[],
|
|
385
|
-
):
|
|
391
|
+
): boolean
|
|
386
392
|
```
|
|
387
393
|
|
|
388
|
-
|
|
394
|
+
Determines whether vector A Pareto-dominates vector B.
|
|
389
395
|
|
|
390
|
-
|
|
391
|
-
-
|
|
392
|
-
|
|
393
|
-
-
|
|
396
|
+
A dominates B iff:
|
|
397
|
+
- A is **no worse** than B in every objective (respecting each objective’s
|
|
398
|
+
direction: maximize/minimize), and
|
|
399
|
+
- A is **strictly better** in at least one objective.
|
|
394
400
|
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
401
|
+
This helper is deliberately pair-local. It does not mutate bookkeeping or
|
|
402
|
+
know anything about fronts; it only answers the comparison question that the
|
|
403
|
+
wider bookkeeping pass repeats across every pair of matrix rows.
|
|
404
|
+
|
|
405
|
+
Assumptions:
|
|
406
|
+
- `valuesA` and `valuesB` are aligned and have the same length.
|
|
407
|
+
- `descriptors` provides a descriptor for each objective index.
|
|
408
|
+
- If a descriptor has no `direction`, it defaults to `'max'`.
|
|
399
409
|
|
|
400
410
|
Parameters:
|
|
401
|
-
- `
|
|
402
|
-
- `
|
|
403
|
-
- `descriptors` - - Objective descriptors.
|
|
411
|
+
- `valuesA` - - Objective values for candidate A.
|
|
412
|
+
- `valuesB` - - Objective values for candidate B.
|
|
413
|
+
- `descriptors` - - Objective descriptors defining direction semantics.
|
|
404
414
|
|
|
405
|
-
Returns:
|
|
415
|
+
Returns: `true` if A dominates B; otherwise `false`.
|
|
406
416
|
|
|
407
|
-
|
|
417
|
+
Example:
|
|
408
418
|
|
|
409
419
|
```ts
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
):
|
|
420
|
+
// Maximize accuracy, minimize latency:
|
|
421
|
+
vectorDominates([0.9, 120], [0.9, 150], [
|
|
422
|
+
{ accessor: () => 0, direction: 'max' },
|
|
423
|
+
{ accessor: () => 0, direction: 'min' },
|
|
424
|
+
]);
|
|
425
|
+
// => true (equal accuracy, lower latency)
|
|
414
426
|
```
|
|
415
|
-
|
|
416
|
-
Determines whether a candidate has zero domination count.
|
|
417
|
-
|
|
418
|
-
A zero count means the current row survived every pairwise comparison without
|
|
419
|
-
finding a dominating opponent, which is exactly the criterion for first-front
|
|
420
|
-
membership before frontier peeling begins.
|
|
421
|
-
|
|
422
|
-
Parameters:
|
|
423
|
-
- `dominanceState` - - Dominance bookkeeping.
|
|
424
|
-
- `candidateIndex` - - Candidate genome index.
|
|
425
|
-
|
|
426
|
-
Returns: `true` if the candidate is currently non-dominated.
|
|
@@ -44,51 +44,49 @@ computed in the first place.
|
|
|
44
44
|
|
|
45
45
|
## neat/multiobjective/fronts/multiobjective.fronts.ts
|
|
46
46
|
|
|
47
|
-
###
|
|
47
|
+
### annotateGenomeRank
|
|
48
48
|
|
|
49
49
|
```ts
|
|
50
|
-
|
|
50
|
+
annotateGenomeRank(
|
|
51
51
|
population: default[],
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
):
|
|
52
|
+
genomeIndex: number,
|
|
53
|
+
frontRank: number,
|
|
54
|
+
): void
|
|
55
55
|
```
|
|
56
56
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
This performs the “peeling” phase of fast non-dominated sorting:
|
|
60
|
-
- Start with the first front (all non-dominated genomes).
|
|
61
|
-
- For each front, reduce domination counts of the genomes it dominates.
|
|
62
|
-
- Each genome whose domination count becomes zero moves to the next front.
|
|
63
|
-
|
|
64
|
-
The implementation is intentionally breadth-first. It never revisits pairwise
|
|
65
|
-
comparisons; instead it trusts the dominance-state handoff and repeatedly
|
|
66
|
-
relaxes domination counts until the next layer becomes visible.
|
|
67
|
-
|
|
68
|
-
Side effects:
|
|
69
|
-
- Annotates each genome in `population` with `_moRank` (0 = best front).
|
|
57
|
+
Annotates a genome with its Pareto front rank.
|
|
70
58
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
be incomplete.
|
|
59
|
+
Ranking is stored directly on the genome so later selection, telemetry, and
|
|
60
|
+
archive helpers can read one stable annotation instead of carrying a parallel
|
|
61
|
+
rank table beside the population.
|
|
75
62
|
|
|
76
63
|
Parameters:
|
|
77
|
-
- `population` - - Genome population
|
|
78
|
-
|
|
79
|
-
- `
|
|
80
|
-
- `maxFrontRankGuard` - - Safety guard for ranking iterations.
|
|
64
|
+
- `population` - - Genome population.
|
|
65
|
+
- `genomeIndex` - - Index of the genome to annotate.
|
|
66
|
+
- `frontRank` - - Pareto front rank (0 = best front).
|
|
81
67
|
|
|
82
|
-
|
|
68
|
+
### appendFront
|
|
83
69
|
|
|
84
|
-
|
|
70
|
+
```ts
|
|
71
|
+
appendFront(
|
|
72
|
+
paretoFronts: default[][],
|
|
73
|
+
population: default[],
|
|
74
|
+
currentFrontIndices: number[],
|
|
75
|
+
): void
|
|
76
|
+
```
|
|
85
77
|
|
|
86
|
-
|
|
78
|
+
Appends the current front (index list) as genome references to the
|
|
79
|
+
`paretoFronts` accumulator.
|
|
87
80
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
81
|
+
The accumulator stores genomes, not indices, because the returned fronts are
|
|
82
|
+
meant to be consumed by later crowding and archive code. The conversion from
|
|
83
|
+
stable indices to genome references happens only after the current layer has
|
|
84
|
+
been fully identified.
|
|
85
|
+
|
|
86
|
+
Parameters:
|
|
87
|
+
- `paretoFronts` - - Accumulator for Pareto fronts.
|
|
88
|
+
- `population` - - Genome population.
|
|
89
|
+
- `currentFrontIndices` - - Indices for the current front.
|
|
92
90
|
|
|
93
91
|
### buildNextFrontIndices
|
|
94
92
|
|
|
@@ -115,26 +113,42 @@ Parameters:
|
|
|
115
113
|
|
|
116
114
|
Returns: Indices for the next front.
|
|
117
115
|
|
|
118
|
-
###
|
|
116
|
+
### buildParetoFronts
|
|
119
117
|
|
|
120
118
|
```ts
|
|
121
|
-
|
|
119
|
+
buildParetoFronts(
|
|
122
120
|
population: default[],
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
):
|
|
121
|
+
dominanceState: DominanceState,
|
|
122
|
+
maxFrontRankGuard: number,
|
|
123
|
+
): default[][]
|
|
126
124
|
```
|
|
127
125
|
|
|
128
|
-
|
|
126
|
+
Builds Pareto fronts from a precomputed dominance state.
|
|
129
127
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
128
|
+
This performs the “peeling” phase of fast non-dominated sorting:
|
|
129
|
+
- Start with the first front (all non-dominated genomes).
|
|
130
|
+
- For each front, reduce domination counts of the genomes it dominates.
|
|
131
|
+
- Each genome whose domination count becomes zero moves to the next front.
|
|
132
|
+
|
|
133
|
+
The implementation is intentionally breadth-first. It never revisits pairwise
|
|
134
|
+
comparisons; instead it trusts the dominance-state handoff and repeatedly
|
|
135
|
+
relaxes domination counts until the next layer becomes visible.
|
|
136
|
+
|
|
137
|
+
Side effects:
|
|
138
|
+
- Annotates each genome in `population` with `_moRank` (0 = best front).
|
|
139
|
+
|
|
140
|
+
Guard:
|
|
141
|
+
- Stops when `currentFrontRank > maxFrontRankGuard` to avoid pathological
|
|
142
|
+
infinite/degenerate runs. If the guard triggers, the returned fronts may
|
|
143
|
+
be incomplete.
|
|
133
144
|
|
|
134
145
|
Parameters:
|
|
135
|
-
- `population` - - Genome population
|
|
136
|
-
|
|
137
|
-
- `
|
|
146
|
+
- `population` - - Genome population (same ordering used by dominance
|
|
147
|
+
bookkeeping).
|
|
148
|
+
- `dominanceState` - - Dominance bookkeeping.
|
|
149
|
+
- `maxFrontRankGuard` - - Safety guard for ranking iterations.
|
|
150
|
+
|
|
151
|
+
Returns: Ordered Pareto fronts (rank order).
|
|
138
152
|
|
|
139
153
|
### collectNextFrontIndices
|
|
140
154
|
|
|
@@ -159,29 +173,6 @@ Parameters:
|
|
|
159
173
|
- `genomeIndex` - - Index of the current genome.
|
|
160
174
|
- `nextFrontIndices` - - Accumulator for the next front.
|
|
161
175
|
|
|
162
|
-
### appendFront
|
|
163
|
-
|
|
164
|
-
```ts
|
|
165
|
-
appendFront(
|
|
166
|
-
paretoFronts: default[][],
|
|
167
|
-
population: default[],
|
|
168
|
-
currentFrontIndices: number[],
|
|
169
|
-
): void
|
|
170
|
-
```
|
|
171
|
-
|
|
172
|
-
Appends the current front (index list) as genome references to the
|
|
173
|
-
`paretoFronts` accumulator.
|
|
174
|
-
|
|
175
|
-
The accumulator stores genomes, not indices, because the returned fronts are
|
|
176
|
-
meant to be consumed by later crowding and archive code. The conversion from
|
|
177
|
-
stable indices to genome references happens only after the current layer has
|
|
178
|
-
been fully identified.
|
|
179
|
-
|
|
180
|
-
Parameters:
|
|
181
|
-
- `paretoFronts` - - Accumulator for Pareto fronts.
|
|
182
|
-
- `population` - - Genome population.
|
|
183
|
-
- `currentFrontIndices` - - Indices for the current front.
|
|
184
|
-
|
|
185
176
|
### incrementFrontRank
|
|
186
177
|
|
|
187
178
|
```ts
|
|
@@ -200,6 +191,15 @@ Parameters:
|
|
|
200
191
|
|
|
201
192
|
Returns: Incremented front rank.
|
|
202
193
|
|
|
194
|
+
### MAX_PARETO_FRONT_RANK_GUARD
|
|
195
|
+
|
|
196
|
+
Maximum number of Pareto fronts to allow during ranking before aborting.
|
|
197
|
+
|
|
198
|
+
This is a defensive guard against pathological conditions (e.g., corrupted
|
|
199
|
+
dominance bookkeeping) that could otherwise cause long/infinite loops.
|
|
200
|
+
A healthy ranking pass should terminate well before this threshold, so the
|
|
201
|
+
constant exists as a safety rail rather than a normal control knob.
|
|
202
|
+
|
|
203
203
|
### shouldStopFrontRanking
|
|
204
204
|
|
|
205
205
|
```ts
|