@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.
Files changed (215) hide show
  1. package/.github/copilot-instructions.md +11 -0
  2. package/.github/skills/trace-analyzer-extension/SKILL.md +3 -3
  3. package/.github/skills/trace-analyzer-extension/assets/extension-checklist.md +1 -1
  4. package/.github/skills/trace-analyzer-extension/references/analyzer-extension-workflow.md +1 -1
  5. package/.github/skills/trace-audit-reporting/SKILL.md +3 -3
  6. package/.github/skills/trace-audit-reporting/references/trace-analysis-workflow.md +1 -1
  7. package/.github/workflows/ci.yml +3 -3
  8. package/.github/workflows/deploy-pages.yml +6 -6
  9. package/.github/workflows/manual_release_pipeline.yml +3 -3
  10. package/.github/workflows/publish.yml +18 -19
  11. package/.github/workflows/release_dispatch.yml +3 -3
  12. package/package.json +26 -20
  13. package/plans/Flappy_Bird_Folder_Documentation_Pass.md +4 -4
  14. package/plans/README.md +24 -0
  15. package/plans/Roadmap.md +62 -40
  16. package/plans/analyze-trace-solid-split.plans.md +66 -0
  17. package/plans/architecture-solid-split.plans.md +9 -15
  18. package/plans/asciiMaze-typescript-repair.plans.md +1 -1
  19. package/plans/generate-docs-solid-split.plans.md +87 -0
  20. package/plans/methods-docs.plans.md +25 -1
  21. package/plans/methods-solid-split.plans.md +14 -14
  22. package/plans/neat-docs.plans.md +9 -1
  23. package/plans/neat-test-surface-repair.plans.md +1 -1
  24. package/plans/render-docs-html-solid-split.plans.md +68 -0
  25. package/plans/src-no-explicit-any-cleanup.plans.md +1 -1
  26. package/plans/utils-docs.plans.md +6 -1
  27. package/scripts/analyze-trace/analyze-trace.analysis.ts +479 -0
  28. package/scripts/analyze-trace/analyze-trace.constants.ts +35 -0
  29. package/scripts/analyze-trace/analyze-trace.io.ts +69 -0
  30. package/scripts/analyze-trace/analyze-trace.report.ts +100 -0
  31. package/scripts/analyze-trace/analyze-trace.shared.ts +116 -0
  32. package/scripts/analyze-trace/analyze-trace.ts +45 -0
  33. package/scripts/analyze-trace/analyze-trace.types.ts +72 -0
  34. package/scripts/assets/theme.css +80 -23
  35. package/scripts/copy-examples.ts +239 -0
  36. package/scripts/export-onnx.ts +223 -0
  37. package/scripts/generate-bench-tables.ts +378 -37
  38. package/scripts/generate-docs/generate-docs.constants.ts +107 -0
  39. package/scripts/generate-docs/generate-docs.order.ts +355 -0
  40. package/scripts/generate-docs/generate-docs.state.ts +31 -0
  41. package/scripts/generate-docs/generate-docs.targets.ts +165 -0
  42. package/scripts/generate-docs/generate-docs.ts +63 -0
  43. package/scripts/generate-docs/generate-docs.types.ts +112 -0
  44. package/scripts/generate-docs/output/generate-docs.output.folder-index.utils.ts +167 -0
  45. package/scripts/generate-docs/output/generate-docs.output.ordering.utils.ts +353 -0
  46. package/scripts/generate-docs/output/generate-docs.output.readme.utils.ts +420 -0
  47. package/scripts/generate-docs/output/generate-docs.output.ts +123 -0
  48. package/scripts/generate-docs/output/generate-docs.output.warnings.utils.ts +219 -0
  49. package/scripts/generate-docs/symbols/generate-docs.symbols.collection.utils.ts +365 -0
  50. package/scripts/generate-docs/symbols/generate-docs.symbols.jsdoc.utils.ts +373 -0
  51. package/scripts/generate-docs/symbols/generate-docs.symbols.normalize.utils.ts +155 -0
  52. package/scripts/generate-docs/symbols/generate-docs.symbols.render.utils.ts +149 -0
  53. package/scripts/generate-docs/symbols/generate-docs.symbols.signature.utils.ts +289 -0
  54. package/scripts/generate-docs/symbols/generate-docs.symbols.ts +11 -0
  55. package/scripts/mermaid-cli.mjs +102 -22
  56. package/scripts/mermaid-cli.ts +736 -0
  57. package/scripts/render-docs-html/render-docs-html.assets.ts +54 -0
  58. package/scripts/render-docs-html/render-docs-html.mermaid.ts +245 -0
  59. package/scripts/{render-docs-html.sidebar.ts → render-docs-html/render-docs-html.navigation.ts} +141 -144
  60. package/scripts/render-docs-html/render-docs-html.pages.ts +333 -0
  61. package/scripts/render-docs-html/render-docs-html.shared.ts +333 -0
  62. package/scripts/render-docs-html/render-docs-html.types.ts +42 -0
  63. package/scripts/render-docs-html.ts +23 -587
  64. package/scripts/run-docs.ts +238 -0
  65. package/scripts/write-dist-docs-pkg.ts +40 -0
  66. package/src/README.md +75 -75
  67. package/src/architecture/connection/README.md +5 -5
  68. package/src/architecture/layer/README.md +508 -508
  69. package/src/architecture/network/README.md +1458 -1458
  70. package/src/architecture/network/activate/README.md +694 -694
  71. package/src/architecture/network/bootstrap/README.md +77 -77
  72. package/src/architecture/network/connect/README.md +74 -74
  73. package/src/architecture/network/deterministic/README.md +135 -135
  74. package/src/architecture/network/evolve/README.md +364 -364
  75. package/src/architecture/network/gating/README.md +130 -130
  76. package/src/architecture/network/genetic/README.md +399 -399
  77. package/src/architecture/network/mutate/README.md +897 -897
  78. package/src/architecture/network/onnx/README.md +720 -720
  79. package/src/architecture/network/onnx/export/README.md +728 -728
  80. package/src/architecture/network/onnx/export/layers/README.md +450 -450
  81. package/src/architecture/network/onnx/import/README.md +618 -618
  82. package/src/architecture/network/onnx/schema/README.md +32 -32
  83. package/src/architecture/network/prune/README.md +245 -245
  84. package/src/architecture/network/remove/README.md +135 -135
  85. package/src/architecture/network/runtime/README.md +106 -106
  86. package/src/architecture/network/serialize/README.md +542 -542
  87. package/src/architecture/network/slab/README.md +608 -608
  88. package/src/architecture/network/standalone/README.md +212 -212
  89. package/src/architecture/network/stats/README.md +84 -84
  90. package/src/architecture/network/topology/README.md +465 -465
  91. package/src/architecture/network/training/README.md +200 -200
  92. package/src/architecture/node/README.md +5 -5
  93. package/src/architecture/nodePool/README.md +14 -14
  94. package/src/methods/README.md +99 -99
  95. package/src/methods/activation/README.md +189 -189
  96. package/src/methods/cost/README.md +131 -131
  97. package/src/methods/rate/README.md +86 -86
  98. package/src/multithreading/README.md +77 -77
  99. package/src/multithreading/workers/browser/README.md +8 -8
  100. package/src/multithreading/workers/node/README.md +8 -8
  101. package/src/neat/README.md +148 -148
  102. package/src/neat/adaptive/README.md +120 -120
  103. package/src/neat/adaptive/acceptance/README.md +40 -40
  104. package/src/neat/adaptive/complexity/README.md +137 -137
  105. package/src/neat/adaptive/core/README.md +197 -197
  106. package/src/neat/adaptive/lineage/README.md +90 -90
  107. package/src/neat/adaptive/mutation/README.md +284 -284
  108. package/src/neat/compat/README.md +43 -43
  109. package/src/neat/compat/core/README.md +90 -90
  110. package/src/neat/diversity/README.md +35 -35
  111. package/src/neat/diversity/core/README.md +88 -88
  112. package/src/neat/evaluate/README.md +85 -85
  113. package/src/neat/evaluate/auto-distance/README.md +75 -75
  114. package/src/neat/evaluate/entropy-compat/README.md +37 -37
  115. package/src/neat/evaluate/entropy-sharing/README.md +43 -43
  116. package/src/neat/evaluate/fitness/README.md +23 -23
  117. package/src/neat/evaluate/novelty/README.md +120 -120
  118. package/src/neat/evaluate/objectives/README.md +17 -17
  119. package/src/neat/evaluate/shared/README.md +94 -94
  120. package/src/neat/evolve/README.md +96 -96
  121. package/src/neat/evolve/adaptive/README.md +60 -60
  122. package/src/neat/evolve/objectives/README.md +63 -63
  123. package/src/neat/evolve/offspring/README.md +56 -56
  124. package/src/neat/evolve/population/README.md +171 -171
  125. package/src/neat/evolve/runtime/README.md +79 -79
  126. package/src/neat/evolve/speciation/README.md +74 -74
  127. package/src/neat/evolve/warnings/README.md +10 -10
  128. package/src/neat/export/README.md +114 -114
  129. package/src/neat/helpers/README.md +50 -50
  130. package/src/neat/init/README.md +9 -9
  131. package/src/neat/lineage/core/README.md +101 -101
  132. package/src/neat/multiobjective/category/README.md +74 -74
  133. package/src/neat/multiobjective/crowding/README.md +272 -272
  134. package/src/neat/multiobjective/dominance/README.md +171 -171
  135. package/src/neat/multiobjective/fronts/README.md +68 -68
  136. package/src/neat/multiobjective/metrics/README.md +43 -43
  137. package/src/neat/multiobjective/objectives/README.md +31 -31
  138. package/src/neat/multiobjective/shared/README.md +27 -27
  139. package/src/neat/mutation/README.md +97 -97
  140. package/src/neat/mutation/add-conn/README.md +115 -115
  141. package/src/neat/mutation/add-node/README.md +126 -126
  142. package/src/neat/mutation/flow/README.md +149 -149
  143. package/src/neat/mutation/repair/README.md +185 -185
  144. package/src/neat/mutation/select/README.md +117 -117
  145. package/src/neat/mutation/shared/README.md +32 -32
  146. package/src/neat/objectives/README.md +25 -25
  147. package/src/neat/objectives/core/README.md +67 -67
  148. package/src/neat/pruning/README.md +40 -40
  149. package/src/neat/pruning/core/README.md +171 -171
  150. package/src/neat/pruning/facade/README.md +32 -32
  151. package/src/neat/rng/README.md +104 -104
  152. package/src/neat/rng/core/README.md +137 -137
  153. package/src/neat/rng/facade/README.md +50 -50
  154. package/src/neat/selection/README.md +111 -111
  155. package/src/neat/selection/core/README.md +227 -227
  156. package/src/neat/selection/facade/README.md +61 -61
  157. package/src/neat/shared/README.md +163 -163
  158. package/src/neat/speciation/README.md +31 -31
  159. package/src/neat/speciation/threshold/README.md +35 -35
  160. package/src/neat/species/README.md +25 -25
  161. package/src/neat/species/core/README.md +20 -20
  162. package/src/neat/species/core/shared/README.md +18 -18
  163. package/src/neat/species/history/context/README.md +22 -22
  164. package/src/neat/telemetry/accessors/README.md +58 -58
  165. package/src/neat/telemetry/exports/README.md +233 -233
  166. package/src/neat/telemetry/facade/README.md +252 -252
  167. package/src/neat/telemetry/facade/archive/README.md +57 -57
  168. package/src/neat/telemetry/facade/buffer/README.md +43 -43
  169. package/src/neat/telemetry/facade/lineage/README.md +12 -12
  170. package/src/neat/telemetry/facade/objectives/README.md +44 -44
  171. package/src/neat/telemetry/facade/runtime/README.md +26 -26
  172. package/src/neat/telemetry/facade/species/README.md +27 -27
  173. package/src/neat/telemetry/metrics/README.md +696 -696
  174. package/src/neat/telemetry/recorder/README.md +57 -57
  175. package/src/neat/telemetry/types/README.md +32 -32
  176. package/src/neat/topology-intent/README.md +75 -75
  177. package/src/utils/README.md +193 -193
  178. package/test/examples/asciiMaze/browser-entry/README.md +92 -92
  179. package/test/examples/asciiMaze/dashboardManager/README.md +109 -109
  180. package/test/examples/asciiMaze/dashboardManager/telemetry/README.md +28 -28
  181. package/test/examples/asciiMaze/evolutionEngine/README.md +1527 -1527
  182. package/test/examples/asciiMaze/mazeMovement/README.md +105 -105
  183. package/test/examples/asciiMaze/mazeMovement/finalization/README.md +16 -16
  184. package/test/examples/asciiMaze/mazeMovement/policy/README.md +57 -57
  185. package/test/examples/asciiMaze/mazeMovement/runtime/README.md +52 -52
  186. package/test/examples/asciiMaze/mazeMovement/shaping/README.md +46 -46
  187. package/test/examples/flappy_bird/browser-entry/README.md +508 -508
  188. package/test/examples/flappy_bird/browser-entry/host/README.md +101 -101
  189. package/test/examples/flappy_bird/browser-entry/host/resize/README.md +144 -144
  190. package/test/examples/flappy_bird/browser-entry/network-view/README.md +194 -194
  191. package/test/examples/flappy_bird/browser-entry/playback/README.md +278 -278
  192. package/test/examples/flappy_bird/browser-entry/playback/background/README.md +129 -129
  193. package/test/examples/flappy_bird/browser-entry/playback/background/ground-grid/README.md +502 -502
  194. package/test/examples/flappy_bird/browser-entry/playback/frame-render/README.md +139 -139
  195. package/test/examples/flappy_bird/browser-entry/playback/snapshot/README.md +10 -10
  196. package/test/examples/flappy_bird/browser-entry/playback/trail/README.md +43 -43
  197. package/test/examples/flappy_bird/browser-entry/playback/worker-channel/README.md +30 -30
  198. package/test/examples/flappy_bird/browser-entry/runtime/README.md +59 -59
  199. package/test/examples/flappy_bird/browser-entry/visualization/README.md +276 -276
  200. package/test/examples/flappy_bird/browser-entry/worker-channel/README.md +16 -16
  201. package/test/examples/flappy_bird/constants/README.md +1070 -1070
  202. package/test/examples/flappy_bird/environment/README.md +22 -22
  203. package/test/examples/flappy_bird/evaluation/README.md +32 -32
  204. package/test/examples/flappy_bird/evaluation/rollout/README.md +141 -141
  205. package/test/examples/flappy_bird/flappy-evolution-worker/README.md +425 -425
  206. package/test/examples/flappy_bird/simulation-shared/README.md +170 -170
  207. package/test/examples/flappy_bird/simulation-shared/observation/README.md +109 -109
  208. package/test/examples/flappy_bird/trainer/README.md +325 -325
  209. package/test/examples/flappy_bird/trainer/evaluation/README.md +74 -74
  210. package/scripts/analyze-trace.ts +0 -590
  211. package/scripts/copy-examples.mjs +0 -114
  212. package/scripts/export-onnx.mjs +0 -86
  213. package/scripts/generate-bench-tables.mjs +0 -182
  214. package/scripts/generate-docs.ts +0 -2900
  215. package/scripts/write-dist-docs-pkg.mjs +0 -16
