~/bend-docscommunity

normalization.bend checks

raw source on the hub · import 0x2bc7fb472c80bd6a0e04725c117edb2a/normalization.bend as Normalization

Normalization — C# Unsga3.Core.Normalization (v0). Persistent ideal / worst, ASF extreme points (previous extremes ∪ ND, or the whole population when the ND index set is empty), intercept hyperplane nadir via (E−ideal)·b = 1, then C# front/pop/unit fallbacks. ASF: floor 1e-3 on ideal-translated objectives; preferred axis weight 1, other axes 1e-6 (divide form).

3 imports
import Base
import ./individual.bend as Ind
import ./util.bend as Util

Types

type State source · line 12 · raw

Data

type ExtCtx source · line 224 · raw

Data

Definitions

def new_state source · line 22 · raw

@n_objectives:Nat -> State

def state_n source · line 25 · raw

@st:State -> Nat

def state_ideal source · line 30 · raw

@st:State -> List<&2, F32>

def col_min.go source · line 36 · raw

@+fuel:Nat -> @pop:List<&2, 0x2bc7fb472c80bd6a0e04725c117edb2a/individual.Individual> -> List<&2, F32>

Column min/max are associative. Mid-split then vec_min / vec_max.

def col_min source · line 52 · raw

@+pop:List<&2, 0x2bc7fb472c80bd6a0e04725c117edb2a/individual.Individual> -> List<&2, F32>

def col_max.go source · line 55 · raw

@+fuel:Nat -> @pop:List<&2, 0x2bc7fb472c80bd6a0e04725c117edb2a/individual.Individual> -> List<&2, F32>

def col_max source · line 71 · raw

@+pop:List<&2, 0x2bc7fb472c80bd6a0e04725c117edb2a/individual.Individual> -> List<&2, F32>

def get_ind source · line 74 · raw

@+pop:List<&2, 0x2bc7fb472c80bd6a0e04725c117edb2a/individual.Individual> -> @i:Nat -> Maybe<&2, 0x2bc7fb472c80bd6a0e04725c117edb2a/individual.Individual>

def max_at.go source · line 77 · raw

@acc:List<&2, F32> -> @m:Maybe<&2, 0x2bc7fb472c80bd6a0e04725c117edb2a/individual.Individual> -> List<&2, F32>

def max_at source · line 84 · raw

@+pop:List<&2, 0x2bc7fb472c80bd6a0e04725c117edb2a/individual.Individual> -> @acc:List<&2, F32> -> @i:Nat -> List<&2, F32>

def col_max_idx.go source · line 87 · raw

@+pop:List<&2, 0x2bc7fb472c80bd6a0e04725c117edb2a/individual.Individual> -> @+fuel:Nat -> @idxs:List<&2, Nat> -> List<&2, F32>

def col_max_idx source · line 103 · raw

@+pop:List<&2, 0x2bc7fb472c80bd6a0e04725c117edb2a/individual.Individual> -> @idxs:List<&2, Nat> -> List<&2, F32>

def merge_ideal source · line 111 · raw

@prev:List<&2, F32> -> @cur:List<&2, F32> -> List<&2, F32>

def merge_worst source · line 118 · raw

@prev:List<&2, F32> -> @cur:List<&2, F32> -> List<&2, F32>

def nd_or_all source · line 125 · raw

@nd:List<&2, Nat> -> @n:Nat -> List<&2, Nat>

def obj_at.go source · line 132 · raw

@m:Maybe<&2, 0x2bc7fb472c80bd6a0e04725c117edb2a/individual.Individual> -> List<&2, F32>

def obj_at source · line 139 · raw

@+pop:List<&2, 0x2bc7fb472c80bd6a0e04725c117edb2a/individual.Individual> -> @i:Nat -> List<&2, F32>

def gather_objs.one source · line 142 · raw

@+pop:List<&2, 0x2bc7fb472c80bd6a0e04725c117edb2a/individual.Individual> -> @+i:Nat -> List<&2, F32>

def gather_objs source · line 145 · raw

