@reicek/neataptic-ts 0.1.23 → 0.1.25
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/agents/boundary-mapper.agent.md +23 -0
- package/.github/agents/docs-scout.agent.md +27 -1
- package/.github/agents/plan-scout.agent.md +18 -0
- package/.github/agents/solid-split.agent.md +36 -20
- package/.github/copilot-instructions.md +108 -101
- package/.github/skills/educational-docs/SKILL.md +604 -0
- package/.github/skills/educational-docs/assets/external-sources-and-media.md +118 -0
- package/.github/skills/educational-docs/assets/mermaid-diagram-playbook.md +763 -0
- package/.github/skills/educational-docs/assets/readme-tone-model.md +74 -0
- package/.github/skills/educational-docs/assets/source-mapping-checklist.md +60 -0
- package/.github/skills/educational-docs/assets/visual-style-guide.md +165 -0
- package/.github/skills/plan-alignment/SKILL.md +114 -0
- package/.github/skills/solid-split/SKILL.md +426 -0
- package/.github/skills/{solid-split-playbook → solid-split}/assets/docs-checklist.md +8 -2
- package/.github/skills/{solid-split-playbook → solid-split}/assets/split-workflow-checklist.md +2 -2
- package/.github/skills/test-fix-workflow/SKILL.md +105 -0
- package/.github/skills/trace-analyzer-extension/SKILL.md +5 -0
- package/.github/skills/trace-audit-reporting/SKILL.md +9 -0
- package/.github/skills/tracker-handoff/SKILL.md +153 -0
- 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/README.md +84 -1610
- package/eslint.config.mjs +1 -1
- package/jest.config.mjs +1 -3
- package/nn.jpg +0 -0
- package/package.json +37 -32
- package/plans/Architecture_Primitives_Node_Group_Layer.md +2 -0
- package/plans/Browser_Build_and_CDN_Distribution.md +2 -0
- package/plans/Construct_From_Parts_Graph_Assembly.md +2 -0
- package/plans/ES2023 migration +2 -0
- package/plans/Evolution_Training_Interoperability_Contracts.md +2 -0
- package/plans/Flappy_Bird_Folder_Documentation_Pass.md +67 -3
- package/plans/HyperEvoDevoMorphoNEAT.md +2 -0
- package/plans/Interactive_Examples_and_Learning_Path.md +2 -0
- package/plans/Memory_Optimization.md +2 -0
- package/plans/Network_Visualization_Export_Schema.md +2 -0
- package/plans/ONNX_EXPORT_PLAN.md +2 -0
- package/plans/Population_Save_Resume_and_Checkpointing.md +2 -0
- package/plans/Preconfigured_Architectures_MLP_LSTM_GRU_NARX.md +2 -0
- package/plans/README.md +9 -0
- package/plans/Roadmap.md +92 -25
- package/plans/Stable_Activation_Ordering_and_Explicit_IO_Roles.md +2 -0
- package/plans/Standalone_Inference_Export.md +2 -0
- package/plans/Turnkey_Multithread_Evaluation_API.md +2 -0
- package/plans/Worker_Friendly_Network_Serialization_Fastpath.md +2 -0
- package/plans/architecture-solid-split.plans.md +675 -0
- package/plans/asciiMaze-typescript-repair.plans.md +42 -0
- package/plans/methods-docs.plans.md +173 -0
- package/plans/methods-solid-split.plans.md +78 -0
- package/plans/neat-docs.plans.md +68 -0
- package/plans/neat-test-surface-repair.plans.md +38 -0
- package/plans/neat.plans.md +4 -2
- package/plans/src-no-explicit-any-cleanup.plans.md +175 -0
- package/plans/utils-docs.plans.md +44 -0
- package/scripts/assets/theme.css +532 -55
- package/scripts/generate-docs.ts +1491 -114
- package/scripts/mermaid-cli.mjs +158 -0
- package/scripts/render-docs-html.sidebar.ts +513 -0
- package/scripts/render-docs-html.ts +391 -90
- package/src/README.md +2284 -924
- package/src/architecture/README.md +19 -2102
- package/src/architecture/activationArrayPool/README.md +35 -0
- package/src/architecture/activationArrayPool/activationArrayPool.ts +185 -0
- package/src/architecture/activationArrayPool.ts +6 -136
- package/src/architecture/architect/README.md +198 -0
- package/src/architecture/architect/architect.ts +550 -0
- package/src/architecture/architect.ts +5 -641
- package/src/architecture/connection/README.md +260 -0
- package/src/architecture/connection/connection.ts +455 -0
- package/src/architecture/connection.ts +4 -397
- package/src/architecture/docs.order.json +35 -0
- package/src/architecture/group/README.md +193 -0
- package/src/architecture/group/group.ts +506 -0
- package/src/architecture/group.ts +5 -417
- package/src/architecture/layer/README.md +1101 -458
- package/src/architecture/layer/layer.activation.utils.ts +1 -1
- package/src/architecture/layer/layer.connection.utils.ts +2 -2
- package/src/architecture/layer/layer.factory.core.utils.ts +2 -2
- package/src/architecture/layer/layer.factory.experimental.utils.ts +1 -1
- package/src/architecture/layer/layer.factory.normalization.utils.ts +1 -1
- package/src/architecture/layer/layer.factory.recurrent.utils.ts +3 -7
- package/src/architecture/layer/layer.guard.utils.ts +1 -1
- package/src/architecture/layer/layer.ts +488 -0
- package/src/architecture/layer/layer.utils.types.ts +2 -2
- package/src/architecture/layer.ts +4 -470
- package/src/architecture/network/README.md +2559 -1276
- package/src/architecture/network/activate/README.md +1001 -522
- package/src/architecture/network/activate/network.activate.contexts.utils.ts +1 -1
- package/src/architecture/network/activate/network.activate.core.utils.ts +4 -4
- package/src/architecture/network/activate/network.activate.notrace.utils.ts +1 -1
- package/src/architecture/network/activate/network.activate.raw.utils.ts +1 -1
- package/src/architecture/network/activate/network.activate.utils.ts +3 -3
- package/src/architecture/network/activate/network.activate.utils.types.ts +2 -2
- package/src/architecture/network/bootstrap/README.md +207 -0
- package/src/architecture/network/bootstrap/network.bootstrap.utils.ts +295 -0
- package/src/architecture/network/connect/README.md +146 -60
- package/src/architecture/network/connect/network.connect.create.utils.ts +1 -1
- package/src/architecture/network/connect/network.connect.remove.utils.ts +1 -1
- package/src/architecture/network/connect/network.connect.utils.ts +2 -2
- package/src/architecture/network/deterministic/README.md +236 -113
- package/src/architecture/network/deterministic/network.deterministic.lifecycle.utils.ts +1 -1
- package/src/architecture/network/deterministic/network.deterministic.setup.utils.ts +2 -2
- package/src/architecture/network/deterministic/network.deterministic.state.utils.ts +2 -2
- package/src/architecture/network/deterministic/network.deterministic.utils.ts +2 -2
- package/src/architecture/network/docs.order.json +8 -0
- package/src/architecture/network/evolve/README.md +550 -261
- package/src/architecture/network/evolve/network.evolve.finalize.utils.ts +1 -1
- package/src/architecture/network/evolve/network.evolve.fitness.utils.ts +1 -1
- package/src/architecture/network/evolve/network.evolve.loop.utils.ts +1 -1
- package/src/architecture/network/evolve/network.evolve.setup.utils.ts +1 -1
- package/src/architecture/network/evolve/network.evolve.utils.ts +1 -1
- package/src/architecture/network/gating/README.md +221 -111
- package/src/architecture/network/gating/network.gating.gate.utils.ts +1 -1
- package/src/architecture/network/gating/network.gating.remove.utils.ts +2 -2
- package/src/architecture/network/gating/network.gating.utils.ts +2 -2
- package/src/architecture/network/genetic/README.md +624 -287
- package/src/architecture/network/genetic/network.genetic.setup.utils.ts +2 -2
- package/src/architecture/network/genetic/network.genetic.utils.ts +1 -1
- package/src/architecture/network/mutate/README.md +1248 -653
- package/src/architecture/network/mutate/network.mutate.dispatch.utils.ts +1 -1
- package/src/architecture/network/mutate/network.mutate.handlers.utils.ts +15 -42
- package/src/architecture/network/mutate/network.mutate.public.utils.ts +60 -0
- package/src/architecture/network/mutate/network.mutate.utils.ts +1 -1
- package/src/architecture/network/mutate/network.mutate.utils.types.ts +0 -5
- package/src/architecture/network/network.ts +1153 -0
- package/src/architecture/network/network.types.ts +102 -8
- package/src/architecture/network/network.utils.ts +22 -15
- package/src/architecture/network/onnx/README.md +1039 -3171
- package/src/architecture/network/onnx/docs.order.json +13 -0
- package/src/architecture/network/onnx/export/README.md +1691 -0
- package/src/architecture/network/onnx/export/layers/README.md +1121 -0
- package/src/architecture/network/onnx/{network.onnx.export-conv.utils.ts → export/layers/network.onnx.export-conv.utils.ts} +35 -7
- package/src/architecture/network/onnx/{network.onnx.export-dense.utils.ts → export/layers/network.onnx.export-dense.utils.ts} +42 -9
- package/src/architecture/network/onnx/{network.onnx.export-layer-common.utils.ts → export/layers/network.onnx.export-layer-common.utils.ts} +22 -16
- package/src/architecture/network/onnx/{network.onnx.export-layer-graph.utils.ts → export/layers/network.onnx.export-layer-graph.utils.ts} +51 -4
- package/src/architecture/network/onnx/{network.onnx.export-recurrent.utils.ts → export/layers/network.onnx.export-recurrent.utils.ts} +27 -6
- package/src/architecture/network/onnx/{network.onnx.export-build.utils.ts → export/network.onnx.export-build.utils.ts} +5 -5
- package/src/architecture/network/onnx/{network.onnx.export-flow.utils.ts → export/network.onnx.export-flow.utils.ts} +3 -2
- package/src/architecture/network/onnx/{network.onnx.export-orchestrators.utils.ts → export/network.onnx.export-orchestrators.utils.ts} +9 -5
- package/src/architecture/network/onnx/{network.onnx.export-postprocess.utils.ts → export/network.onnx.export-postprocess.utils.ts} +11 -7
- package/src/architecture/network/onnx/{network.onnx.export-setup.utils.ts → export/network.onnx.export-setup.utils.ts} +9 -7
- package/src/architecture/network/onnx/export/network.onnx.export.types.ts +734 -0
- package/src/architecture/network/onnx/import/README.md +1515 -0
- package/src/architecture/network/onnx/import/docs.order.json +15 -0
- package/src/architecture/network/onnx/{network.onnx.import-activations.utils.ts → import/network.onnx.import-activations.utils.ts} +3 -3
- package/src/architecture/network/onnx/{network.onnx.import-flow.utils.ts → import/network.onnx.import-flow.utils.ts} +25 -5
- package/src/architecture/network/onnx/import/network.onnx.import-fused-recurrent.types.ts +101 -0
- package/src/architecture/network/onnx/{network.onnx.import-fused-recurrent.utils.ts → import/network.onnx.import-fused-recurrent.utils.ts} +10 -6
- package/src/architecture/network/onnx/import/network.onnx.import-orchestrators.types.ts +74 -0
- package/src/architecture/network/onnx/{network.onnx.import-orchestrators.utils.ts → import/network.onnx.import-orchestrators.utils.ts} +9 -7
- package/src/architecture/network/onnx/import/network.onnx.import-weights.types.ts +189 -0
- package/src/architecture/network/onnx/{network.onnx.import-weights.utils.ts → import/network.onnx.import-weights.utils.ts} +11 -7
- package/src/architecture/network/onnx/import/network.onnx.runtime-load.types.ts +52 -0
- package/src/architecture/network/onnx/{network.onnx.runtime-load.utils.ts → import/network.onnx.runtime-load.utils.ts} +2 -2
- package/src/architecture/network/onnx/network.onnx.layer-analysis.utils.ts +1 -1
- package/src/architecture/network/onnx/network.onnx.ts +20 -5
- package/src/architecture/network/onnx/network.onnx.utils.ts +32 -11
- package/src/architecture/network/onnx/network.onnx.utils.types.ts +172 -1195
- package/src/architecture/network/onnx/schema/README.md +120 -0
- package/src/architecture/network/onnx/schema/network.onnx.schema.types.ts +202 -0
- package/src/architecture/network/prune/README.md +453 -210
- package/src/architecture/network/prune/network.prune.evolutionary.utils.ts +1 -1
- package/src/architecture/network/prune/network.prune.regrowth.utils.ts +1 -1
- package/src/architecture/network/prune/network.prune.schedule.utils.ts +1 -1
- package/src/architecture/network/prune/network.prune.sparsity.utils.ts +1 -1
- package/src/architecture/network/prune/network.prune.utils.ts +16 -19
- package/src/architecture/network/remove/README.md +267 -132
- package/src/architecture/network/remove/network.remove.finalize.utils.ts +1 -1
- package/src/architecture/network/remove/network.remove.reconnect.utils.ts +1 -1
- package/src/architecture/network/remove/network.remove.snapshot.utils.ts +1 -1
- package/src/architecture/network/remove/network.remove.utils.ts +2 -2
- package/src/architecture/network/remove/network.remove.utils.types.ts +1 -1
- package/src/architecture/network/remove/network.remove.validation.utils.ts +1 -1
- package/src/architecture/network/runtime/README.md +332 -0
- package/src/architecture/network/runtime/network.runtime.controls.utils.ts +301 -0
- package/src/architecture/network/runtime/network.runtime.diagnostics.utils.ts +150 -0
- package/src/architecture/network/serialize/README.md +903 -359
- package/src/architecture/network/serialize/network.serialize.activation.utils.ts +1 -1
- package/src/architecture/network/serialize/network.serialize.public.utils.ts +28 -0
- package/src/architecture/network/serialize/network.serialize.runtime.utils.ts +1 -1
- package/src/architecture/network/serialize/network.serialize.utils.ts +1 -1
- package/src/architecture/network/slab/README.md +907 -492
- package/src/architecture/network/slab/network.slab.activate.utils.ts +1 -1
- package/src/architecture/network/slab/network.slab.adjacency.helpers.utils.ts +1 -1
- package/src/architecture/network/slab/network.slab.fast-path.helpers.utils.ts +2 -2
- package/src/architecture/network/slab/network.slab.rebuild.helpers.utils.ts +2 -2
- package/src/architecture/network/slab/network.slab.shared.helpers.utils.ts +1 -1
- package/src/architecture/network/slab/network.slab.utils.ts +3 -3
- package/src/architecture/network/slab/network.slab.utils.types.ts +1 -1
- package/src/architecture/network/slab/network.slab.view.utils.ts +1 -1
- package/src/architecture/network/standalone/README.md +401 -161
- package/src/architecture/network/standalone/network.standalone.utils.setup.ts +1 -1
- package/src/architecture/network/standalone/network.standalone.utils.ts +1 -1
- package/src/architecture/network/stats/README.md +152 -64
- package/src/architecture/network/stats/network.stats.test.utils.ts +1 -1
- package/src/architecture/network/stats/network.stats.utils.ts +5 -4
- package/src/architecture/network/topology/README.md +773 -280
- package/src/architecture/network/topology/network.topology.architecture.utils.ts +55 -1
- package/src/architecture/network/topology/network.topology.contract.utils.ts +78 -0
- package/src/architecture/network/topology/network.topology.factory.utils.ts +5 -1
- package/src/architecture/network/topology/network.topology.utils.ts +19 -3
- package/src/architecture/network/topology/network.topology.utils.types.ts +1 -1
- package/src/architecture/network/training/README.md +385 -158
- package/src/architecture/network/training/network.training.backprop.utils.ts +1 -1
- package/src/architecture/network/training/network.training.finalize.utils.ts +1 -1
- package/src/architecture/network/training/network.training.gradient-clip.utils.ts +1 -1
- package/src/architecture/network/training/network.training.loop.utils.ts +1 -1
- package/src/architecture/network/training/network.training.utils.ts +1 -1
- package/src/architecture/network/training/network.training.utils.types.ts +1 -1
- package/src/architecture/network.ts +18 -1744
- package/src/architecture/node/README.md +464 -0
- package/src/architecture/node/node.ts +1338 -0
- package/src/architecture/node.ts +4 -1317
- package/src/architecture/nodePool/README.md +78 -0
- package/src/architecture/nodePool/nodePool.ts +169 -0
- package/src/architecture/nodePool.ts +12 -150
- package/src/architecture/onnx.ts +7 -0
- package/src/methods/README.md +533 -982
- package/src/methods/activation/README.md +639 -0
- package/src/methods/{activation.ts → activation/activation.ts} +104 -11
- package/src/methods/{activation.utils.ts → activation/activation.utils.ts} +147 -1
- package/src/methods/activation/docs.order.json +7 -0
- package/src/methods/connection/README.md +97 -0
- package/src/methods/connection/connection.ts +100 -0
- package/src/methods/cost/README.md +509 -0
- package/src/methods/{cost.ts → cost/cost.ts} +56 -0
- package/src/methods/{cost.utils.ts → cost/cost.utils.ts} +1 -1
- package/src/methods/cost/docs.order.json +7 -0
- package/src/methods/crossover/README.md +52 -0
- package/src/methods/{crossover.ts → crossover/crossover.ts} +56 -0
- package/src/methods/docs.order.json +16 -0
- package/src/methods/gating/README.md +52 -0
- package/src/methods/gating/gating.ts +106 -0
- package/src/methods/methods.ts +58 -8
- package/src/methods/mutation/README.md +123 -0
- package/src/methods/{mutation.ts → mutation/mutation.ts} +87 -7
- package/src/methods/rate/README.md +490 -0
- package/src/methods/rate/docs.order.json +7 -0
- package/src/methods/{rate.ts → rate/rate.ts} +85 -4
- package/src/methods/{rate.utils.ts → rate/rate.utils.ts} +3 -3
- package/src/methods/selection/README.md +60 -0
- package/src/methods/{selection.ts → selection/selection.ts} +64 -0
- package/src/multithreading/README.md +281 -95
- package/src/multithreading/multi.ts +2 -2
- package/src/multithreading/workers/README.md +8 -6
- package/src/multithreading/workers/browser/README.md +21 -11
- package/src/multithreading/workers/node/README.md +52 -20
- package/src/neat/README.md +397 -10476
- package/src/neat/adaptive/README.md +281 -0
- package/src/neat/adaptive/acceptance/README.md +361 -0
- package/src/neat/adaptive/acceptance/adaptive.acceptance.ts +46 -0
- package/src/neat/{neat.adaptive.minimal-criterion.utils.ts → adaptive/acceptance/adaptive.minimal-criterion.utils.ts} +59 -5
- package/src/neat/{neat.adaptive.ts → adaptive/adaptive.ts} +103 -54
- package/src/neat/adaptive/complexity/README.md +519 -0
- package/src/neat/adaptive/complexity/adaptive.complexity.ts +42 -0
- package/src/neat/{neat.adaptive.complexity.utils.ts → adaptive/complexity/adaptive.complexity.utils.ts} +72 -10
- package/src/neat/{neat.adaptive.phases.utils.ts → adaptive/complexity/adaptive.phases.utils.ts} +27 -4
- package/src/neat/adaptive/core/README.md +587 -0
- package/src/neat/adaptive/core/adaptive.core.constants.ts +160 -0
- package/src/neat/adaptive/core/adaptive.core.ts +33 -0
- package/src/neat/{neat.adaptive.shared.ts → adaptive/core/adaptive.core.types.ts} +114 -134
- package/src/neat/adaptive/lineage/README.md +369 -0
- package/src/neat/{neat.adaptive.ancestor-uniqueness.utils.ts → adaptive/lineage/adaptive.ancestor-uniqueness.utils.ts} +59 -6
- package/src/neat/adaptive/lineage/adaptive.lineage.ts +49 -0
- package/src/neat/adaptive/mutation/README.md +754 -0
- package/src/neat/adaptive/mutation/adaptive.mutation.ts +51 -0
- package/src/neat/{neat.adaptive.mutation.utils.ts → adaptive/mutation/adaptive.mutation.utils.ts} +98 -4
- package/src/neat/{neat.adaptive.operator.utils.ts → adaptive/mutation/adaptive.operator.utils.ts} +30 -3
- package/src/neat/cache/README.md +156 -0
- package/src/neat/cache/cache.ts +79 -0
- package/src/neat/cache/core/README.md +151 -0
- package/src/neat/cache/core/cache.constants.ts +70 -0
- package/src/neat/cache/core/cache.core.ts +89 -0
- package/src/neat/compat/README.md +186 -0
- package/src/neat/compat/compat.ts +222 -0
- package/src/neat/compat/core/README.md +257 -0
- package/src/neat/{neat.compat.utils.ts → compat/core/compat.core.ts} +92 -102
- package/src/neat/compat/core/compat.types.ts +122 -0
- package/src/neat/diversity/README.md +160 -0
- package/src/neat/diversity/core/README.md +242 -0
- package/src/neat/diversity/core/diversity.core.ts +278 -0
- package/src/neat/diversity/core/diversity.types.ts +114 -0
- package/src/neat/diversity/diversity.ts +170 -0
- package/src/neat/evaluate/README.md +268 -0
- package/src/neat/evaluate/auto-distance/README.md +242 -0
- package/src/neat/evaluate/auto-distance/evaluate.auto-distance.ts +328 -0
- package/src/neat/evaluate/entropy-compat/README.md +128 -0
- package/src/neat/evaluate/entropy-compat/evaluate.entropy-compat.ts +163 -0
- package/src/neat/evaluate/entropy-sharing/README.md +147 -0
- package/src/neat/evaluate/entropy-sharing/evaluate.entropy-sharing.ts +179 -0
- package/src/neat/evaluate/evaluate.ts +158 -0
- package/src/neat/evaluate/fitness/README.md +90 -0
- package/src/neat/evaluate/fitness/evaluate.fitness.ts +104 -0
- package/src/neat/evaluate/novelty/README.md +281 -0
- package/src/neat/evaluate/novelty/evaluate.novelty.ts +348 -0
- package/src/neat/evaluate/objectives/README.md +112 -0
- package/src/neat/evaluate/objectives/evaluate.objectives.ts +121 -0
- package/src/neat/evaluate/shared/README.md +248 -0
- package/src/neat/evaluate/shared/evaluate.constants.ts +191 -0
- package/src/neat/{neat.evaluate.utils.types.ts → evaluate/shared/evaluate.types.ts} +112 -14
- package/src/neat/evaluate/speciation/README.md +138 -0
- package/src/neat/evaluate/speciation/evaluate.speciation.ts +144 -0
- package/src/neat/evolve/README.md +360 -0
- package/src/neat/evolve/adaptive/README.md +219 -0
- package/src/neat/evolve/adaptive/evolve.adaptive.utils.ts +324 -0
- package/src/neat/{neat.evolve.ts → evolve/evolve.ts} +204 -80
- package/src/neat/{neat.evolve.types.ts → evolve/evolve.types.ts} +92 -5
- package/src/neat/evolve/objectives/README.md +204 -0
- package/src/neat/{neat.evolve.objectives.utils.ts → evolve/objectives/evolve.objectives.utils.ts} +129 -24
- package/src/neat/evolve/offspring/README.md +145 -0
- package/src/neat/evolve/offspring/evolve.offspring.constants.ts +44 -0
- package/src/neat/evolve/offspring/evolve.offspring.utils.ts +163 -0
- package/src/neat/evolve/population/README.md +477 -0
- package/src/neat/{neat.evolve.population.utils.ts → evolve/population/evolve.population.utils.ts} +258 -40
- package/src/neat/evolve/runtime/README.md +188 -0
- package/src/neat/evolve/runtime/evolve.runtime.utils.ts +215 -0
- package/src/neat/evolve/speciation/README.md +227 -0
- package/src/neat/evolve/speciation/evolve.speciation.utils.ts +359 -0
- package/src/neat/evolve/telemetry/README.md +133 -0
- package/src/neat/evolve/telemetry/evolve.telemetry.utils.ts +143 -0
- package/src/neat/evolve/warnings/README.md +43 -0
- package/src/neat/evolve/warnings/evolve.warnings.utils.ts +48 -0
- package/src/neat/export/README.md +289 -0
- package/src/neat/{neat.export.ts → export/neat.export.ts} +127 -45
- package/src/neat/harness/README.md +136 -0
- package/src/neat/harness/neat.harness.types.ts +144 -0
- package/src/neat/helpers/README.md +232 -0
- package/src/neat/helpers/neat.helpers.ts +408 -0
- package/src/neat/init/README.md +140 -0
- package/src/neat/init/neat.init.ts +375 -0
- package/src/neat/lineage/README.md +141 -0
- package/src/neat/lineage/core/README.md +292 -0
- package/src/neat/lineage/core/lineage.core.ts +372 -0
- package/src/neat/lineage/core/lineage.types.ts +105 -0
- package/src/neat/lineage/lineage.ts +163 -0
- package/src/neat/maintenance/README.md +78 -0
- package/src/neat/maintenance/facade/README.md +143 -0
- package/src/neat/maintenance/facade/maintenance.facade.ts +168 -0
- package/src/neat/maintenance/maintenance.ts +80 -0
- package/src/neat/multiobjective/README.md +90 -0
- package/src/neat/multiobjective/archive/README.md +81 -0
- package/src/neat/multiobjective/archive/multiobjective.archive.ts +100 -0
- package/src/neat/multiobjective/category/README.md +208 -0
- package/src/neat/{neat.multiobjective.category.utils.ts → multiobjective/category/multiobjective.category.ts} +109 -18
- package/src/neat/multiobjective/crowding/README.md +516 -0
- package/src/neat/{neat.multiobjective.crowding.utils.ts → multiobjective/crowding/multiobjective.crowding.ts} +105 -3
- package/src/neat/multiobjective/dominance/README.md +426 -0
- package/src/neat/{neat.multiobjective.dominance.utils.ts → multiobjective/dominance/multiobjective.dominance.ts} +110 -4
- package/src/neat/multiobjective/fronts/README.md +222 -0
- package/src/neat/{neat.multiobjective.fronts.utils.ts → multiobjective/fronts/multiobjective.fronts.ts} +82 -4
- package/src/neat/multiobjective/metrics/README.md +140 -0
- package/src/neat/multiobjective/metrics/multiobjective.metrics.ts +153 -0
- package/src/neat/multiobjective/multiobjective.ts +140 -0
- package/src/neat/multiobjective/objectives/README.md +113 -0
- package/src/neat/{neat.multiobjective.objectives.utils.ts → multiobjective/objectives/multiobjective.objectives.ts} +42 -2
- package/src/neat/multiobjective/shared/README.md +85 -0
- package/src/neat/multiobjective/shared/multiobjective.types.ts +155 -0
- package/src/neat/mutation/README.md +282 -0
- package/src/neat/mutation/add-conn/README.md +271 -0
- package/src/neat/{neat.mutation.add-conn.utils.ts → mutation/add-conn/mutation.add-conn.ts} +87 -6
- package/src/neat/mutation/add-node/README.md +293 -0
- package/src/neat/{neat.mutation.add-node.utils.ts → mutation/add-node/mutation.add-node.ts} +97 -8
- package/src/neat/mutation/flow/README.md +379 -0
- package/src/neat/{neat.mutation.flow.utils.ts → mutation/flow/mutation.flow.ts} +147 -6
- package/src/neat/mutation/mutation.ts +482 -0
- package/src/neat/mutation/repair/README.md +497 -0
- package/src/neat/{neat.mutation.dead-ends.utils.ts → mutation/repair/mutation.dead-ends.ts} +75 -9
- package/src/neat/{neat.mutation.min-hidden.utils.ts → mutation/repair/mutation.min-hidden.ts} +73 -7
- package/src/neat/mutation/select/README.md +285 -0
- package/src/neat/{neat.mutation.select.utils.ts → mutation/select/mutation.select.ts} +102 -4
- package/src/neat/mutation/shared/README.md +109 -0
- package/src/neat/{neat.mutation.types.ts → mutation/shared/mutation.types.ts} +77 -4
- package/src/neat/neat.constants.ts +116 -7
- package/src/neat/neat.defaults.constants.ts +183 -0
- package/src/neat/neat.diversity.ts +5 -53
- package/src/neat/neat.lineage.ts +2 -134
- package/src/neat/neat.types.ts +59 -791
- package/src/neat/objectives/README.md +142 -0
- package/src/neat/objectives/core/README.md +288 -0
- package/src/neat/objectives/core/objectives.core.ts +273 -0
- package/src/neat/objectives/core/objectives.types.ts +63 -0
- package/src/neat/objectives/objectives.ts +175 -0
- package/src/neat/pruning/README.md +120 -0
- package/src/neat/pruning/core/README.md +420 -0
- package/src/neat/pruning/core/pruning.core.ts +410 -0
- package/src/neat/pruning/core/pruning.types.ts +104 -0
- package/src/neat/pruning/facade/README.md +121 -0
- package/src/neat/pruning/facade/pruning.facade.ts +124 -0
- package/src/neat/pruning/pruning.ts +192 -0
- package/src/neat/rng/README.md +323 -0
- package/src/neat/rng/core/README.md +503 -0
- package/src/neat/rng/core/rng.constants.ts +44 -0
- package/src/neat/rng/core/rng.core.ts +27 -0
- package/src/neat/rng/core/rng.types.ts +87 -0
- package/src/neat/rng/core/rng.utils.ts +238 -0
- package/src/neat/rng/facade/README.md +162 -0
- package/src/neat/rng/facade/rng.facade.ts +150 -0
- package/src/neat/rng/rng.ts +88 -0
- package/src/neat/selection/README.md +307 -0
- package/src/neat/selection/core/README.md +546 -0
- package/src/neat/selection/core/selection.core.ts +580 -0
- package/src/neat/selection/core/selection.types.ts +120 -0
- package/src/neat/selection/facade/README.md +180 -0
- package/src/neat/selection/facade/selection.facade.ts +177 -0
- package/src/neat/selection/selection.ts +255 -0
- package/src/neat/shared/README.md +361 -0
- package/src/neat/shared/neat.shared.types.ts +1120 -0
- package/src/neat/speciation/README.md +171 -0
- package/src/neat/speciation/assignment/README.md +274 -0
- package/src/neat/speciation/assignment/docs.order.json +12 -0
- package/src/neat/speciation/assignment/speciation.assignment.utils.ts +325 -0
- package/src/neat/speciation/history/README.md +254 -0
- package/src/neat/speciation/history/docs.order.json +12 -0
- package/src/neat/speciation/history/speciation.history.utils.ts +449 -0
- package/src/neat/speciation/shared/README.md +313 -0
- package/src/neat/speciation/shared/docs.order.json +31 -0
- package/src/neat/speciation/shared/speciation.shared.ts +393 -0
- package/src/neat/speciation/sharing/README.md +131 -0
- package/src/neat/speciation/sharing/speciation.sharing.utils.ts +287 -0
- package/src/neat/speciation/speciation.ts +243 -0
- package/src/neat/speciation/threshold/README.md +189 -0
- package/src/neat/speciation/threshold/speciation.threshold.utils.ts +310 -0
- package/src/neat/species/README.md +113 -0
- package/src/neat/species/core/README.md +92 -0
- package/src/neat/species/core/augmentation/README.md +60 -0
- package/src/neat/species/core/augmentation/species.core.augmentation.ts +109 -0
- package/src/neat/species/core/shared/README.md +92 -0
- package/src/neat/species/core/shared/species.core.shared.ts +154 -0
- package/src/neat/species/core/species.core.ts +92 -0
- package/src/neat/species/history/README.md +102 -0
- package/src/neat/species/history/context/README.md +86 -0
- package/src/neat/species/history/context/species.history.context.ts +112 -0
- package/src/neat/species/history/read/README.md +74 -0
- package/src/neat/species/history/read/species.history.read.ts +86 -0
- package/src/neat/species/history/species.history.ts +105 -0
- package/src/neat/species/species.ts +114 -0
- package/src/neat/species/stats/README.md +91 -0
- package/src/neat/species/stats/species.stats.ts +109 -0
- package/src/neat/telemetry/README.md +44 -0
- package/src/neat/telemetry/accessors/README.md +183 -0
- package/src/neat/telemetry/accessors/telemetry.accessors.ts +168 -0
- package/src/neat/telemetry/exports/README.md +600 -0
- package/src/neat/telemetry/exports/telemetry.exports.ts +549 -0
- package/src/neat/{neat.telemetry.exports.utils.ts → telemetry/exports/telemetry.exports.utils.ts} +76 -2
- package/src/neat/telemetry/facade/README.md +582 -0
- package/src/neat/telemetry/facade/archive/README.md +173 -0
- package/src/neat/telemetry/facade/archive/telemetry.facade.archive.ts +175 -0
- package/src/neat/telemetry/facade/buffer/README.md +141 -0
- package/src/neat/telemetry/facade/buffer/telemetry.facade.buffer.ts +132 -0
- package/src/neat/telemetry/facade/lineage/README.md +87 -0
- package/src/neat/telemetry/facade/lineage/telemetry.facade.lineage.ts +93 -0
- package/src/neat/telemetry/facade/novelty/README.md +79 -0
- package/src/neat/telemetry/facade/novelty/telemetry.facade.novelty.ts +70 -0
- package/src/neat/telemetry/facade/objectives/README.md +161 -0
- package/src/neat/telemetry/facade/objectives/telemetry.facade.objectives.ts +163 -0
- package/src/neat/telemetry/facade/operator-stats/README.md +62 -0
- package/src/neat/telemetry/facade/operator-stats/telemetry.facade.operator-stats.ts +63 -0
- package/src/neat/telemetry/facade/runtime/README.md +96 -0
- package/src/neat/telemetry/facade/runtime/telemetry.facade.runtime.ts +104 -0
- package/src/neat/telemetry/facade/species/README.md +165 -0
- package/src/neat/telemetry/facade/species/telemetry.facade.species.ts +171 -0
- package/src/neat/telemetry/facade/telemetry.facade.ts +555 -0
- package/src/neat/telemetry/metrics/README.md +1717 -0
- package/src/neat/{neat.telemetry.complexity.utils.ts → telemetry/metrics/telemetry.metrics.complexity.ts} +5 -2
- package/src/neat/{neat.telemetry.diversity.utils.ts → telemetry/metrics/telemetry.metrics.diversity.ts} +2 -2
- package/src/neat/{neat.telemetry.entropy.utils.ts → telemetry/metrics/telemetry.metrics.entropy.ts} +1 -1
- package/src/neat/{neat.telemetry.lineage.utils.ts → telemetry/metrics/telemetry.metrics.lineage.ts} +4 -4
- package/src/neat/{neat.telemetry.objectives.utils.ts → telemetry/metrics/telemetry.metrics.objectives.ts} +3 -3
- package/src/neat/{neat.telemetry.operator.utils.ts → telemetry/metrics/telemetry.metrics.operator.ts} +4 -1
- package/src/neat/{neat.telemetry.performance.utils.ts → telemetry/metrics/telemetry.metrics.performance.ts} +2 -2
- package/src/neat/{neat.telemetry.rng.utils.ts → telemetry/metrics/telemetry.metrics.rng.ts} +2 -2
- package/src/neat/{neat.telemetry.selection.utils.ts → telemetry/metrics/telemetry.metrics.selection.ts} +3 -3
- package/src/neat/telemetry/metrics/telemetry.metrics.ts +60 -0
- package/src/neat/telemetry/recorder/README.md +220 -0
- package/src/neat/{neat.telemetry.ts → telemetry/recorder/telemetry.recorder.ts} +91 -30
- package/src/neat/telemetry/runtime/README.md +106 -0
- package/src/neat/telemetry/runtime/telemetry.runtime.ts +119 -0
- package/src/neat/telemetry/telemetry.ts +46 -0
- package/src/neat/telemetry/types/README.md +85 -0
- package/src/neat/telemetry/types/telemetry.types.ts +121 -0
- package/src/neat/topology-intent/README.md +225 -0
- package/src/neat/topology-intent/neat.topology-intent.ts +305 -0
- package/src/neat.ts +710 -405
- package/src/utils/README.md +367 -114
- package/src/utils/memory.ts +74 -10
- package/src/utils/memory.utils.ts +77 -4
- package/test/architecture/node.test.ts +2 -2
- package/test/examples/README.md +168 -0
- package/test/examples/asciiMaze/README.md +263 -253
- package/test/examples/asciiMaze/asciiMaze.e2e.test.ts +4 -3
- package/test/examples/asciiMaze/browser-entry/README.md +316 -57
- package/test/examples/asciiMaze/browser-entry/browser-entry.globals.services.ts +7 -4
- package/test/examples/asciiMaze/browser-entry/browser-entry.host.services.ts +1 -1
- package/test/examples/asciiMaze/browser-entry/browser-entry.ts +16 -0
- package/test/examples/asciiMaze/browser-entry.ts +5 -0
- package/test/examples/asciiMaze/dashboardManager/README.md +182 -101
- package/test/examples/asciiMaze/dashboardManager/archive/README.md +25 -1
- package/test/examples/asciiMaze/dashboardManager/archive/dashboardManager.archive.services.ts +17 -0
- package/test/examples/asciiMaze/dashboardManager/dashboardManager.types.ts +1 -1
- package/test/examples/asciiMaze/dashboardManager/live/README.md +28 -1
- package/test/examples/asciiMaze/dashboardManager/live/dashboardManager.live.services.ts +22 -0
- package/test/examples/asciiMaze/dashboardManager/telemetry/README.md +60 -21
- package/test/examples/asciiMaze/dashboardManager/telemetry/dashboardManager.telemetry.services.ts +20 -0
- package/test/examples/asciiMaze/evolutionEngine/README.md +3471 -567
- package/test/examples/asciiMaze/evolutionEngine/engineState.types.ts +10 -3
- package/test/examples/asciiMaze/evolutionEngine/evolutionEngine.constants.ts +95 -0
- package/test/examples/asciiMaze/evolutionEngine/evolutionEngine.services.ts +93 -0
- package/test/examples/asciiMaze/evolutionEngine/evolutionEngine.types.ts +74 -5
- package/test/examples/asciiMaze/evolutionEngine/evolutionEngine.utils.ts +123 -0
- package/test/examples/asciiMaze/evolutionEngine/evolutionLoop.ts +58 -86
- package/test/examples/asciiMaze/evolutionEngine/neatConfiguration.ts +29 -17
- package/test/examples/asciiMaze/evolutionEngine/networkInspection.ts +19 -38
- package/test/examples/asciiMaze/evolutionEngine/optionsAndSetup.ts +96 -36
- package/test/examples/asciiMaze/evolutionEngine/populationDynamics.ts +194 -180
- package/test/examples/asciiMaze/evolutionEngine/populationPruning.ts +47 -54
- package/test/examples/asciiMaze/evolutionEngine/sampling.ts +18 -3
- package/test/examples/asciiMaze/evolutionEngine/telemetryMetrics.ts +24 -17
- package/test/examples/asciiMaze/evolutionEngine/trainingWarmStart.ts +83 -52
- package/test/examples/asciiMaze/evolutionEngine.ts +119 -231
- package/test/examples/asciiMaze/index.ts +30 -7
- package/test/examples/asciiMaze/mazeMovement/README.md +221 -108
- package/test/examples/asciiMaze/mazeMovement/finalization/README.md +44 -17
- package/test/examples/asciiMaze/mazeMovement/finalization/mazeMovement.finalization.ts +13 -1
- package/test/examples/asciiMaze/mazeMovement/policy/README.md +98 -46
- package/test/examples/asciiMaze/mazeMovement/policy/mazeMovement.policy.ts +13 -2
- package/test/examples/asciiMaze/mazeMovement/runtime/README.md +93 -43
- package/test/examples/asciiMaze/mazeMovement/runtime/mazeMovement.runtime.ts +13 -2
- package/test/examples/asciiMaze/mazeMovement/shaping/README.md +115 -44
- package/test/examples/asciiMaze/mazeMovement/shaping/mazeMovement.shaping.ts +13 -2
- package/test/examples/asciiMaze/mazeVisualization.ts +2 -2
- package/test/examples/flappy_bird/README.md +201 -136
- package/test/examples/flappy_bird/browser-entry/README.md +891 -553
- package/test/examples/flappy_bird/browser-entry/browser-entry.observation.utils.ts +0 -1
- package/test/examples/flappy_bird/browser-entry/browser-entry.ts +24 -0
- package/test/examples/flappy_bird/browser-entry/browser-entry.types.ts +20 -0
- package/test/examples/flappy_bird/browser-entry/browser-entry.worker.types.ts +1 -0
- package/test/examples/flappy_bird/browser-entry/docs.order.json +15 -0
- package/test/examples/flappy_bird/browser-entry/host/README.md +296 -134
- package/test/examples/flappy_bird/browser-entry/host/docs.order.json +15 -0
- package/test/examples/flappy_bird/browser-entry/host/host.ts +13 -9
- package/test/examples/flappy_bird/browser-entry/host/resize/README.md +278 -119
- package/test/examples/flappy_bird/browser-entry/host/resize/docs.order.json +10 -0
- package/test/examples/flappy_bird/browser-entry/host/resize/host.resize.service.ts +18 -3
- package/test/examples/flappy_bird/browser-entry/network-view/README.md +401 -190
- package/test/examples/flappy_bird/browser-entry/network-view/docs.order.json +12 -0
- package/test/examples/flappy_bird/browser-entry/network-view/network-view.ts +31 -53
- package/test/examples/flappy_bird/browser-entry/playback/README.md +844 -450
- package/test/examples/flappy_bird/browser-entry/playback/background/README.md +324 -117
- package/test/examples/flappy_bird/browser-entry/playback/background/docs.order.json +16 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/ground-grid/README.md +935 -497
- package/test/examples/flappy_bird/browser-entry/playback/background/ground-grid/docs.order.json +22 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/ground-grid/playback.background.ground-grid.geometry.utils.ts +0 -3
- package/test/examples/flappy_bird/browser-entry/playback/background/ground-grid/playback.background.ground-grid.pulse.utils.test.ts +2 -2
- package/test/examples/flappy_bird/browser-entry/playback/background/ground-grid/playback.background.ground-grid.pulse.utils.ts +0 -2
- package/test/examples/flappy_bird/browser-entry/playback/background/ground-grid/playback.background.ground-grid.services.ts +1 -4
- package/test/examples/flappy_bird/browser-entry/playback/background/ground-grid/playback.background.ground-grid.ts +16 -3
- package/test/examples/flappy_bird/browser-entry/playback/background/playback.background.ts +16 -4
- package/test/examples/flappy_bird/browser-entry/playback/docs.order.json +23 -0
- package/test/examples/flappy_bird/browser-entry/playback/frame-render/README.md +490 -149
- package/test/examples/flappy_bird/browser-entry/playback/frame-render/docs.order.json +14 -0
- package/test/examples/flappy_bird/browser-entry/playback/frame-render/playback.frame-render.service.ts +19 -7
- package/test/examples/flappy_bird/browser-entry/playback/frame-render/playback.frame-render.services.ts +0 -23
- package/test/examples/flappy_bird/browser-entry/playback/playback.iteration.services.test.ts +136 -0
- package/test/examples/flappy_bird/browser-entry/playback/playback.iteration.services.ts +64 -0
- package/test/examples/flappy_bird/browser-entry/playback/playback.orchestration.types.ts +12 -0
- package/test/examples/flappy_bird/browser-entry/playback/playback.session.services.ts +1 -0
- package/test/examples/flappy_bird/browser-entry/playback/playback.ts +18 -1
- package/test/examples/flappy_bird/browser-entry/playback/snapshot/README.md +75 -16
- package/test/examples/flappy_bird/browser-entry/playback/snapshot/docs.order.json +7 -0
- package/test/examples/flappy_bird/browser-entry/playback/snapshot/playback.snapshot.services.ts +18 -0
- package/test/examples/flappy_bird/browser-entry/playback/trail/README.md +96 -28
- package/test/examples/flappy_bird/browser-entry/playback/trail/docs.order.json +7 -0
- package/test/examples/flappy_bird/browser-entry/playback/trail/playback.trail.history.services.ts +14 -2
- package/test/examples/flappy_bird/browser-entry/playback/trail/playback.trail.opacity.utils.ts +21 -0
- package/test/examples/flappy_bird/browser-entry/playback/worker-channel/README.md +79 -22
- package/test/examples/flappy_bird/browser-entry/playback/worker-channel/docs.order.json +8 -0
- package/test/examples/flappy_bird/browser-entry/playback/worker-channel/playback.worker-channel.types.ts +8 -0
- package/test/examples/flappy_bird/browser-entry/runtime/README.md +300 -130
- package/test/examples/flappy_bird/browser-entry/runtime/docs.order.json +14 -0
- package/test/examples/flappy_bird/browser-entry/runtime/runtime.evolution-loop.service.ts +52 -0
- package/test/examples/flappy_bird/browser-entry/runtime/runtime.ts +19 -6
- package/test/examples/flappy_bird/browser-entry/visualization/README.md +544 -249
- package/test/examples/flappy_bird/browser-entry/visualization/docs.order.json +13 -0
- package/test/examples/flappy_bird/browser-entry/visualization/visualization.ts +10 -0
- package/test/examples/flappy_bird/browser-entry/visualization/visualization.types.ts +4 -0
- package/test/examples/flappy_bird/browser-entry/worker-channel/README.md +198 -119
- package/test/examples/flappy_bird/browser-entry/worker-channel/docs.order.json +12 -0
- package/test/examples/flappy_bird/browser-entry/worker-channel/worker-channel.ts +6 -0
- package/test/examples/flappy_bird/constants/README.md +1865 -573
- package/test/examples/flappy_bird/constants/constants.runtime.ts +1 -1
- package/test/examples/flappy_bird/constants/constants.ts +33 -3
- package/test/examples/flappy_bird/constants/docs.order.json +23 -0
- package/test/examples/flappy_bird/environment/README.md +113 -40
- package/test/examples/flappy_bird/environment/docs.order.json +11 -0
- package/test/examples/flappy_bird/environment/environment.step.service.ts +0 -1
- package/test/examples/flappy_bird/environment/environment.types.ts +16 -0
- package/test/examples/flappy_bird/evaluation/README.md +159 -50
- package/test/examples/flappy_bird/evaluation/docs.order.json +13 -0
- package/test/examples/flappy_bird/evaluation/evaluation.rollout.service.ts +8 -0
- package/test/examples/flappy_bird/evaluation/evaluation.types.ts +19 -0
- package/test/examples/flappy_bird/evaluation/rollout/README.md +323 -173
- package/test/examples/flappy_bird/evaluation/rollout/docs.order.json +10 -0
- package/test/examples/flappy_bird/evaluation/rollout/evaluation.rollout.constants.ts +3 -2
- package/test/examples/flappy_bird/evaluation/rollout/evaluation.rollout.service.ts +23 -4
- package/test/examples/flappy_bird/evaluation/rollout/evaluation.rollout.services.ts +24 -3
- package/test/examples/flappy_bird/evaluation/rollout/evaluation.rollout.types.ts +8 -4
- package/test/examples/flappy_bird/evaluation/rollout/evaluation.rollout.utils.ts +3 -2
- package/test/examples/flappy_bird/flappy-evolution-worker/README.md +982 -469
- package/test/examples/flappy_bird/flappy-evolution-worker/docs.order.json +18 -0
- package/test/examples/flappy_bird/flappy-evolution-worker/flappy-evolution-worker.constants.ts +42 -0
- package/test/examples/flappy_bird/flappy-evolution-worker/flappy-evolution-worker.evolution.service.test.ts +50 -0
- package/test/examples/flappy_bird/flappy-evolution-worker/flappy-evolution-worker.evolution.service.ts +5 -0
- package/test/examples/flappy_bird/flappy-evolution-worker/flappy-evolution-worker.simulation.utils.ts +1 -1
- package/test/examples/flappy_bird/flappy-evolution-worker/flappy-evolution-worker.ts +19 -1
- package/test/examples/flappy_bird/flappy-evolution-worker/flappy-evolution-worker.types.ts +1 -0
- package/test/examples/flappy_bird/flappy-evolution-worker/flappy-evolution-worker.warm-start.service.test.ts +71 -0
- package/test/examples/flappy_bird/flappy-evolution-worker/flappy-evolution-worker.warm-start.service.ts +276 -19
- package/test/examples/flappy_bird/index.ts +15 -0
- package/test/examples/flappy_bird/simulation-shared/README.md +401 -241
- package/test/examples/flappy_bird/simulation-shared/docs.order.json +18 -0
- package/test/examples/flappy_bird/simulation-shared/observation/README.md +219 -93
- package/test/examples/flappy_bird/simulation-shared/observation/docs.order.json +8 -0
- package/test/examples/flappy_bird/simulation-shared/simulation-shared.types.ts +15 -0
- package/test/examples/flappy_bird/trainer/README.md +901 -183
- package/test/examples/flappy_bird/trainer/evaluation/README.md +163 -54
- package/test/examples/flappy_bird/trainer/evaluation/trainer.evaluation.service.ts +19 -1
- package/test/examples/flappy_bird/trainer/trainer.constants.ts +278 -33
- package/test/examples/flappy_bird/trainer/trainer.errors.ts +12 -0
- package/test/examples/flappy_bird/trainer/trainer.evaluation-plan.utils.ts +60 -0
- package/test/examples/flappy_bird/trainer/trainer.evaluation.service.ts +12 -0
- package/test/examples/flappy_bird/trainer/trainer.fitness.service.ts +20 -0
- package/test/examples/flappy_bird/trainer/trainer.loop.service.ts +20 -1
- package/test/examples/flappy_bird/trainer/trainer.report.service.services.ts +10 -1
- package/test/examples/flappy_bird/trainer/trainer.report.service.ts +9 -2
- package/test/examples/flappy_bird/trainer/trainer.reporting.utils.ts +11 -0
- package/test/examples/flappy_bird/trainer/trainer.selection.utils.ts +11 -0
- package/test/examples/flappy_bird/trainer/trainer.setup.service.ts +10 -1
- package/test/examples/flappy_bird/trainer/trainer.signals.service.ts +10 -1
- package/test/examples/flappy_bird/trainer/trainer.ts +65 -12
- package/test/examples/flappy_bird/trainer/trainer.types.ts +42 -7
- package/test/methods/activation.test.ts +1 -1
- package/test/methods/connection.test.ts +1 -1
- package/test/methods/cost.test.ts +1 -1
- package/test/methods/crossover.test.ts +1 -1
- package/test/methods/gating.test.ts +1 -1
- package/test/methods/mutation.test.ts +2 -2
- package/test/methods/rate.cosineWarmRestarts.test.ts +1 -1
- package/test/methods/rate.linearWarmupDecay.test.ts +1 -1
- package/test/methods/rate.reduceOnPlateau.test.ts +1 -1
- package/test/methods/rate.test.ts +1 -1
- package/test/methods/selection.test.ts +1 -1
- package/test/neat/neat.adaptive.ancestorUniq.cooldown.test.ts +3 -3
- package/test/neat/neat.adaptive.ancestorUniq.epsilon.test.ts +7 -7
- package/test/neat/neat.adaptive.ancestorUniq.lineagePressure.test.ts +7 -7
- package/test/neat/neat.adaptive.complexityBudget.connShrink.test.ts +2 -2
- package/test/neat/neat.adaptive.complexityBudget.growth.novelty.test.ts +2 -2
- package/test/neat/neat.adaptive.complexityBudget.minClamp.test.ts +2 -2
- package/test/neat/neat.adaptive.complexityBudget.test.ts +1 -1
- package/test/neat/neat.adaptive.complexityBudget.trend.test.ts +2 -2
- package/test/neat/neat.adaptive.minimalCriterion.rejection.test.ts +2 -2
- package/test/neat/neat.adaptive.mutation.amount.adapt.test.ts +3 -3
- package/test/neat/neat.adaptive.mutation.anneal.strategy.test.ts +3 -3
- package/test/neat/neat.adaptive.mutation.exploreLow.strategy.test.ts +3 -3
- package/test/neat/neat.adaptive.mutation.twotier.balance.test.ts +3 -3
- package/test/neat/neat.adaptive.mutation.twotier.fallback.single.test.ts +3 -3
- package/test/neat/neat.adaptive.operator.adaptation.decay.balance.test.ts +3 -3
- package/test/neat/neat.adaptive.operator.bandit.decay.test.ts +3 -3
- package/test/neat/neat.adaptive.phasedComplexity.toggle.test.ts +2 -2
- package/test/neat/neat.additional.coverage.test.ts +1 -1
- package/test/neat/neat.export.meta.fromjson.test.ts +1 -1
- package/test/neat/neat.export.state.rehydrate.test.ts +4 -3
- package/test/neat/neat.helpers.spawn.pool.test.ts +1 -1
- package/test/neat/neat.lineage.entropy.test.ts +1 -1
- package/test/neat/neat.lineage.inbreeding.test.ts +1 -1
- package/test/neat/neat.mutation.addconn.cycle.guard.test.ts +1 -1
- package/test/neat/neat.mutation.undefined.pool.test.ts +1 -1
- package/test/neat/neat.operator.phases.test.ts +1 -1
- package/test/neat/neat.spawn.add.test.ts +1 -1
- package/test/neat/neat.speciation.age.penalty.test.ts +2 -2
- package/test/neat/neat.speciation.assign.existing.test.ts +2 -2
- package/test/neat/neat.speciation.auto.tuning.jitter.test.ts +2 -2
- package/test/neat/neat.speciation.create.newSpecies.test.ts +2 -2
- package/test/neat/neat.speciation.fitnessSharing.equal.test.ts +5 -2
- package/test/neat/neat.speciation.fitnessSharing.kernel.test.ts +5 -2
- package/test/neat/neat.speciation.pid.threshold.clip.max.test.ts +2 -2
- package/test/neat/neat.speciation.pid.threshold.clip.min.test.ts +2 -2
- package/test/neat/neat.speciation.stagnation.prune.test.ts +5 -2
- package/test/neat/neat.species.history.fallbacks.test.ts +2 -2
- package/test/neat/neat.telemetry.advanced.test.ts +1 -1
- package/test/neat/neat.telemetry.fastmode.diversity.test.ts +5 -2
- package/test/neat/neat.telemetry.objective.events.test.ts +2 -2
- package/test/neat/neat.telemetry.select.entropy.cache.test.ts +1 -1
- package/test/network/network.deterministic.test.ts +0 -2
- package/test/network/network.evolve.multithread.branches.test.ts +0 -2
- package/test/network/network.gating.removal.test.ts +1 -1
- package/test/network/network.mutate.additional.test.ts +1 -1
- package/test/network/network.mutate.edgecases.test.ts +1 -1
- package/test/network/network.mutate.test.ts +1 -1
- package/test/network/structure.serialization.test.ts +60 -98
- package/test/utils/test-helpers.ts +1 -1
- package/.github/skills/solid-split-playbook/SKILL.md +0 -220
- package/plans/Flappy_Evolution_Worker_Documentation_Pass.md +0 -58
- package/plans/asciiMaze_SOLID_split.done.md +0 -130
- package/plans/flappy_bird_SOLID_split.done.md +0 -67
- package/src/methods/connection.ts +0 -31
- package/src/methods/gating.ts +0 -43
- package/src/neat/neat.adaptive.utils.ts +0 -7
- package/src/neat/neat.cache.ts +0 -1
- package/src/neat/neat.cache.utils.ts +0 -12
- package/src/neat/neat.compat.ts +0 -103
- package/src/neat/neat.diversity.utils.ts +0 -359
- package/src/neat/neat.evaluate.auto-distance.utils.ts +0 -210
- package/src/neat/neat.evaluate.constants.utils.ts +0 -42
- package/src/neat/neat.evaluate.entropy-compat.utils.ts +0 -67
- package/src/neat/neat.evaluate.entropy-sharing.utils.ts +0 -78
- package/src/neat/neat.evaluate.fitness.utils.ts +0 -48
- package/src/neat/neat.evaluate.novelty.utils.ts +0 -225
- package/src/neat/neat.evaluate.objectives.utils.ts +0 -50
- package/src/neat/neat.evaluate.speciation.utils.ts +0 -35
- package/src/neat/neat.evaluate.ts +0 -90
- package/src/neat/neat.evaluate.utils.ts +0 -9
- package/src/neat/neat.evolve.adaptive.utils.ts +0 -224
- package/src/neat/neat.evolve.offspring.constants.ts +0 -8
- package/src/neat/neat.evolve.offspring.utils.ts +0 -107
- package/src/neat/neat.evolve.runtime.utils.ts +0 -128
- package/src/neat/neat.evolve.speciation.utils.ts +0 -251
- package/src/neat/neat.evolve.telemetry.utils.ts +0 -39
- package/src/neat/neat.evolve.utils.ts +0 -10
- package/src/neat/neat.evolve.warnings.utils.ts +0 -14
- package/src/neat/neat.harness.types.ts +0 -35
- package/src/neat/neat.helpers.ts +0 -316
- package/src/neat/neat.lineage.utils.ts +0 -387
- package/src/neat/neat.multiobjective.archive.utils.ts +0 -59
- package/src/neat/neat.multiobjective.metrics.utils.ts +0 -65
- package/src/neat/neat.multiobjective.ts +0 -93
- package/src/neat/neat.multiobjective.utils.ts +0 -10
- package/src/neat/neat.multiobjective.utils.types.ts +0 -112
- package/src/neat/neat.mutation.ts +0 -335
- package/src/neat/neat.mutation.utils.ts +0 -6
- package/src/neat/neat.novelty.utils.ts +0 -17
- package/src/neat/neat.objectives.ts +0 -133
- package/src/neat/neat.objectives.utils.ts +0 -195
- package/src/neat/neat.pruning.ts +0 -129
- package/src/neat/neat.pruning.utils.ts +0 -375
- package/src/neat/neat.rng.constants.ts +0 -18
- package/src/neat/neat.rng.ts +0 -2
- package/src/neat/neat.rng.utils.ts +0 -158
- package/src/neat/neat.selection.ts +0 -142
- package/src/neat/neat.selection.utils.ts +0 -470
- package/src/neat/neat.speciation.ts +0 -136
- package/src/neat/neat.speciation.utils.ts +0 -926
- package/src/neat/neat.species.history.utils.ts +0 -13
- package/src/neat/neat.species.ts +0 -114
- package/src/neat/neat.species.utils.ts +0 -156
- package/src/neat/neat.telemetry.accessors.utils.ts +0 -71
- package/src/neat/neat.telemetry.buffer.utils.ts +0 -58
- package/src/neat/neat.telemetry.exports.ts +0 -452
- package/src/neat/neat.telemetry.types.ts +0 -51
- package/src/neat/neat.telemetry.utils.ts +0 -12
- package/src/neat/neat.topology-intent.utils.ts +0 -160
- package/srcLint.md +0 -185
- package/test/benchmarks/asciiMaze.micro.bench.ts +0 -0
- /package/.github/skills/{solid-split-playbook → solid-split}/assets/split-plan-template.md +0 -0
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
|
|
18
18
|
import type { Neat, Network } from '../../../../src/neataptic';
|
|
19
19
|
import type { EngineState } from './engineState';
|
|
20
|
+
import type { NetworkConnection, NetworkNode } from './evolutionEngine.types';
|
|
20
21
|
import { drawFastRandom, resolveRngParameters } from './rngAndTiming';
|
|
21
22
|
|
|
22
23
|
/** Weight initialization minimum value for warm-start connections. */
|
|
@@ -35,8 +36,20 @@ const OUTPUT_BIAS_CLAMP = 5;
|
|
|
35
36
|
*/
|
|
36
37
|
const PRUNE_BULK_INSERTION_MAX = 64;
|
|
37
38
|
|
|
38
|
-
|
|
39
|
-
|
|
39
|
+
interface OutputBiasStats {
|
|
40
|
+
mean: number;
|
|
41
|
+
std: number;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
interface NetworkWithWarmStartSurface {
|
|
45
|
+
nodes?: NetworkNode[];
|
|
46
|
+
connections?: NetworkConnection[];
|
|
47
|
+
connect: (from: NetworkNode, to: NetworkNode, weight?: number) => unknown;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
interface NetworkWithOutputBiasStats extends NetworkWithWarmStartSurface {
|
|
51
|
+
_outputBiasStats?: OutputBiasStats;
|
|
52
|
+
}
|
|
40
53
|
|
|
41
54
|
/**
|
|
42
55
|
* Parameters for applying simplify pruning to a population.
|
|
@@ -132,8 +145,10 @@ export const applyCompassWarmStart = ({
|
|
|
132
145
|
// Step 1: defensive guards
|
|
133
146
|
if (!network) return;
|
|
134
147
|
|
|
135
|
-
const
|
|
136
|
-
|
|
148
|
+
const runtimeNetwork = network as unknown as NetworkWithWarmStartSurface;
|
|
149
|
+
|
|
150
|
+
const nodesRef = runtimeNetwork.nodes ?? [];
|
|
151
|
+
const connectionsRef = runtimeNetwork.connections ?? [];
|
|
137
152
|
|
|
138
153
|
// Determine counts for input/output nodes using the engine helper that populates
|
|
139
154
|
// the pooled node index buffer with indices by type.
|
|
@@ -160,9 +175,7 @@ export const applyCompassWarmStart = ({
|
|
|
160
175
|
if (!inputNode || !outputNode) continue; // nothing to wire for this direction
|
|
161
176
|
|
|
162
177
|
// Find existing connection input→output (linear scan; avoids allocations)
|
|
163
|
-
|
|
164
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
165
|
-
let existingConn: any = undefined;
|
|
178
|
+
let existingConn: NetworkConnection | undefined;
|
|
166
179
|
for (let ci = 0, cLen = connectionsRef.length; ci < cLen; ci++) {
|
|
167
180
|
const conn = connectionsRef[ci];
|
|
168
181
|
if (conn.from === inputNode && conn.to === outputNode) {
|
|
@@ -174,7 +187,8 @@ export const applyCompassWarmStart = ({
|
|
|
174
187
|
// Small random initialization in [wInitMin, wInitMin + wInitRange)
|
|
175
188
|
const initWeight =
|
|
176
189
|
drawFastRandom(state, randomParameters) * W_INIT_RANGE + W_INIT_MIN;
|
|
177
|
-
if (!existingConn)
|
|
190
|
+
if (!existingConn)
|
|
191
|
+
runtimeNetwork.connect(inputNode, outputNode, initWeight);
|
|
178
192
|
else existingConn.weight = initWeight;
|
|
179
193
|
}
|
|
180
194
|
|
|
@@ -190,9 +204,7 @@ export const applyCompassWarmStart = ({
|
|
|
190
204
|
if (!outNode) continue;
|
|
191
205
|
|
|
192
206
|
// Find existing connection compass→outNode
|
|
193
|
-
|
|
194
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
195
|
-
let existingConn: any = undefined;
|
|
207
|
+
let existingConn: NetworkConnection | undefined;
|
|
196
208
|
for (let ci = 0, cLen = connectionsRef.length; ci < cLen; ci++) {
|
|
197
209
|
const conn = connectionsRef[ci];
|
|
198
210
|
if (conn.from === compassNode && conn.to === outNode) {
|
|
@@ -202,7 +214,8 @@ export const applyCompassWarmStart = ({
|
|
|
202
214
|
}
|
|
203
215
|
|
|
204
216
|
const baseWeight = OUTPUT_BIAS_BASE + outIndex * OUTPUT_BIAS_STEP;
|
|
205
|
-
if (!existingConn)
|
|
217
|
+
if (!existingConn)
|
|
218
|
+
runtimeNetwork.connect(compassNode, outNode, baseWeight);
|
|
206
219
|
else existingConn.weight = baseWeight;
|
|
207
220
|
}
|
|
208
221
|
} catch {
|
|
@@ -239,7 +252,8 @@ export const centerOutputBiases = ({
|
|
|
239
252
|
network,
|
|
240
253
|
}: CenterOutputBiasesParams): void => {
|
|
241
254
|
try {
|
|
242
|
-
const
|
|
255
|
+
const runtimeNetwork = network as unknown as NetworkWithOutputBiasStats;
|
|
256
|
+
const nodeList = runtimeNetwork.nodes ?? [];
|
|
243
257
|
const totalNodeCount = nodeList.length | 0;
|
|
244
258
|
if (totalNodeCount === 0) return;
|
|
245
259
|
|
|
@@ -274,9 +288,7 @@ export const centerOutputBiases = ({
|
|
|
274
288
|
}
|
|
275
289
|
|
|
276
290
|
// Step 4: Persist stats for optional telemetry.
|
|
277
|
-
|
|
278
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
279
|
-
(network as any)._outputBiasStats = { mean: meanBias, std: stdBias };
|
|
291
|
+
runtimeNetwork._outputBiasStats = { mean: meanBias, std: stdBias };
|
|
280
292
|
} catch {
|
|
281
293
|
// swallow errors (best-effort maintenance routine)
|
|
282
294
|
}
|
|
@@ -312,9 +324,7 @@ const pruneWeakConnectionsForGenome = (
|
|
|
312
324
|
if (rawFraction <= 0) return; // nothing requested
|
|
313
325
|
|
|
314
326
|
// Step 2: Collect enabled connections.
|
|
315
|
-
|
|
316
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
317
|
-
const allConnections = genome.connections as any[];
|
|
327
|
+
const allConnections = genome.connections as unknown as NetworkConnection[];
|
|
318
328
|
let candidateConnections = collectEnabledConnections(allConnections);
|
|
319
329
|
const enabledConnectionCount = candidateConnections.length;
|
|
320
330
|
if (enabledConnectionCount === 0) return; // no work
|
|
@@ -357,18 +367,16 @@ const pruneWeakConnectionsForGenome = (
|
|
|
357
367
|
* const enabled = collectEnabledConnections(genome.connections);
|
|
358
368
|
* const stableCopy = enabled.slice(); // only if retention needed
|
|
359
369
|
*/
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
370
|
+
const collectEnabledConnections = (
|
|
371
|
+
connectionsSource: NetworkConnection[],
|
|
372
|
+
): NetworkConnection[] => {
|
|
363
373
|
// Step 1: Validate input & fast exit.
|
|
364
374
|
if (!Array.isArray(connectionsSource) || connectionsSource.length === 0)
|
|
365
375
|
return [];
|
|
366
376
|
|
|
367
377
|
// Step 2: Reset pooled buffer (reusing the scratch array from state; needs access via closure or parameter).
|
|
368
378
|
// Note: This is a simplified version; in practice this would access state.scratch.connectionCandidates
|
|
369
|
-
|
|
370
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
371
|
-
const candidateBuffer: any[] = [];
|
|
379
|
+
const candidateBuffer: NetworkConnection[] = [];
|
|
372
380
|
|
|
373
381
|
// Step 3: Linear scan & collect enabled connections.
|
|
374
382
|
for (
|
|
@@ -401,12 +409,9 @@ const collectEnabledConnections = (connectionsSource: any[]): any[] => {
|
|
|
401
409
|
* sortCandidatesByStrategy(candidates, 'weakRecurrentPreferred');
|
|
402
410
|
*/
|
|
403
411
|
const sortCandidatesByStrategy = (
|
|
404
|
-
|
|
405
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
406
|
-
candidateConnections: any[],
|
|
412
|
+
candidateConnections: NetworkConnection[],
|
|
407
413
|
strategyKey: string,
|
|
408
|
-
|
|
409
|
-
): any[] => {
|
|
414
|
+
): NetworkConnection[] => {
|
|
410
415
|
// Step 1: Validate input.
|
|
411
416
|
if (!Array.isArray(candidateConnections) || candidateConnections.length === 0)
|
|
412
417
|
return candidateConnections;
|
|
@@ -471,9 +476,7 @@ const sortCandidatesByStrategy = (
|
|
|
471
476
|
* insertionSortByAbsWeight(buf, 0, 10);
|
|
472
477
|
*/
|
|
473
478
|
const insertionSortByAbsWeight = (
|
|
474
|
-
|
|
475
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
476
|
-
connectionsBuffer: any[],
|
|
479
|
+
connectionsBuffer: NetworkConnection[],
|
|
477
480
|
startIndex: number,
|
|
478
481
|
endExclusive: number,
|
|
479
482
|
): void => {
|
|
@@ -491,17 +494,17 @@ const insertionSortByAbsWeight = (
|
|
|
491
494
|
for (let scanIndex = from + 1; scanIndex < to; scanIndex++) {
|
|
492
495
|
// 2.1: Extract the candidate and compute its absolute weight (treat non-finite as 0).
|
|
493
496
|
const candidate = connectionsBuffer[scanIndex];
|
|
497
|
+
const candidateWeight = Number(candidate?.weight);
|
|
494
498
|
const candidateAbs = Math.abs(
|
|
495
|
-
|
|
499
|
+
Number.isFinite(candidateWeight) ? candidateWeight : 0,
|
|
496
500
|
);
|
|
497
501
|
|
|
498
502
|
// 2.2: Shift larger elements one slot to the right to make room for the candidate.
|
|
499
503
|
let writePos = scanIndex - 1;
|
|
500
504
|
while (writePos >= from) {
|
|
501
505
|
const probe = connectionsBuffer[writePos];
|
|
502
|
-
const
|
|
503
|
-
|
|
504
|
-
);
|
|
506
|
+
const probeWeight = Number(probe?.weight);
|
|
507
|
+
const probeAbs = Math.abs(Number.isFinite(probeWeight) ? probeWeight : 0);
|
|
505
508
|
// Preserve stability: stop when probe <= candidate (no swap for equals).
|
|
506
509
|
if (probeAbs <= candidateAbs) break;
|
|
507
510
|
connectionsBuffer[writePos + 1] = probe;
|
|
@@ -529,9 +532,7 @@ const insertionSortByAbsWeight = (
|
|
|
529
532
|
* disableSmallestEnabledConnections(candidates, 5);
|
|
530
533
|
*/
|
|
531
534
|
const disableSmallestEnabledConnections = (
|
|
532
|
-
|
|
533
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
534
|
-
candidateConnections: any[],
|
|
535
|
+
candidateConnections: NetworkConnection[],
|
|
535
536
|
pruneCount: number,
|
|
536
537
|
): void => {
|
|
537
538
|
// Step 0: Defensive validation & normalization.
|
|
@@ -563,9 +564,7 @@ const disableSmallestEnabledConnections = (
|
|
|
563
564
|
candidateConnections
|
|
564
565
|
.slice(0, activeEnabledCount) // sort only active slice; slice() to avoid comparing undefined tail beyond active
|
|
565
566
|
.sort(
|
|
566
|
-
|
|
567
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
568
|
-
(firstConnection: any, secondConnection: any) =>
|
|
567
|
+
(firstConnection, secondConnection) =>
|
|
569
568
|
Math.abs(firstConnection?.weight || 0) -
|
|
570
569
|
Math.abs(secondConnection?.weight || 0),
|
|
571
570
|
)
|
|
@@ -588,16 +587,12 @@ const disableSmallestEnabledConnections = (
|
|
|
588
587
|
while (remainingToDisable > 0 && activeSliceLength > 0) {
|
|
589
588
|
// 3a. Find index of current minimum |weight| in [0, activeSliceLength).
|
|
590
589
|
let minIndex = 0;
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
? candidateConnections[0].weight
|
|
594
|
-
: 0,
|
|
595
|
-
);
|
|
590
|
+
const firstWeight = Number(candidateConnections[0]?.weight);
|
|
591
|
+
let minAbsWeight = Math.abs(Number.isFinite(firstWeight) ? firstWeight : 0);
|
|
596
592
|
for (let probeIndex = 1; probeIndex < activeSliceLength; probeIndex++) {
|
|
597
593
|
const probe = candidateConnections[probeIndex];
|
|
598
|
-
const
|
|
599
|
-
|
|
600
|
-
);
|
|
594
|
+
const probeWeight = Number(probe?.weight);
|
|
595
|
+
const probeAbs = Math.abs(Number.isFinite(probeWeight) ? probeWeight : 0);
|
|
601
596
|
if (probeAbs < minAbsWeight) {
|
|
602
597
|
minAbsWeight = probeAbs;
|
|
603
598
|
minIndex = probeIndex;
|
|
@@ -633,9 +628,7 @@ const disableSmallestEnabledConnections = (
|
|
|
633
628
|
*/
|
|
634
629
|
const collectNodeIndicesByType = (
|
|
635
630
|
state: EngineState,
|
|
636
|
-
|
|
637
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
638
|
-
nodes: any[] | undefined,
|
|
631
|
+
nodes: NetworkNode[] | undefined,
|
|
639
632
|
nodeType: string,
|
|
640
633
|
): number => {
|
|
641
634
|
// Step 1: Defensive validation & fast exit.
|
|
@@ -5,6 +5,10 @@
|
|
|
5
5
|
* 1. Provide allocation-light array sampling utilities that reuse the shared `EngineState` scratch pools.
|
|
6
6
|
* 2. Expose history helpers that mirror the façade behaviour while keeping pooled buffers centralised.
|
|
7
7
|
* 3. Centralise RNG parameter resolution for sampling paths to keep behaviour deterministic under shared state.
|
|
8
|
+
*
|
|
9
|
+
* These helpers look small, but they sit under several hot paths. The main job
|
|
10
|
+
* is not "random choice" in the abstract; it is random choice without quietly
|
|
11
|
+
* reintroducing per-generation array churn into long-running experiments.
|
|
8
12
|
*/
|
|
9
13
|
|
|
10
14
|
import type { EngineState } from './engineState.types';
|
|
@@ -14,6 +18,10 @@ import { MazeUtils } from '../mazeUtils';
|
|
|
14
18
|
/**
|
|
15
19
|
* Sample `sampleCount` items (with replacement) from `source` into the pooled scratch buffer.
|
|
16
20
|
*
|
|
21
|
+
* This helper is for callers that want an ephemeral array view immediately. The
|
|
22
|
+
* returned array reuses shared scratch storage, so callers should copy it first
|
|
23
|
+
* if they need the contents to survive another helper call.
|
|
24
|
+
*
|
|
17
25
|
* Steps:
|
|
18
26
|
* 1. Validate the input array and normalise `sampleCount` to an integer.
|
|
19
27
|
* 2. Grow the shared `sampleResultBuffer` to the next power of two when capacity is insufficient.
|
|
@@ -62,6 +70,10 @@ export const sampleArray = <T>(
|
|
|
62
70
|
/**
|
|
63
71
|
* Sample up to `sampleCount` items (with replacement) into the shared `samplePool` buffer.
|
|
64
72
|
*
|
|
73
|
+
* Compared with `sampleArray`, this form is for callers that only need a count
|
|
74
|
+
* plus access to the pooled buffer on `state.scratch.samplePool`. That avoids
|
|
75
|
+
* one more logical array object on the hottest paths.
|
|
76
|
+
*
|
|
65
77
|
* Steps:
|
|
66
78
|
* 1. Validate inputs and ensure the pooled buffer exists.
|
|
67
79
|
* 2. Grow the buffer by powers of two when more capacity is required.
|
|
@@ -91,9 +103,9 @@ export const sampleIntoScratch = <T>(
|
|
|
91
103
|
if (sourceLength === 0 || normalisedCount <= 0) return 0;
|
|
92
104
|
|
|
93
105
|
const scratch = state.scratch;
|
|
94
|
-
//
|
|
95
|
-
//
|
|
96
|
-
let pooledBuffer = scratch.samplePool as
|
|
106
|
+
// The shared pool is declared as Array<unknown> because different helpers reuse it
|
|
107
|
+
// for different element types across generations.
|
|
108
|
+
let pooledBuffer = scratch.samplePool as T[];
|
|
97
109
|
if (!Array.isArray(pooledBuffer)) {
|
|
98
110
|
pooledBuffer = [];
|
|
99
111
|
scratch.samplePool = pooledBuffer;
|
|
@@ -141,6 +153,9 @@ export const sampleIntoScratch = <T>(
|
|
|
141
153
|
/**
|
|
142
154
|
* Sample from a suffix of `source` starting at `segmentStart` into the pooled buffer.
|
|
143
155
|
*
|
|
156
|
+
* The common use case is "sample from the non-elite tail" or some later slice
|
|
157
|
+
* of a population without first allocating `source.slice(segmentStart)`.
|
|
158
|
+
*
|
|
144
159
|
* Steps:
|
|
145
160
|
* 1. Clamp indices and ensure there is a non-empty segment.
|
|
146
161
|
* 2. Ensure the pooled buffer can store the requested sample count.
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* internal error is swallowed so that logging never impacts the evolution loop.
|
|
7
7
|
*/
|
|
8
8
|
import type { Neat, Network } from '../../../../src/neataptic';
|
|
9
|
-
import type { GenomeDetailed } from '../../../../src/neat/neat.types';
|
|
9
|
+
import type { GenomeDetailed } from '../../../../src/neat/shared/neat.shared.types';
|
|
10
10
|
import type { EngineState } from './engineState.types';
|
|
11
11
|
import type {
|
|
12
12
|
EvolutionGenomeLike,
|
|
@@ -84,6 +84,10 @@ type TelemetryWriter = (message: string) => void;
|
|
|
84
84
|
interface GenerationResult {
|
|
85
85
|
/** Path taken by the agent (array of [x, y] coordinate pairs). */
|
|
86
86
|
path?: ReadonlyArray<[number, number]>;
|
|
87
|
+
/** Progress score accumulated during the run. */
|
|
88
|
+
progress?: number;
|
|
89
|
+
/** Fraction of the maze saturation reached during the run. */
|
|
90
|
+
saturationFraction?: number;
|
|
87
91
|
}
|
|
88
92
|
|
|
89
93
|
/**
|
|
@@ -524,12 +528,10 @@ const computeExplorationStats = (
|
|
|
524
528
|
}
|
|
525
529
|
|
|
526
530
|
// Step 2: Choose the most efficient distinct-coordinate counter based on path length.
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
unique = countDistinctCoordinatesHashed(state, path!, pathLength);
|
|
532
|
-
}
|
|
531
|
+
const unique =
|
|
532
|
+
pathLength < 32
|
|
533
|
+
? countDistinctCoordinatesTiny(state, path!, pathLength)
|
|
534
|
+
: countDistinctCoordinatesHashed(state, path!, pathLength);
|
|
533
535
|
|
|
534
536
|
// Step 3: Aggregate the summary metrics while keeping floating-point ratios guarded.
|
|
535
537
|
return {
|
|
@@ -707,12 +709,16 @@ const computeDiversityMetrics = (
|
|
|
707
709
|
let weightMean = 0;
|
|
708
710
|
let weightM2 = 0;
|
|
709
711
|
let enabledWeights = 0;
|
|
710
|
-
const sampleBuffer = state.scratch.samplePool ?? EMPTY_VECTOR;
|
|
711
712
|
for (let sampleIndex = 0; sampleIndex < sampledLength; sampleIndex++) {
|
|
712
|
-
const genome =
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
713
|
+
const genome = state.scratch.samplePool[sampleIndex] as
|
|
714
|
+
| GenomeDetailed
|
|
715
|
+
| undefined;
|
|
716
|
+
const connections = (
|
|
717
|
+
Array.isArray(genome?.connections) ? genome.connections : EMPTY_VECTOR
|
|
718
|
+
) as Array<{
|
|
719
|
+
enabled?: boolean;
|
|
720
|
+
weight?: number;
|
|
721
|
+
}>;
|
|
716
722
|
for (
|
|
717
723
|
let connectionIndex = 0;
|
|
718
724
|
connectionIndex < connections.length;
|
|
@@ -859,15 +865,16 @@ const computeLogitStats = ({
|
|
|
859
865
|
|
|
860
866
|
resetLogitScratch(state, actionDimension, reducedTelemetry);
|
|
861
867
|
|
|
862
|
-
|
|
868
|
+
const entropySum = reducedTelemetry
|
|
869
|
+
? accumulateLogitStatsReduced(state, recent, actionDimension)
|
|
870
|
+
: actionDimension === 4
|
|
871
|
+
? accumulateLogitStatsUnrolled4(state, recent, recent.length)
|
|
872
|
+
: accumulateLogitStatsGeneric(state, recent, actionDimension);
|
|
863
873
|
if (reducedTelemetry) {
|
|
864
|
-
entropySum = accumulateLogitStatsReduced(state, recent, actionDimension);
|
|
865
874
|
finalizeLogitStatsReduced(state, actionDimension, recent.length);
|
|
866
875
|
} else if (actionDimension === 4) {
|
|
867
|
-
entropySum = accumulateLogitStatsUnrolled4(state, recent, recent.length);
|
|
868
876
|
finalizeLogitStatsFull(state, actionDimension, recent.length);
|
|
869
877
|
} else {
|
|
870
|
-
entropySum = accumulateLogitStatsGeneric(state, recent, actionDimension);
|
|
871
878
|
finalizeLogitStatsFull(state, actionDimension, recent.length);
|
|
872
879
|
}
|
|
873
880
|
|
|
@@ -1356,7 +1363,7 @@ const computeDecisionStability = (
|
|
|
1356
1363
|
for (let rowIndex = 0; rowIndex < sequenceLength; rowIndex++) {
|
|
1357
1364
|
const row = recent[rowIndex];
|
|
1358
1365
|
if (!row || row.length === 0) continue;
|
|
1359
|
-
let argmax
|
|
1366
|
+
let argmax: number;
|
|
1360
1367
|
if (unrolled && row.length >= 4) {
|
|
1361
1368
|
let bestValue = row[0] ?? 0;
|
|
1362
1369
|
argmax = 0;
|
|
@@ -3,14 +3,21 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Lamarckian warm-start and population pretraining subsystem.
|
|
5
5
|
*
|
|
6
|
+
* This module is the part of the ASCII Maze engine that briefly steps outside
|
|
7
|
+
* pure neuroevolution and asks a pragmatic question: can a small amount of
|
|
8
|
+
* supervised guidance give the population a better starting shape before the
|
|
9
|
+
* main search pressure takes over again?
|
|
10
|
+
*
|
|
6
11
|
* Responsibilities:
|
|
7
|
-
* - Build supervised
|
|
8
|
-
* - Apply Lamarckian backpropagation
|
|
9
|
-
* -
|
|
10
|
-
* - Orchestrate
|
|
12
|
+
* - Build a tiny curriculum-style supervised dataset for compass-guided motion
|
|
13
|
+
* - Apply bounded Lamarckian backpropagation to whole populations
|
|
14
|
+
* - Re-center output biases after training so exploration does not collapse
|
|
15
|
+
* - Orchestrate optional warm-start passes without polluting the main loop
|
|
11
16
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
17
|
+
* The important design constraint is restraint. These helpers are not trying to
|
|
18
|
+
* solve the maze with backprop. They are trying to give evolution a better
|
|
19
|
+
* first draft while preserving the example's core identity as an evolutionary
|
|
20
|
+
* system.
|
|
14
21
|
*
|
|
15
22
|
* @module trainingWarmStart
|
|
16
23
|
*/
|
|
@@ -19,12 +26,44 @@ import type { Neat, Network } from '../../../../src/neataptic';
|
|
|
19
26
|
import { methods } from '../../../../src/neataptic';
|
|
20
27
|
import type { EngineState, RngCacheParameters } from './engineState.types';
|
|
21
28
|
import { initialiseTelemetryScratch } from './engineState';
|
|
29
|
+
import type { NetworkNode } from './evolutionEngine.types';
|
|
22
30
|
import { drawFastRandom, readHighResolutionTime } from './rngAndTiming';
|
|
23
31
|
import { sampleArray } from './sampling';
|
|
24
32
|
|
|
25
33
|
/** Empty array constant for defensive fallbacks. */
|
|
26
34
|
const EMPTY_VEC: readonly never[] = [];
|
|
27
35
|
|
|
36
|
+
/** Small supervised case used during Lamarckian warm-start. */
|
|
37
|
+
interface LamarckianTrainingCase {
|
|
38
|
+
input: number[];
|
|
39
|
+
output: number[];
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** The warm-start path trains ordinary runtime networks; this alias keeps intent explicit. */
|
|
43
|
+
type TrainableNetwork = Network;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Narrow NEAT view used by the warm-start helpers.
|
|
47
|
+
*
|
|
48
|
+
* These helpers only need population access and a couple of option fields, so
|
|
49
|
+
* they avoid depending on the entire engine-facing driver surface.
|
|
50
|
+
*/
|
|
51
|
+
type WarmStartNeatLike = Neat & {
|
|
52
|
+
population: TrainableNetwork[];
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
/** Callback used when a helper needs to write node indices of a specific role into scratch. */
|
|
56
|
+
type NodeIndexCollector = (nodes: NetworkNode[], nodeType: string) => number;
|
|
57
|
+
|
|
58
|
+
/** Best-effort post-training hook applied to one network at a time. */
|
|
59
|
+
type WarmStartNetworkCallback = (network: TrainableNetwork) => void;
|
|
60
|
+
|
|
61
|
+
/** Population-wide warm-start hook used by the public orchestration helper. */
|
|
62
|
+
type PretrainPopulationCallback = (
|
|
63
|
+
neat: Neat,
|
|
64
|
+
trainingSet: LamarckianTrainingCase[],
|
|
65
|
+
) => void;
|
|
66
|
+
|
|
28
67
|
/**
|
|
29
68
|
* Build the supervised training set used for Lamarckian warm-start training.
|
|
30
69
|
*
|
|
@@ -190,8 +229,10 @@ export const buildLamarckianTrainingSet = (
|
|
|
190
229
|
/**
|
|
191
230
|
* Adjust output node biases after training to maintain exploration diversity.
|
|
192
231
|
*
|
|
193
|
-
* This heuristic
|
|
194
|
-
*
|
|
232
|
+
* This heuristic exists because short supervised bursts can make the action
|
|
233
|
+
* head too confident too early. By re-centering output biases and nudging very
|
|
234
|
+
* low-variance heads back outward, the engine keeps exploration pressure alive
|
|
235
|
+
* after warm-start training instead of letting one action dominate forever.
|
|
195
236
|
*
|
|
196
237
|
* Steps:
|
|
197
238
|
* 1. Collect output node biases into scratch buffer
|
|
@@ -223,15 +264,15 @@ export const adjustOutputBiasesAfterTraining = (
|
|
|
223
264
|
DEFAULT_STD_ADJUST_MULT: number;
|
|
224
265
|
},
|
|
225
266
|
scratchNodeIdx: Int32Array,
|
|
226
|
-
|
|
227
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
228
|
-
getNodeIndicesByType: (nodes: any[], nodeType: string) => number,
|
|
267
|
+
getNodeIndicesByType: NodeIndexCollector,
|
|
229
268
|
): void => {
|
|
230
269
|
try {
|
|
231
270
|
// Step 1: Early exit when no network or no nodes exist.
|
|
232
271
|
if (!network) return;
|
|
233
272
|
|
|
234
|
-
const nodesRef = network.nodes
|
|
273
|
+
const nodesRef: NetworkNode[] = Array.isArray(network.nodes)
|
|
274
|
+
? (network.nodes as unknown as NetworkNode[])
|
|
275
|
+
: [];
|
|
235
276
|
const outputNodeCount = getNodeIndicesByType(nodesRef, 'output');
|
|
236
277
|
if (outputNodeCount <= 0) return;
|
|
237
278
|
|
|
@@ -280,10 +321,14 @@ export const adjustOutputBiasesAfterTraining = (
|
|
|
280
321
|
* Pretrain the population using a small supervised dataset and apply warm-start heuristics.
|
|
281
322
|
*
|
|
282
323
|
* Behaviour & contract:
|
|
283
|
-
* - Runs a short supervised training pass
|
|
284
|
-
* -
|
|
285
|
-
* -
|
|
286
|
-
* -
|
|
324
|
+
* - Runs a short supervised training pass on each network in `neat.population`
|
|
325
|
+
* - Treats the training set as a biasing hint, not as a replacement for later evolution
|
|
326
|
+
* - Applies lightweight warm-start heuristics after training: compass wiring
|
|
327
|
+
* and output-bias centering
|
|
328
|
+
* - Isolates failures per network so one bad trainer state does not abort the
|
|
329
|
+
* rest of the population
|
|
330
|
+
* - Stays allocation-light so warm-start remains cheap enough to use as a
|
|
331
|
+
* tactical assist instead of a second training regime
|
|
287
332
|
*
|
|
288
333
|
* Steps:
|
|
289
334
|
* 1. Validate inputs and obtain `population` (fast-exit on empty populations)
|
|
@@ -307,9 +352,7 @@ export const adjustOutputBiasesAfterTraining = (
|
|
|
307
352
|
*/
|
|
308
353
|
export const pretrainPopulationWarmStart = (
|
|
309
354
|
neat: Neat,
|
|
310
|
-
|
|
311
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
312
|
-
lamarckianTrainingSet: any[],
|
|
355
|
+
lamarckianTrainingSet: LamarckianTrainingCase[],
|
|
313
356
|
constants: {
|
|
314
357
|
PRETRAIN_MAX_ITER: number;
|
|
315
358
|
PRETRAIN_BASE_ITER: number;
|
|
@@ -318,22 +361,17 @@ export const pretrainPopulationWarmStart = (
|
|
|
318
361
|
DEFAULT_PRETRAIN_MOMENTUM: number;
|
|
319
362
|
DEFAULT_TRAIN_BATCH_SMALL: number;
|
|
320
363
|
},
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
applyCompassWarmStart: (network: any) => void,
|
|
324
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
325
|
-
centerOutputBiases: (network: any) => void,
|
|
364
|
+
applyCompassWarmStart: WarmStartNetworkCallback,
|
|
365
|
+
centerOutputBiases: WarmStartNetworkCallback,
|
|
326
366
|
): void => {
|
|
327
367
|
// Step 1: Defensive validation & fast exit.
|
|
328
368
|
if (!neat) return;
|
|
329
|
-
const population = neat.population ?? EMPTY_VEC;
|
|
369
|
+
const population = (neat as WarmStartNeatLike).population ?? EMPTY_VEC;
|
|
330
370
|
if (!Array.isArray(population) || population.length === 0) return;
|
|
331
371
|
|
|
332
372
|
// Step 2: Iterate population and apply supervised training per network (best-effort).
|
|
333
373
|
for (let networkIndex = 0; networkIndex < population.length; networkIndex++) {
|
|
334
|
-
|
|
335
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
336
|
-
const network: any = population[networkIndex];
|
|
374
|
+
const network = population[networkIndex];
|
|
337
375
|
try {
|
|
338
376
|
if (!network || typeof network.train !== 'function') continue; // skip non-trainable entries
|
|
339
377
|
|
|
@@ -376,9 +414,11 @@ export const pretrainPopulationWarmStart = (
|
|
|
376
414
|
/**
|
|
377
415
|
* Apply Lamarckian backpropagation training to the entire population with optional profiling.
|
|
378
416
|
*
|
|
379
|
-
* Runs a bounded supervised training pass on each network in the population,
|
|
380
|
-
* downsampling the training set for efficiency.
|
|
381
|
-
*
|
|
417
|
+
* Runs a bounded supervised training pass on each network in the population,
|
|
418
|
+
* optionally downsampling the training set for efficiency. The intent is to
|
|
419
|
+
* "tilt" the policy landscape toward obviously sensible moves before the main
|
|
420
|
+
* evolutionary loop takes over, while still measuring and logging enough to see
|
|
421
|
+
* whether the warm-start is becoming too aggressive or too weak.
|
|
382
422
|
*
|
|
383
423
|
* Steps:
|
|
384
424
|
* 1. Validate inputs & early exits
|
|
@@ -418,9 +458,7 @@ export const pretrainPopulationWarmStart = (
|
|
|
418
458
|
*/
|
|
419
459
|
export const applyLamarckianTraining = (
|
|
420
460
|
neat: Neat,
|
|
421
|
-
|
|
422
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
423
|
-
trainingSet: any[],
|
|
461
|
+
trainingSet: LamarckianTrainingCase[],
|
|
424
462
|
iterations: number,
|
|
425
463
|
sampleSize: number | undefined,
|
|
426
464
|
safeWrite: (msg: string) => void,
|
|
@@ -433,9 +471,7 @@ export const applyLamarckianTraining = (
|
|
|
433
471
|
DEFAULT_TRAIN_MOMENTUM: number;
|
|
434
472
|
DEFAULT_TRAIN_BATCH_SMALL: number;
|
|
435
473
|
},
|
|
436
|
-
|
|
437
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
438
|
-
adjustOutputBiases: (network: any) => void,
|
|
474
|
+
adjustOutputBiases: WarmStartNetworkCallback,
|
|
439
475
|
): number => {
|
|
440
476
|
// Step 1: Validate inputs & early exits.
|
|
441
477
|
if (
|
|
@@ -460,9 +496,7 @@ export const applyLamarckianTraining = (
|
|
|
460
496
|
// Step 4: Iterate networks performing a bounded training pass.
|
|
461
497
|
let gradientNormSum = 0;
|
|
462
498
|
let gradientNormSamples = 0;
|
|
463
|
-
|
|
464
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
465
|
-
const populationRef = neat.population as any[];
|
|
499
|
+
const populationRef = (neat as WarmStartNeatLike).population;
|
|
466
500
|
|
|
467
501
|
for (const network of populationRef) {
|
|
468
502
|
if (!network) continue; // defensive guard for sparse arrays
|
|
@@ -483,9 +517,7 @@ export const applyLamarckianTraining = (
|
|
|
483
517
|
|
|
484
518
|
// 4.3: Collect optional training stats (use optional chaining to avoid errors).
|
|
485
519
|
try {
|
|
486
|
-
|
|
487
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
488
|
-
const stats = (network as any).getTrainingStats?.();
|
|
520
|
+
const stats = network.getTrainingStats?.();
|
|
489
521
|
const gradNorm = stats?.gradNorm;
|
|
490
522
|
if (Number.isFinite(gradNorm)) {
|
|
491
523
|
gradientNormSum += gradNorm;
|
|
@@ -545,13 +577,9 @@ export const applyLamarckianTraining = (
|
|
|
545
577
|
*/
|
|
546
578
|
export const warmStartPopulationIfNeeded = (
|
|
547
579
|
neat: Neat,
|
|
548
|
-
|
|
549
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
550
|
-
trainingSet: any[],
|
|
580
|
+
trainingSet: LamarckianTrainingCase[],
|
|
551
581
|
state: EngineState,
|
|
552
|
-
|
|
553
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
554
|
-
pretrainPopulation: (neat: any, trainingSet: any[]) => void,
|
|
582
|
+
pretrainPopulation: PretrainPopulationCallback,
|
|
555
583
|
): void => {
|
|
556
584
|
try {
|
|
557
585
|
// Step 1: Fast-guard invalid inputs – nothing to do when no data or driver.
|
|
@@ -561,9 +589,12 @@ export const warmStartPopulationIfNeeded = (
|
|
|
561
589
|
|
|
562
590
|
// Step 2: Best-effort ensure pooled buffers exist and have capacity.
|
|
563
591
|
// Determine a sensible sizing target (prefer driver configured popSize when available).
|
|
564
|
-
const
|
|
565
|
-
|
|
566
|
-
|
|
592
|
+
const neatRef = neat as WarmStartNeatLike;
|
|
593
|
+
const rawPopSize = neatRef.options?.popSize;
|
|
594
|
+
const configuredPopulationSize =
|
|
595
|
+
typeof rawPopSize === 'number' && Number.isFinite(rawPopSize)
|
|
596
|
+
? Math.max(0, Math.floor(rawPopSize))
|
|
597
|
+
: Math.max(8, trainingSet.length);
|
|
567
598
|
|
|
568
599
|
// Helper: next power-of-two >= n
|
|
569
600
|
const nextPowerOfTwo = (n: number) =>
|