@@ -44,170 +44,113 @@ missing context is how the fronts themselves were constructed.
44
44
 
45
45
  ## neat/multiobjective/crowding/multiobjective.crowding.ts
46
46
 
47
- ### buildGenomeIndexByReference
48
-
49
- ```ts
50
- buildGenomeIndexByReference(
51
- population: default[],
52
- ): Map<default, number>
53
- ```
54
-
55
- Builds a stable mapping from genome object references to their population
56
- index.
57
-
58
- This relies on object identity (reference equality), not structural
59
- equality. It is used to resolve objective values from a values matrix when
60
- working with reordered views such as per-objective sorted fronts.
61
- The map preserves the controller's original population order even while this
62
- chapter temporarily reorders front-local views for spacing calculations.
63
-
64
- Parameters:
65
- - `population` - - Genomes in population order.
66
-
67
- Returns: Map from genome references to their index.
68
-
69
- ### resolveGenomeIndex
70
-
71
- ```ts
72
- resolveGenomeIndex(
73
- genomeIndexByReference: Map<default, number>,
74
- genomeItem: default,
75
- ): number
76
- ```
77
-
78
- Resolves a genome’s index using a reference-based map.
79
-
80
- Crowding works with reordered arrays of genome references, but the value
81
- matrix still lives in population order. This lookup reconnects those two
82
- views without copying the matrix.
83
-
84
- Parameters:
85
- - `genomeIndexByReference` - - Lookup map created by
86
- * {@link buildGenomeIndexByReference} .
87
- - `genomeItem` - - Genome to resolve.
88
-
89
- Returns: The population index of the genome.
90
-
91
- ### resolveObjectiveValue
47
+ ### accumulateCrowdingForObjective
92
48
 
