reference_directions.bend relies on unsafe/foreign
raw source on the hub · import 0xa2f9d6ef8c474468bf1de15ebe70c512/reference_directions.bend as Reference_directions
ReferenceDirections — C# Unsga3.Utilities.ReferenceDirections. Das–Dennis structured points on the unit simplex. Count = C(p + M - 1, M - 1); M == 1n → 1n. Points match C# recurse order (first coordinate increases 0..p, DFS).
count and das_dennis disagree at partitions == 0 when M > 1. count(2, 0) = C(1, 1) = 1. das_dennis(2, 0) is Nil{} (length 0). C# throws if partitions < 1. Law das_dennis_len quantifies p+1 and its comment in LAWS.bend records that split. Oracles use p >= 4. Do not treat count and the generator as the same function.
2 imports
import Base import ./util.bend as Util
Types
type DasCtx source · line 55 · raw
Data
k-th composition of p into m parts, C# DFS order (first coord
increases 0..p). Enumerating range(Count) makes |DasDennis| = Count
by construction. @unsafe: Bool dispatch on k < count(rest) then
either shrinks M or advances i; fuel is a bound, not the shrink key.
DasCtx@m:Nat -> @p:Nat -> DasCtx
Definitions
def binomial source · line 15 · raw
@+n:Nat -> @+k:Nat -> Nat
def count.succ source · line 18 · raw
@+rest:Nat -> @+partitions:Nat -> @z:Bool -> Nat
def count.go source · line 25 · raw
@+rest:Nat -> @+partitions:Nat -> Nat
def count source · line 30 · raw
@number_of_objectives:Nat -> @partitions:Nat -> Nat
Number of Das–Dennis points. M == 0n is a guard (0). M == 1n → 1. M == 1n+rest → if rest == 0 then 1 else C(p + rest, rest) = C(p + M - 1, M - 1).
def to_dir source · line 37 · raw
@+p:Nat -> @comps:List<&2, Nat> -> List<&2, F32>
def to_dirs source · line 44 · raw
@+p:Nat -> @rows:List<&2, List<&2, Nat>> -> List<&2, List<&2, F32>>
def nth_comp.fallback source · line 61 · raw
@m:Nat -> @p:Nat -> List<&2, Nat>
def nth_comp source · line 99 · raw
@+m:Nat -> @+p:Nat -> @+k:Nat -> List<&2, Nat>
def nth_row source · line 102 · raw
@+ctx:DasCtx -> @+k:Nat -> List<&2, Nat>
def comps_all source · line 107 · raw
@+m:Nat -> @+p:Nat -> List<&2, List<&2, Nat>>
def das_dennis.from source · line 110 · raw
@+m:Nat -> @+p:Nat -> @rest:Nat -> List<&2, List<&2, F32>>
def das_dennis.p0 source · line 117 · raw
@rest:Nat -> List<&2, List<&2, F32>>
def das_dennis source · line 125 · raw
@number_of_objectives:Nat -> @partitions:Nat -> List<&2, List<&2, F32>>
Generate directions. M == 1n → [[1.0]]. M == 0n → Nil{}. p == 0n → Nil{} when M > 1.
Unsafe
unsafe nth_comp.go source · line 70 · raw
@ready:Bool -> @take:Bool -> @fuel:Nat -> @+m:Nat -> @+p:Nat -> @+k:Nat -> @+i:Nat -> @left:Nat -> @c:Nat -> List<&2, Nat>