@+pop:List<&2, 0x2bc7fb472c80bd6a0e04725c117edb2a/individual.Individual> -> @+idxs:List<&2, Nat> -> List<&2, List<&2, F32>>

def map_norm.one source · line 148 · raw

@+ideal:List<&2, F32> -> @+nadir:List<&2, F32> -> @+ind:0x2bc7fb472c80bd6a0e04725c117edb2a/individual.Individual -> List<&2, F32>

def map_norm.go source · line 152 · raw

@+ideal:List<&2, F32> -> @+nadir:List<&2, F32> -> @+fuel:Nat -> @pop:List<&2, 0x2bc7fb472c80bd6a0e04725c117edb2a/individual.Individual> -> List<&2, List<&2, F32>>

Independent per individual given ideal/nadir. Mid-split + parallel recurse.

def map_norm source · line 168 · raw

@+ideal:List<&2, F32> -> @+nadir:List<&2, F32> -> @+pop:List<&2, 0x2bc7fb472c80bd6a0e04725c117edb2a/individual.Individual> -> List<&2, List<&2, F32>>

def n_obj_pop source · line 171 · raw

@pop:List<&2, 0x2bc7fb472c80bd6a0e04725c117edb2a/individual.Individual> -> Nat

def asf_term source · line 179 · raw

@+fj:F32 -> @+ij:F32 -> @on_axis:Bool -> F32

ASF on ideal-translated objectives (pymoo __F = F − ideal).

def asf.go source · line 185 · raw

@f:List<&2, F32> -> @ideal:List<&2, F32> -> @+axis:Nat -> @+j:Nat -> @acc:F32 -> F32

def asf source · line 194 · raw

@f:List<&2, F32> -> @+axis:Nat -> @+ideal:List<&2, F32> -> F32

def pick_axis.go source · line 203 · raw

@rest:List<&2, List<&2, F32>> -> @+ideal:List<&2, F32> -> @+axis:Nat -> @+best_f:List<&2, F32> -> @+best_asf:F32 -> List<&2, F32>

def pick_axis source · line 217 · raw

@cand:List<&2, List<&2, F32>> -> @+ideal:List<&2, F32> -> @+axis:Nat -> List<&2, F32>

def pick_axis.one source · line 230 · raw

@+ctx:ExtCtx -> @+axis:Nat -> List<&2, F32>

def pick_extremes source · line 236 · raw

@+cand:List<&2, List<&2, F32>> -> @+ideal:List<&2, F32> -> @m:Nat -> List<&2, List<&2, F32>>

One ASF extreme per axis; axes are independent.

def get_row source · line 239 · raw

@+mat:List<&2, List<&2, F32>> -> @i:Nat -> List<&2, F32>

def mat_get source · line 242 · raw

@+mat:List<&2, List<&2, F32>> -> @i:Nat -> @j:Nat -> F32

def swap_rows.do source · line 245 · raw

@+mat:List<&2, List<&2, F32>> -> @+i:Nat -> @+k:Nat -> List<&2, List<&2, F32>>

def swap_rows.when source · line 250 · raw

@+mat:List<&2, List<&2, F32>> -> @+i:Nat -> @+k:Nat -> @same:Bool -> List<&2, List<&2, F32>>

def swap_rows source · line 257 · raw

@+mat:List<&2, List<&2, F32>> -> @+i:Nat -> @+k:Nat -> List<&2, List<&2, F32>>

def scale_vec.go source · line 260 · raw

@fuel:Nat -> @+row:List<&2, F32> -> @+j:Nat -> @+div:F32 -> List<&2, F32>

def scale_row source · line 267 · raw

@+mat:List<&2, List<&2, F32>> -> @+col:Nat -> @+n:Nat -> @+div:F32 -> List<&2, List<&2, F32>>

def axpy_vec.go source · line 270 · raw

@fuel:Nat -> @+row:List<&2, F32> -> @+piv:List<&2, F32> -> @+j:Nat -> @+factor:F32 -> List<&2, F32>

def axpy_row source · line 279 · raw