93
49
  ```ts
94
- resolveObjectiveValue(
50
+ accumulateCrowdingForObjective(
51
+ sortedFront: default[],
95
52
  valuesMatrixInput: number[][],
96
53
  genomeIndexByReference: Map<default, number>,
97
- genomeItem: default,
98
54
  objectiveIndex: number,
99
- ): number
100
- ```
101
-
102
- Resolves an objective value for a genome from a values matrix.
103
-
104
- This is a convenience helper for working with sorted/reordered views of the
105
- population while keeping objective values in a dense matrix.
106
- It lets the crowding pass ask "what is this genome's value on the current
107
- objective?" without assuming the front is still in population order.
108
-
109
- Parameters:
110
- - `valuesMatrixInput` - - Values matrix indexed by population index.
111
- - `genomeIndexByReference` - - Lookup map from genome reference to index.
112
- - `genomeItem` - - Genome to resolve.
113
- - `objectiveIndex` - - Objective column index.
114
-
115
- Returns: The objective value for the genome.
116
-
117
- ### initializeCrowding
118
-
119
- ```ts
120
- initializeCrowding(
121
- front: default[],
122
55
  ): void
123
56
  ```
124
57
 
125
- Initializes crowding-distance annotations for a front.
58
+ Accumulates crowding distance contributions for a single objective.
126
59
 
