individual.bend checks
raw source on the hub · import 0xd1de66b5d9157913a654c39186289f3d/individual.bend as Individual
Individual — C# Unsga3.Algorithm.Individual.
Objectives + decision variables + evaluated + tournament bookkeeping
(rank / niche / associated ref / perp distance).
Constraints are g ≤ 0. cv is the sum of the positive parts
(RefreshConstraintViolation). Feasible iff cv ≤ 0. Empty g is cv 0,
so unconstrained ZDT / DTLZ stay on the Pareto path.
lnk is false until stamp (C# AssociatedReference starts at -1).
CV-fill clears it again: those members are not in a niche.
1 import
import Base
Types
type Individual source · line 12 · raw
Data
MkIndividual@x:List<&2, F32> -> @f:List<&2, F32> -> @g:List<&2, F32> -> @cv:F32 -> @rnk:Nat -> @nic:Nat -> @aref:Nat -> @dist:F32 -> @ev:Bool -> @lnk:Bool -> Individual
Definitions
def pos_part source · line 26 · raw
@+x:F32 -> F32
def sum_pos source · line 30 · raw
@xs:List<&2, F32> -> F32
Sum of g_i where g_i > 0. Non-positive parts add nothing.
def from_objectives source · line 39 · raw
@+f:List<&2, F32> -> Individual
v0 / A/B path: objectives already known; no decision vector. No constraints → cv 0 (feasible).
def from_variables source · line 44 · raw
@+x:List<&2, F32> -> @n_obj:Nat -> Individual
Unevaluated candidate: variables set, objectives zeroed (C# ctor). Constraints empty until a problem writes them.
def variables source · line 47 · raw
@ind:Individual -> List<&2, F32>
def objectives source · line 52 · raw
@ind:Individual -> List<&2, F32>
def constraints source · line 57 · raw
@ind:Individual -> List<&2, F32>
def constraint_violation source · line 62 · raw
@ind:Individual -> F32
def feasible source · line 68 · raw
@ind:Individual -> Bool
C# IsFeasible: ConstraintViolation <= 0.
def rank source · line 71 · raw
@ind:Individual -> Nat
def evaluated source · line 76 · raw
@ind:Individual -> Bool
def n_obj source · line 81 · raw
@ind:Individual -> Nat
def n_var source · line 84 · raw
@ind:Individual -> Nat
def var_at source · line 87 · raw
@ind:Individual -> @i:Nat -> F32
def set_var_at source · line 90 · raw
@ind:Individual -> @i:Nat -> @v:F32 -> Individual
def set_evaluated source · line 95 · raw
@ind:Individual -> @ev2:Bool -> Individual
def niche source · line 100 · raw
@ind:Individual -> Nat
def associated_ref source · line 105 · raw
@ind:Individual -> Nat
def perp_dist source · line 110 · raw
@ind:Individual -> F32
def set_objectives source · line 115 · raw
@ind:Individual -> @+f2:List<&2, F32> -> Individual
def set_constraints source · line 121 · raw
@ind:Individual -> @+g2:List<&2, F32> -> Individual
Replace g and recompute cv (sum of positive parts).
def set_rank source · line 126 · raw
@ind:Individual -> @rnk2:Nat -> Individual
def stamp source · line 131 · raw
@ind:Individual -> @+rnk2:Nat -> @+nic2:Nat -> @+aref2:Nat -> @+dist2:F32 -> Individual
def niche_linked source · line 137 · raw
@ind:Individual -> Bool
C# AssociatedReference starts at -1. stamp is the assignment.
def clear_niche source · line 143 · raw
@ind:Individual -> Individual
CV fill does not assign a niche (pymoo merges these after survival).