~/bend-docscommunity

polynomial_mutation.bend checks

raw source on the hub · import 0xd1de66b5d9157913a654c39186289f3d/polynomial_mutation.bend as Polynomial_mutation

Polynomial mutation — C# Unsga3.Operators.Mutation.PolynomialMutation. Default η = 20. Probability per variable is an argument (C# Run uses 1/n). Walks the decision vector and box intervals together (no List.get / set_var_at per index). Same RNG order as the old indexed loop.

5 imports
import Base
import ./individual.bend as Ind
import ./bounds.bend as Bounds
import ./rng.bend as Rng
import ./util.bend as Util

Types

type Poly source · line 12 · raw

Data

Definitions

def mk source · line 17 · raw

@+e:F32 -> Poly

def default source · line 20 · raw

Poly

def eta source · line 23 · raw

@op:Poly -> F32

def typical_probability source · line 29 · raw

@n_var:Nat -> F32

C# Unsga3Algorithm: mutationProbability ?? (1.0 / nVars) at the call site.

def result source · line 36 · raw

@pair:Pair(0xd1de66b5d9157913a654c39186289f3d/rng.State, 0xd1de66b5d9157913a654c39186289f3d/individual.Individual) -> 0xd1de66b5d9157913a654c39186289f3d/individual.Individual

def deltaq.lo source · line 40 · raw

@+eta:F32 -> @+mut_pow:F32 -> @+delta1:F32 -> @+rand:F32 -> F32

def deltaq.hi source · line 48 · raw

@+eta:F32 -> @+mut_pow:F32 -> @+delta2:F32 -> @+rand:F32 -> F32

def deltaq.pick source · line 56 · raw

@+eta:F32 -> @+mut_pow:F32 -> @+delta1:F32 -> @+delta2:F32 -> @+rand:F32 -> @lo_side:Bool -> F32

def deltaq source · line 63 · raw

@+eta:F32 -> @+mut_pow:F32 -> @+delta1:F32 -> @+delta2:F32 -> @+rand:F32 -> F32

def tiny_head source · line 66 · raw

@ivs:List<&2, 0xd1de66b5d9157913a654c39186289f3d/bounds.Interval> -> Bool

def advance source · line 73 · raw

@rng:0xd1de66b5d9157913a654c39186289f3d/rng.State -> @rest:Nat -> 0xd1de66b5d9157913a654c39186289f3d/rng.State

def skip_kind source · line 80 · raw

@skip:Bool -> @tiny:Bool -> Nat

def finish source · line 91 · raw

@+m:Nat -> @pair:Pair(0xd1de66b5d9157913a654c39186289f3d/rng.State, List<&2, F32>) -> Pair(0xd1de66b5d9157913a654c39186289f3d/rng.State, 0xd1de66b5d9157913a654c39186289f3d/individual.Individual)

def done source · line 95 · raw

@rng:0xd1de66b5d9157913a654c39186289f3d/rng.State -> @acc:List<&2, F32> -> Pair(0xd1de66b5d9157913a654c39186289f3d/rng.State, List<&2, F32>)

def loop.go source · line 99 · raw

@fuel:Nat -> @kind:Nat -> @xs:List<&2, F32> -> @ivs:List<&2, 0xd1de66b5d9157913a654c39186289f3d/bounds.Interval> -> @+eta:F32 -> @rng:0xd1de66b5d9157913a654c39186289f3d/rng.State -> @acc:List<&2, F32> -> @+p:F32 -> Pair(0xd1de66b5d9157913a654c39186289f3d/rng.State, List<&2, F32>)

Kind: 0n = copy the head (skip or tiny span), 1n = mutate the head.

def start source · line 139 · raw

@+eta:F32 -> @+box:0xd1de66b5d9157913a654c39186289f3d/bounds.Box -> @rng:0xd1de66b5d9157913a654c39186289f3d/rng.State -> @+ind:0xd1de66b5d9157913a654c39186289f3d/individual.Individual -> @+p:F32 -> @n:Nat -> Pair(0xd1de66b5d9157913a654c39186289f3d/rng.State, 0xd1de66b5d9157913a654c39186289f3d/individual.Individual)

def start_or_copy source · line 165 · raw

@+eta:F32 -> @+box:0xd1de66b5d9157913a654c39186289f3d/bounds.Box -> @rng:0xd1de66b5d9157913a654c39186289f3d/rng.State -> @ind:0xd1de66b5d9157913a654c39186289f3d/individual.Individual -> @+p:F32 -> @n:Nat -> @zero:Bool -> Pair(0xd1de66b5d9157913a654c39186289f3d/rng.State, 0xd1de66b5d9157913a654c39186289f3d/individual.Individual)

p=0 leaves the decision vector unchanged before any NextDouble. Matches C# when per-variable probability is 0 (every draw is > 0).

def mutate source · line 180 · raw

@+op:Poly -> @+ind:0xd1de66b5d9157913a654c39186289f3d/individual.Individual -> @+box:0xd1de66b5d9157913a654c39186289f3d/bounds.Box -> @rng:0xd1de66b5d9157913a654c39186289f3d/rng.State -> @+p:F32 -> Pair(0xd1de66b5d9157913a654c39186289f3d/rng.State, 0xd1de66b5d9157913a654c39186289f3d/individual.Individual)