127
- This sets each genome’s `_moCrowd` to `0`. Later steps accumulate per-
128
- objective spacing deltas.
60
+ Pre-conditions / expectations:
61
+ - `sortedFront` must be sorted ascending by the selected objective.
62
+ - {@link initializeCrowding} has already set `_moCrowd = 0` for the front.
63
+ - {@link markBoundaryCrowding} is typically called before this to set the
64
+ boundary genomes to `Infinity`.
129
65
 
130
- Resetting the field once per front keeps the later per-objective helpers
131
- additive and makes the final score easy to interpret as one accumulated
132
- spacing signal across all objectives.
66
+ Edge cases:
67
+ - If the front has fewer than 2 genomes, this is a no-op.
68
+ - If the objective range is `0`, a range of `1` is used (see
69
+ {@link resolveObjectiveRange}).
70
+
71
+ This helper deliberately ignores objective direction. Crowding measures raw
72
+ spacing between neighboring values, so the same frontier width matters
73
+ whether the controller is minimizing or maximizing that objective.
133
74
 
134
75
  Parameters:
135
- - `front` - - Pareto front.
76
+ - `sortedFront` - - Front sorted by objective.
77
+ - `valuesMatrixInput` - - Values matrix.
78
+ - `genomeIndexByReference` - - Lookup map.
79
+ - `objectiveIndex` - - Objective column index.
136
80
 
137
- ### markBoundaryCrowding
81
+ ### accumulateInteriorCrowding
138
82
 
139
83
  ```ts
140
- markBoundaryCrowding(
84
+ accumulateInteriorCrowding(
141
85
  sortedFront: default[],
86
+ valuesMatrixInput: number[][],
87
+ genomeIndexByReference: Map<default, number>,
88
+ objectiveIndex: number,
89
+ valueRange: number,
142
90
  ): void
143
91
  ```
144
92
 
145
- Marks the boundary genomes of a sorted front as infinitely crowded.
93
+ Accumulates crowding deltas for the interior genomes of a sorted front.
146
94
 
147
- In NSGA-II style crowding distance, boundary solutions (extremes for the
148
- objective) are assigned an infinite crowding distance to ensure they are
149
- always preferred when ranks tie.
95
+ Interior genomes receive a normalized spacing delta:
96
+ `delta = (nextValue - previousValue) / valueRange`.
150
97
 
151
- This preserves the ends of the tradeoff surface. Even when interior genomes
152
- become densely packed, the extreme solutions remain available to later
153
- selection because they carry unique objective-space coverage.
98
+ Looking at both neighbors matters because crowding is trying to estimate how
99
+ much empty objective-space surrounds the current genome, not merely whether
100
+ it differs from one adjacent point.
154
101
 
155
102
  Parameters:
156
- - `sortedFront` - - Front sorted by the current objective.
103
+ - `sortedFront` - - Front sorted by objective.
104
+ - `valuesMatrixInput` - - Values matrix.
105
+ - `genomeIndexByReference` - - Lookup map.
106
+ - `objectiveIndex` - - Objective column index.
107
+ - `valueRange` - - Normalized objective range.
157
108
 
158
- ### resolveObjectiveRange
109
+ ### applyCrowdingDelta
159
110
 
160
111
  ```ts
161
- resolveObjectiveRange(
162
- minValue: number,
163
- maxValue: number,
164
- ): number
112
+ applyCrowdingDelta(
113
+ currentGenome: NetworkWithMOAnnotations,
114
+ previousValue: number,
115
+ nextValue: number,
116
+ valueRange: number,
117
+ ): void
165
118
  ```