@+mat:List<&2, List<&2, F32>> -> @+row:Nat -> @+col:Nat -> @+n:Nat -> @+factor:F32 -> @+piv:List<&2, F32> -> List<&2, List<&2, F32>>

def find_pivot.go source · line 282 · raw

@fuel:Nat -> @+mat:List<&2, List<&2, F32>> -> @+col:Nat -> @+row:Nat -> @+best_row:Nat -> @+best:F32 -> Nat

def find_pivot source · line 297 · raw

@+mat:List<&2, List<&2, F32>> -> @+col:Nat -> @+n:Nat -> Nat

def elim_one source · line 300 · raw

@+row:Nat -> @+col:Nat -> @+n:Nat -> @+piv:List<&2, F32> -> @+mat:List<&2, List<&2, F32>> -> @skip:Bool -> List<&2, List<&2, F32>>

def elim_rows source · line 307 · raw

@fuel:Nat -> @+row:Nat -> @+col:Nat -> @+n:Nat -> @+piv:List<&2, F32> -> @mat:List<&2, List<&2, F32>> -> List<&2, List<&2, F32>>

def ge_step source · line 314 · raw

@+col:Nat -> @+n:Nat -> @+mat:List<&2, List<&2, F32>> -> @+pivot:Nat -> @tiny:Bool -> Maybe<&2, List<&2, List<&2, F32>>>

def ge_col.go source · line 324 · raw

@fuel:Nat -> @+col:Nat -> @+n:Nat -> @acc:Maybe<&2, List<&2, List<&2, F32>>> -> Maybe<&2, List<&2, List<&2, F32>>>

def ge_col source · line 339 · raw

@fuel:Nat -> @+col:Nat -> @+n:Nat -> @mat:List<&2, List<&2, F32>> -> Maybe<&2, List<&2, List<&2, F32>>>

def extract_x.go source · line 342 · raw

@fuel:Nat -> @+mat:List<&2, List<&2, F32>> -> @+n:Nat -> @+i:Nat -> @acc:List<&2, F32> -> List<&2, F32>

def extract_x source · line 349 · raw

@+mat:List<&2, List<&2, F32>> -> @+n:Nat -> List<&2, F32>

def solve_linear.go source · line 352 · raw

@done:Maybe<&2, List<&2, List<&2, F32>>> -> @+n:Nat -> Maybe<&2, List<&2, F32>>

def build_aug source · line 359 · raw

@+ideal:List<&2, F32> -> @ext:List<&2, List<&2, F32>> -> List<&2, List<&2, F32>>

def solve_linear source · line 366 · raw

@+ext:List<&2, List<&2, F32>> -> @+ideal:List<&2, F32> -> @+n:Nat -> Maybe<&2, List<&2, F32>>

def intercept_bad source · line 369 · raw

@+inv:F32 -> Bool

def inv_ok.fin source · line 375 · raw

@+inv:F32 -> @bad:Bool -> Maybe<&2, F32>

def inv_ok.pos source · line 382 · raw

@+xj:F32 -> @tiny:Bool -> Maybe<&2, F32>

def inv_ok source · line 391 · raw

@+xj:F32 -> Maybe<&2, F32>

C#: |x| < 1e-12 or x < 0 fails; then intercept = 1/x must be finite and > 1e-6.

def intercepts_from_x.one source · line 394 · raw

@h:Maybe<&2, F32> -> @ys:List<&2, F32> -> Maybe<&2, List<&2, F32>>

def intercepts_from_x.cons source · line 401 · raw

@+xj:F32 -> @rest:Maybe<&2, List<&2, F32>> -> Maybe<&2, List<&2, F32>>

def intercepts_from_x source · line 408 · raw

@x:List<&2, F32> -> Maybe<&2, List<&2, F32>>

def try_intercepts.go source · line 415 · raw

@x:Maybe<&2, List<&2, F32>> -> Maybe<&2, List<&2, F32>>

def try_intercepts source · line 422 · raw

