def associate_raw.go
unified-nsga-iii@0.2.2.0 · survival.bend:271
import unified-nsga-iii@0.2.2.0/survival.bend as Survival
import Base
import unified-nsga-iii@0.2.2.0/individual.bend as Ind
import unified-nsga-iii@0.2.2.0/util.bend as Util
271
272def associate_raw.go(
273 +dirs: List<&2, List<&2, F32>>,
274 +fuel: Nat,
275 pop: List<&2, Ind.Individual>,
276 +F: List<&2, List<&2, F32>>
277) -> List<&2, Assignment>:
278 match fuel pop:
279 case 0n Nil{}:
280 Nil{}
281 case 0n ind <> rest:
282 match F:
283 case Nil{}:
284 nearest_one(Ind.objectives(ind), dirs) <> associate_raw.go(dirs, 0n, rest, Nil{})
285 case f <> fs:
286 nearest_one(f, dirs) <> associate_raw.go(dirs, 0n, rest, fs)
287 case 1n+p Nil{}:
288 Nil{}
289 case 1n+p ind <> Nil{}:
290 associate_head(dirs, ind, F) <> Nil{}
291 case 1n+p h <> t:
292 +all = {h <> t : List<&2, Ind.Individual>}
293 +mid = Nat.div(Util.list_len(Ind.Individual, all), 2n)
294 lo hi = associate_raw.go(dirs, p, List.take(&2, Ind.Individual, all, mid), List.take(&2, List<&2, F32>, F, mid)) associate_raw.go(dirs, p, List.drop(&2, Ind.Individual, all, mid), List.drop(&2, List<&2, F32>, F, mid))
295 List.append(&2, Assignment, lo, hi)