166
119
 
167
- Resolves a non-zero objective range used to normalize crowding deltas.
120
+ Applies a normalized crowding-distance delta to a genome.
168
121
 
169
- If all genomes have the same objective value, the raw range is `0`. This
170
- returns `1` in that case to avoid division by zero while still producing a
171
- well-defined crowding delta of `0`.
172
- The fallback means a flat objective contributes no spacing signal instead of
173
- exploding numerically or distorting the remaining objectives.
122
+ If the genome’s crowding distance is `Infinity`, it will remain `Infinity`.
123
+ This helper only updates when `_moCrowd` is initialized.
124
+ That preserves the boundary-solutions rule while still allowing interior
125
+ genomes to accumulate spacing contributions across many objectives.
174
126
 
175
127
  Parameters:
176
- - `minValue` - - Minimum objective value.
177
- - `maxValue` - - Maximum objective value.
178
-
179
- Returns: Normalized range with a non-zero floor.
128
+ - `currentGenome` - - Genome to update.
129
+ - `previousValue` - - Objective value of previous genome.
130
+ - `nextValue` - - Objective value of next genome.
131
+ - `valueRange` - - Normalized objective range.
180
132
 
181
- ### accumulateCrowdingForObjective
133
+ ### applyCrowdingForObjective
182
134
 
183
135
  ```ts
184
- accumulateCrowdingForObjective(
185
- sortedFront: default[],
136
+ applyCrowdingForObjective(
137
+ front: default[],
186
138
  valuesMatrixInput: number[][],
187
139
  genomeIndexByReference: Map<default, number>,
188
140
  objectiveIndex: number,
189
141
  ): void
190
142
  ```
191
143
 
192
- Accumulates crowding distance contributions for a single objective.
193
-
194
- Pre-conditions / expectations:
195
- - `sortedFront` must be sorted ascending by the selected objective.
196
- - {@link initializeCrowding} has already set `_moCrowd = 0` for the front.
197
- - {@link markBoundaryCrowding} is typically called before this to set the
198
- boundary genomes to `Infinity`.
199
-
200
- Edge cases:
201
- - If the front has fewer than 2 genomes, this is a no-op.
202
- - If the objective range is `0`, a range of `1` is used (see
203
- {@link resolveObjectiveRange}).
144
+ Applies crowding-distance accumulation for a single objective within a
145
+ single front.
204
146
 
205
- This helper deliberately ignores objective direction. Crowding measures raw
206
- spacing between neighboring values, so the same frontier width matters
207
- whether the controller is minimizing or maximizing that objective.
147
+ The work happens in two phases: create the sorted frontier view for the
148
+ chosen objective, then protect its boundaries and accumulate interior
149
+ spacing. Keeping those phases together makes the per-objective flow easy to
150
+ audit in the generated chapter.
208
151
 
209
152
  Parameters:
210
- - `sortedFront` - - Front sorted by objective.
153
+ - `front` - - Pareto front.
211
154
  - `valuesMatrixInput` - - Values matrix.
212
155
  - `genomeIndexByReference` - - Lookup map.
213
156
  - `objectiveIndex` - - Objective column index.
@@ -250,267 +193,324 @@ Parameters:
250
193
  - `descriptors` - - Objective descriptors (provides objective count).
251
194
  - `population` - - Population to resolve indices.
252
195
 
253
- ### resolveBoundaryGenomes
196
+ ### assignCrowdingForFront
254
197
 
255
198
  ```ts
256
- resolveBoundaryGenomes(
257
- sortedFront: default[],
258
- ): { firstGenome: default; lastGenome: default; } | null
199
+ assignCrowdingForFront(
200
+ front: default[],
201
+ valuesMatrixInput: number[][],
202
+ genomeIndexByReference: Map<default, number>,
203
+ objectiveIndices: number[],
204
+ ): void
259
205
  ```
260
206
 
261
- Resolves the boundary (first/last) genomes for a sorted front.
207
+ Assigns crowding distances for a single front across all objectives.
262
208
 
263
- Parameters:
264
- - `sortedFront` - - Front sorted by objective.
209
+ This helper keeps the front-local story clear: once the front exists and its
210
+ crowding fields are initialized, simply walk the objective columns and let
211
+ each one contribute its own spacing signal.
265
212
 
266
- Returns: Boundary genomes, or `null` if the front is empty.
213
+ Parameters:
214
+ - `front` - - Pareto front.
215
+ - `valuesMatrixInput` - - Values matrix.
216
+ - `genomeIndexByReference` - - Lookup map.
217
+ - `objectiveIndices` - - Objective indices to process.
267
218
 
268
- ### resolveObjectiveRangeFromBoundaries
219
+ ### buildGenomeIndexByReference
269
220
 
270
221
  ```ts
271
- resolveObjectiveRangeFromBoundaries(
272
- valuesMatrixInput: number[][],
273
- genomeIndexByReference: Map<default, number>,
274
- boundaryGenomes: { firstGenome: default; lastGenome: default; },
275
- objectiveIndex: number,
276
- ): number
222
+ buildGenomeIndexByReference(
223
+ population: default[],
224
+ ): Map<default, number>
277
225
  ```
278
226
 
279
- Resolves the normalized objective range for a front from its boundary
280
- genomes.
227
+ Builds a stable mapping from genome object references to their population
228
+ index.
281
229
 