@+ext:List<&2, List<&2, F32>> -> @+ideal:List<&2, F32> -> Maybe<&2, List<&2, F32>>

def add_ideal source · line 425 · raw

@ideal:List<&2, F32> -> @icepts:List<&2, F32> -> List<&2, F32>

def clamp_worst source · line 434 · raw

@nadir:List<&2, F32> -> @worst:List<&2, F32> -> List<&2, F32>

def nadir_from_maybe source · line 443 · raw

@m:Maybe<&2, List<&2, F32>> -> @+ideal:List<&2, F32> -> @+worst:List<&2, F32> -> @+front:List<&2, F32> -> List<&2, F32>

def fallback_pop source · line 450 · raw

@nadir:List<&2, F32> -> @ideal:List<&2, F32> -> @wpop:List<&2, F32> -> List<&2, F32>

def fallback_unit source · line 461 · raw

@nadir:List<&2, F32> -> @ideal:List<&2, F32> -> List<&2, F32>

def spans_or_one source · line 470 · raw

@nadir:List<&2, F32> -> @ideal:List<&2, F32> -> List<&2, F32>

def normalize_nd.body source · line 480 · raw

@+ideal0:List<&2, F32> -> @+worst0:List<&2, F32> -> @+ext0:List<&2, List<&2, F32>> -> @+pop:List<&2, 0x2bc7fb472c80bd6a0e04725c117edb2a/individual.Individual> -> @nd:List<&2, Nat> -> Pair(State, List<&2, List<&2, F32>>)

def normalize_nd.go source · line 495 · raw

@state:State -> @+pop:List<&2, 0x2bc7fb472c80bd6a0e04725c117edb2a/individual.Individual> -> @nd:List<&2, Nat> -> Pair(State, List<&2, List<&2, F32>>)

def has_infeas.on source · line 502 · raw

@later:Bool -> @feas:Bool -> Bool

A computed Bool is matched only as a parameter. The recursive result is an argument, so these walks are not mutually recursive.

def has_infeas source · line 509 · raw

@pop:List<&2, 0x2bc7fb472c80bd6a0e04725c117edb2a/individual.Individual> -> Bool

def has_feas.on source · line 516 · raw

@later:Bool -> @feas:Bool -> Bool

def has_feas source · line 523 · raw

@pop:List<&2, 0x2bc7fb472c80bd6a0e04725c117edb2a/individual.Individual> -> Bool

def feas_inds.on source · line 530 · raw

@+h:0x2bc7fb472c80bd6a0e04725c117edb2a/individual.Individual -> @rest:List<&2, 0x2bc7fb472c80bd6a0e04725c117edb2a/individual.Individual> -> @ok:Bool -> List<&2, 0x2bc7fb472c80bd6a0e04725c117edb2a/individual.Individual>

def feas_inds source · line 537 · raw

@pop:List<&2, 0x2bc7fb472c80bd6a0e04725c117edb2a/individual.Individual> -> List<&2, 0x2bc7fb472c80bd6a0e04725c117edb2a/individual.Individual>

def feas_idx.on source · line 544 · raw

@+i:Nat -> @rest:List<&2, Nat> -> @ok:Bool -> List<&2, Nat>

def feas_idx.go source · line 551 · raw

@pop:List<&2, 0x2bc7fb472c80bd6a0e04725c117edb2a/individual.Individual> -> @+i:Nat -> List<&2, Nat>

def feas_idx source · line 558 · raw

@pop:List<&2, 0x2bc7fb472c80bd6a0e04725c117edb2a/individual.Individual> -> List<&2, Nat>

def keep_in.go source · line 561 · raw

@idxs:List<&2, Nat> -> @+pool:List<&2, Nat> -> List<&2, Nat>

def keep_in source · line 568 · raw

@idxs:List<&2, Nat> -> @+pool:List<&2, Nat> -> List<&2, Nat>

def nd_mixed.use source · line 571 · raw

@pool:List<&2, Nat> -> @kept:List<&2, Nat> -> List<&2, Nat>

def nd_mixed.go source · line 580 · raw

