gras-engine 0.2.0__tar.gz → 0.4.0__tar.gz
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.
- {gras_engine-0.2.0 → gras_engine-0.4.0}/Cargo.lock +13 -2
- {gras_engine-0.2.0 → gras_engine-0.4.0}/Cargo.toml +3 -3
- {gras_engine-0.2.0 → gras_engine-0.4.0}/PKG-INFO +3 -8
- {gras_engine-0.2.0 → gras_engine-0.4.0}/README.md +1 -1
- {gras_engine-0.2.0 → gras_engine-0.4.0}/examples/cartpole.rs +204 -70
- {gras_engine-0.2.0 → gras_engine-0.4.0}/examples/mnist.rs +140 -49
- {gras_engine-0.2.0 → gras_engine-0.4.0}/gras-py/Cargo.toml +2 -2
- {gras_engine-0.2.0 → gras_engine-0.4.0}/gras-py/src/config.rs +3 -2
- {gras_engine-0.2.0 → gras_engine-0.4.0}/pyproject.toml +2 -2
- {gras_engine-0.2.0 → gras_engine-0.4.0}/python/README.md +0 -5
- {gras_engine-0.2.0 → gras_engine-0.4.0}/src/engine/clock/stop.rs +11 -0
- {gras_engine-0.2.0 → gras_engine-0.4.0}/src/engine/config/builder/topology.rs +1 -1
- {gras_engine-0.2.0 → gras_engine-0.4.0}/src/engine/core/mod.rs +179 -3
- {gras_engine-0.2.0 → gras_engine-0.4.0}/src/engine/core/tests.rs +140 -2
- {gras_engine-0.2.0 → gras_engine-0.4.0}/src/engine/reporting/mod.rs +45 -12
- {gras_engine-0.2.0 → gras_engine-0.4.0}/src/graph/topology.rs +6 -6
- {gras_engine-0.2.0 → gras_engine-0.4.0}/LICENSE +0 -0
- {gras_engine-0.2.0 → gras_engine-0.4.0}/benches/flamegraph.rs +0 -0
- {gras_engine-0.2.0 → gras_engine-0.4.0}/benches/memgraph.rs +0 -0
- {gras_engine-0.2.0 → gras_engine-0.4.0}/benches/ref_trainer.rs +0 -0
- {gras_engine-0.2.0 → gras_engine-0.4.0}/benches/stream.rs +0 -0
- {gras_engine-0.2.0 → gras_engine-0.4.0}/benches/support/mod.rs +0 -0
- {gras_engine-0.2.0 → gras_engine-0.4.0}/examples/cartpole/tests.rs +0 -0
- {gras_engine-0.2.0 → gras_engine-0.4.0}/examples/python/load_gras_net.py +0 -0
- {gras_engine-0.2.0 → gras_engine-0.4.0}/examples/python/test_load_gras_net.py +0 -0
- {gras_engine-0.2.0 → gras_engine-0.4.0}/gras-py/src/arrays.rs +0 -0
- {gras_engine-0.2.0 → gras_engine-0.4.0}/gras-py/src/defaults.rs +0 -0
- {gras_engine-0.2.0 → gras_engine-0.4.0}/gras-py/src/engine.rs +0 -0
- {gras_engine-0.2.0 → gras_engine-0.4.0}/gras-py/src/gym.rs +0 -0
- {gras_engine-0.2.0 → gras_engine-0.4.0}/gras-py/src/lib.rs +0 -0
- {gras_engine-0.2.0 → gras_engine-0.4.0}/gras-py/src/logging.rs +0 -0
- {gras_engine-0.2.0 → gras_engine-0.4.0}/gras-py/src/menu.rs +0 -0
- {gras_engine-0.2.0 → gras_engine-0.4.0}/gras-py/src/topology.rs +0 -0
- {gras_engine-0.2.0 → gras_engine-0.4.0}/python/gras/__init__.py +0 -0
- {gras_engine-0.2.0 → gras_engine-0.4.0}/src/engine/breed/child.rs +0 -0
- {gras_engine-0.2.0 → gras_engine-0.4.0}/src/engine/breed/cull.rs +0 -0
- {gras_engine-0.2.0 → gras_engine-0.4.0}/src/engine/breed/evolve.rs +0 -0
- {gras_engine-0.2.0 → gras_engine-0.4.0}/src/engine/breed/mod.rs +0 -0
- {gras_engine-0.2.0 → gras_engine-0.4.0}/src/engine/clock/lottery.rs +0 -0
- {gras_engine-0.2.0 → gras_engine-0.4.0}/src/engine/clock/mod.rs +0 -0
- {gras_engine-0.2.0 → gras_engine-0.4.0}/src/engine/clock/smoothing.rs +0 -0
- {gras_engine-0.2.0 → gras_engine-0.4.0}/src/engine/clock/step.rs +0 -0
- {gras_engine-0.2.0 → gras_engine-0.4.0}/src/engine/config/builder/evolution.rs +0 -0
- {gras_engine-0.2.0 → gras_engine-0.4.0}/src/engine/config/builder/lottery.rs +0 -0
- {gras_engine-0.2.0 → gras_engine-0.4.0}/src/engine/config/builder/population.rs +0 -0
- {gras_engine-0.2.0 → gras_engine-0.4.0}/src/engine/config/builder/ranking.rs +0 -0
- {gras_engine-0.2.0 → gras_engine-0.4.0}/src/engine/config/builder/run.rs +0 -0
- {gras_engine-0.2.0 → gras_engine-0.4.0}/src/engine/config/builder.rs +0 -0
- {gras_engine-0.2.0 → gras_engine-0.4.0}/src/engine/config.rs +0 -0
- {gras_engine-0.2.0 → gras_engine-0.4.0}/src/engine/core/durability.rs +0 -0
- {gras_engine-0.2.0 → gras_engine-0.4.0}/src/engine/core/evolution.rs +0 -0
- {gras_engine-0.2.0 → gras_engine-0.4.0}/src/engine/core/exam.rs +0 -0
- {gras_engine-0.2.0 → gras_engine-0.4.0}/src/engine/core/ranking.rs +0 -0
- {gras_engine-0.2.0 → gras_engine-0.4.0}/src/engine/core/resume.rs +0 -0
- {gras_engine-0.2.0 → gras_engine-0.4.0}/src/engine/core/roles.rs +0 -0
- {gras_engine-0.2.0 → gras_engine-0.4.0}/src/engine/diversity/mod.rs +0 -0
- {gras_engine-0.2.0 → gras_engine-0.4.0}/src/engine/diversity/novelty.rs +0 -0
- {gras_engine-0.2.0 → gras_engine-0.4.0}/src/engine/founding/mod.rs +0 -0
- {gras_engine-0.2.0 → gras_engine-0.4.0}/src/engine/founding/pool.rs +0 -0
- {gras_engine-0.2.0 → gras_engine-0.4.0}/src/engine/founding/population.rs +0 -0
- {gras_engine-0.2.0 → gras_engine-0.4.0}/src/engine/founding/seed.rs +0 -0
- {gras_engine-0.2.0 → gras_engine-0.4.0}/src/engine/mod.rs +0 -0
- {gras_engine-0.2.0 → gras_engine-0.4.0}/src/engine/reporting/format.rs +0 -0
- {gras_engine-0.2.0 → gras_engine-0.4.0}/src/engine/reporting/lineage.rs +0 -0
- {gras_engine-0.2.0 → gras_engine-0.4.0}/src/engine/reporting/logging.rs +0 -0
- {gras_engine-0.2.0 → gras_engine-0.4.0}/src/engine/reporting/reports.rs +0 -0
- {gras_engine-0.2.0 → gras_engine-0.4.0}/src/engine/start/mod.rs +0 -0
- {gras_engine-0.2.0 → gras_engine-0.4.0}/src/engine/start/rl_engine.rs +0 -0
- {gras_engine-0.2.0 → gras_engine-0.4.0}/src/engine/start/run_spec.rs +0 -0
- {gras_engine-0.2.0 → gras_engine-0.4.0}/src/engine/start/tabular_engine.rs +0 -0
- {gras_engine-0.2.0 → gras_engine-0.4.0}/src/evolution/crossover.rs +0 -0
- {gras_engine-0.2.0 → gras_engine-0.4.0}/src/evolution/mod.rs +0 -0
- {gras_engine-0.2.0 → gras_engine-0.4.0}/src/evolution/mutation.rs +0 -0
- {gras_engine-0.2.0 → gras_engine-0.4.0}/src/evolution/pools.rs +0 -0
- {gras_engine-0.2.0 → gras_engine-0.4.0}/src/evolution/selection.rs +0 -0
- {gras_engine-0.2.0 → gras_engine-0.4.0}/src/graph/inventory.rs +0 -0
- {gras_engine-0.2.0 → gras_engine-0.4.0}/src/graph/mod.rs +0 -0
- {gras_engine-0.2.0 → gras_engine-0.4.0}/src/graph/network.rs +0 -0
- {gras_engine-0.2.0 → gras_engine-0.4.0}/src/graph/node.rs +0 -0
- {gras_engine-0.2.0 → gras_engine-0.4.0}/src/lib.rs +0 -0
- {gras_engine-0.2.0 → gras_engine-0.4.0}/src/spec/blueprint.rs +0 -0
- {gras_engine-0.2.0 → gras_engine-0.4.0}/src/spec/mod.rs +0 -0
- {gras_engine-0.2.0 → gras_engine-0.4.0}/src/spec/network_facts.rs +0 -0
- {gras_engine-0.2.0 → gras_engine-0.4.0}/src/state/mod.rs +0 -0
- {gras_engine-0.2.0 → gras_engine-0.4.0}/src/state/persistence.rs +0 -0
- {gras_engine-0.2.0 → gras_engine-0.4.0}/src/trainer/challenge.rs +0 -0
- {gras_engine-0.2.0 → gras_engine-0.4.0}/src/trainer/core.rs +0 -0
- {gras_engine-0.2.0 → gras_engine-0.4.0}/src/trainer/decision_lag.rs +0 -0
- {gras_engine-0.2.0 → gras_engine-0.4.0}/src/trainer/env.rs +0 -0
- {gras_engine-0.2.0 → gras_engine-0.4.0}/src/trainer/menu.rs +0 -0
- {gras_engine-0.2.0 → gras_engine-0.4.0}/src/trainer/mod.rs +0 -0
- {gras_engine-0.2.0 → gras_engine-0.4.0}/src/trainer/optimizer.rs +0 -0
- {gras_engine-0.2.0 → gras_engine-0.4.0}/src/trainer/reinforce.rs +0 -0
- {gras_engine-0.2.0 → gras_engine-0.4.0}/src/trainer/schedule.rs +0 -0
- {gras_engine-0.2.0 → gras_engine-0.4.0}/src/trainer/stream.rs +0 -0
- {gras_engine-0.2.0 → gras_engine-0.4.0}/src/trainer/supervised.rs +0 -0
- {gras_engine-0.2.0 → gras_engine-0.4.0}/src/utils/ascii.rs +0 -0
- {gras_engine-0.2.0 → gras_engine-0.4.0}/src/utils/cfy.rs +0 -0
- {gras_engine-0.2.0 → gras_engine-0.4.0}/src/utils/display.rs +0 -0
- {gras_engine-0.2.0 → gras_engine-0.4.0}/src/utils/error.rs +0 -0
- {gras_engine-0.2.0 → gras_engine-0.4.0}/src/utils/fitness.rs +0 -0
- {gras_engine-0.2.0 → gras_engine-0.4.0}/src/utils/graph_utils.rs +0 -0
- {gras_engine-0.2.0 → gras_engine-0.4.0}/src/utils/markdown.rs +0 -0
- {gras_engine-0.2.0 → gras_engine-0.4.0}/src/utils/mermaid.rs +0 -0
- {gras_engine-0.2.0 → gras_engine-0.4.0}/src/utils/mod.rs +0 -0
- {gras_engine-0.2.0 → gras_engine-0.4.0}/src/utils/race_steps.rs +0 -0
- {gras_engine-0.2.0 → gras_engine-0.4.0}/src/utils/safetensors.rs +0 -0
- {gras_engine-0.2.0 → gras_engine-0.4.0}/src/utils/score.rs +0 -0
- {gras_engine-0.2.0 → gras_engine-0.4.0}/src/utils/seed.rs +0 -0
- {gras_engine-0.2.0 → gras_engine-0.4.0}/src/utils/tabular_data.rs +0 -0
- {gras_engine-0.2.0 → gras_engine-0.4.0}/src/utils/training.rs +0 -0
|
@@ -202,6 +202,7 @@ dependencies = [
|
|
|
202
202
|
"anstyle",
|
|
203
203
|
"clap_lex",
|
|
204
204
|
"strsim",
|
|
205
|
+
"terminal_size",
|
|
205
206
|
]
|
|
206
207
|
|
|
207
208
|
[[package]]
|
|
@@ -407,7 +408,7 @@ checksum = "e629b9b98ef3dd8afe6ca2bd0f89306cec16d43d907889945bc5d6687f2f13c7"
|
|
|
407
408
|
|
|
408
409
|
[[package]]
|
|
409
410
|
name = "gras"
|
|
410
|
-
version = "2.
|
|
411
|
+
version = "2.3.0"
|
|
411
412
|
dependencies = [
|
|
412
413
|
"clap",
|
|
413
414
|
"comfy-table",
|
|
@@ -426,7 +427,7 @@ dependencies = [
|
|
|
426
427
|
|
|
427
428
|
[[package]]
|
|
428
429
|
name = "gras-py"
|
|
429
|
-
version = "0.
|
|
430
|
+
version = "0.4.0"
|
|
430
431
|
dependencies = [
|
|
431
432
|
"gras",
|
|
432
433
|
"pyo3",
|
|
@@ -1042,6 +1043,16 @@ dependencies = [
|
|
|
1042
1043
|
"windows-sys",
|
|
1043
1044
|
]
|
|
1044
1045
|
|
|
1046
|
+
[[package]]
|
|
1047
|
+
name = "terminal_size"
|
|
1048
|
+
version = "0.4.4"
|
|
1049
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
1050
|
+
checksum = "230a1b821ccbd75b185820a1f1ff7b14d21da1e442e22c0863ea5f08771a8874"
|
|
1051
|
+
dependencies = [
|
|
1052
|
+
"rustix",
|
|
1053
|
+
"windows-sys",
|
|
1054
|
+
]
|
|
1055
|
+
|
|
1045
1056
|
[[package]]
|
|
1046
1057
|
name = "thousands"
|
|
1047
1058
|
version = "0.2.0"
|
|
@@ -6,13 +6,13 @@ resolver = "2"
|
|
|
6
6
|
|
|
7
7
|
[package]
|
|
8
8
|
name = "gras"
|
|
9
|
-
version = "2.
|
|
9
|
+
version = "2.3.0"
|
|
10
10
|
edition = "2024"
|
|
11
11
|
description = "Neuroevolutionary architecture search: evolve the graph while its weights train, in Rust"
|
|
12
12
|
license = "MIT"
|
|
13
13
|
readme = "README.md"
|
|
14
14
|
rust-version = "1.91"
|
|
15
|
-
keywords = ["neural-network", "
|
|
15
|
+
keywords = ["neural-network", "neuroevolution", "neural-search", "machine-learning", "evolutionary"]
|
|
16
16
|
categories = ["algorithms", "artificial-intelligence", "mathematics"]
|
|
17
17
|
homepage = "https://github.com/maulberto3/gras"
|
|
18
18
|
repository = "https://github.com/maulberto3/gras"
|
|
@@ -50,7 +50,7 @@ comfy-table = { version = "7.2", default-features = false }
|
|
|
50
50
|
[dev-dependencies]
|
|
51
51
|
proptest = "1.11.0"
|
|
52
52
|
dhat = "0.3"
|
|
53
|
-
clap = { version = "4.6.7", features = ["derive"] }
|
|
53
|
+
clap = { version = "4.6.7", features = ["derive", "wrap_help"] }
|
|
54
54
|
|
|
55
55
|
[profile.dev]
|
|
56
56
|
opt-level = 0
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: gras-engine
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.0
|
|
4
4
|
Classifier: Development Status :: 3 - Alpha
|
|
5
5
|
Classifier: Intended Audience :: Developers
|
|
6
6
|
Classifier: Intended Audience :: Science/Research
|
|
@@ -14,8 +14,8 @@ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
|
14
14
|
Requires-Dist: pandas>=2.0 ; extra == 'test'
|
|
15
15
|
Provides-Extra: test
|
|
16
16
|
License-File: LICENSE
|
|
17
|
-
Summary:
|
|
18
|
-
Keywords: neural-architecture-search,evolution,
|
|
17
|
+
Summary: Evolutionary neural architecture search: a step-race that evolves, trains and ranks flodl networks
|
|
18
|
+
Keywords: neural-architecture-search,evolution,neuroevolution,automl,deep-learning,libtorch
|
|
19
19
|
Author-email: Mauricio Maroto <maulberto3@hotmail.com>
|
|
20
20
|
License: MIT
|
|
21
21
|
Requires-Python: >=3.12
|
|
@@ -196,11 +196,6 @@ language, and the parity guard says so.
|
|
|
196
196
|
- The wheel is Linux x86_64. It is `linux_x86_64`, not `manylinux`: the
|
|
197
197
|
wheel needs the system's libtorch, so it cannot claim to be self-contained.
|
|
198
198
|
|
|
199
|
-
## Versions
|
|
200
|
-
|
|
201
|
-
`gras.__version__` is the **binding's** version (0.2.x) and moves independently
|
|
202
|
-
of the Rust crate (`gras` on crates.io, 2.2.0). A binding release that needs a
|
|
203
|
-
newer crate says so in its release notes.
|
|
204
199
|
|
|
205
200
|
## More
|
|
206
201
|
|
|
@@ -93,7 +93,7 @@ A vacated slot does not stay empty. There are two ways in:
|
|
|
93
93
|
- **Crossover** draws two parents and builds a child from them. The default draw
|
|
94
94
|
is fitness-proportionate roulette, so stronger nets are more likely to be
|
|
95
95
|
picked but nothing is locked out. The fitter parent is the base by default,
|
|
96
|
-
and inherited genes can drift slightly (`drift_prob = 0.
|
|
96
|
+
and inherited genes can drift slightly (`drift_prob = 0.05`). If the two parents
|
|
97
97
|
cannot be combined, the roll is a no-op — a failed crossover never inserts a
|
|
98
98
|
random net.
|
|
99
99
|
- **Mutation** inserts a fresh random immigrant, built from the configured
|
|
@@ -234,49 +234,191 @@ const EVAL_MATCHES_PER_STEP: usize = 5;
|
|
|
234
234
|
#[derive(clap::Parser, Debug)]
|
|
235
235
|
#[command(
|
|
236
236
|
name = "cartpole",
|
|
237
|
-
about = "CartPole RL race: every engine knob is a flag, each one carrying the value the run uses."
|
|
237
|
+
about = "CartPole RL race: every engine knob is a flag, each one carrying the value the run uses.",
|
|
238
|
+
// Help starts on the flag's own row (`next_line_help = false`) and wraps at a MEDIUM
|
|
239
|
+
// width — about the `--drift` row — instead of running to whatever the terminal is.
|
|
240
|
+
term_width = 200,
|
|
241
|
+
next_line_help = false
|
|
238
242
|
)]
|
|
239
243
|
struct Cli {
|
|
240
|
-
/// Every engine knob shared with the other example (`examples/common/mod.rs`).
|
|
241
|
-
#[command(flatten)]
|
|
242
|
-
engine: EngineArgs,
|
|
243
|
-
|
|
244
244
|
/// Pin the run seed (otherwise fresh per launch); it is always recorded in `engine.json`.
|
|
245
|
-
#[arg(long, value_name = "U64")]
|
|
245
|
+
#[arg(long, value_name = "U64", help_heading = "Run")]
|
|
246
246
|
seed: Option<u64>,
|
|
247
247
|
|
|
248
|
-
///
|
|
249
|
-
#[arg(
|
|
248
|
+
/// Name recorded in `engine.json` (informational only).
|
|
249
|
+
#[arg(
|
|
250
|
+
long,
|
|
251
|
+
value_name = "NAME",
|
|
252
|
+
default_value = "cartpole",
|
|
253
|
+
help_heading = "Run"
|
|
254
|
+
)]
|
|
255
|
+
run_name: String,
|
|
256
|
+
|
|
257
|
+
/// Survival bar (window centre): ENDS the race the clock the field reaches it. Read in the
|
|
258
|
+
/// run's own direction, so it also works on a minimize metric; a bar nothing reaches never fires.
|
|
259
|
+
#[arg(
|
|
260
|
+
long,
|
|
261
|
+
value_name = "F32",
|
|
262
|
+
default_value_t = 400.0,
|
|
263
|
+
help_heading = "Stop"
|
|
264
|
+
)]
|
|
250
265
|
stop_score: f32,
|
|
251
266
|
|
|
252
|
-
/// Clocks the best score may sit still
|
|
253
|
-
|
|
267
|
+
/// Clocks the best score may sit still (no gain over 0.01) before the race stops — no bar of
|
|
268
|
+
/// its own, so it also fires below the bar above; `0` = no-change stop off.
|
|
269
|
+
#[arg(long, value_name = "N", default_value_t = 40, help_heading = "Stop")]
|
|
254
270
|
stop_patience: usize,
|
|
255
271
|
|
|
272
|
+
/// Peak probability that a step fires the anti-plateau challenge; `0` disables it.
|
|
273
|
+
#[arg(
|
|
274
|
+
long,
|
|
275
|
+
value_name = "P",
|
|
276
|
+
default_value_t = DEFAULT_CHALLENGE_PROB,
|
|
277
|
+
help_heading = "Challenge"
|
|
278
|
+
)]
|
|
279
|
+
challenge_prob: f32,
|
|
280
|
+
|
|
281
|
+
// Flattened HERE, not first: clap orders help sections by first appearance, so the
|
|
282
|
+
// example's own "Run" / "Stop" / "Challenge" flags have to come before the shared
|
|
283
|
+
// block, while the shared sections (Tickets → Elites) keep their own order.
|
|
284
|
+
/// Every engine knob shared with the other example (`examples/common/mod.rs`).
|
|
285
|
+
#[command(flatten)]
|
|
286
|
+
engine: EngineArgs,
|
|
287
|
+
|
|
256
288
|
/// Candidates one mutation may spend clearing the floor; the most novel refusal is taken anyway.
|
|
257
|
-
#[arg(
|
|
289
|
+
#[arg(
|
|
290
|
+
long,
|
|
291
|
+
value_name = "N",
|
|
292
|
+
default_value_t = 10,
|
|
293
|
+
help_heading = "Mutation"
|
|
294
|
+
)]
|
|
258
295
|
mutation_novelty_draws: usize,
|
|
259
296
|
|
|
297
|
+
// The node-count bounds live here, MIN then MAX, because their upper bound is this
|
|
298
|
+
// example's own number (20) — split across `EngineArgs` the pair printed far apart.
|
|
299
|
+
/// Hidden nodes per net: the lower sampling bound.
|
|
300
|
+
#[arg(
|
|
301
|
+
long,
|
|
302
|
+
value_name = "N",
|
|
303
|
+
default_value_t = 2,
|
|
304
|
+
help_heading = "Search space"
|
|
305
|
+
)]
|
|
306
|
+
hidden_min: usize,
|
|
307
|
+
|
|
308
|
+
/// Hidden nodes per net: the upper sampling bound.
|
|
309
|
+
#[arg(
|
|
310
|
+
long,
|
|
311
|
+
value_name = "N",
|
|
312
|
+
default_value_t = 20,
|
|
313
|
+
help_heading = "Search space"
|
|
314
|
+
)]
|
|
315
|
+
hidden_max: usize,
|
|
316
|
+
|
|
317
|
+
/// Inputs per node: the lower sampling bound.
|
|
318
|
+
#[arg(
|
|
319
|
+
long,
|
|
320
|
+
value_name = "N",
|
|
321
|
+
default_value_t = 2,
|
|
322
|
+
help_heading = "Search space"
|
|
323
|
+
)]
|
|
324
|
+
inputs_min: usize,
|
|
325
|
+
|
|
326
|
+
/// Inputs per node: the upper sampling bound.
|
|
327
|
+
#[arg(
|
|
328
|
+
long,
|
|
329
|
+
value_name = "N",
|
|
330
|
+
default_value_t = 20,
|
|
331
|
+
help_heading = "Search space"
|
|
332
|
+
)]
|
|
333
|
+
inputs_max: usize,
|
|
334
|
+
|
|
335
|
+
/// Outputs per node: the lower sampling bound.
|
|
336
|
+
#[arg(
|
|
337
|
+
long,
|
|
338
|
+
value_name = "N",
|
|
339
|
+
default_value_t = 2,
|
|
340
|
+
help_heading = "Search space"
|
|
341
|
+
)]
|
|
342
|
+
outputs_min: usize,
|
|
343
|
+
|
|
344
|
+
/// Outputs per node: the upper sampling bound.
|
|
345
|
+
#[arg(
|
|
346
|
+
long,
|
|
347
|
+
value_name = "N",
|
|
348
|
+
default_value_t = 20,
|
|
349
|
+
help_heading = "Search space"
|
|
350
|
+
)]
|
|
351
|
+
outputs_max: usize,
|
|
352
|
+
|
|
353
|
+
/// Counter stride of the hidden-width range (`2` = 16, 18, 20, …).
|
|
354
|
+
#[arg(
|
|
355
|
+
long,
|
|
356
|
+
value_name = "N",
|
|
357
|
+
default_value_t = 2,
|
|
358
|
+
help_heading = "Search space"
|
|
359
|
+
)]
|
|
360
|
+
hidden_dim_stride: usize,
|
|
361
|
+
|
|
362
|
+
/// Chance a slot of an inherited circuit (mask, activation, combine, standardize, dropout,
|
|
363
|
+
/// port activation, hidden width, the `input_reach` wiring gene) is re-drawn.
|
|
364
|
+
#[arg(
|
|
365
|
+
long,
|
|
366
|
+
value_name = "P",
|
|
367
|
+
default_value_t = gras::engine::config::DEFAULT_TOPOLOGY_DRIFT,
|
|
368
|
+
help_heading = "Search space"
|
|
369
|
+
)]
|
|
370
|
+
drift: f32,
|
|
371
|
+
|
|
372
|
+
/// Dropout probability applied when building the run's networks.
|
|
373
|
+
#[arg(
|
|
374
|
+
long,
|
|
375
|
+
value_name = "P",
|
|
376
|
+
default_value_t = DROPOUT_PROB,
|
|
377
|
+
help_heading = "Search space"
|
|
378
|
+
)]
|
|
379
|
+
dropout: f32,
|
|
380
|
+
|
|
381
|
+
/// Recurrence: every hidden node whose input width equals its output width feeds its
|
|
382
|
+
/// pre-activation back through its OWN layer once — the same weights, twice. CartPole nets
|
|
383
|
+
/// are 4 → 2, so only the hidden nodes can loop; a crossover child can drift the gene either
|
|
384
|
+
/// way.
|
|
385
|
+
#[arg(
|
|
386
|
+
long,
|
|
387
|
+
value_name = "BOOL",
|
|
388
|
+
num_args = 0..=1,
|
|
389
|
+
default_missing_value = "true",
|
|
390
|
+
default_value_t = true,
|
|
391
|
+
help_heading = "Search space"
|
|
392
|
+
)]
|
|
393
|
+
recur: bool,
|
|
394
|
+
|
|
260
395
|
/// What the net is told about the past: `none`, `delta` (obs − prev) or a smoothed `ema`; the fed row doubles.
|
|
261
396
|
#[arg(
|
|
262
397
|
long,
|
|
263
398
|
value_name = "KIND",
|
|
264
399
|
value_parser = ["none", "delta", "ema"],
|
|
265
|
-
default_value = "none"
|
|
400
|
+
default_value = "none",
|
|
401
|
+
help_heading = "Policy (RL)"
|
|
266
402
|
)]
|
|
267
403
|
obs_memory: String,
|
|
268
404
|
|
|
269
|
-
/// EMA β for `--obs-memory ema
|
|
270
|
-
#[arg(
|
|
405
|
+
/// EMA β for `--obs-memory ema`. Clamped to `0.0 …= 1.0`.
|
|
406
|
+
#[arg(
|
|
407
|
+
long,
|
|
408
|
+
value_name = "F32",
|
|
409
|
+
default_value_t = 0.9,
|
|
410
|
+
help_heading = "Policy (RL)"
|
|
411
|
+
)]
|
|
271
412
|
obs_memory_beta: f32,
|
|
272
413
|
|
|
273
|
-
/// Exam axis: `true`
|
|
414
|
+
/// Exam axis: `true` draws fresh shared starts every CLOCK, `false` restores the ERA exam.
|
|
274
415
|
#[arg(
|
|
275
416
|
long,
|
|
276
417
|
value_name = "BOOL",
|
|
277
418
|
num_args = 0..=1,
|
|
278
419
|
default_missing_value = "true",
|
|
279
|
-
default_value_t = true
|
|
420
|
+
default_value_t = true,
|
|
421
|
+
help_heading = "Policy (RL)"
|
|
280
422
|
)]
|
|
281
423
|
per_clock_exam: bool,
|
|
282
424
|
|
|
@@ -285,20 +427,22 @@ struct Cli {
|
|
|
285
427
|
long,
|
|
286
428
|
value_name = "KIND",
|
|
287
429
|
value_parser = ["turns", "return"],
|
|
288
|
-
default_value = "turns"
|
|
430
|
+
default_value = "turns",
|
|
431
|
+
help_heading = "Policy (RL)"
|
|
289
432
|
)]
|
|
290
433
|
signal: String,
|
|
291
434
|
|
|
292
435
|
/// Discount γ shaping the per-turn returns the GRADIENT uses; the fitness stays undiscounted.
|
|
293
|
-
#[arg(long, value_name = "GAMMA", default_value_t = DISCOUNT)]
|
|
436
|
+
#[arg(long, value_name = "GAMMA", default_value_t = DISCOUNT, help_heading = "Policy (RL)")]
|
|
294
437
|
discount: f32,
|
|
295
438
|
|
|
296
|
-
/// TRAIN arm: `argmax`
|
|
439
|
+
/// TRAIN arm: `argmax` or `softmax` sampling at T from the episode's own seeded generator.
|
|
297
440
|
#[arg(
|
|
298
441
|
long,
|
|
299
442
|
value_name = "RULE",
|
|
300
443
|
value_parser = ["argmax", "softmax"],
|
|
301
|
-
default_value = "argmax"
|
|
444
|
+
default_value = "argmax",
|
|
445
|
+
help_heading = "Policy (RL)"
|
|
302
446
|
)]
|
|
303
447
|
action_rule: String,
|
|
304
448
|
|
|
@@ -307,47 +451,20 @@ struct Cli {
|
|
|
307
451
|
long,
|
|
308
452
|
value_name = "RULE",
|
|
309
453
|
value_parser = ["argmax", "softmax"],
|
|
310
|
-
default_value = "argmax"
|
|
454
|
+
default_value = "argmax",
|
|
455
|
+
help_heading = "Policy (RL)"
|
|
311
456
|
)]
|
|
312
457
|
eval_action_rule: String,
|
|
313
458
|
|
|
314
|
-
/// Temperature T for the softmax arm — SHARED by `--action-rule` and `--eval-action-rule
|
|
315
|
-
///
|
|
316
|
-
#[arg(
|
|
459
|
+
/// Temperature T for the softmax arm — SHARED by `--action-rule` and `--eval-action-rule`:
|
|
460
|
+
/// smaller sharpens toward argmax, larger flattens the policy.
|
|
461
|
+
#[arg(
|
|
462
|
+
long,
|
|
463
|
+
value_name = "T",
|
|
464
|
+
default_value_t = ACTING_TEMPERATURE,
|
|
465
|
+
help_heading = "Policy (RL)"
|
|
466
|
+
)]
|
|
317
467
|
softmax_temperature: f32,
|
|
318
|
-
|
|
319
|
-
/// Chance a slot of an inherited circuit (mask, activation, combine, standardize, dropout,
|
|
320
|
-
/// port activation, hidden width, the `input_reach` wiring gene) is re-drawn.
|
|
321
|
-
#[arg(long, value_name = "P", default_value_t = 0.05)]
|
|
322
|
-
drift: f32,
|
|
323
|
-
|
|
324
|
-
/// Name recorded in `engine.json` (informational only).
|
|
325
|
-
#[arg(long, value_name = "NAME", default_value = "cartpole")]
|
|
326
|
-
run_name: String,
|
|
327
|
-
|
|
328
|
-
/// Peak probability that a step fires the anti-plateau challenge; `0` disables it.
|
|
329
|
-
#[arg(long, value_name = "P", default_value_t = DEFAULT_CHALLENGE_PROB)]
|
|
330
|
-
challenge_prob: f32,
|
|
331
|
-
|
|
332
|
-
/// Hidden nodes per net: the upper sampling bound.
|
|
333
|
-
#[arg(long, value_name = "N", default_value_t = 20)]
|
|
334
|
-
hidden_max: usize,
|
|
335
|
-
|
|
336
|
-
/// Inputs per node: the upper sampling bound.
|
|
337
|
-
#[arg(long, value_name = "N", default_value_t = 20)]
|
|
338
|
-
inputs_max: usize,
|
|
339
|
-
|
|
340
|
-
/// Outputs per node: the upper sampling bound.
|
|
341
|
-
#[arg(long, value_name = "N", default_value_t = 20)]
|
|
342
|
-
outputs_max: usize,
|
|
343
|
-
|
|
344
|
-
/// Counter stride of the hidden-width range (`2` = 16, 18, 20, …).
|
|
345
|
-
#[arg(long, value_name = "N", default_value_t = 2)]
|
|
346
|
-
hidden_dim_stride: usize,
|
|
347
|
-
|
|
348
|
-
/// Dropout probability applied when building the run's networks.
|
|
349
|
-
#[arg(long, value_name = "P", default_value_t = DROPOUT_PROB)]
|
|
350
|
-
dropout: f32,
|
|
351
468
|
}
|
|
352
469
|
|
|
353
470
|
/// The body reads `cli.pop`, `cli.max_steps`, … — the overlay never hides a knob.
|
|
@@ -382,29 +499,46 @@ fn main() {
|
|
|
382
499
|
let baseline = random_baseline(20);
|
|
383
500
|
println!("baseline: random policy survives {baseline:.1} turns (race must beat this)");
|
|
384
501
|
|
|
385
|
-
|
|
502
|
+
// The fitness metric to be reported and optimized: "match_survival" by default. Declared
|
|
503
|
+
// BEFORE the config so the two stop criteria can read its direction.
|
|
504
|
+
let fitness = Fitness::reported(Direction::Maximize, "match_survival");
|
|
505
|
+
let direction = fitness.direction();
|
|
506
|
+
// STOP 2 of 3: the solved bar. The window CENTRE reaching `--stop-score` ends the race on
|
|
507
|
+
// that clock (compared in `direction`, so it is not a maximize-only `>=`); the step budget
|
|
508
|
+
// and the no-change stop below are the other two.
|
|
509
|
+
let bar = cli.stop_score;
|
|
510
|
+
let builder = common::engine_config(rl_race_config_builder(), &cli.engine, log_level)
|
|
386
511
|
// This example's own half: the flags whose default is its identity.
|
|
387
512
|
.set_run_name(cli.run_name.clone())
|
|
388
513
|
.set_topology_drift(cli.drift)
|
|
514
|
+
.set_topology_min_hidden_num_nodes(cli.hidden_min)
|
|
389
515
|
.set_topology_max_hidden_num_nodes(cli.hidden_max)
|
|
516
|
+
.set_topology_min_inputs_per_node(cli.inputs_min)
|
|
390
517
|
.set_topology_max_inputs_per_node(cli.inputs_max)
|
|
518
|
+
.set_topology_min_outputs_per_node(cli.outputs_min)
|
|
391
519
|
.set_topology_max_outputs_per_node(cli.outputs_max)
|
|
392
520
|
.set_topology_hidden_dim_stride(cli.hidden_dim_stride)
|
|
393
521
|
.set_topology_dropout_prob(cli.dropout)
|
|
394
522
|
.set_mutation_novelty_draws(cli.mutation_novelty_draws)
|
|
395
|
-
|
|
396
|
-
.set_stop_plateau(cli.stop_score, cli.stop_patience)
|
|
523
|
+
.set_stop_custom(move |snap: &RaceSnapshot| common::bar_reached(bar, snap))
|
|
397
524
|
.set_topology_input_dim(input_dim)
|
|
398
|
-
.set_topology_output_dim(ACTIONS)
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
525
|
+
.set_topology_output_dim(ACTIONS);
|
|
526
|
+
// The four POOLS (`--feature-split-pool`, `--combine-op-pool`, `--activation-pool`,
|
|
527
|
+
// `--standardize-pool`) are wired inside `common::engine_config`, where they are declared —
|
|
528
|
+
// a one-entry pool pins a policy, the same call `set_topology_feature_split` makes.
|
|
529
|
+
// STOP 3 of 3: the no-change stop, with NO bar of its own — `common::no_bar` parks the
|
|
530
|
+
// plateau's target on the hopeless end of this run's direction, so its target gate is always
|
|
531
|
+
// open and only the patience window decides. `0` turns it off (a `0` patience would stop at
|
|
532
|
+
// clock 0 instead).
|
|
533
|
+
let mut builder = builder;
|
|
534
|
+
if cli.stop_patience > 0 {
|
|
535
|
+
builder = builder.set_stop_plateau(common::no_bar(direction), cli.stop_patience);
|
|
536
|
+
}
|
|
537
|
+
let mut config = builder.build();
|
|
538
|
+
// Recurrence is a per-net gene carried in the blueprint, not a run measured from the
|
|
539
|
+
// header: stamp the flag on the search space so founders and immigrants are born with it.
|
|
540
|
+
config.topology.options.recur = cli.recur;
|
|
541
|
+
|
|
408
542
|
// The signal the step optimizes and ranks on: `return` at γ on request, else the const.
|
|
409
543
|
|
|
410
544
|
let signal = match cli.signal.as_str() {
|