282
- Because `sortedFront` is sorted by objective, the first and last genomes are
283
- the extrema used for range normalization.
230
+ This relies on object identity (reference equality), not structural
231
+ equality. It is used to resolve objective values from a values matrix when
232
+ working with reordered views such as per-objective sorted fronts.
233
+ The map preserves the controller's original population order even while this
234
+ chapter temporarily reorders front-local views for spacing calculations.
284
235
 
285
236
  Parameters:
286
- - `valuesMatrixInput` - - Values matrix.
287
- - `genomeIndexByReference` - - Lookup map.
288
- - `boundaryGenomes` - - Boundary genomes for the front.
289
- - `objectiveIndex` - - Objective column index.
237
+ - `population` - - Genomes in population order.
290
238
 
291
- Returns: Normalized value range for the objective.
239
+ Returns: Map from genome references to their index.
292
240
 
293
- ### accumulateInteriorCrowding
241
+ ### buildInteriorIndexRange
294
242
 
295
243
  ```ts
296
- accumulateInteriorCrowding(
297
- sortedFront: default[],
298
- valuesMatrixInput: number[][],
299
- genomeIndexByReference: Map<default, number>,
300
- objectiveIndex: number,
301
- valueRange: number,
302
- ): void
244
+ buildInteriorIndexRange(
245
+ frontLength: number,
246
+ ): number[]
303
247
  ```
304
248
 
305
- Accumulates crowding deltas for the interior genomes of a sorted front.
249
+ Builds the index range for interior genomes of a front.
306
250
 
307
- Interior genomes receive a normalized spacing delta:
308
- `delta = (nextValue - previousValue) / valueRange`.
251
+ Boundary genomes are excluded because their crowding distance is treated as
252
+ infinite.
309
253
 
310
- Looking at both neighbors matters because crowding is trying to estimate how
311
- much empty objective-space surrounds the current genome, not merely whether
312
- it differs from one adjacent point.
254
+ Parameters:
255
+ - `frontLength` - - Length of the sorted front.
256
+
257
+ Returns: Interior indices excluding boundary genomes.
258
+
259
+ ### buildObjectiveIndexRange
260
+
261
+ ```ts
262
+ buildObjectiveIndexRange(
263
+ objectiveCount: number,
264
+ ): number[]
265
+ ```
266
+
267
+ Builds a stable objective index range.
268
+
269
+ Keeping objective iteration explicit makes the front-level accumulation order
270
+ easy to inspect and keeps the per-objective helper signatures small.
313
271
 
314
272
  Parameters:
315
- - `sortedFront` - - Front sorted by objective.
273
+ - `objectiveCount` - - Number of objectives.
274
+
275
+ Returns: Objective indices `0..objectiveCount-1`.
276
+
277
+ ### buildSortedFrontByObjective
278
+
279
+ ```ts
280
+ buildSortedFrontByObjective(
281
+ front: default[],
282
+ valuesMatrixInput: number[][],
283
+ genomeIndexByReference: Map<default, number>,
284
+ objectiveIndex: number,
285
+ ): default[]
286
+ ```
287
+
288
+ Builds a copy of the front sorted by the specified objective.
289
+
290
+ Sorting is ascending by the raw objective value. This ordering is used for
291
+ computing neighbor spacing in objective space.
292
+ The original front array remains untouched so Pareto-rank grouping stays
293
+ stable while each objective gets its own temporary geometric view.
294
+
295
+ Parameters:
296
+ - `front` - - Pareto front.
316
297
  - `valuesMatrixInput` - - Values matrix.
317
298
  - `genomeIndexByReference` - - Lookup map.
318
299
  - `objectiveIndex` - - Objective column index.
319
- - `valueRange` - - Normalized objective range.
320
300
 
321
- ### buildInteriorIndexRange
301
+ Returns: Front sorted by objective value.
302
+
303
+ ### compareObjectiveValuesForCrowding
322
304
 
323
305
  ```ts
324
- buildInteriorIndexRange(
325
- frontLength: number,
326
- ): number[]
306
+ compareObjectiveValuesForCrowding(
307
+ valuesMatrixInput: number[][],
308
+ genomeIndexByReference: Map<default, number>,
309
+ objectiveIndex: number,
310
+ leftGenome: default,
311
+ rightGenome: default,
312
+ ): number
327
313
  ```
328
314
 
329
- Builds the index range for interior genomes of a front.
315
+ Comparator used to sort genomes by a specific objective value.
330
316
 
331
- Boundary genomes are excluded because their crowding distance is treated as
332
- infinite.
317
+ The comparator resolves values through the shared matrix so the sorted view
318
+ stays consistent with the same objective data used during dominance and
319
+ frontier construction.
333
320
 
334
321
  Parameters:
335
- - `frontLength` - - Length of the sorted front.
322
+ - `valuesMatrixInput` - - Values matrix.
323
+ - `genomeIndexByReference` - - Lookup map.
324
+ - `objectiveIndex` - - Objective column index.
325
+ - `leftGenome` - - Left genome.
326
+ - `rightGenome` - - Right genome.
336
327
 
337
- Returns: Interior indices excluding boundary genomes.
328
+ Returns: Numeric sort comparison value (ascending).
338
329
 
339
- ### resolveNeighborPair
330
+ ### initializeCrowding
340
331
 
341
332
  ```ts
342
- resolveNeighborPair(
343
- sortedFront: default[],
344
- sortedIndex: number,
345
- ): { previousGenome: default; nextGenome: default; }
333
+ initializeCrowding(
334
+ front: default[],
335
+ ): void
346
336
  ```
347
337
 
348
- Resolves the neighbor genomes for an interior element of a sorted front.
338
+ Initializes crowding-distance annotations for a front.
349
339
 
