code wiki / _hdl_build / nx_evolve_gap.nx

nx_evolve_gap.nx

buildroot/runtime/_hdl_build/nx_evolve_gap.nx

11058 B229 linesdepth 2pulls 2 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

nx_evolve_gap.nx -- the EVOLUTIONARY-COMPUTATION team member, wired into team-solve as TIER-2: when tier-1 mechanistic-search can't solve a gap (it needs PARAMETERS a bare capability can't supply), EVOLUTION searches the parameter (GENE) space. Concretely: the team has a PARAMETERIZED capability reduce_op <op> <init> (op in {add,mul,max,min}, init); this organ EVOLVES the (op,init) genes with the EC operators from the taxonomy (evo_params.tsv): a POPULATION of genes, TOURNAMENT selection, per-gene MUTATION, ELITISM, FIXED-seed reproducibility -- and the FITNESS is the EXTERNAL ALE HARNESS SCORE (the designed "swap fitness_id for a gate permil"). It evolves until a gene scores 1000 -> the gap is SOLVED by the evolutionary member, NO LLM. HONEST: for this small/binary gap evolution is a guided search; nx_evolve validates GP's gradient-climbing on smooth/multimodal landscapes (sphere/rastrigin) -- together they are the team's evolutionary search across landscapes. (DRY note: the shared GP loop wants extraction to a lib once a 3rd consumer appears, per rule 15.) args mode: nx_evolve_gap <gap_task> -> evolve genes; print the solving (op,init) or UNSOLVED. no-arg: SELF-GATE on the product gap task_reduce -> evolution MUST discover (mul,1) -> GREEN. license_tier: ORIGINAL module: nishi-core.team.evolve_gap depends: nishi-core.sys.syscalls capability: EVOLUTIONARY_GAP_SOLVE

dependencies 1 imports · 0 importers

nx_syscalls.nx nx_evolve_gap.nx

imports: nx_syscalls.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main sys_mmap eg_evolve sys_mmap ↻ eg_read sys_openat_rd sys_read sys_close eg_modn eg_fitness eg_variant sys_mmap ↻ eg_unlink sys_openat_wr sys_write sys_close ↻ sys_mkdir eg_unlink ↻ sys_fork sys_openat_wr ↻ sys_dup3 sys_mmap ↻ sys_execve sys_exit sys_wait4 eg_score_of sys_mmap ↻ eg_read ↻ eg_rand eg_p sys_write ↻ eg_opname eg_fn sys_mmap ↻ sys_write ↻ sys_exit ↻ sys_openat_append eg_fp sys_write ↻ sys_now_realtime_sec

structs

none

consts

20const EG_MAGIC_262144: i64 = 262144
22const EG_POP: i64 = 16
23const EG_GENS: i64 = 4
24const EG_TOURK: i64 = 3

functions

26func eg_p(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 }
called by 1: main calls 1: sys_write
27func eg_fp(fd: i64, s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(fd, s, n); return 0 }
called by 1: main calls 1: sys_write
28func eg_fn(fd: i64, v: i64) -> i64 { let bb: *u8 = sys_mmap(28); var m: i64 = v; if m < 0 { m = 0 - m; sys_write(fd, "-" as *u8, 1) }; let t: *u8 = sys_mmap(28); var k: i64 = 0; if m == 0 { t[0] = 48; k = 1 }; while m > 0 { t[k] = (48 + (m % 10)) as u8; m = m / 10; k = k + 1 }; var i: i64 = 0; while i < k { bb[i] = t[k - 1 - i]; i = i + 1 }; sys_write(fd, bb, k); return 0 }
called by 1: main calls 2: sys_mmapsys_write
29func eg_len(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
32func eg_read(path: *u8, buf: *u8, cap: i64) -> i64
46func eg_score_of(path: *u8) -> i64
called by 1: eg_fitness calls 2: sys_mmapeg_read
57func eg_rand(s: *i64) -> i64
called by 1: eg_evolve
67func eg_modn(v: i64, n: i64) -> i64 { var r: i64 = v % n; if r < 0 { r = r + n } return r }
called by 1: eg_evolve
70func eg_variant(taskbuf: *u8, tn: i64, op: i64, init: i64, outpath: *u8) -> i64
117func eg_fitness(taskbuf: *u8, tn: i64, op: i64, init: i64) -> i64
146func eg_evolve(taskpath: *u8, bop: *i64, binit: *i64) -> i64
198func eg_opname(op: i64) -> *u8 { if op == 1 { return "mul" as *u8 } if op == 2 { return "max" as *u8 } if op == 3 { return "min" as *u8 } return "add" as *u8 }
called by 1: main
200func main(argc: i64, argv: *i64) -> i64