def crossover
unified-nsga-iii@0.2.2.0 · sbx.bend:234
import unified-nsga-iii@0.2.2.0/sbx.bend as Sbx
import Base
import unified-nsga-iii@0.2.2.0/individual.bend as Ind
import unified-nsga-iii@0.2.2.0/bounds.bend as Bounds
import unified-nsga-iii@0.2.2.0/rng.bend as Rng
import unified-nsga-iii@0.2.2.0/util.bend as Util
234def crossover(
235 +op: Sbx,
236 +p1: Ind.Individual,
237 +p2: Ind.Individual,
238 +box: Bounds.Box,
239 rng: Rng.State
240) -> Rng.State & Ind.Individual & Ind.Individual:
241 +x1s = Ind.variables(p1)
242 +x2s = Ind.variables(p2)
243 +m = Bounds.n_obj(box)
244 +prob = probability(op)
245 draw_or_copy(
246 eta(op),
247 prob,
248 x1s,
249 x2s,
250 box,
251 rng,
252 m,
253 Bounds.n_var(box),
254 Util.f32_is_zero(prob)
255 )