350
- Parameters:
351
- - `sortedFront` - - Front sorted by objective.
352
- - `sortedIndex` - - Current index in sorted front.
340
+ This sets each genome’s `_moCrowd` to `0`. Later steps accumulate per-
341
+ objective spacing deltas.
353
342
 
354
- Returns: Previous and next neighbor genomes.
343
+ Resetting the field once per front keeps the later per-objective helpers
344
+ additive and makes the final score easy to interpret as one accumulated
345
+ spacing signal across all objectives.
355
346
 
356
- ### applyCrowdingDelta
347
+ Parameters:
348
+ - `front` - - Pareto front.
349
+
350
+ ### markBoundaryCrowding
357
351
 
358
352
  ```ts
359
- applyCrowdingDelta(
360
- currentGenome: NetworkWithMOAnnotations,
361
- previousValue: number,
362
- nextValue: number,
363
- valueRange: number,
353
+ markBoundaryCrowding(
354
+ sortedFront: default[],
364
355
  ): void
365
356
  ```
366
357
 
367
- Applies a normalized crowding-distance delta to a genome.
358
+ Marks the boundary genomes of a sorted front as infinitely crowded.
368
359
 
369
- If the genome’s crowding distance is `Infinity`, it will remain `Infinity`.
370
- This helper only updates when `_moCrowd` is initialized.
371
- That preserves the boundary-solutions rule while still allowing interior
372
- genomes to accumulate spacing contributions across many objectives.
360
+ In NSGA-II style crowding distance, boundary solutions (extremes for the
361
+ objective) are assigned an infinite crowding distance to ensure they are
362
+ always preferred when ranks tie.
363
+
364
+ This preserves the ends of the tradeoff surface. Even when interior genomes
365
+ become densely packed, the extreme solutions remain available to later
366
+ selection because they carry unique objective-space coverage.
373
367
 
374
368
  Parameters:
375
- - `currentGenome` - - Genome to update.
376
- - `previousValue` - - Objective value of previous genome.
377
- - `nextValue` - - Objective value of next genome.
378
- - `valueRange` - - Normalized objective range.
369
+ - `sortedFront` - - Front sorted by the current objective.
379
370
 
380
- ### buildObjectiveIndexRange
371
+ ### resolveBoundaryGenomes
381
372
 
382
373
  ```ts
383
- buildObjectiveIndexRange(
384
- objectiveCount: number,
385
- ): number[]
374
+ resolveBoundaryGenomes(
375
+ sortedFront: default[],
376
+ ): { firstGenome: default; lastGenome: default; } | null
386
377
  ```
387
378
 
388
- Builds a stable objective index range.
389
-
390
- Keeping objective iteration explicit makes the front-level accumulation order
391
- easy to inspect and keeps the per-objective helper signatures small.
379
+ Resolves the boundary (first/last) genomes for a sorted front.
392
380
 
393
381
  Parameters:
394
- - `objectiveCount` - - Number of objectives.
382
+ - `sortedFront` - - Front sorted by objective.
395
383
 
396
- Returns: Objective indices `0..objectiveCount-1`.
384
+ Returns: Boundary genomes, or `null` if the front is empty.
397
385
 
398
- ### shouldSkipCrowdingFront
386
+ ### resolveGenomeIndex
399
387
 
400
388
  ```ts
401
- shouldSkipCrowdingFront(
402
- front: default[],
403
- ): boolean
389
+ resolveGenomeIndex(
390
+ genomeIndexByReference: Map<default, number>,
391
+ genomeItem: default,
392
+ ): number
404
393
  ```
405
394
 
406
- Determines whether crowding-distance processing should be skipped for a
407
- front.
395
+ Resolves a genome’s index using a reference-based map.
408
396
 
409
- Empty fronts are ignored because they carry no genomes to annotate and would
410
- otherwise force needless setup work.
397
+ Crowding works with reordered arrays of genome references, but the value
398
+ matrix still lives in population order. This lookup reconnects those two
399
+ views without copying the matrix.
411
400
 
412
401
  Parameters:
413
- - `front` - - Pareto front.
402
+ - `genomeIndexByReference` - - Lookup map created by
403
+ * {@link buildGenomeIndexByReference} .
404
+ - `genomeItem` - - Genome to resolve.
414
405
 
415
- Returns: `true` if the front should be skipped.
406
+ Returns: The population index of the genome.
416
407
 
417
- ### assignCrowdingForFront
408
+ ### resolveNeighborPair
418
409
 
419
410
  ```ts
420
- assignCrowdingForFront(
421
- front: default[],
422
- valuesMatrixInput: number[][],
423
- genomeIndexByReference: Map<default, number>,
424
- objectiveIndices: number[],
425
- ): void
411
+ resolveNeighborPair(
412
+ sortedFront: default[],
413
+ sortedIndex: number,
414
+ ): { previousGenome: default; nextGenome: default; }
426
415
  ```
427
416
 
428
- Assigns crowding distances for a single front across all objectives.
429
-
430
- This helper keeps the front-local story clear: once the front exists and its
431
- crowding fields are initialized, simply walk the objective columns and let
432
- each one contribute its own spacing signal.
417
+ Resolves the neighbor genomes for an interior element of a sorted front.
433
418
 
434
419
  Parameters:
435
- - `front` - - Pareto front.
436
- - `valuesMatrixInput` - - Values matrix.
437
- - `genomeIndexByReference` - - Lookup map.
438
- - `objectiveIndices` - - Objective indices to process.
420
+ - `sortedFront` - - Front sorted by objective.
421
+ - `sortedIndex` - - Current index in sorted front.
439
422
 
