~/bend-docscommunity

problems.bend checks

raw source on the hub · import 0x2bc7fb472c80bd6a0e04725c117edb2a/problems.bend as Problems

Named problems — C# Unsga3.Problems. ZDT1 / ZDT2 / DTLZ2 stay the oracle problems. The rest of the unconstrained catalog (ZDT3 / ZDT4 / ZDT6, DTLZ1 / DTLZ3 / DTLZ4 / DTLZ7, Sphere / Ackley / Rosenbrock) matches the same C# Evaluate formulas. Minimize. OSY / TNK / C1-DTLZ1 match ConstrainedProblems.cs (g ≤ 0, positive = violation). Unconstrained kinds write an empty constraint vector (cv 0). No IGD here. alpha is DTLZ4's exponent (C# default 100). Other kinds ignore it.

4 imports
import Base
import ./individual.bend as Ind
import ./bounds.bend as Bounds
import ./util.bend as Util

Types

type Family source · line 14 · raw

Data

type Problem source · line 32 · raw

Data

type Acc2 source · line 456 · raw

Data

type Scored source · line 513 · raw

Data

Objectives plus g ≤ 0. Unconstrained kinds leave g empty.

Definitions

def box_of source · line 39 · raw

@p:Problem -> 0x2bc7fb472c80bd6a0e04725c117edb2a/bounds.Box

def kind_of source · line 44 · raw

@p:Problem -> Family

def alpha_of source · line 49 · raw

@p:Problem -> F32

def n_obj source · line 54 · raw

@p:Problem -> Nat

def n_var source · line 57 · raw

@p:Problem -> Nat

def mk_prob source · line 60 · raw

@kind:Family -> @box:0x2bc7fb472c80bd6a0e04725c117edb2a/bounds.Box -> Problem

def zdt1 source · line 64 · raw

@n:Nat -> Problem

