@reicek/neataptic-ts 0.1.26 → 0.1.27
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 +13 -8
- package/.github/agents/docs-scout.agent.md +14 -9
- package/.github/agents/plan-scout.agent.md +11 -6
- package/.github/agents/solid-split.agent.md +33 -17
- package/.github/copilot-instructions.md +100 -88
- package/.github/skills/educational-docs/SKILL.md +90 -40
- package/.github/skills/educational-docs/assets/mermaid-diagram-playbook.md +141 -141
- package/.github/skills/educational-docs/assets/visual-style-guide.md +1 -1
- package/.github/skills/plan-alignment/SKILL.md +1 -1
- package/.github/skills/solid-split/SKILL.md +54 -35
- package/.github/skills/solid-split/assets/docs-checklist.md +1 -1
- package/.github/skills/solid-split/assets/split-plan-template.md +41 -12
- package/.github/skills/solid-split/assets/split-workflow-checklist.md +4 -1
- package/.github/skills/test-fix-workflow/SKILL.md +12 -7
- package/.github/skills/trace-analyzer-extension/SKILL.md +1 -1
- package/.github/skills/trace-analyzer-extension/assets/extension-checklist.md +1 -1
- package/.github/skills/trace-analyzer-extension/references/analyzer-extension-workflow.md +1 -1
- package/.github/skills/trace-audit-reporting/SKILL.md +1 -1
- package/.github/skills/trace-audit-reporting/assets/performance-report-template.md +1 -1
- package/.github/skills/trace-audit-reporting/references/trace-analysis-workflow.md +1 -1
- package/.github/skills/tracker-handoff/SKILL.md +53 -5
- package/package.json +1 -1
- package/plans/Flappy_Bird_Folder_Documentation_Pass.logs.md +42 -0
- package/plans/Flappy_Bird_Folder_Documentation_Pass.md +22 -104
- package/plans/README.md +6 -2
- package/plans/Roadmap.md +35 -31
- package/plans/analyze-trace-solid-split.logs.md +35 -0
- package/plans/analyze-trace-solid-split.plans.md +21 -52
- package/plans/architecture-solid-split.logs.md +44 -0
- package/plans/architecture-solid-split.plans.md +20 -653
- package/plans/asciiMaze-typescript-repair.logs.md +35 -0
- package/plans/asciiMaze-typescript-repair.plans.md +30 -36
- package/plans/generate-docs-solid-split.logs.md +36 -0
- package/plans/generate-docs-solid-split.plans.md +21 -73
- package/plans/methods-docs.logs.md +37 -0
- package/plans/methods-docs.plans.md +22 -183
- package/plans/methods-solid-split.logs.md +41 -0
- package/plans/methods-solid-split.plans.md +23 -65
- package/plans/neat-docs.logs.md +38 -0
- package/plans/neat-docs.plans.md +21 -63
- package/plans/neat-test-surface-repair.logs.md +38 -0
- package/plans/neat-test-surface-repair.plans.md +24 -24
- package/plans/readme-first-section-pass.logs.md +63 -0
- package/plans/readme-first-section-pass.plans.md +42 -0
- package/plans/render-docs-html-solid-split.logs.md +36 -0
- package/plans/render-docs-html-solid-split.plans.md +20 -54
- package/plans/src-no-explicit-any-cleanup.logs.md +39 -0
- package/plans/src-no-explicit-any-cleanup.plans.md +23 -161
- package/plans/utils-docs.logs.md +37 -0
- package/plans/utils-docs.plans.md +20 -35
- package/src/README.md +88 -22
- package/src/architecture/README.md +94 -17
- package/src/architecture/activationArrayPool/README.md +53 -0
- package/src/architecture/activationArrayPool/activationArrayPool.ts +53 -0
- package/src/architecture/layer/README.md +94 -5
- package/src/architecture/layer/layer.ts +94 -5
- package/src/architecture/network/README.md +85 -14
- package/src/architecture/network/activate/README.md +301 -213
- package/src/architecture/network/activate/docs.order.json +9 -0
- package/src/architecture/network/activate/network.activate.utils.ts +90 -0
- package/src/architecture/network/connect/README.md +80 -3
- package/src/architecture/network/connect/docs.order.json +9 -0
- package/src/architecture/network/connect/network.connect.utils.ts +79 -0
- package/src/architecture/network/deterministic/README.md +96 -12
- package/src/architecture/network/deterministic/docs.order.json +10 -0
- package/src/architecture/network/deterministic/network.deterministic.utils.ts +90 -0
- package/src/architecture/network/evolve/README.md +286 -228
- package/src/architecture/network/evolve/docs.order.json +11 -0
- package/src/architecture/network/evolve/network.evolve.utils.ts +59 -0
- package/src/architecture/network/gating/README.md +58 -16
- package/src/architecture/network/gating/docs.order.json +9 -0
- package/src/architecture/network/gating/network.gating.utils.ts +43 -0
- package/src/architecture/network/genetic/README.md +75 -36
- package/src/architecture/network/genetic/docs.order.json +10 -0
- package/src/architecture/network/genetic/network.genetic.utils.ts +53 -17
- package/src/architecture/network/network.ts +91 -46
- package/src/architecture/network/standalone/README.md +309 -285
- package/src/architecture/network/standalone/docs.order.json +13 -0
- package/src/architecture/network/standalone/network.standalone.utils.ts +51 -28
- package/src/architecture/network.ts +94 -17
- package/src/architecture/nodePool/README.md +53 -0
- package/src/architecture/nodePool/nodePool.ts +53 -0
- package/src/methods/README.md +80 -34
- package/src/methods/methods.ts +80 -34
- package/src/methods/mutation/README.md +39 -93
- package/src/methods/mutation/mutation.ts +58 -0
- package/src/multithreading/README.md +114 -14
- package/src/multithreading/docs.order.json +5 -0
- package/src/multithreading/multi.ts +103 -7
- package/src/multithreading/types.ts +6 -1
- package/src/multithreading/workers/README.md +72 -2
- package/src/multithreading/workers/browser/README.md +39 -0
- package/src/multithreading/workers/browser/testworker.ts +40 -0
- package/src/multithreading/workers/node/README.md +50 -11
- package/src/multithreading/workers/node/docs.order.json +4 -0
- package/src/multithreading/workers/node/testworker.ts +43 -3
- package/src/multithreading/workers/workers.ts +36 -1
- package/src/neat/README.md +230 -152
- package/src/neat/adaptive/core/README.md +99 -42
- package/src/neat/adaptive/core/adaptive.core.ts +71 -14
- package/src/neat/adaptive/core/docs.order.json +8 -0
- package/src/neat/docs.order.json +9 -0
- package/src/neat/lineage/README.md +118 -16
- package/src/neat/lineage/lineage.ts +115 -13
- package/src/neat/neat.defaults.constants.ts +91 -13
- package/src/neat.ts +86 -20
- package/src/utils/README.md +71 -21
- package/src/utils/memory.ts +69 -19
- package/test/examples/asciiMaze/browser-entry/README.md +81 -8
- package/test/examples/asciiMaze/browser-entry/browser-entry.ts +81 -8
- package/test/examples/asciiMaze/dashboardManager/README.md +68 -4
- package/test/examples/asciiMaze/dashboardManager/dashboardManager.ts +68 -4
- package/test/examples/asciiMaze/evolutionEngine/README.md +1259 -1174
- package/test/examples/asciiMaze/evolutionEngine/docs.order.json +10 -0
- package/test/examples/asciiMaze/evolutionEngine/evolutionEngine.types.ts +87 -0
- package/test/examples/asciiMaze/mazeMovement/README.md +81 -4
- package/test/examples/asciiMaze/mazeMovement/mazeMovement.ts +81 -4
- package/test/examples/flappy_bird/browser-entry/README.md +64 -21
- package/test/examples/flappy_bird/browser-entry/browser-entry.ts +64 -21
- package/test/examples/flappy_bird/flappy-evolution-worker/README.md +98 -10
- package/test/examples/flappy_bird/flappy-evolution-worker/flappy-evolution-worker.ts +98 -10
- package/test/examples/flappy_bird/simulation-shared/README.md +88 -4
- package/test/examples/flappy_bird/simulation-shared/simulation-shared.types.ts +88 -4
|
@@ -1,3 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser-side evaluation worker wrapper for serialized networks.
|
|
3
|
+
*
|
|
4
|
+
* This chapter is the Web Worker half of the multithreading boundary. It does
|
|
5
|
+
* not teach activation math again. Its job is to take the flat dataset and
|
|
6
|
+
* network contract from `multithreading/`, package it into browser-friendly
|
|
7
|
+
* transfer buffers, and return one scalar error without blocking the main
|
|
8
|
+
* thread.
|
|
9
|
+
*
|
|
10
|
+
* The lifecycle is intentionally coarse grained. The constructor transfers the
|
|
11
|
+
* dataset once and creates a blob-backed worker program. Each `evaluate()` call
|
|
12
|
+
* then sends only the activation, state, and connection buffers for one
|
|
13
|
+
* candidate network. That keeps the wrapper focused on whole-network scoring
|
|
14
|
+
* jobs rather than chatty per-layer messaging.
|
|
15
|
+
*
|
|
16
|
+
* Read the file in runtime order: constructor first, `evaluate()` second,
|
|
17
|
+
* `_createBlobString()` last. That matches the actual browser story: bootstrap
|
|
18
|
+
* a worker, run repeated evaluations, then inspect how the inline worker code
|
|
19
|
+
* is assembled.
|
|
20
|
+
*
|
|
21
|
+
* ```mermaid
|
|
22
|
+
* flowchart LR
|
|
23
|
+
* Host[Browser host] --> Dataset[Transfer dataset once]
|
|
24
|
+
* Dataset --> Blob[Create blob worker]
|
|
25
|
+
* Blob --> Evaluate[Transfer network buffers]
|
|
26
|
+
* Evaluate --> Error[Return scalar error]
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* For background on the browser primitive behind this wrapper, see MDN Web
|
|
30
|
+
* Docs,
|
|
31
|
+
* [Using Web Workers](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers).
|
|
32
|
+
*
|
|
33
|
+
* Example: create one browser worker and reuse it across repeated evaluations.
|
|
34
|
+
*
|
|
35
|
+
* ```ts
|
|
36
|
+
* const worker = new TestWorker(serializedSet, { name: 'mse' });
|
|
37
|
+
* const score = await worker.evaluate(network);
|
|
38
|
+
* worker.terminate();
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
1
41
|
import Multi from '../../multi';
|
|
2
42
|
|
|
3
43
|
/**
|
|
@@ -1,16 +1,42 @@
|
|
|
1
1
|
# multithreading/workers/node
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
This
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
Node-side evaluation worker wrapper for serialized networks.
|
|
4
|
+
|
|
5
|
+
This chapter is the server-runtime twin of the browser worker wrapper. It
|
|
6
|
+
keeps the same public evaluation contract - serialized dataset in,
|
|
7
|
+
serialized network in, scalar score out - but implements it with a forked
|
|
8
|
+
helper process instead of a browser `Worker` instance.
|
|
9
|
+
|
|
10
|
+
That split matters because Node and the browser expose different isolation
|
|
11
|
+
primitives even when the computation is the same. This file owns process
|
|
12
|
+
startup, one-time dataset handoff, repeated `evaluate()` calls, and cleanup.
|
|
13
|
+
The neighboring `worker.ts` file owns the child-process message handler that
|
|
14
|
+
turns those payloads back into a local evaluation run.
|
|
15
|
+
|
|
16
|
+
Read the folder as two layers: `testworker.ts` is the host-side facade and
|
|
17
|
+
`worker.ts` is the child-process entrypoint. Together they keep evaluation
|
|
18
|
+
parallelism explicit without leaking process lifecycle details into the rest
|
|
19
|
+
of the library.
|
|
20
|
+
|
|
21
|
+
```mermaid
|
|
22
|
+
flowchart LR
|
|
23
|
+
Host[Node host] --> Fork[Fork helper process]
|
|
24
|
+
Fork --> Init[Send dataset and cost]
|
|
25
|
+
Init --> Evaluate[Send serialized network]
|
|
26
|
+
Evaluate --> Score[Receive scalar score]
|
|
27
|
+
```
|
|
8
28
|
|
|
9
|
-
|
|
29
|
+
For background on the Node primitive used here, see Node.js Documentation,
|
|
30
|
+
[child_process.fork](https://nodejs.org/api/child_process.html#child_processforkmodulepath-args-options).
|
|
10
31
|
|
|
11
|
-
|
|
32
|
+
Example: keep one worker process around while scoring several candidate
|
|
33
|
+
networks.
|
|
12
34
|
|
|
13
|
-
|
|
35
|
+
```ts
|
|
36
|
+
const worker = new TestWorker(serializedSet, { name: 'mse' });
|
|
37
|
+
const score = await worker.evaluate(network);
|
|
38
|
+
worker.terminate();
|
|
39
|
+
```
|
|
14
40
|
|
|
15
41
|
## multithreading/workers/node/testworker.ts
|
|
16
42
|
|
|
@@ -24,11 +50,12 @@ Interface for serializable network used in worker evaluation.
|
|
|
24
50
|
|
|
25
51
|
### TestWorker
|
|
26
52
|
|
|
27
|
-
TestWorker class for handling network evaluations in a Node.js environment
|
|
53
|
+
TestWorker class for handling network evaluations in a Node.js environment
|
|
54
|
+
through a forked helper process.
|
|
28
55
|
|
|
29
56
|
This implementation aligns with the Instinct algorithm's emphasis on efficient evaluation of
|
|
30
|
-
neural networks in parallel environments. The use of
|
|
31
|
-
computationally expensive tasks, such as network evaluation, to separate
|
|
57
|
+
neural networks in parallel environments. The use of a forked process allows for offloading
|
|
58
|
+
computationally expensive tasks, such as network evaluation, to a separate process.
|
|
32
59
|
|
|
33
60
|
Example:
|
|
34
61
|
|
|
@@ -86,3 +113,15 @@ Example:
|
|
|
86
113
|
const worker = new TestWorker([0, 1, 2], { name: 'mse' });
|
|
87
114
|
// ...use worker.evaluate(...) as needed
|
|
88
115
|
worker.terminate();
|
|
116
|
+
|
|
117
|
+
## multithreading/workers/node/worker.ts
|
|
118
|
+
|
|
119
|
+
Handles messages sent to the worker process.
|
|
120
|
+
|
|
121
|
+
This function listens for messages sent to the worker process and performs one of two actions:
|
|
122
|
+
1. If the message contains serialized activations, states, and connections, it evaluates the network using the dataset.
|
|
123
|
+
2. If the message contains a dataset and cost function, it initializes the worker with the provided data.
|
|
124
|
+
|
|
125
|
+
### WorkerMessage
|
|
126
|
+
|
|
127
|
+
Interface for messages sent to the worker process.
|
|
@@ -1,3 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Node-side evaluation worker wrapper for serialized networks.
|
|
3
|
+
*
|
|
4
|
+
* This chapter is the server-runtime twin of the browser worker wrapper. It
|
|
5
|
+
* keeps the same public evaluation contract - serialized dataset in,
|
|
6
|
+
* serialized network in, scalar score out - but implements it with a forked
|
|
7
|
+
* helper process instead of a browser `Worker` instance.
|
|
8
|
+
*
|
|
9
|
+
* That split matters because Node and the browser expose different isolation
|
|
10
|
+
* primitives even when the computation is the same. This file owns process
|
|
11
|
+
* startup, one-time dataset handoff, repeated `evaluate()` calls, and cleanup.
|
|
12
|
+
* The neighboring `worker.ts` file owns the child-process message handler that
|
|
13
|
+
* turns those payloads back into a local evaluation run.
|
|
14
|
+
*
|
|
15
|
+
* Read the folder as two layers: `testworker.ts` is the host-side facade and
|
|
16
|
+
* `worker.ts` is the child-process entrypoint. Together they keep evaluation
|
|
17
|
+
* parallelism explicit without leaking process lifecycle details into the rest
|
|
18
|
+
* of the library.
|
|
19
|
+
*
|
|
20
|
+
* ```mermaid
|
|
21
|
+
* flowchart LR
|
|
22
|
+
* Host[Node host] --> Fork[Fork helper process]
|
|
23
|
+
* Fork --> Init[Send dataset and cost]
|
|
24
|
+
* Init --> Evaluate[Send serialized network]
|
|
25
|
+
* Evaluate --> Score[Receive scalar score]
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* For background on the Node primitive used here, see Node.js Documentation,
|
|
29
|
+
* [child_process.fork](https://nodejs.org/api/child_process.html#child_processforkmodulepath-args-options).
|
|
30
|
+
*
|
|
31
|
+
* Example: keep one worker process around while scoring several candidate
|
|
32
|
+
* networks.
|
|
33
|
+
*
|
|
34
|
+
* ```ts
|
|
35
|
+
* const worker = new TestWorker(serializedSet, { name: 'mse' });
|
|
36
|
+
* const score = await worker.evaluate(network);
|
|
37
|
+
* worker.terminate();
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
1
40
|
import { fork, ChildProcess } from 'child_process';
|
|
2
41
|
import * as path from 'path';
|
|
3
42
|
|
|
@@ -16,11 +55,12 @@ interface CostFunction {
|
|
|
16
55
|
}
|
|
17
56
|
|
|
18
57
|
/**
|
|
19
|
-
* TestWorker class for handling network evaluations in a Node.js environment
|
|
58
|
+
* TestWorker class for handling network evaluations in a Node.js environment
|
|
59
|
+
* through a forked helper process.
|
|
20
60
|
*
|
|
21
61
|
* This implementation aligns with the Instinct algorithm's emphasis on efficient evaluation of
|
|
22
|
-
* neural networks in parallel environments. The use of
|
|
23
|
-
* computationally expensive tasks, such as network evaluation, to separate
|
|
62
|
+
* neural networks in parallel environments. The use of a forked process allows for offloading
|
|
63
|
+
* computationally expensive tasks, such as network evaluation, to a separate process.
|
|
24
64
|
*
|
|
25
65
|
* @see {@link https://medium.com/data-science/neuro-evolution-on-steroids-82bd14ddc2f6#4-constraints Instinct Algorithm - Section 4 Constraints}
|
|
26
66
|
*
|
|
@@ -1,5 +1,40 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Runtime loader shelf for browser and Node evaluation workers.
|
|
3
|
+
*
|
|
4
|
+
* The multithreading root explains the serialization contract. This file
|
|
5
|
+
* answers a narrower question: once a dataset and a network have already been
|
|
6
|
+
* flattened into portable arrays, which runtime-specific worker wrapper should
|
|
7
|
+
* own the evaluation run?
|
|
8
|
+
*
|
|
9
|
+
* Keeping that choice behind one tiny loader shelf has two benefits. The host
|
|
10
|
+
* runtime can defer importing browser-only or Node-only code until it actually
|
|
11
|
+
* needs it, and the rest of the library can talk about one worker boundary
|
|
12
|
+
* without pretending that Web Workers and forked Node helpers expose the same
|
|
13
|
+
* constructor surface.
|
|
14
|
+
*
|
|
15
|
+
* `getBrowserTestWorker()` loads the wrapper that creates a blob-backed worker
|
|
16
|
+
* in the browser. `getNodeTestWorker()` loads the wrapper that forks a helper
|
|
17
|
+
* process in Node. Both wrappers consume the same serialized payload shape and
|
|
18
|
+
* return the same scalar evaluation contract.
|
|
19
|
+
*
|
|
20
|
+
* ```mermaid
|
|
21
|
+
* flowchart LR
|
|
22
|
+
* Host[Host runtime] --> Choose[Choose worker wrapper]
|
|
23
|
+
* Choose --> Browser[Browser worker facade]
|
|
24
|
+
* Choose --> Node[Node worker facade]
|
|
25
|
+
* Browser --> Score[Scalar evaluation]
|
|
26
|
+
* Node --> Score
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* Example: choose the runtime-specific worker facade without importing both
|
|
30
|
+
* implementations up front.
|
|
31
|
+
*
|
|
32
|
+
* ```ts
|
|
33
|
+
* const WorkerClass =
|
|
34
|
+
* typeof window === 'undefined'
|
|
35
|
+
* ? await Workers.getNodeTestWorker()
|
|
36
|
+
* : await Workers.getBrowserTestWorker();
|
|
37
|
+
* ```
|
|
3
38
|
*/
|
|
4
39
|
export class Workers {
|
|
5
40
|
/**
|
package/src/neat/README.md
CHANGED
|
@@ -1,5 +1,235 @@
|
|
|
1
1
|
# neat
|
|
2
2
|
|
|
3
|
+
Root chapter map and public default knobs for the internal `src/neat` controller surface.
|
|
4
|
+
|
|
5
|
+
`src/neat.ts` is the public control desk. `src/neat/` is the machine room
|
|
6
|
+
behind it. This folder owns the controller chapters that make a run real:
|
|
7
|
+
initialization, evaluation, evolution, mutation, speciation, telemetry,
|
|
8
|
+
persistence, and the shared bookkeeping that keeps experiments deterministic
|
|
9
|
+
instead of magical. Promoting the defaults file to the chapter opening is
|
|
10
|
+
intentional because default knobs are the quickest way to make the
|
|
11
|
+
controller's personality legible before a reader dives into implementation
|
|
12
|
+
detail.
|
|
13
|
+
|
|
14
|
+
The most helpful reading move is to split the folder into four working
|
|
15
|
+
lanes. `init/`, `evaluate/`, and `evolve/` explain how a population is
|
|
16
|
+
created, scored, and replaced. `mutation/`, `selection/`, and `speciation/`
|
|
17
|
+
explain how search pressure and diversity are managed. `telemetry/`,
|
|
18
|
+
`lineage/`, `diversity/`, and `multiobjective/` explain how the run becomes
|
|
19
|
+
inspectable. `export/`, `rng/`, `cache/`, `maintenance/`, and `pruning/`
|
|
20
|
+
explain how the controller stays reproducible and tractable as experiments
|
|
21
|
+
get larger.
|
|
22
|
+
|
|
23
|
+
The flat root files are small bridges rather than the whole story.
|
|
24
|
+
`neat.defaults.constants.ts` and `neat.types.ts` keep the public constructor
|
|
25
|
+
and option bag readable. `neat.lineage.ts` and `neat.constants.ts` keep
|
|
26
|
+
small shared logic close to the root when multiple chapters need it. The
|
|
27
|
+
deeper folders own the heavier policy and runtime details.
|
|
28
|
+
|
|
29
|
+
These defaults matter because they are the baseline promises the controller
|
|
30
|
+
makes when a caller says "give me an ordinary NEAT run." Population size,
|
|
31
|
+
mutation tempo, compatibility pressure, structural ceilings, and
|
|
32
|
+
observability sampling are not random numbers. They are the quiet assumptions
|
|
33
|
+
that decide whether the controller behaves like a conservative search, an
|
|
34
|
+
exploratory search, or an unstable one.
|
|
35
|
+
|
|
36
|
+
That design follows the original NEAT intuition: protect structural
|
|
37
|
+
innovation long enough for it to compete, rather than forcing every new
|
|
38
|
+
topology to beat established species immediately. See Stanley and
|
|
39
|
+
Miikkulainen,
|
|
40
|
+
[Evolving Neural Networks through Augmenting Topologies](https://nn.cs.utexas.edu/?stanley:ec02),
|
|
41
|
+
for the background behind the compatibility and growth vocabulary that keeps
|
|
42
|
+
surfacing across this folder.
|
|
43
|
+
|
|
44
|
+
Read this root chapter in three passes. Start with this defaults file and
|
|
45
|
+
`neat.types.ts` for the public knobs and broad contracts. Continue into
|
|
46
|
+
`evaluate/`, `evolve/`, and `speciation/` for the live search loop. Finish
|
|
47
|
+
with `telemetry/`, `lineage/`, `multiobjective/`, `export/`, and `rng/` when
|
|
48
|
+
you want to inspect, replay, or compare runs rather than only advance them.
|
|
49
|
+
|
|
50
|
+
```mermaid
|
|
51
|
+
flowchart TD
|
|
52
|
+
classDef base fill:#08131f,stroke:#1ea7ff,color:#dff6ff,stroke-width:1px;
|
|
53
|
+
classDef accent fill:#0f2233,stroke:#ffd166,color:#fff4cc,stroke-width:1.5px;
|
|
54
|
+
|
|
55
|
+
Root["src/neat root"]:::accent --> Loop["init / evaluate / evolve"]:::base
|
|
56
|
+
Root --> Pressure["mutation / selection / speciation"]:::base
|
|
57
|
+
Root --> Observe["telemetry / lineage / diversity / multiobjective"]:::base
|
|
58
|
+
Root --> Replay["export / rng / cache / maintenance / pruning"]:::base
|
|
59
|
+
Root --> Bridges["root bridges<br/>defaults / types / constants"]:::base
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
```mermaid
|
|
63
|
+
flowchart LR
|
|
64
|
+
classDef base fill:#08131f,stroke:#1ea7ff,color:#dff6ff,stroke-width:1px;
|
|
65
|
+
classDef accent fill:#0f2233,stroke:#ffd166,color:#fff4cc,stroke-width:1.5px;
|
|
66
|
+
|
|
67
|
+
Defaults[Root defaults]:::accent --> Population[popsize elitism provenance]:::base
|
|
68
|
+
Defaults --> Variation[mutationRate mutationAmount]:::base
|
|
69
|
+
Defaults --> Species[compatibility and weight coefficients]:::base
|
|
70
|
+
Defaults --> Observation[diversity and novelty samples]:::base
|
|
71
|
+
Population --> Run[Controller behavior]:::base
|
|
72
|
+
Variation --> Run
|
|
73
|
+
Species --> Run
|
|
74
|
+
Observation --> Run
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Example: build one explicit baseline options bag from the documented root
|
|
78
|
+
defaults.
|
|
79
|
+
|
|
80
|
+
```ts
|
|
81
|
+
const baselineOptions = {
|
|
82
|
+
popsize: DEFAULT_POPULATION_SIZE,
|
|
83
|
+
mutationRate: DEFAULT_MUTATION_RATE,
|
|
84
|
+
compatibilityThreshold: DEFAULT_COMPATIBILITY_THRESHOLD,
|
|
85
|
+
};
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Example: keep the observability defaults visible when teaching or
|
|
89
|
+
benchmarking runs.
|
|
90
|
+
|
|
91
|
+
```ts
|
|
92
|
+
const observabilityDefaults = {
|
|
93
|
+
diversityPairSample: DEFAULT_DIVERSITY_PAIR_SAMPLE,
|
|
94
|
+
diversityGraphletSample: DEFAULT_DIVERSITY_GRAPHLET_SAMPLE,
|
|
95
|
+
noveltyK: DEFAULT_NOVELTY_K,
|
|
96
|
+
};
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## neat/neat.defaults.constants.ts
|
|
100
|
+
|
|
101
|
+
### DEFAULT_COMPATIBILITY_THRESHOLD
|
|
102
|
+
|
|
103
|
+
Default compatibility threshold controlling speciation distance.
|
|
104
|
+
|
|
105
|
+
This starts the speciation-pressure family of defaults. It is the neutral
|
|
106
|
+
boundary the controller uses before adaptive tuning or custom settings make
|
|
107
|
+
species splits stricter or more permissive.
|
|
108
|
+
|
|
109
|
+
### DEFAULT_DISJOINT_COEFF
|
|
110
|
+
|
|
111
|
+
Default disjoint coefficient for NEAT compatibility distance.
|
|
112
|
+
|
|
113
|
+
Matching the excess coefficient by default gives the root controller a
|
|
114
|
+
balanced structural view: excess and disjoint innovation gaps both count as
|
|
115
|
+
first-class evidence during compatibility comparisons.
|
|
116
|
+
|
|
117
|
+
### DEFAULT_DIVERSITY_GRAPHLET_SAMPLE
|
|
118
|
+
|
|
119
|
+
Default graphlet sample size used by diversity metrics in fast mode.
|
|
120
|
+
|
|
121
|
+
Read this beside {@link DEFAULT_DIVERSITY_PAIR_SAMPLE}: pair samples give the
|
|
122
|
+
controller quick distance evidence, while graphlet samples provide a small
|
|
123
|
+
structural texture read without forcing whole-population analysis.
|
|
124
|
+
|
|
125
|
+
### DEFAULT_DIVERSITY_PAIR_SAMPLE
|
|
126
|
+
|
|
127
|
+
Default pair-sample size used by diversity metrics in fast mode.
|
|
128
|
+
|
|
129
|
+
This starts the observability-sampling family. The root controller uses a
|
|
130
|
+
bounded sample instead of exhaustive pair checks so diversity reads stay
|
|
131
|
+
cheap enough for ordinary runs.
|
|
132
|
+
|
|
133
|
+
### DEFAULT_ELITISM
|
|
134
|
+
|
|
135
|
+
Default elitism count applied when unspecified.
|
|
136
|
+
|
|
137
|
+
Read this beside {@link DEFAULT_POPULATION_SIZE} and
|
|
138
|
+
{@link DEFAULT_PROVENANCE}: the trio defines how much of each generation is
|
|
139
|
+
reserved for carry-over, how much is freshly injected, and how much capacity
|
|
140
|
+
remains for ordinary offspring.
|
|
141
|
+
|
|
142
|
+
### DEFAULT_EXCESS_COEFF
|
|
143
|
+
|
|
144
|
+
Default excess coefficient for NEAT compatibility distance.
|
|
145
|
+
|
|
146
|
+
This begins the root compatibility-weight family. These coefficients explain
|
|
147
|
+
which kinds of genome disagreement matter most when the controller decides
|
|
148
|
+
whether two genomes still belong in the same species neighborhood.
|
|
149
|
+
|
|
150
|
+
### DEFAULT_MAX_CONNS
|
|
151
|
+
|
|
152
|
+
Default maximum allowed connections where `Infinity` means unbounded growth.
|
|
153
|
+
|
|
154
|
+
This preserves the same baseline policy as {@link DEFAULT_MAX_NODES}: the
|
|
155
|
+
controller does not impose a fixed connection ceiling unless the caller wants
|
|
156
|
+
one.
|
|
157
|
+
|
|
158
|
+
### DEFAULT_MAX_GATES
|
|
159
|
+
|
|
160
|
+
Default maximum allowed gates where `Infinity` means unbounded growth.
|
|
161
|
+
|
|
162
|
+
Gate limits stay in the same family as node and connection limits so the
|
|
163
|
+
whole structural-cap story remains consistent at the root surface.
|
|
164
|
+
|
|
165
|
+
### DEFAULT_MAX_NODES
|
|
166
|
+
|
|
167
|
+
Default maximum allowed nodes where `Infinity` means unbounded growth.
|
|
168
|
+
|
|
169
|
+
Read the three `DEFAULT_MAX_*` exports as one structural-ceiling family.
|
|
170
|
+
Leaving them unbounded by default tells the root controller to rely on
|
|
171
|
+
mutation policy, pruning, and adaptive limits instead of an immediate hard
|
|
172
|
+
cap.
|
|
173
|
+
|
|
174
|
+
### DEFAULT_MUTATION_AMOUNT
|
|
175
|
+
|
|
176
|
+
Default number of mutation operations applied per genome.
|
|
177
|
+
|
|
178
|
+
The default keeps the baseline search policy conservative: most runs mutate
|
|
179
|
+
often enough to keep topology moving, but each genome usually pays for only
|
|
180
|
+
one structural or parametric change per mutation pass.
|
|
181
|
+
|
|
182
|
+
### DEFAULT_MUTATION_RATE
|
|
183
|
+
|
|
184
|
+
Default mutation rate used by the root controller when no explicit rate is supplied.
|
|
185
|
+
|
|
186
|
+
This belongs to the same search-tempo family as
|
|
187
|
+
{@link DEFAULT_MUTATION_AMOUNT}. Together they define how often mutation is
|
|
188
|
+
attempted and how many mutation steps a genome can receive once mutation is
|
|
189
|
+
active.
|
|
190
|
+
|
|
191
|
+
### DEFAULT_NEAT_CONSTRUCTOR_DEFAULTS
|
|
192
|
+
|
|
193
|
+
Shared defaults packet consumed by the constructor bootstrap chapter.
|
|
194
|
+
|
|
195
|
+
The root public surface still exports the individual constants for callers
|
|
196
|
+
and docs, but the constructor now hands one named packet to `init/` instead
|
|
197
|
+
of rebuilding the same object inline inside `src/neat.ts`.
|
|
198
|
+
|
|
199
|
+
### DEFAULT_NOVELTY_K
|
|
200
|
+
|
|
201
|
+
Default neighbor count for novelty search when `k` is unspecified.
|
|
202
|
+
|
|
203
|
+
This closes the root observability-and-exploration shelf. It controls how
|
|
204
|
+
many nearby behaviors contribute to novelty before the caller tunes novelty
|
|
205
|
+
search more explicitly.
|
|
206
|
+
|
|
207
|
+
### DEFAULT_POPULATION_SIZE
|
|
208
|
+
|
|
209
|
+
Default population size when caller does not specify `popsize`.
|
|
210
|
+
|
|
211
|
+
This opens the root defaults shelf's search-volume family. It controls how
|
|
212
|
+
many genomes compete in each generation before elitism, provenance, or
|
|
213
|
+
mutation pressure begin to reshape the population.
|
|
214
|
+
|
|
215
|
+
### DEFAULT_PROVENANCE
|
|
216
|
+
|
|
217
|
+
Default provenance count applied when unspecified.
|
|
218
|
+
|
|
219
|
+
Provenance is the root controller's small "fresh seed" policy. A value of
|
|
220
|
+
`0` means the default run does not spend population budget on extra
|
|
221
|
+
generation-zero style injections unless the caller asks for them.
|
|
222
|
+
|
|
223
|
+
### DEFAULT_WEIGHT_DIFF_COEFF
|
|
224
|
+
|
|
225
|
+
Default average weight difference coefficient for compatibility distance.
|
|
226
|
+
|
|
227
|
+
This keeps parameter drift relevant without letting weight deltas dominate
|
|
228
|
+
the whole speciation read. In the default family, topology disagreement still
|
|
229
|
+
carries more weight than modest edge-weight differences.
|
|
230
|
+
|
|
231
|
+
## neat/neat.types.ts
|
|
232
|
+
|
|
3
233
|
Root compatibility types for the public `Neat` controller boundary.
|
|
4
234
|
|
|
5
235
|
The chapter exists to keep `src/neat.ts` orchestration-first while still
|
|
@@ -15,8 +245,6 @@ Read the file in three passes:
|
|
|
15
245
|
- finish with the restore and mutation aliases when you are tracing how the
|
|
16
246
|
root facade forwards work into the `init/`, `rng/`, and `export/` chapters.
|
|
17
247
|
|
|
18
|
-
## neat/neat.types.ts
|
|
19
|
-
|
|
20
248
|
### NeatExportFitnessFunction
|
|
21
249
|
|
|
22
250
|
```ts
|
|
@@ -434,153 +662,3 @@ Parameters:
|
|
|
434
662
|
- `graph` - - Network to summarize structurally.
|
|
435
663
|
|
|
436
664
|
Returns: Shannon-style entropy of the out-degree distribution.
|
|
437
|
-
|
|
438
|
-
## neat/neat.defaults.constants.ts
|
|
439
|
-
|
|
440
|
-
Public default knobs for the root `Neat` controller.
|
|
441
|
-
|
|
442
|
-
These constants describe the controller personality a caller gets before a
|
|
443
|
-
custom option bag starts bending the run toward a different search style.
|
|
444
|
-
Keeping them in their own root chapter lets `src/neat.ts` stay focused on
|
|
445
|
-
orchestration while the `init/` chapter consumes one shared defaults packet.
|
|
446
|
-
|
|
447
|
-
The constants fall into four small families:
|
|
448
|
-
|
|
449
|
-
- search volume and tempo,
|
|
450
|
-
- speciation pressure,
|
|
451
|
-
- structural ceilings,
|
|
452
|
-
- observability sampling.
|
|
453
|
-
|
|
454
|
-
Read them as the public defaults shelf, not as hidden implementation trivia.
|
|
455
|
-
These values are the baseline promises the root controller makes when a user
|
|
456
|
-
says, "give me an ordinary NEAT run," without specifying every knob.
|
|
457
|
-
|
|
458
|
-
### DEFAULT_COMPATIBILITY_THRESHOLD
|
|
459
|
-
|
|
460
|
-
Default compatibility threshold controlling speciation distance.
|
|
461
|
-
|
|
462
|
-
This starts the speciation-pressure family of defaults. It is the neutral
|
|
463
|
-
boundary the controller uses before adaptive tuning or custom settings make
|
|
464
|
-
species splits stricter or more permissive.
|
|
465
|
-
|
|
466
|
-
### DEFAULT_DISJOINT_COEFF
|
|
467
|
-
|
|
468
|
-
Default disjoint coefficient for NEAT compatibility distance.
|
|
469
|
-
|
|
470
|
-
Matching the excess coefficient by default gives the root controller a
|
|
471
|
-
balanced structural view: excess and disjoint innovation gaps both count as
|
|
472
|
-
first-class evidence during compatibility comparisons.
|
|
473
|
-
|
|
474
|
-
### DEFAULT_DIVERSITY_GRAPHLET_SAMPLE
|
|
475
|
-
|
|
476
|
-
Default graphlet sample size used by diversity metrics in fast mode.
|
|
477
|
-
|
|
478
|
-
Read this beside {@link DEFAULT_DIVERSITY_PAIR_SAMPLE}: pair samples give the
|
|
479
|
-
controller quick distance evidence, while graphlet samples provide a small
|
|
480
|
-
structural texture read without forcing whole-population analysis.
|
|
481
|
-
|
|
482
|
-
### DEFAULT_DIVERSITY_PAIR_SAMPLE
|
|
483
|
-
|
|
484
|
-
Default pair-sample size used by diversity metrics in fast mode.
|
|
485
|
-
|
|
486
|
-
This starts the observability-sampling family. The root controller uses a
|
|
487
|
-
bounded sample instead of exhaustive pair checks so diversity reads stay
|
|
488
|
-
cheap enough for ordinary runs.
|
|
489
|
-
|
|
490
|
-
### DEFAULT_ELITISM
|
|
491
|
-
|
|
492
|
-
Default elitism count applied when unspecified.
|
|
493
|
-
|
|
494
|
-
Read this beside {@link DEFAULT_POPULATION_SIZE} and
|
|
495
|
-
{@link DEFAULT_PROVENANCE}: the trio defines how much of each generation is
|
|
496
|
-
reserved for carry-over, how much is freshly injected, and how much capacity
|
|
497
|
-
remains for ordinary offspring.
|
|
498
|
-
|
|
499
|
-
### DEFAULT_EXCESS_COEFF
|
|
500
|
-
|
|
501
|
-
Default excess coefficient for NEAT compatibility distance.
|
|
502
|
-
|
|
503
|
-
This begins the root compatibility-weight family. These coefficients explain
|
|
504
|
-
which kinds of genome disagreement matter most when the controller decides
|
|
505
|
-
whether two genomes still belong in the same species neighborhood.
|
|
506
|
-
|
|
507
|
-
### DEFAULT_MAX_CONNS
|
|
508
|
-
|
|
509
|
-
Default maximum allowed connections where `Infinity` means unbounded growth.
|
|
510
|
-
|
|
511
|
-
This preserves the same baseline policy as {@link DEFAULT_MAX_NODES}: the
|
|
512
|
-
controller does not impose a fixed connection ceiling unless the caller wants
|
|
513
|
-
one.
|
|
514
|
-
|
|
515
|
-
### DEFAULT_MAX_GATES
|
|
516
|
-
|
|
517
|
-
Default maximum allowed gates where `Infinity` means unbounded growth.
|
|
518
|
-
|
|
519
|
-
Gate limits stay in the same family as node and connection limits so the
|
|
520
|
-
whole structural-cap story remains consistent at the root surface.
|
|
521
|
-
|
|
522
|
-
### DEFAULT_MAX_NODES
|
|
523
|
-
|
|
524
|
-
Default maximum allowed nodes where `Infinity` means unbounded growth.
|
|
525
|
-
|
|
526
|
-
Read the three `DEFAULT_MAX_*` exports as one structural-ceiling family.
|
|
527
|
-
Leaving them unbounded by default tells the root controller to rely on
|
|
528
|
-
mutation policy, pruning, and adaptive limits instead of an immediate hard
|
|
529
|
-
cap.
|
|
530
|
-
|
|
531
|
-
### DEFAULT_MUTATION_AMOUNT
|
|
532
|
-
|
|
533
|
-
Default number of mutation operations applied per genome.
|
|
534
|
-
|
|
535
|
-
The default keeps the baseline search policy conservative: most runs mutate
|
|
536
|
-
often enough to keep topology moving, but each genome usually pays for only
|
|
537
|
-
one structural or parametric change per mutation pass.
|
|
538
|
-
|
|
539
|
-
### DEFAULT_MUTATION_RATE
|
|
540
|
-
|
|
541
|
-
Default mutation rate used by the root controller when no explicit rate is supplied.
|
|
542
|
-
|
|
543
|
-
This belongs to the same search-tempo family as
|
|
544
|
-
{@link DEFAULT_MUTATION_AMOUNT}. Together they define how often mutation is
|
|
545
|
-
attempted and how many mutation steps a genome can receive once mutation is
|
|
546
|
-
active.
|
|
547
|
-
|
|
548
|
-
### DEFAULT_NEAT_CONSTRUCTOR_DEFAULTS
|
|
549
|
-
|
|
550
|
-
Shared defaults packet consumed by the constructor bootstrap chapter.
|
|
551
|
-
|
|
552
|
-
The root public surface still exports the individual constants for callers
|
|
553
|
-
and docs, but the constructor now hands one named packet to `init/` instead
|
|
554
|
-
of rebuilding the same object inline inside `src/neat.ts`.
|
|
555
|
-
|
|
556
|
-
### DEFAULT_NOVELTY_K
|
|
557
|
-
|
|
558
|
-
Default neighbor count for novelty search when `k` is unspecified.
|
|
559
|
-
|
|
560
|
-
This closes the root observability-and-exploration shelf. It controls how
|
|
561
|
-
many nearby behaviors contribute to novelty before the caller tunes novelty
|
|
562
|
-
search more explicitly.
|
|
563
|
-
|
|
564
|
-
### DEFAULT_POPULATION_SIZE
|
|
565
|
-
|
|
566
|
-
Default population size when caller does not specify `popsize`.
|
|
567
|
-
|
|
568
|
-
This opens the root defaults shelf's search-volume family. It controls how
|
|
569
|
-
many genomes compete in each generation before elitism, provenance, or
|
|
570
|
-
mutation pressure begin to reshape the population.
|
|
571
|
-
|
|
572
|
-
### DEFAULT_PROVENANCE
|
|
573
|
-
|
|
574
|
-
Default provenance count applied when unspecified.
|
|
575
|
-
|
|
576
|
-
Provenance is the root controller's small "fresh seed" policy. A value of
|
|
577
|
-
`0` means the default run does not spend population budget on extra
|
|
578
|
-
generation-zero style injections unless the caller asks for them.
|
|
579
|
-
|
|
580
|
-
### DEFAULT_WEIGHT_DIFF_COEFF
|
|
581
|
-
|
|
582
|
-
Default average weight difference coefficient for compatibility distance.
|
|
583
|
-
|
|
584
|
-
This keeps parameter drift relevant without letting weight deltas dominate
|
|
585
|
-
the whole speciation read. In the default family, topology disagreement still
|
|
586
|
-
carries more weight than modest edge-weight differences.
|