440
- ### applyCrowdingForObjective
423
+ Returns: Previous and next neighbor genomes.
424
+
425
+ ### resolveObjectiveRange
441
426
 
442
427
  ```ts
443
- applyCrowdingForObjective(
444
- front: default[],
445
- valuesMatrixInput: number[][],
446
- genomeIndexByReference: Map<default, number>,
447
- objectiveIndex: number,
448
- ): void
428
+ resolveObjectiveRange(
429
+ minValue: number,
430
+ maxValue: number,
431
+ ): number
449
432
  ```
450
433
 
451
- Applies crowding-distance accumulation for a single objective within a
452
- single front.
434
+ Resolves a non-zero objective range used to normalize crowding deltas.
453
435
 
454
- The work happens in two phases: create the sorted frontier view for the
455
- chosen objective, then protect its boundaries and accumulate interior
456
- spacing. Keeping those phases together makes the per-objective flow easy to
457
- audit in the generated chapter.
436
+ If all genomes have the same objective value, the raw range is `0`. This
437
+ returns `1` in that case to avoid division by zero while still producing a
438
+ well-defined crowding delta of `0`.
439
+ The fallback means a flat objective contributes no spacing signal instead of
440
+ exploding numerically or distorting the remaining objectives.
458
441
 
459
442
  Parameters:
460
- - `front` - - Pareto front.
461
- - `valuesMatrixInput` - - Values matrix.
462
- - `genomeIndexByReference` - - Lookup map.
463
- - `objectiveIndex` - - Objective column index.
443
+ - `minValue` - - Minimum objective value.
444
+ - `maxValue` - - Maximum objective value.
464
445
 
465
- ### buildSortedFrontByObjective
446
+ Returns: Normalized range with a non-zero floor.
447
+
448
+ ### resolveObjectiveRangeFromBoundaries
466
449
 
467
450
  ```ts
468
- buildSortedFrontByObjective(
469
- front: default[],
451
+ resolveObjectiveRangeFromBoundaries(
470
452
  valuesMatrixInput: number[][],
471
453
  genomeIndexByReference: Map<default, number>,
454
+ boundaryGenomes: { firstGenome: default; lastGenome: default; },
472
455
  objectiveIndex: number,
473
- ): default[]
456
+ ): number
474
457
  ```
475
458
 
476
- Builds a copy of the front sorted by the specified objective.
459
+ Resolves the normalized objective range for a front from its boundary
460
+ genomes.
477
461
 
478
- Sorting is ascending by the raw objective value. This ordering is used for
479
- computing neighbor spacing in objective space.
480
- The original front array remains untouched so Pareto-rank grouping stays
481
- stable while each objective gets its own temporary geometric view.
462
+ Because `sortedFront` is sorted by objective, the first and last genomes are
463
+ the extrema used for range normalization.
482
464
 
483
465
  Parameters:
484
- - `front` - - Pareto front.
485
466
  - `valuesMatrixInput` - - Values matrix.
486
467
  - `genomeIndexByReference` - - Lookup map.
468
+ - `boundaryGenomes` - - Boundary genomes for the front.
487
469
  - `objectiveIndex` - - Objective column index.
488
470
 
489
- Returns: Front sorted by objective value.
471
+ Returns: Normalized value range for the objective.
490
472
 
491
- ### compareObjectiveValuesForCrowding
473
+ ### resolveObjectiveValue
492
474
 
493
475
  ```ts
494
- compareObjectiveValuesForCrowding(
476
+ resolveObjectiveValue(
495
477
  valuesMatrixInput: number[][],
496
478
  genomeIndexByReference: Map<default, number>,
479
+ genomeItem: default,
497
480
  objectiveIndex: number,
498
- leftGenome: default,
499
- rightGenome: default,
500
481
  ): number
501
482
  ```
502
483
 
503
- Comparator used to sort genomes by a specific objective value.
484
+ Resolves an objective value for a genome from a values matrix.
504
485
 
505
- The comparator resolves values through the shared matrix so the sorted view
506
- stays consistent with the same objective data used during dominance and
507
- frontier construction.
486
+ This is a convenience helper for working with sorted/reordered views of the
487
+ population while keeping objective values in a dense matrix.
488
+ It lets the crowding pass ask "what is this genome's value on the current
489
+ objective?" without assuming the front is still in population order.
508
490
 
509
491
  Parameters:
510
- - `valuesMatrixInput` - - Values matrix.
511
- - `genomeIndexByReference` - - Lookup map.
492
+ - `valuesMatrixInput` - - Values matrix indexed by population index.
493
+ - `genomeIndexByReference` - - Lookup map from genome reference to index.
494
+ - `genomeItem` - - Genome to resolve.
512
495
  - `objectiveIndex` - - Objective column index.
513
- - `leftGenome` - - Left genome.
514
- - `rightGenome` - - Right genome.
515
496
 
516
- Returns: Numeric sort comparison value (ascending).
497
+ Returns: The objective value for the genome.
498
+
499
+ ### shouldSkipCrowdingFront
500
+
501
+ ```ts
502
+ shouldSkipCrowdingFront(
503
+ front: default[],
504
+ ): boolean
505
+ ```
506
+
507
+ Determines whether crowding-distance processing should be skipped for a
508
+ front.
509
+
510
+ Empty fronts are ignored because they carry no genomes to annotate and would
511
+ otherwise force needless setup work.
512
+
513
+ Parameters:
514
+ - `front` - - Pareto front.
515
+
516
+ Returns: `true` if the front should be skipped.