@nd:List<&2, Nat> -> @+pool:List<&2, Nat> -> List<&2, Nat>

ND indices restricted to feasible members. Empty or fully infeasible fronts fall back to every feasible index (C# ExtremeIndices).

def nd_mixed source · line 587 · raw

@pop:List<&2, 0x2bc7fb472c80bd6a0e04725c117edb2a/individual.Individual> -> @nd:List<&2, Nat> -> List<&2, Nat>

def project_fixed.back source · line 592 · raw

@n:Nat -> @+ideal:List<&2, F32> -> @worst:List<&2, F32> -> @+nadir:List<&2, F32> -> @intercepts:List<&2, F32> -> @extremes:List<&2, List<&2, F32>> -> @+pop:List<&2, 0x2bc7fb472c80bd6a0e04725c117edb2a/individual.Individual> -> @open:Bool -> Pair(State, List<&2, List<&2, F32>>)

All-infeasible: do not write ideal / nadir. A fresh state projects with this generation's min/max only. A persisted state reuses its hyperplane.

def project_fixed.ideal source · line 599 · raw

@n:Nat -> @ideal:List<&2, F32> -> @worst:List<&2, F32> -> @nadir:List<&2, F32> -> @intercepts:List<&2, F32> -> @extremes:List<&2, List<&2, F32>> -> @+pop:List<&2, 0x2bc7fb472c80bd6a0e04725c117edb2a/individual.Individual> -> Pair(State, List<&2, List<&2, F32>>)

def project_fixed source · line 606 · raw

@state:State -> @+pop:List<&2, 0x2bc7fb472c80bd6a0e04725c117edb2a/individual.Individual> -> Pair(State, List<&2, List<&2, F32>>)

def normalize_mixed source · line 613 · raw

@state:State -> @+pop:List<&2, 0x2bc7fb472c80bd6a0e04725c117edb2a/individual.Individual> -> @nd:List<&2, Nat> -> Pair(State, List<&2, List<&2, F32>>)

Stats (ideal, worst, extremes, nadir) use the feasible subset. Every member, including infeasible, is translated by that hyperplane.

def normalize_nd.bad source · line 631 · raw

@state:State -> @+pop:List<&2, 0x2bc7fb472c80bd6a0e04725c117edb2a/individual.Individual> -> @nd:List<&2, Nat> -> @feas:Bool -> Pair(State, List<&2, List<&2, F32>>)

def normalize_nd.pick source · line 638 · raw

@state:State -> @+pop:List<&2, 0x2bc7fb472c80bd6a0e04725c117edb2a/individual.Individual> -> @nd:List<&2, Nat> -> @bad:Bool -> Pair(State, List<&2, List<&2, F32>>)

def normalize_nd source · line 647 · raw

@state:State -> @+pop:List<&2, 0x2bc7fb472c80bd6a0e04725c117edb2a/individual.Individual> -> @nd:List<&2, Nat> -> Pair(State, List<&2, List<&2, F32>>)

Public normalize stays the all-member hyperplane. Laws.normalize_len unfolds this function. Constrained Run uses normalize_nd_cv.

def normalize_nd_cv source · line 656 · raw

@state:State -> @+pop:List<&2, 0x2bc7fb472c80bd6a0e04725c117edb2a/individual.Individual> -> @nd:List<&2, Nat> -> Pair(State, List<&2, List<&2, F32>>)

Feasible-only ideal / nadir when any member is infeasible. All-feasible and empty pools are normalize_nd.

def normalize source · line 663 · raw

@state:State -> @pop:List<&2, 0x2bc7fb472c80bd6a0e04725c117edb2a/individual.Individual> -> Pair(State, List<&2, List<&2, F32>>)

def normalize_vecs.snd source · line 666 · raw

@pair:Pair(State, List<&2, List<&2, F32>>) -> List<&2, List<&2, F32>>

def normalize_vecs source · line 670 · raw

@+xs:List<&2, 0x2bc7fb472c80bd6a0e04725c117edb2a/individual.Individual> -> List<&2, List<&2, F32>>