ZDT1 / ZDT2 / ZDT3: n variables (C# default 30), 2 objectives, x ∈ [0,1]^n.

def zdt2 source · line 67 · raw

@n:Nat -> Problem

def zdt3 source · line 70 · raw

@n:Nat -> Problem

def zdt4_ivs source · line 74 · raw

@n:Nat -> List<&2, 0x2bc7fb472c80bd6a0e04725c117edb2a/bounds.Interval>

ZDT4: C# default n=10. x0 ∈ [0,1], x1.. ∈ [-5,5].

def zdt4 source · line 81 · raw

@n:Nat -> Problem

def zdt6 source · line 85 · raw

@n:Nat -> Problem

ZDT6: C# default n=10, x ∈ [0,1]^n.

def dtlz_n source · line 89 · raw

@m:Nat -> @k:Nat -> Nat

n = M + k - 1 (C# Dtlz*Problem).

def dtlz2 source · line 101 · raw

@+m:Nat -> @k:Nat -> Problem

DTLZ2: C# default M=3, k=10 ⇒ n=12, x ∈ [0,1]^n.

def dtlz1 source · line 105 · raw

@+m:Nat -> @k:Nat -> Problem

DTLZ1: C# default M=3, k=5 ⇒ n=7.

def dtlz3 source · line 109 · raw

@+m:Nat -> @k:Nat -> Problem

DTLZ3: C# default M=3, k=10. DTLZ2 map, DTLZ1 g.

def dtlz4_alpha source · line 113 · raw

@+m:Nat -> @k:Nat -> @+alpha:F32 -> Problem

DTLZ4: C# default α=100, k=10.

def dtlz4 source · line 116 · raw

@+m:Nat -> @k:Nat -> Problem

def dtlz7 source · line 120 · raw

@+m:Nat -> @k:Nat -> Problem

DTLZ7: C# default M=3, k=20 ⇒ n=22.

def sphere source · line 124 · raw

@n:Nat -> Problem

Single-objective. M=1. C# defaults: Sphere n=10, Ackley n=30, Rosenbrock n=10.

def ackley source · line 127 · raw

@n:Nat -> Problem

def rosenbrock source · line 130 · raw

@n:Nat -> Problem

def osy source · line 134 · raw

Problem

OSY: 6 variables, 2 objectives, 6 inequalities. pymoo 0.6 scaling.

def tnk source · line 149 · raw

Problem

TNK: [0, π] × [1e-30, π]. Disk constraint uses pymoo's factor of two.

def c1_dtlz1 source · line 156 · raw

@+m:Nat -> @k:Nat -> Problem

C1-DTLZ1: DTLZ1 plus one inequality. C# default M=3, k=5 (n = M+k-1).

def sum_from source · line 159 · raw

@xs:List<&2, F32> -> F32

def sum_tail source · line 166 · raw

@xs:List<&2, F32> -> F32

def list_tail source · line 173 · raw

@xs:List<&2, F32> -> List<&2, F32>

def zdt_den source · line 180 · raw

@n:Nat -> F32

def zdt_g source · line 190 · raw

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

C# Zdt1Problem.GLinear: 1 + 9 * sum(x[1..]) / (n - 1).

def zdt1_f source · line 194 · raw

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

def zdt2_f source · line 199 · raw

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

def zdt3_f source · line 206 · raw

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

C# Zdt3Problem: g * (1 - sqrt(r) - r * sin(10 π x0)), r = x0/g.

def zdt4_term source · line 213 · raw

@+xi:F32 -> F32

def sum_zdt4 source · line 216 · raw

@xs:List<&2, F32> -> F32

def pred source · line 223 · raw

@n:Nat -> Nat

def zdt4_g source · line 231 · raw

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

C# Zdt4Problem: 1 + 10*(n-1) + Σ_{i≥1} (x_i² - 10 cos(4 π x_i)).

def zdt4_f source · line 235 · raw

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

def zdt6_f source · line 241 · raw

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

C# Zdt6Problem: biased density. g = 1 + 9 * (mean of x[1..])^0.25.

def sum_sq_half source · line 250 · raw

@xs:List<&2, F32> -> F32

def tail_from_m source · line 257 · raw

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

def dtlz2_g source · line 261 · raw

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

C# DtlzHelper.GDtlz2: sum (x[i] - 0.5)^2 for i >= M-1.

def dtlz1_term source · line 264 · raw

@+xi:F32 -> F32

def sum_dtlz1 source · line 268 · raw

@xs:List<&2, F32> -> F32

def dtlz1_g source · line 277 · raw

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

C# DtlzHelper.GDtlz1: 100 * ((n - M + 1) + Σ (d² - cos(20 π d))), d = x-0.5. On a legal k≥1 box the tail length is n-M+1, which is that coefficient.

def half_pi source · line 281 · raw

F32

def prod_cos.go source · line 284 · raw

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

def prod_cos source · line 296 · raw

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

def dtlz2_sin source · line 299 · raw

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

def dtlz2_fi.tail source · line 302 · raw

@+x:List<&2, F32> -> @+m:Nat -> @+g:F32 -> @+i:Nat -> @+body:F32 -> @first:Bool -> F32

def dtlz2_fi source · line 310 · raw

@+x:List<&2, F32> -> @+m:Nat -> @+g:F32 -> @+i:Nat -> F32

C# Dtlz2Problem: (1+g) * prod_{j<M-i-1} cos(x[j] π/2) [* sin(x[M-i-1] π/2) if i>0].

def dtlz2_fs.go source · line 320 · raw

@+x:List<&2, F32> -> @+m:Nat -> @+g:F32 -> @fuel:Nat -> @+i:Nat -> List<&2, F32>

def dtlz2_f source · line 327 · raw

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

def prod_xs.go source · line 330 · raw

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

def prod_xs source · line 337 · raw

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

def dtlz1_scale source · line 340 · raw

@+body:F32 -> @+x:List<&2, F32> -> @+idx:Nat -> @first:Bool -> F32

def dtlz1_fi source · line 348 · raw

@+x:List<&2, F32> -> @+m:Nat -> @+g:F32 -> @+i:Nat -> F32

C# Dtlz1Problem: 0.5*(1+g) * prod_{j<M-i-1} x[j] [* (1-x[M-i-1]) if i>0].

def dtlz1_fs.go source · line 352 · raw

@+x:List<&2, F32> -> @+m:Nat -> @+g:F32 -> @fuel:Nat -> @+i:Nat -> List<&2, F32>

def dtlz1_f source · line 359 · raw

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

def nn_obj source · line 369 · raw

@+v:F32 -> F32

F32 cos(π/2) is -4.371139e-8, not 0. The DTLZ2 map multiplies that factor by (1+g). DTLZ3's g stays large on local fronts, so an in-bound x=1 (SBX / polynomial mutation clamp to the box) gets a strictly negative objective. Every feasible point has f≥0, so nothing dominates that row. It stays on the ND front and pins an ASF extreme at (1+g). DTLZ2's (1+g) is ~1, so the same raw trig is left alone (published fronts). Clamp only this map back to the mathematical range f≥0.

def nn_objs source · line 372 · raw

@xs:List<&2, F32> -> List<&2, F32>

def dtlz3_f source · line 380 · raw

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

C# Dtlz3Problem: DTLZ2 map with DTLZ1's g.

def map_prefix_pow.go source · line 384 · raw

@fuel:Nat -> @xs:List<&2, F32> -> @+alpha:F32 -> List<&2, F32>

Fuel shrinks first so the recursive call terminates. The g-tail stays raw.

def map_prefix_pow source · line 396 · raw

@+xs:List<&2, F32> -> @fuel:Nat -> @+alpha:F32 -> List<&2, F32>

Raise the first fuel decision variables to α.

def dtlz4_f source · line 400 · raw

@+x:List<&2, F32> -> @+m:Nat -> @+alpha:F32 -> List<&2, F32>

C# Dtlz4Problem: DTLZ2 with x^α inside the sine/cosine map. g is still GDtlz2.

def pos_or.fin source · line 403 · raw

@+x:F32 -> @+fallback:F32 -> @ok:Bool -> F32

def pos_or source · line 410 · raw

@+x:F32 -> @+fallback:F32 -> F32

def dtlz7_g source · line 414 · raw

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

C# Dtlz7Problem g: 1 + 9 * sum(x[M-1..]) / (n - M + 1).

def dtlz7_h.go source · line 419 · raw

@+x:List<&2, F32> -> @+g1:F32 -> @fuel:Nat -> @+i:Nat -> @acc:F32 -> F32

def dtlz7_prefix source · line 428 · raw

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

def dtlz7_f source · line 436 · raw

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

f[i]=x[i] for i<M-1; f[M-1]=(1+g)*h; h = M - Σ f_i/(1+g) * (1+sin(3 π f_i)).

def sum_sq source · line 446 · raw

@xs:List<&2, F32> -> F32

def sphere_f source · line 453 · raw

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

def ackley_go source · line 462 · raw

@xs:List<&2, F32> -> @+s1:F32 -> @+s2:F32 -> Acc2

def ackley_den source · line 473 · raw

@n:Nat -> F32

def ackley_from source · line 480 · raw

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

def ackley_f source · line 493 · raw

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

C# AckleyProblem. n=0 stays total (denominator 1) instead of dividing by zero.

def rosen_step source · line 496 · raw

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

def rosenbrock_f source · line 505 · raw

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

def plain source · line 519 · raw

@+f:List<&2, F32> -> Scored

def scored_f source · line 522 · raw

@s:Scored -> List<&2, F32>

def scored_g source · line 527 · raw

@s:Scored -> List<&2, F32>

def osy_f source · line 533 · raw

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

C# OsyProblem. f0 negates the weighted squares (x5 is not in f0).

def osy_g source · line 552 · raw

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

pymoo divisors, then negated so a positive value is a violation.

def osy_score source · line 566 · raw

@+x:List<&2, F32> -> Scored

def tnk_g source · line 570 · raw

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

C# TnkProblem. g0 = -(x²+y²-1-0.1 cos(16 atan(x/y))). g1 = 2((x-0.5)²+(y-0.5)²)-1.

def tnk_score source · line 581 · raw

@+x:List<&2, F32> -> Scored

def c1_w source · line 585 · raw

@fuel:Nat -> @fs:List<&2, F32> -> @+acc:F32 -> F32

Last objective / 0.6, earlier objectives / 0.5. fuel starts at |f|.

def c1_g source · line 602 · raw

@+fs:List<&2, F32> -> List<&2, F32>

def c1_score source · line 605 · raw

@+x:List<&2, F32> -> @+m:Nat -> Scored

def eval_kind source · line 609 · raw

@kind:Family -> @+x:List<&2, F32> -> @+m:Nat -> @+alpha:F32 -> Scored

def apply_score source · line 644 · raw

@+ind:0x2bc7fb472c80bd6a0e04725c117edb2a/individual.Individual -> @s:Scored -> 0x2bc7fb472c80bd6a0e04725c117edb2a/individual.Individual

def evaluate source · line 649 · raw

@+p:Problem -> @+ind:0x2bc7fb472c80bd6a0e04725c117edb2a/individual.Individual -> 0x2bc7fb472c80bd6a0e04725c117edb2a/individual.Individual

def evaluate_all source · line 653 · raw

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

Independent per individual. Mid-split + parallel recurse; same order as cons.