survival.bend checks
raw source on the hub · import 0xd1de66b5d9157913a654c39186289f3d/survival.bend as Survival
Survival / niching — C# ReferencePointManager + NondominatedSortingSurvival.
Independent maps (associate / histograms / gather) use mid-split
a b = f(lo) f(hi). Nearest-ref stays sequential (associate_raw already
splits per individual). Perpendicular distance squares f - t*w in one
walk (same F32 order as scale-then-subtract). Last-front fill builds
NRow{i, ref, dist} once so the sequential niche loop never List.gets
an Assignment (or a fat
Individual) per remaining candidate. Run's rng fill groups those rows
into per-ref bags so each pick walks bags, not the whole front and not
List.get on the counts spine. Same pick rules / same RNG order.
Associate normalized individuals to Das–Dennis rays; select target_size
from a combined pool (fill complete fronts, niche-preserve the last).
Deterministic when C# rng is null (select): lowest ref among min-count
niches, then min perpendicular distance if that niche is empty, else
lowest index. select_st (Run) threads rng: random among equal
min-count niches (C# Select(..., rng)). Empty niches take the closest
unused member; extras draw among members within 2×best+0.01 of the
ray — not uniform inNiche[rng.Next], which collapsed oracle ZDT2.
6 imports
import Base import ./individual.bend as Ind import ./non_dominated_sort.bend as NDS import ./normalization.bend as Norm import ./rng.bend as Rng import ./util.bend as Util
Types
type Assignment source · line 27 · raw
Data
MkAssignment@reference_index:Nat -> @perpendicular_distance:F32 -> @niche_count:Nat -> Assignment
type NRow source · line 58 · raw
Data
Last-front row: population index plus the two fields the fill loop
reads. Built once from asgs so each pick walks this thin list
instead of List.get into the combined-pool assignment spine.
NRow@i:Nat -> @r:Nat -> @d:F32 -> NRow
type CntNeed source · line 412 · raw
Data
CN@counts:List<&2, Nat> -> @need:Nat -> CntNeed
type RefPick source · line 444 · raw
Data
RP@asgs:List<&2, Assignment> -> @r:Nat -> RefPick
type NearPick source · line 546 · raw
Data
NP@asgs:List<&2, Assignment> -> @lim:F32 -> NearPick
type MRow source · line 724 · raw
Data
Occupied last-front reference. Members stay in original row order.
pos is that row's place in the last front, so a per-pick sort by the
earliest remaining member restores first-seen ref order (deleting an
early row can move its ref behind one that started later). count is
the niche histogram, not the member length. Counts live on the bag, so
a pick does not List.get the counts spine.
MRow@pos:Nat -> @row:NRow -> MRow
type Bag source · line 730 · raw
Data
Bag@ref:Nat -> @count:Nat -> @members:List<&2, MRow> -> Bag
type CvRow source · line 1005 · raw
Data
CvRow@i:Nat -> @ind:0xd1de66b5d9157913a654c39186289f3d/individual.Individual -> CvRow
type Split source · line 1131 · raw
Data
Split@feas:List<&2, 0xd1de66b5d9157913a654c39186289f3d/individual.Individual> -> @rows:List<&2, CvRow> -> Split
Definitions
def asg_ref source · line 34 · raw
@a:Assignment -> Nat
def asg_dist source · line 39 · raw
@a:Assignment -> F32
def asg_count source · line 44 · raw
@a:Assignment -> Nat
def get_asg source · line 49 · raw
@asgs:List<&2, Assignment> -> @i:Nat -> Assignment
def get_ind source · line 52 · raw
@+pop:List<&2, 0xd1de66b5d9157913a654c39186289f3d/individual.Individual> -> @i:Nat -> 0xd1de66b5d9157913a654c39186289f3d/individual.Individual
def nrow_i source · line 65 · raw
@row:NRow -> Nat
def nrow_r source · line 70 · raw
@row:NRow -> Nat
def nrow_d source · line 75 · raw
@row:NRow -> F32
def nrows_of.go source · line 80 · raw
@+asgs:List<&2, Assignment> -> @cand:List<&2, Nat> -> @acc:List<&2, NRow> -> List<&2, NRow>
def nrows_of source · line 88 · raw
@+asgs:List<&2, Assignment> -> @+cand:List<&2, Nat> -> List<&2, NRow>
def first_row_i source · line 91 · raw
@rows:List<&2, NRow> -> Nat
def get_nrow source · line 98 · raw
@rows:List<&2, NRow> -> @i:Nat -> NRow
def drop_nrow.put source · line 101 · raw
@+row:NRow -> @rest:List<&2, NRow> -> @drop:Bool -> List<&2, NRow>
def drop_nrow source · line 108 · raw
@rows:List<&2, NRow> -> @+pick:Nat -> List<&2, NRow>
def keep_nat source · line 115 · raw
@h:Nat -> @rest:List<&2, Nat> -> @keep:Bool -> List<&2, Nat>
def uniq_refs.go source · line 122 · raw
@rows:List<&2, NRow> -> @+acc:List<&2, Nat> -> List<&2, Nat>
def uniq_refs source · line 130 · raw
@rows:List<&2, NRow> -> List<&2, Nat>
def min_count_rows.go source · line 133 · raw
@+counts:List<&2, Nat> -> @rows:List<&2, NRow> -> @+acc:Nat -> Nat
def min_count_rows source · line 140 · raw
@+counts:List<&2, Nat> -> @rows:List<&2, NRow> -> Nat
def refs_at_seq source · line 143 · raw
@+counts:List<&2, Nat> -> @+need:Nat -> @refs:List<&2, Nat> -> List<&2, Nat>
def in_ref_rows source · line 150 · raw
@+r:Nat -> @rows:List<&2, NRow> -> List<&2, NRow>
def argmin_dist_rows.go source · line 157 · raw
@rows:List<&2, NRow> -> @+best_i:Nat -> @+best_d:F32 -> Nat
def argmin_dist_rows source · line 166 · raw
@rows:List<&2, NRow> -> Nat
def min_dist_rows.go source · line 173 · raw
@rows:List<&2, NRow> -> @+acc:F32 -> F32
def min_dist_rows source · line 181 · raw
@rows:List<&2, NRow> -> F32
def min_idx_rows.go source · line 188 · raw
@rows:List<&2, NRow> -> @+acc:Nat -> Nat
def min_idx_rows source · line 195 · raw
@rows:List<&2, NRow> -> Nat
def near_rows source · line 202 · raw
@+lim:F32 -> @rows:List<&2, NRow> -> List<&2, NRow>
def resid_sq source · line 211 · raw
@+t:F32 -> @f:List<&2, F32> -> @w:List<&2, F32> -> F32
Same F32 steps as vec_sqnorm(vec_sub(f, vec_scale(t, w))): left-to-right
r*r with r = f - t*w, no scaled-vector and residual-vector spines.
def perp.big source · line 223 · raw
@+f:List<&2, F32> -> @+w:List<&2, F32> -> @+ww:F32 -> F32
def perp.zero source · line 227 · raw
@+f:List<&2, F32> -> @tiny:Bool -> F32
def perp.pick source · line 234 · raw
@+f:List<&2, F32> -> @+w:List<&2, F32> -> @+ww:F32 -> @tiny:Bool -> F32
def perp source · line 241 · raw
@+f:List<&2, F32> -> @+w:List<&2, F32> -> F32
def nearest_go source · line 247 · raw
@+f:List<&2, F32> -> @dirs:List<&2, List<&2, F32>> -> @+i:Nat -> @+best_i:Nat -> @+best_d:F32 -> Assignment
First-min on strict < (ties keep the lower index). Sequential over
dirs; associate_raw already mid-splits per individual.
def nearest_one source · line 261 · raw
@f:List<&2, F32> -> @dirs:List<&2, List<&2, F32>> -> Assignment
def associate_head source · line 264 · raw
@+dirs:List<&2, List<&2, F32>> -> @+ind:0xd1de66b5d9157913a654c39186289f3d/individual.Individual -> @F:List<&2, List<&2, F32>> -> Assignment
def associate_raw.go source · line 272 · raw
@+dirs:List<&2, List<&2, F32>> -> @+fuel:Nat -> @pop:List<&2, 0xd1de66b5d9157913a654c39186289f3d/individual.Individual> -> @+F:List<&2, List<&2, F32>> -> List<&2, Assignment>
Nearest-ref per individual is independent given dirs. Mid-split pop and F.
def associate_raw source · line 297 · raw
@+pop:List<&2, 0xd1de66b5d9157913a654c39186289f3d/individual.Individual> -> @+F:List<&2, List<&2, F32>> -> @+dirs:List<&2, List<&2, F32>> -> List<&2, Assignment>
def count_raw.go source · line 301 · raw
@+n:Nat -> @+fuel:Nat -> @asgs:List<&2, Assignment> -> List<&2, Nat>
Histogram increments commute. Mid-split asgs, then add count vectors.
def count_asg source · line 317 · raw
@+asgs:List<&2, Assignment> -> @+acc:List<&2, Nat> -> List<&2, Nat>
def in_bin_count source · line 322 · raw
@asgs:List<&2, Assignment> -> @+n:Nat -> Nat
Assignments whose reference_index lands in a length-n histogram. Out-of-range refs are silent no-ops in inc_at / List.set.
def with_counts.one source · line 329 · raw
@+counts:List<&2, Nat> -> @+a:Assignment -> Assignment
def with_counts source · line 334 · raw
@+counts:List<&2, Nat> -> @+asgs:List<&2, Assignment> -> List<&2, Assignment>
def associate source · line 337 · raw
@+pop:List<&2, 0xd1de66b5d9157913a654c39186289f3d/individual.Individual> -> @+F:List<&2, List<&2, F32>> -> @+dirs:List<&2, List<&2, F32>> -> List<&2, Assignment>
def front0 source · line 341 · raw
@fronts:List<&2, List<&2, Nat>> -> List<&2, Nat>
def n_fronts source · line 348 · raw
@fronts:List<&2, List<&2, Nat>> -> Nat
def head_len source · line 351 · raw
@fronts:List<&2, List<&2, Nat>> -> Nat
def gather.one source · line 358 · raw
@+pop:List<&2, 0xd1de66b5d9157913a654c39186289f3d/individual.Individual> -> @+i:Nat -> 0xd1de66b5d9157913a654c39186289f3d/individual.Individual
def gather source · line 361 · raw
@+pop:List<&2, 0xd1de66b5d9157913a654c39186289f3d/individual.Individual> -> @+idxs:List<&2, Nat> -> List<&2, 0xd1de66b5d9157913a654c39186289f3d/individual.Individual>
def cand_ref.one source · line 364 · raw
@+asgs:List<&2, Assignment> -> @+i:Nat -> Nat
def cand_refs source · line 367 · raw
@+asgs:List<&2, Assignment> -> @cand:List<&2, Nat> -> List<&2, Nat>
def min_count.go source · line 370 · raw
@+counts:List<&2, Nat> -> @+fuel:Nat -> @refs:List<&2, Nat> -> Nat
def min_count source · line 386 · raw
@+counts:List<&2, Nat> -> @refs:List<&2, Nat> -> @acc:Nat -> Nat
def cons_if source · line 394 · raw
@h:Nat -> @rest:List<&2, Nat> -> @keep:Bool -> List<&2, Nat>
def uniq_nats.go source · line 402 · raw
@xs:List<&2, Nat> -> @+acc:List<&2, Nat> -> List<&2, Nat>
First-occurrence unique (C# HashSet of refs-with-candidates).
def uniq_nats source · line 409 · raw
@xs:List<&2, Nat> -> List<&2, Nat>
def refs_at.ok source · line 418 · raw
@+ctx:CntNeed -> @+r:Nat -> Bool
def refs_at source · line 423 · raw
@+counts:List<&2, Nat> -> @+need:Nat -> @refs:List<&2, Nat> -> List<&2, Nat>
def min_idx source · line 426 · raw
@xs:List<&2, Nat> -> @acc:Nat -> Nat
def min_idx_ne source · line 433 · raw
@xs:List<&2, Nat> -> Nat
def pick_ref source · line 440 · raw
@+asgs:List<&2, Assignment> -> @+counts:List<&2, Nat> -> @+cand:List<&2, Nat> -> Nat
def in_ref.ok source · line 450 · raw
@+ctx:RefPick -> @+i:Nat -> Bool
def in_ref source · line 455 · raw
@+asgs:List<&2, Assignment> -> @+r:Nat -> @cand:List<&2, Nat> -> List<&2, Nat>
def argmin_join source · line 458 · raw
@+asgs:List<&2, Assignment> -> @+ia:Nat -> @+ib:Nat -> Nat
def argmin_dist.go source · line 461 · raw
@+asgs:List<&2, Assignment> -> @+fuel:Nat -> @cand:List<&2, Nat> -> Nat
def argmin_dist source · line 479 · raw
@+asgs:List<&2, Assignment> -> @cand:List<&2, Nat> -> Nat
def pick_member.by source · line 487 · raw
@+asgs:List<&2, Assignment> -> @group:List<&2, Nat> -> @empty_niche:Bool -> Nat
def first_cand source · line 496 · raw
@cand:List<&2, Nat> -> Nat
First remaining last-front index. Used when inNiche is empty (C# would throw; never pick a phantom combined-pool index 0).
def pick_member.by.safe source · line 503 · raw
@+asgs:List<&2, Assignment> -> @group:List<&2, Nat> -> @empty_niche:Bool -> @+fallback:Nat -> Nat
def pick_member source · line 510 · raw
@+asgs:List<&2, Assignment> -> @+counts:List<&2, Nat> -> @+cand:List<&2, Nat> -> @+r:Nat -> Nat
def pick_ref.rng.go source · line 515 · raw
@+mins:List<&2, Nat> -> @n:Nat -> @+fallback:Nat -> @rng:0xd1de66b5d9157913a654c39186289f3d/rng.State -> 0xd1de66b5d9157913a654c39186289f3d/rng.State
Affine API: advanced State; chosen index is Rng.last_nat (no pair match).
C# Select(..., rng): draw only when more than one min-count ref.
def pick_ref.rng.after source · line 525 · raw
@+mins:List<&2, Nat> -> @+fallback:Nat -> @rng:0xd1de66b5d9157913a654c39186289f3d/rng.State -> 0xd1de66b5d9157913a654c39186289f3d/rng.State
def pick_ref.rng source · line 528 · raw
@+asgs:List<&2, Assignment> -> @+counts:List<&2, Nat> -> @+cand:List<&2, Nat> -> @rng:0xd1de66b5d9157913a654c39186289f3d/rng.State -> 0xd1de66b5d9157913a654c39186289f3d/rng.State
def near_lim source · line 540 · raw
@+best:F32 -> F32
Uniform inNiche[rng.Next] (C# non-empty + rng) lets far-from-ray last-front junk into a niche. With this LCG that pile-up dominates ZDT2's concave front (x0 → 0). Draw extras only among members within 2×best+0.01 of the ray (first assignment to a niche stays closest).
def near_ok source · line 543 · raw
@+asgs:List<&2, Assignment> -> @+i:Nat -> @+lim:F32 -> Bool
def near_members.ok source · line 552 · raw
@+ctx:NearPick -> @+i:Nat -> Bool
def near_members source · line 557 · raw
@+asgs:List<&2, Assignment> -> @group:List<&2, Nat> -> @+lim:F32 -> List<&2, Nat>
def pick_among.rng source · line 560 · raw
@+group:List<&2, Nat> -> @n:Nat -> @+fallback:Nat -> @rng:0xd1de66b5d9157913a654c39186289f3d/rng.State -> 0xd1de66b5d9157913a654c39186289f3d/rng.State
def pick_near.rng source · line 570 · raw
@+asgs:List<&2, Assignment> -> @+group:List<&2, Nat> -> @rng:0xd1de66b5d9157913a654c39186289f3d/rng.State -> 0xd1de66b5d9157913a654c39186289f3d/rng.State
def pick_member.rng.empty source · line 574 · raw
@+asgs:List<&2, Assignment> -> @+group:List<&2, Nat> -> @empty_niche:Bool -> @rng:0xd1de66b5d9157913a654c39186289f3d/rng.State -> 0xd1de66b5d9157913a654c39186289f3d/rng.State
def pick_member.rng.by source · line 581 · raw
@+asgs:List<&2, Assignment> -> @group:List<&2, Nat> -> @empty_niche:Bool -> @+fallback:Nat -> @rng:0xd1de66b5d9157913a654c39186289f3d/rng.State -> 0xd1de66b5d9157913a654c39186289f3d/rng.State
def pick_member.rng source · line 588 · raw
@+asgs:List<&2, Assignment> -> @+counts:List<&2, Nat> -> @+cand:List<&2, Nat> -> @+r:Nat -> @rng:0xd1de66b5d9157913a654c39186289f3d/rng.State -> 0xd1de66b5d9157913a654c39186289f3d/rng.State
def seed_raw.go source · line 597 · raw
@+asgs:List<&2, Assignment> -> @+n:Nat -> @+fuel:Nat -> @selected:List<&2, Nat> -> List<&2, Nat>
def seed_counts source · line 613 · raw
@+asgs:List<&2, Assignment> -> @+selected:List<&2, Nat> -> @+acc:List<&2, Nat> -> List<&2, Nat>
def pick_ref.rows source · line 617 · raw
@+counts:List<&2, Nat> -> @+rows:List<&2, NRow> -> Nat
fuel, k, cand first so the match follows binder order and fuel shrinks.
def pick_member.by.ne.rows source · line 621 · raw
@+group:List<&2, NRow> -> @empty_niche:Bool -> Nat
def pick_member.by.rows source · line 628 · raw
@group:List<&2, NRow> -> @empty_niche:Bool -> @+fallback:Nat -> Nat
def pick_member.rows source · line 635 · raw
@+counts:List<&2, Nat> -> @+rows:List<&2, NRow> -> @+r:Nat -> Nat
def pick_among.nrows source · line 638 · raw
@+rows:List<&2, NRow> -> @n:Nat -> @+fallback:Nat -> @rng:0xd1de66b5d9157913a654c39186289f3d/rng.State -> 0xd1de66b5d9157913a654c39186289f3d/rng.State
def pick_near.rng.rows source · line 648 · raw
@+group:List<&2, NRow> -> @rng:0xd1de66b5d9157913a654c39186289f3d/rng.State -> 0xd1de66b5d9157913a654c39186289f3d/rng.State
def pick_member.rng.empty.rows source · line 652 · raw
@+group:List<&2, NRow> -> @empty_niche:Bool -> @rng:0xd1de66b5d9157913a654c39186289f3d/rng.State -> 0xd1de66b5d9157913a654c39186289f3d/rng.State
def niche_loop source · line 659 · raw
@fuel:Nat -> @k:Nat -> @rows:List<&2, NRow> -> @+counts:List<&2, Nat> -> @selected:List<&2, Nat> -> List<&2, Nat>
def fill source · line 679 · raw
@fuel:Nat -> @fronts:List<&2, List<&2, Nat>> -> @fits:Bool -> @+acc:List<&2, Nat> -> @+target:Nat -> @+asgs:List<&2, Assignment> -> @+n_dirs:Nat -> List<&2, Nat>
def fill.wrap source · line 707 · raw
@+fronts:List<&2, List<&2, Nat>> -> @+target:Nat -> @+asgs:List<&2, Assignment> -> @+n_dirs:Nat -> List<&2, Nat>
def head_is_ref source · line 737 · raw
@bags:List<&2, Bag> -> @+r:Nat -> Bool
def bag_put.go source · line 744 · raw
@bags:List<&2, Bag> -> @+row:NRow -> @+seeded:Nat -> @+pos:Nat -> @+rev:List<&2, Bag> -> @same:Bool -> List<&2, Bag>
def bag_put source · line 765 · raw
@+bags:List<&2, Bag> -> @+row:NRow -> @+seeded:Nat -> @+pos:Nat -> List<&2, Bag>
def bags_of.go source · line 768 · raw
@+counts:List<&2, Nat> -> @rows:List<&2, NRow> -> @+acc:List<&2, Bag> -> @+pos:Nat -> List<&2, Bag>
def bags_of source · line 775 · raw
@+counts:List<&2, Nat> -> @+rows:List<&2, NRow> -> List<&2, Bag>
def first_bag_ref source · line 778 · raw
@bags:List<&2, Bag> -> Nat
def min_bag_count.go source · line 785 · raw
@bags:List<&2, Bag> -> @+acc:Nat -> Nat
def min_bag_count source · line 792 · raw
@bags:List<&2, Bag> -> Nat
def refs_of_count.go source · line 795 · raw
@bags:List<&2, Bag> -> @+need:Nat -> @+acc:List<&2, Nat> -> List<&2, Nat>
def refs_of_count source · line 802 · raw
@+bags:List<&2, Bag> -> List<&2, Nat>
def pick_ref.rng.bags source · line 805 · raw
@+bags:List<&2, Bag> -> @rng:0xd1de66b5d9157913a654c39186289f3d/rng.State -> 0xd1de66b5d9157913a654c39186289f3d/rng.State
def bag_count_go source · line 808 · raw
@bags:List<&2, Bag> -> @+r:Nat -> @hit:Bool -> Nat
def bag_count_of source · line 817 · raw
@+bags:List<&2, Bag> -> @+r:Nat -> Nat
def mrows_rows source · line 820 · raw
@ms:List<&2, MRow> -> List<&2, NRow>
def bag_members_go source · line 827 · raw
@bags:List<&2, Bag> -> @+r:Nat -> @hit:Bool -> List<&2, NRow>
def bag_members_of source · line 836 · raw
@+bags:List<&2, Bag> -> @+r:Nat -> List<&2, NRow>
def drop_mrow.put source · line 839 · raw
@+row:MRow -> @rest:List<&2, MRow> -> @drop:Bool -> List<&2, MRow>
def drop_mrow source · line 846 · raw
@ms:List<&2, MRow> -> @+pick:Nat -> List<&2, MRow>
def bags_kept source · line 853 · raw
@+ref:Nat -> @+count:Nat -> @members:List<&2, MRow> -> @rest:List<&2, Bag> -> List<&2, Bag>
def bags_refill.go source · line 860 · raw
@bags:List<&2, Bag> -> @+r:Nat -> @+pick:Nat -> @hit:Bool -> List<&2, Bag>
def bags_refill source · line 869 · raw
@+bags:List<&2, Bag> -> @+r:Nat -> @+pick:Nat -> List<&2, Bag>
def head_pos.ms source · line 872 · raw
@ms:List<&2, MRow> -> Nat
def head_pos source · line 879 · raw
@b:Bag -> Nat
def insert_before source · line 884 · raw
@acc:List<&2, Bag> -> @+b:Bag -> Bool
def insert_bag source · line 891 · raw
@acc:List<&2, Bag> -> @+b:Bag -> @before:Bool -> List<&2, Bag>
def sort_put source · line 900 · raw
@+acc:List<&2, Bag> -> @+b:Bag -> List<&2, Bag>
def sort_go source · line 903 · raw
@bags:List<&2, Bag> -> @+acc:List<&2, Bag> -> List<&2, Bag>
def sort_bags source · line 910 · raw
@+bags:List<&2, Bag> -> List<&2, Bag>
def niche_loop.bags source · line 913 · raw
@fuel:Nat -> @k:Nat -> @bags:List<&2, Bag> -> @selected:List<&2, Nat> -> @rng:0xd1de66b5d9157913a654c39186289f3d/rng.State -> Pair(List<&2, Nat>, 0xd1de66b5d9157913a654c39186289f3d/rng.State)
def fill.rng source · line 936 · raw
@fuel:Nat -> @fronts:List<&2, List<&2, Nat>> -> @fits:Bool -> @+acc:List<&2, Nat> -> @+target:Nat -> @+asgs:List<&2, Assignment> -> @+n_dirs:Nat -> @rng:0xd1de66b5d9157913a654c39186289f3d/rng.State -> Pair(List<&2, Nat>, 0xd1de66b5d9157913a654c39186289f3d/rng.State)
def fill.wrap.rng source · line 965 · raw
@+fronts:List<&2, List<&2, Nat>> -> @+target:Nat -> @+asgs:List<&2, Assignment> -> @+n_dirs:Nat -> @rng:0xd1de66b5d9157913a654c39186289f3d/rng.State -> Pair(List<&2, Nat>, 0xd1de66b5d9157913a654c39186289f3d/rng.State)
def select_idx.with source · line 977 · raw
@+pop:List<&2, 0xd1de66b5d9157913a654c39186289f3d/individual.Individual> -> @+target:Nat -> @+dirs:List<&2, List<&2, F32>> -> @+fronts:List<&2, List<&2, Nat>> -> @pair:Pair(0xd1de66b5d9157913a654c39186289f3d/normalization.State, List<&2, List<&2, F32>>) -> List<&2, Nat>
def select_idx.big source · line 981 · raw
@+pop:List<&2, 0xd1de66b5d9157913a654c39186289f3d/individual.Individual> -> @+target:Nat -> @+dirs:List<&2, List<&2, F32>> -> List<&2, Nat>
def select_idx.dirs source · line 985 · raw
@+pop:List<&2, 0xd1de66b5d9157913a654c39186289f3d/individual.Individual> -> @+target:Nat -> @+dirs:List<&2, List<&2, F32>> -> @empty_dirs:Bool -> List<&2, Nat>
def select_idx.by source · line 992 · raw
@+pop:List<&2, 0xd1de66b5d9157913a654c39186289f3d/individual.Individual> -> @+target:Nat -> @+dirs:List<&2, List<&2, F32>> -> @small:Bool -> List<&2, Nat>
def any_infeas.on source · line 1011 · raw
@later:Bool -> @feas:Bool -> Bool
def any_infeas source · line 1018 · raw
@pop:List<&2, 0xd1de66b5d9157913a654c39186289f3d/individual.Individual> -> Bool
def row_before source · line 1025 · raw
@a:CvRow -> @b:CvRow -> Bool
def insert_row.go source · line 1041 · raw
@fuel:Nat -> @phase:Nat -> @before:Bool -> @+x:CvRow -> @xs:List<&2, CvRow> -> @+h:CvRow -> List<&2, CvRow>
Insertion sort step. One def: the recursive call is only the
before = False arm, and that arm's tail is the original rest.
before = True conses onto that same rest (no second insert).
phase 0 reads the next cons; phase 1 places the row. Fuel is 1+2|xs|.
Recursing through a tail that already contains x, then consing x
again, duplicates the row. Each smaller CV doubles the list. At the
constrained budgets that exponential spine overflows the native stack
(memory fault (machine stack overflow?) on OSY / C1-DTLZ1; TNK
fail-stops). src/constrained_budget.bend runs those budgets.
def insert_row source · line 1056 · raw
@+x:CvRow -> @+xs:List<&2, CvRow> -> List<&2, CvRow>
def sort_rows source · line 1059 · raw
@xs:List<&2, CvRow> -> List<&2, CvRow>
def row_ind source · line 1066 · raw
@row:CvRow -> 0xd1de66b5d9157913a654c39186289f3d/individual.Individual
def rows_inds source · line 1071 · raw
@xs:List<&2, CvRow> -> List<&2, 0xd1de66b5d9157913a654c39186289f3d/individual.Individual>
def map_clear source · line 1078 · raw
@xs:List<&2, 0xd1de66b5d9157913a654c39186289f3d/individual.Individual> -> List<&2, 0xd1de66b5d9157913a654c39186289f3d/individual.Individual>
def take_clear source · line 1085 · raw
@rows:List<&2, CvRow> -> @+n:Nat -> List<&2, 0xd1de66b5d9157913a654c39186289f3d/individual.Individual>
def append_fill source · line 1088 · raw
@+kept:List<&2, 0xd1de66b5d9157913a654c39186289f3d/individual.Individual> -> @rows:List<&2, CvRow> -> @+target:Nat -> List<&2, 0xd1de66b5d9157913a654c39186289f3d/individual.Individual>
def unused_idxs source · line 1096 · raw
@+used:List<&2, Nat> -> @+n:Nat -> List<&2, Nat>
def pad_idxs source · line 1102 · raw
@+xs:List<&2, Nat> -> @+want:Nat -> @+n:Nat -> List<&2, Nat>
Length lock: |take(pad(core, want, n), want)| = want when want ≤ n. Identity when core is already a unique subset of 0..n-1 of length want (the fill / range / take paths used in A/B).
def clip_idxs source · line 1105 · raw
@+xs:List<&2, Nat> -> @+want:Nat -> List<&2, Nat>
def size_lock source · line 1108 · raw
@+xs:List<&2, Nat> -> @+want:Nat -> @+n:Nat -> List<&2, Nat>
def select_idx source · line 1111 · raw
@+combined:List<&2, 0xd1de66b5d9157913a654c39186289f3d/individual.Individual> -> @+target_size:Nat -> @+dirs:List<&2, List<&2, F32>> -> List<&2, Nat>
def select_plain source · line 1116 · raw
@+combined:List<&2, 0xd1de66b5d9157913a654c39186289f3d/individual.Individual> -> @+target_size:Nat -> @+dirs:List<&2, List<&2, F32>> -> List<&2, 0xd1de66b5d9157913a654c39186289f3d/individual.Individual>
def feas_keep.det.on source · line 1121 · raw
@+feas:List<&2, 0xd1de66b5d9157913a654c39186289f3d/individual.Individual> -> @+target:Nat -> @+dirs:List<&2, List<&2, F32>> -> @fits:Bool -> List<&2, 0xd1de66b5d9157913a654c39186289f3d/individual.Individual>
Feasible subset already fits: keep original order. Niching runs only when that subset is longer than the slot count.
def feas_keep.det source · line 1128 · raw
@+feas:List<&2, 0xd1de66b5d9157913a654c39186289f3d/individual.Individual> -> @+target:Nat -> @+dirs:List<&2, List<&2, F32>> -> List<&2, 0xd1de66b5d9157913a654c39186289f3d/individual.Individual>
def split_add.feas source · line 1137 · raw
@+h:0xd1de66b5d9157913a654c39186289f3d/individual.Individual -> @sp:Split -> Split
def split_add.infeas source · line 1142 · raw
@+h:0xd1de66b5d9157913a654c39186289f3d/individual.Individual -> @+i:Nat -> @sp:Split -> Split
def split_on source · line 1147 · raw
@+h:0xd1de66b5d9157913a654c39186289f3d/individual.Individual -> @rest:Split -> @+i:Nat -> @feas:Bool -> Split
def split.go source · line 1154 · raw
@pop:List<&2, 0xd1de66b5d9157913a654c39186289f3d/individual.Individual> -> @+i:Nat -> Split
def select_constrained.feas source · line 1161 · raw
@feas:List<&2, 0xd1de66b5d9157913a654c39186289f3d/individual.Individual> -> @+rows:List<&2, CvRow> -> @+target:Nat -> @+dirs:List<&2, List<&2, F32>> -> List<&2, 0xd1de66b5d9157913a654c39186289f3d/individual.Individual>
def select_constrained.from source · line 1168 · raw
@sp:Split -> @+target:Nat -> @+dirs:List<&2, List<&2, F32>> -> List<&2, 0xd1de66b5d9157913a654c39186289f3d/individual.Individual>
def select_constrained source · line 1173 · raw
@+pop:List<&2, 0xd1de66b5d9157913a654c39186289f3d/individual.Individual> -> @+target:Nat -> @+dirs:List<&2, List<&2, F32>> -> List<&2, 0xd1de66b5d9157913a654c39186289f3d/individual.Individual>
def size_lock.rng source · line 1179 · raw
@+want:Nat -> @+n:Nat -> @pair:Pair(List<&2, Nat>, 0xd1de66b5d9157913a654c39186289f3d/rng.State) -> Pair(List<&2, Nat>, 0xd1de66b5d9157913a654c39186289f3d/rng.State)
All-feasible Run path. Defined before constrained fill so a feasible subset that still needs niching calls this directly (no cycle through select_st).
def select_st.after source · line 1183 · raw
@+st:0xd1de66b5d9157913a654c39186289f3d/normalization.State -> @+pop:List<&2, 0xd1de66b5d9157913a654c39186289f3d/individual.Individual> -> @pair:Pair(List<&2, Nat>, 0xd1de66b5d9157913a654c39186289f3d/rng.State) -> Pair(0xd1de66b5d9157913a654c39186289f3d/normalization.State, Pair(List<&2, 0xd1de66b5d9157913a654c39186289f3d/individual.Individual>, 0xd1de66b5d9157913a654c39186289f3d/rng.State))
def select_st.with source · line 1187 · raw
@+pop:List<&2, 0xd1de66b5d9157913a654c39186289f3d/individual.Individual> -> @+target:Nat -> @+dirs:List<&2, List<&2, F32>> -> @+fronts:List<&2, List<&2, Nat>> -> @pair:Pair(0xd1de66b5d9157913a654c39186289f3d/normalization.State, List<&2, List<&2, F32>>) -> @rng:0xd1de66b5d9157913a654c39186289f3d/rng.State -> Pair(0xd1de66b5d9157913a654c39186289f3d/normalization.State, Pair(List<&2, 0xd1de66b5d9157913a654c39186289f3d/individual.Individual>, 0xd1de66b5d9157913a654c39186289f3d/rng.State))
def select_st.big source · line 1193 · raw
@+pop:List<&2, 0xd1de66b5d9157913a654c39186289f3d/individual.Individual> -> @+target:Nat -> @+dirs:List<&2, List<&2, F32>> -> @state:0xd1de66b5d9157913a654c39186289f3d/normalization.State -> @rng:0xd1de66b5d9157913a654c39186289f3d/rng.State -> Pair(0xd1de66b5d9157913a654c39186289f3d/normalization.State, Pair(List<&2, 0xd1de66b5d9157913a654c39186289f3d/individual.Individual>, 0xd1de66b5d9157913a654c39186289f3d/rng.State))
def select_st.take source · line 1197 · raw
@+pop:List<&2, 0xd1de66b5d9157913a654c39186289f3d/individual.Individual> -> @+target:Nat -> @state:0xd1de66b5d9157913a654c39186289f3d/normalization.State -> @rng:0xd1de66b5d9157913a654c39186289f3d/rng.State -> Pair(0xd1de66b5d9157913a654c39186289f3d/normalization.State, Pair(List<&2, 0xd1de66b5d9157913a654c39186289f3d/individual.Individual>, 0xd1de66b5d9157913a654c39186289f3d/rng.State))
def select_st.dirs source · line 1201 · raw
@+pop:List<&2, 0xd1de66b5d9157913a654c39186289f3d/individual.Individual> -> @+target:Nat -> @+dirs:List<&2, List<&2, F32>> -> @state:0xd1de66b5d9157913a654c39186289f3d/normalization.State -> @rng:0xd1de66b5d9157913a654c39186289f3d/rng.State -> @empty_dirs:Bool -> Pair(0xd1de66b5d9157913a654c39186289f3d/normalization.State, Pair(List<&2, 0xd1de66b5d9157913a654c39186289f3d/individual.Individual>, 0xd1de66b5d9157913a654c39186289f3d/rng.State))
def feas_keep.st.fit.unpack source · line 1208 · raw
@+feas:List<&2, 0xd1de66b5d9157913a654c39186289f3d/individual.Individual> -> @rng:0xd1de66b5d9157913a654c39186289f3d/rng.State -> @pair:Pair(0xd1de66b5d9157913a654c39186289f3d/normalization.State, List<&2, List<&2, F32>>) -> Pair(0xd1de66b5d9157913a654c39186289f3d/normalization.State, Pair(List<&2, 0xd1de66b5d9157913a654c39186289f3d/individual.Individual>, 0xd1de66b5d9157913a654c39186289f3d/rng.State))
def feas_keep.st.fit source · line 1212 · raw
@+feas:List<&2, 0xd1de66b5d9157913a654c39186289f3d/individual.Individual> -> @state:0xd1de66b5d9157913a654c39186289f3d/normalization.State -> @rng:0xd1de66b5d9157913a654c39186289f3d/rng.State -> Pair(0xd1de66b5d9157913a654c39186289f3d/normalization.State, Pair(List<&2, 0xd1de66b5d9157913a654c39186289f3d/individual.Individual>, 0xd1de66b5d9157913a654c39186289f3d/rng.State))
def feas_keep.st.on source · line 1215 · raw
@+feas:List<&2, 0xd1de66b5d9157913a654c39186289f3d/individual.Individual> -> @+target:Nat -> @+dirs:List<&2, List<&2, F32>> -> @state:0xd1de66b5d9157913a654c39186289f3d/normalization.State -> @rng:0xd1de66b5d9157913a654c39186289f3d/rng.State -> @fits:Bool -> Pair(0xd1de66b5d9157913a654c39186289f3d/normalization.State, Pair(List<&2, 0xd1de66b5d9157913a654c39186289f3d/individual.Individual>, 0xd1de66b5d9157913a654c39186289f3d/rng.State))
def feas_keep.st source · line 1222 · raw
@+feas:List<&2, 0xd1de66b5d9157913a654c39186289f3d/individual.Individual> -> @+target:Nat -> @+dirs:List<&2, List<&2, F32>> -> @state:0xd1de66b5d9157913a654c39186289f3d/normalization.State -> @rng:0xd1de66b5d9157913a654c39186289f3d/rng.State -> Pair(0xd1de66b5d9157913a654c39186289f3d/normalization.State, Pair(List<&2, 0xd1de66b5d9157913a654c39186289f3d/individual.Individual>, 0xd1de66b5d9157913a654c39186289f3d/rng.State))
def select_st.constrained.kept source · line 1225 · raw
@+rows:List<&2, CvRow> -> @+target:Nat -> @trip:Pair(0xd1de66b5d9157913a654c39186289f3d/normalization.State, Pair(List<&2, 0xd1de66b5d9157913a654c39186289f3d/individual.Individual>, 0xd1de66b5d9157913a654c39186289f3d/rng.State)) -> Pair(0xd1de66b5d9157913a654c39186289f3d/normalization.State, Pair(List<&2, 0xd1de66b5d9157913a654c39186289f3d/individual.Individual>, 0xd1de66b5d9157913a654c39186289f3d/rng.State))
def select_st.constrained.feas source · line 1229 · raw
@feas:List<&2, 0xd1de66b5d9157913a654c39186289f3d/individual.Individual> -> @+rows:List<&2, CvRow> -> @+target:Nat -> @+dirs:List<&2, List<&2, F32>> -> @state:0xd1de66b5d9157913a654c39186289f3d/normalization.State -> @rng:0xd1de66b5d9157913a654c39186289f3d/rng.State -> Pair(0xd1de66b5d9157913a654c39186289f3d/normalization.State, Pair(List<&2, 0xd1de66b5d9157913a654c39186289f3d/individual.Individual>, 0xd1de66b5d9157913a654c39186289f3d/rng.State))
def select_st.constrained.from source · line 1236 · raw
@sp:Split -> @+target:Nat -> @+dirs:List<&2, List<&2, F32>> -> @state:0xd1de66b5d9157913a654c39186289f3d/normalization.State -> @rng:0xd1de66b5d9157913a654c39186289f3d/rng.State -> Pair(0xd1de66b5d9157913a654c39186289f3d/normalization.State, Pair(List<&2, 0xd1de66b5d9157913a654c39186289f3d/individual.Individual>, 0xd1de66b5d9157913a654c39186289f3d/rng.State))
def select_st.constrained source · line 1241 · raw
@+pop:List<&2, 0xd1de66b5d9157913a654c39186289f3d/individual.Individual> -> @+target:Nat -> @+dirs:List<&2, List<&2, F32>> -> @state:0xd1de66b5d9157913a654c39186289f3d/normalization.State -> @rng:0xd1de66b5d9157913a654c39186289f3d/rng.State -> Pair(0xd1de66b5d9157913a654c39186289f3d/normalization.State, Pair(List<&2, 0xd1de66b5d9157913a654c39186289f3d/individual.Individual>, 0xd1de66b5d9157913a654c39186289f3d/rng.State))
def select.route source · line 1244 · raw
@+combined:List<&2, 0xd1de66b5d9157913a654c39186289f3d/individual.Individual> -> @+target_size:Nat -> @+dirs:List<&2, List<&2, F32>> -> @constrained:Bool -> List<&2, 0xd1de66b5d9157913a654c39186289f3d/individual.Individual>
def select source · line 1253 · raw
@+combined:List<&2, 0xd1de66b5d9157913a654c39186289f3d/individual.Individual> -> @+target_size:Nat -> @+dirs:List<&2, List<&2, F32>> -> List<&2, 0xd1de66b5d9157913a654c39186289f3d/individual.Individual>
select stays the rng-null length-locked path (Laws.select_size).
Constrained feasible-niching + CV fill is select_st (Run).
def select_st.large source · line 1260 · raw
@+pop:List<&2, 0xd1de66b5d9157913a654c39186289f3d/individual.Individual> -> @+target:Nat -> @+dirs:List<&2, List<&2, F32>> -> @state:0xd1de66b5d9157913a654c39186289f3d/normalization.State -> @rng:0xd1de66b5d9157913a654c39186289f3d/rng.State -> @bad:Bool -> Pair(0xd1de66b5d9157913a654c39186289f3d/normalization.State, Pair(List<&2, 0xd1de66b5d9157913a654c39186289f3d/individual.Individual>, 0xd1de66b5d9157913a654c39186289f3d/rng.State))
Persistent-normalization Select for Unsga3Algorithm.Run. Threads rng
so last-front niching matches C# Select(..., rng) on min-count niche
ties. Empty niches take closest; extras are random among near-best
on that ray. v0 select stays the rng == null path (empty laws).
def select_st.by source · line 1267 · raw
@+pop:List<&2, 0xd1de66b5d9157913a654c39186289f3d/individual.Individual> -> @+target:Nat -> @+dirs:List<&2, List<&2, F32>> -> @state:0xd1de66b5d9157913a654c39186289f3d/normalization.State -> @rng:0xd1de66b5d9157913a654c39186289f3d/rng.State -> @small:Bool -> Pair(0xd1de66b5d9157913a654c39186289f3d/normalization.State, Pair(List<&2, 0xd1de66b5d9157913a654c39186289f3d/individual.Individual>, 0xd1de66b5d9157913a654c39186289f3d/rng.State))
def select_st source · line 1274 · raw
@+combined:List<&2, 0xd1de66b5d9157913a654c39186289f3d/individual.Individual> -> @+target_size:Nat -> @+dirs:List<&2, List<&2, F32>> -> @state:0xd1de66b5d9157913a654c39186289f3d/normalization.State -> @rng:0xd1de66b5d9157913a654c39186289f3d/rng.State -> Pair(0xd1de66b5d9157913a654c39186289f3d/normalization.State, Pair(List<&2, 0xd1de66b5d9157913a654c39186289f3d/individual.Individual>, 0xd1de66b5d9157913a654c39186289f3d/rng.State))