PolynomialMutation.loop.go: def of unified-nsga-iii@0.2.2.0 Import: import unified-nsga-iii@0.2.2.0/polynomial_mutation.bend as PolynomialMutation Lines 98-137 of unified-nsga-iii@0.2.2.0/polynomial_mutation.bend: https://jend.leeeet.dev/read.txt?path=unified-nsga-iii@0.2.2.0/polynomial_mutation.bend&start_line=98&end_line=137 import Base import unified-nsga-iii@0.2.2.0/bounds.bend as Bounds import unified-nsga-iii@0.2.2.0/rng.bend as Rng # Kind: 0n = copy the head (skip or tiny span), 1n = mutate the head. def loop.go( fuel: Nat, kind: Nat, xs: List<&2, F32>, ivs: List<&2, Bounds.Interval>, +eta: F32, rng: Rng.State, acc: List<&2, F32>, +p: F32 ) -> Rng.State & List<&2, F32>: match fuel kind xs ivs: case 0n k a b: done(rng, acc) case 1n++f 0n +x <> rest +iv <> +ivrest: +rng2 = advance(rng, f) loop.go( f, skip_kind(F32.is_gt(Rng.last_double(rng2), p), tiny_head(ivrest)), rest, ivrest, eta, rng2, x <> acc, p ) case 1n++f 1n+q +x <> rest +iv <> +ivrest: +lo = Bounds.lo(iv) +hi = Bounds.hi(iv) +dmax = F32.sub(hi, lo) +rng_a = Rng.next_double(rng) +rand = Rng.last_double(rng_a) +mut_pow = F32.div(1.0, F32.add(eta, 1.0)) +dq = deltaq(eta, mut_pow, F32.div(F32.sub(x, lo), dmax), F32.div(F32.sub(hi, x), dmax), rand) +y = F32.clamp(F32.add(x, F32.mul(dq, dmax)), lo, hi) +rng_b = advance(rng_a, f) loop.go( f, skip_kind(F32.is_gt(Rng.last_double(rng_b), p), tiny_head(ivrest)), rest, ivrest, eta, rng_b, y <> acc, p ) case 1n++f k Nil{} b: done(rng, acc) case 1n++f k a <> as Nil{}: done(rng, acc) Uses (21): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=F32 https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=F32.add https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=F32.clamp https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=F32.div https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=F32.is_gt https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=F32.mul https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=F32.sub https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=List https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Pair https://jend.leeeet.dev/definition.txt?path=unified-nsga-iii@0.2.2.0/bounds.bend&name=Interval https://jend.leeeet.dev/definition.txt?path=unified-nsga-iii@0.2.2.0/bounds.bend&name=hi https://jend.leeeet.dev/definition.txt?path=unified-nsga-iii@0.2.2.0/bounds.bend&name=lo https://jend.leeeet.dev/definition.txt?path=unified-nsga-iii@0.2.2.0/polynomial_mutation.bend&name=advance https://jend.leeeet.dev/definition.txt?path=unified-nsga-iii@0.2.2.0/polynomial_mutation.bend&name=deltaq https://jend.leeeet.dev/definition.txt?path=unified-nsga-iii@0.2.2.0/polynomial_mutation.bend&name=done https://jend.leeeet.dev/definition.txt?path=unified-nsga-iii@0.2.2.0/polynomial_mutation.bend&name=skip_kind https://jend.leeeet.dev/definition.txt?path=unified-nsga-iii@0.2.2.0/polynomial_mutation.bend&name=tiny_head https://jend.leeeet.dev/definition.txt?path=unified-nsga-iii@0.2.2.0/rng.bend&name=State https://jend.leeeet.dev/definition.txt?path=unified-nsga-iii@0.2.2.0/rng.bend&name=last_double https://jend.leeeet.dev/definition.txt?path=unified-nsga-iii@0.2.2.0/rng.bend&name=next_double