@mark1russell7/layout-contract 0.2.10 → 0.2.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -0
- package/build/index.d.ts +163 -1
- package/build/index.d.ts.map +1 -1
- package/build/index.js +347 -5
- package/build/index.js.map +1 -1
- package/package.json +1 -1
- package/src/corpus.ts +144 -4
- package/src/index.ts +1 -0
- package/src/verdict.ts +342 -0
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["isObject"],"sources":["../src/geometry.ts","../src/tolerance.ts","../src/input.ts","../src/turn.ts","../src/output.ts","../src/record.ts","../src/rules.ts","../src/measures.ts","../src/utf8.ts","../src/random.ts","../src/edges.ts","../src/hash.ts","../src/portfolio.ts","../src/corpus.ts","../src/strategy-space.ts"],"sourcesContent":["/** A side of a box. The y axis points down, so `top` has the smallest y. */\nexport type Side = \"top\" | \"right\" | \"bottom\" | \"left\";\n\n/** The sides in clockwise order, from the top. */\nexport const SIDES: readonly Side[] = [\"top\", \"right\", \"bottom\", \"left\"];\n\nexport interface Point {\n readonly x: number;\n readonly y: number;\n}\n\n/** A rectangle: its top-left corner and its size. */\nexport interface Rect {\n readonly x: number;\n readonly y: number;\n readonly w: number;\n readonly h: number;\n}\n\n/** A value for each side of a box. */\nexport interface Sides {\n readonly top: number;\n readonly right: number;\n readonly bottom: number;\n readonly left: number;\n}\n\n/**\n * A region. The forms and the rules are those of `docs/FORMAT.md` of `packing`.\n * A ring of a polygon closes without a copy of its first point.\n */\nexport type Region =\n | { readonly kind: \"rect\"; readonly x: number; readonly y: number; readonly w: number; readonly h: number }\n | {\n readonly kind: \"polygon\";\n readonly points: readonly (readonly [number, number])[];\n readonly holes?: readonly (readonly (readonly [number, number])[])[];\n }\n | { readonly kind: \"circle\"; readonly cx: number; readonly cy: number; readonly r: number }\n | { readonly kind: \"ellipse\"; readonly cx: number; readonly cy: number; readonly rx: number; readonly ry: number };\n\n/** A margin: one value for the four sides, or one value for each side. */\nexport type Margin = number | Sides;\n\n/** This function gives the value of each side of a margin. No margin gives 0 on each side. */\nexport function marginSides(margin: Margin | undefined): Sides {\n if (margin === undefined) return { top: 0, right: 0, bottom: 0, left: 0 };\n if (typeof margin === \"number\") return { top: margin, right: margin, bottom: margin, left: margin };\n return margin;\n}\n\n/** This function gives the rectangle made larger by the margin on each side. */\nexport function grow(rect: Rect, margin: Margin | undefined): Rect {\n const m = marginSides(margin);\n return { x: rect.x - m.left, y: rect.y - m.top, w: rect.w + m.left + m.right, h: rect.h + m.top + m.bottom };\n}\n\n/** This function gives the bounding box of a region. */\nexport function boundsOf(region: Region): Rect {\n switch (region.kind) {\n case \"rect\":\n return { x: region.x, y: region.y, w: region.w, h: region.h };\n case \"circle\":\n return { x: region.cx - region.r, y: region.cy - region.r, w: 2 * region.r, h: 2 * region.r };\n case \"ellipse\":\n return { x: region.cx - region.rx, y: region.cy - region.ry, w: 2 * region.rx, h: 2 * region.ry };\n case \"polygon\": {\n let x0 = Infinity;\n let y0 = Infinity;\n let x1 = -Infinity;\n let y1 = -Infinity;\n for (const [x, y] of region.points) {\n x0 = Math.min(x0, x);\n y0 = Math.min(y0, y);\n x1 = Math.max(x1, x);\n y1 = Math.max(y1, y);\n }\n return { x: x0, y: y0, w: x1 - x0, h: y1 - y0 };\n }\n }\n}\n\n/** This function gives the region moved by `dx` and `dy`. */\nexport function translate(region: Region, dx: number, dy: number): Region {\n switch (region.kind) {\n case \"rect\":\n return { ...region, x: region.x + dx, y: region.y + dy };\n case \"circle\":\n case \"ellipse\":\n return { ...region, cx: region.cx + dx, cy: region.cy + dy };\n case \"polygon\": {\n const move = (ring: readonly (readonly [number, number])[]): [number, number][] => ring.map(([x, y]) => [x + dx, y + dy]);\n return region.holes === undefined\n ? { kind: \"polygon\", points: move(region.points) }\n : { kind: \"polygon\", points: move(region.points), holes: region.holes.map(move) };\n }\n }\n}\n\n/**\n * This function gives the overlap of the insides of two rectangles on each axis.\n * A value of 0 or less on an axis is no overlap. Two rectangles with a common edge have an overlap of 0.\n */\nexport function overlapOf(a: Rect, b: Rect): { readonly x: number; readonly y: number } {\n return {\n x: Math.min(a.x + a.w, b.x + b.w) - Math.max(a.x, b.x),\n y: Math.min(a.y + a.h, b.y + b.h) - Math.max(a.y, b.y),\n };\n}\n","/** The epsilon for the float compares in an engine. */\nexport const EPS = 1e-6;\n\n/**\n * The count of grid steps in one unit of a written file. A file rounds each number `v` to `Math.round(v * RECORD_SCALE) / RECORD_SCALE`.\n * Use a multiplication by this value, not a division by `RECORD_EPS`. The two differ at some half steps.\n */\nexport const RECORD_SCALE = 1000;\n\n/**\n * The epsilon for the float compares on a written file. A file rounds each number to 3 decimals,\n * so a difference of two values can move by up to 0.001. It is `1 / RECORD_SCALE`.\n */\nexport const RECORD_EPS = 1e-3;\n\n/**\n * The tolerance of each hard rule, in layout units. A record writes the tolerance that its run used,\n * in its field `tolerance`, next to `hard`.\n */\nexport interface Tolerance {\n /** Two boxes with their margins break `no-overlap` when their insides overlap by more than this on each axis. */\n readonly overlap: number;\n /** A route breaks `no-pass-through` when a part longer than this is inside a box made this much smaller. */\n readonly through: number;\n}\n\n/**\n * The default tolerance of each rule. The packer is exact, so `overlap` is one unit of the rounding.\n * Routes are sampled curves that follow the margin line, so `through` is larger.\n */\nexport const DEFAULT_TOLERANCE: Tolerance = Object.freeze({ overlap: 0.001, through: 0.5 });\n","import type { Margin, Region, Side } from \"./geometry.ts\";\n\n/**\n * A port of a box: a place where edges go into the box.\n * With `x` and `y`, the port is fixed on the border of the box, relative to its top-left corner.\n * Without them, the router places the port on its `side`. Without a side, the router picks the side.\n */\nexport interface Port {\n readonly id: string;\n readonly side?: Side;\n readonly x?: number;\n readonly y?: number;\n}\n\n/** A box of an input. In the packer, its name is item. */\nexport interface LayoutBox {\n readonly id: string;\n readonly w: number;\n readonly h: number;\n /** The packer writes the position. The router reads it. */\n readonly x?: number;\n readonly y?: number;\n /** A locked box keeps `x` and `y`. The packer reads it as an obstacle. */\n readonly locked?: boolean;\n /** The reading order. Without it, the order of the array is the rank. */\n readonly rank?: number;\n readonly parent?: string;\n readonly group?: string;\n /** A region relative to the origin of the box. Without it, the box is the rectangle `w` by `h`. */\n readonly shape?: Region;\n readonly ports?: readonly Port[];\n /** A ring around the box. No other box enters it. Only a route from a port of the box enters it, at a right angle. */\n readonly margin?: Margin;\n /** The packer can turn the box by 90 degrees. The output has the turned box and ports. */\n readonly turnable?: boolean;\n /** The free data of the node. The grouping rule `keys` of `highways` reads `data.group`. */\n readonly data?: Readonly<Record<string, unknown>>;\n}\n\n/** The packer name of a box. It is the same type. */\nexport type Item = LayoutBox;\n\n/** An edge between two boxes, with optional ports. */\nexport interface LayoutEdge {\n readonly id: string;\n readonly source: string;\n readonly target: string;\n readonly sourcePort?: string;\n readonly targetPort?: string;\n readonly data?: Readonly<Record<string, unknown>>;\n}\n\n/** The container. `fixed` tells which sides of the size stay. */\nexport interface LayoutContainer {\n readonly w?: number;\n readonly h?: number;\n readonly fixed: \"size\" | \"width\" | \"height\" | \"none\";\n /** The target aspect: the width divided by the height. The default is 1. */\n readonly aspect?: number;\n /** The weight of the aspect error in the objective. 0 gives the least area. The default is 1. */\n readonly aspectWeight?: number;\n /** The shape. Without it, the container is the rectangle from 0, 0 to `w`, `h`. */\n readonly shape?: Region;\n /** The space between the border and the boxes with their margins. */\n readonly inset?: number;\n}\n\n/** An area that boxes and routes avoid. Without `move`, it stays. With `move`, the packer can move it for `cost` times the distance. */\nexport interface Obstacle {\n readonly id: string;\n readonly region: Region;\n readonly move?: { readonly cost: number };\n}\n\n/** The generator of an input. The same name, version, parameters and seed give the same file, byte for byte. */\nexport interface LayoutGenerator {\n readonly name: string;\n readonly version: number;\n readonly params: Readonly<Record<string, unknown>>;\n readonly seed: number;\n}\n\n/** The cell of an input in the taxonomy: one value for each dimension. The dimensions are in `docs/FORMAT.md` of `packing`. */\nexport interface LayoutCell {\n readonly containerSize?: \"fixed\" | \"freeHeight\" | \"freeWidth\" | \"freeAspect\" | \"freeArea\";\n readonly containerShape?: \"rect\" | \"convex\" | \"polygon\" | \"circle\" | \"ellipse\" | \"holes\";\n readonly obstacles?: \"none\" | \"center\" | \"scattered\" | \"wall\" | \"corridors\" | \"touching\" | \"edge\";\n readonly sizes?: \"identical\" | \"uniform\" | \"heavyTail\" | \"bimodal\" | \"extremeAspect\" | \"nearIdentical\";\n readonly count?: \"1\" | \"10\" | \"100\" | \"1k\" | \"10k\";\n readonly mode?: \"offline\" | \"online\" | \"incremental\";\n readonly edgeDensity?: \"sparse\" | \"medium\" | \"dense\";\n readonly edgeShape?: \"random\" | \"clustered\" | \"hubChain\" | \"longRange\" | \"tree\" | \"bundled\";\n readonly groups?: \"none\" | \"flat\" | \"nested\";\n readonly ports?: \"free\" | \"sides\" | \"fixed\";\n}\n\n/** An input of the corpus: the format `layout-input/1`. */\nexport interface LayoutInput {\n readonly schema: \"layout-input/1\";\n readonly id: string;\n readonly set?: string;\n readonly family?: string;\n readonly seed?: number;\n /** The origin: `made-up`, `published:<set>` or `known-best:<construction>`. */\n readonly source?: string;\n /** The first 16 hex characters of the SHA-256 of the canonical file without this field. */\n readonly hash?: string;\n /** The generator of the input. `null` or no value tells that a person made the input. */\n readonly generator?: LayoutGenerator | null;\n /** The steps that changed the input after its generator, in their order. `edgeStep` adds one. */\n readonly steps?: readonly LayoutGenerator[];\n readonly cell?: LayoutCell;\n /** The place of the input in a sequence of changes. */\n readonly step?: number;\n /** A router input can have no container. */\n readonly container?: LayoutContainer;\n /** The free space between two boxes with their margins. Routes use it. */\n readonly gap?: number;\n readonly boxes: readonly LayoutBox[];\n readonly edges?: readonly LayoutEdge[];\n readonly obstacles?: readonly Obstacle[];\n /**\n * A variant names its base input and its change.\n * With `packed`, the variant is the packed output of its base input: the router routes the positions of that pack.\n */\n readonly base?: string;\n readonly change?: \"add\" | \"remove\" | \"resize\" | \"reorder\" | \"packed\";\n}\n\n/** The input of a packer: a `layout-input/1` file without the edges. */\nexport interface PackInput {\n readonly container: LayoutContainer;\n readonly items: readonly Item[];\n readonly obstacles?: readonly Obstacle[];\n readonly gap?: number;\n}\n\n/** This function gives the packer input of a file. An input without a container gets `{ fixed: \"none\" }`, so the packer picks the size. */\nexport function toPackInput(input: LayoutInput): PackInput {\n return {\n container: input.container ?? { fixed: \"none\" },\n items: input.boxes,\n ...(input.obstacles === undefined ? {} : { obstacles: input.obstacles }),\n ...(input.gap === undefined ? {} : { gap: input.gap }),\n };\n}\n","import { SIDES, marginSides, type Margin, type Region, type Side } from \"./geometry.ts\";\nimport type { LayoutBox, Port } from \"./input.ts\";\n\n/*\n * The turn: 90 degrees clockwise, with the y axis down. The turned box has `w` and `h` swapped,\n * and its top-left corner stays at the position of the box. A point (px, py) of a box of height h\n * goes to (h - py, px). Thus the top-left corner goes to the top-right corner, and each side moves\n * one step clockwise: top to right, right to bottom, bottom to left, left to top.\n */\n\n/** This function gives the side after a turn of 90 degrees clockwise. */\nexport function turnSide(side: Side): Side {\n return SIDES[(SIDES.indexOf(side) + 1) % 4]!;\n}\n\n/** This function gives a point of a box of height `h` after the turn. */\nexport function turnPoint(x: number, y: number, h: number): [number, number] {\n return [h - y, x];\n}\n\n/** This function gives a port of a box of height `h` after the turn. Each value of the port turns, also a port with only `x` or only `y`. */\nexport function turnPort(port: Port, h: number): Port {\n const { side, x, y, ...rest } = port;\n return {\n ...rest,\n ...(side === undefined ? {} : { side: turnSide(side) }),\n ...(y === undefined ? {} : { x: h - y }),\n ...(x === undefined ? {} : { y: x }),\n };\n}\n\n/** This function gives a margin after the turn: the value of each side moves one side clockwise. */\nexport function turnMargin(margin: Margin): Margin {\n if (typeof margin === \"number\") return margin;\n const m = marginSides(margin);\n return { top: m.left, right: m.top, bottom: m.right, left: m.bottom };\n}\n\n/** This function gives a region relative to the origin of a box of height `h` after the turn. */\nexport function turnRegion(region: Region, h: number): Region {\n switch (region.kind) {\n case \"rect\":\n return { kind: \"rect\", x: h - region.y - region.h, y: region.x, w: region.h, h: region.w };\n case \"circle\":\n return { ...region, cx: h - region.cy, cy: region.cx };\n case \"ellipse\":\n return { kind: \"ellipse\", cx: h - region.cy, cy: region.cx, rx: region.ry, ry: region.rx };\n case \"polygon\": {\n const turn = (ring: readonly (readonly [number, number])[]): [number, number][] => ring.map(([x, y]) => turnPoint(x, y, h));\n return region.holes === undefined\n ? { kind: \"polygon\", points: turn(region.points) }\n : { kind: \"polygon\", points: turn(region.points), holes: region.holes.map(turn) };\n }\n }\n}\n\n/** This function gives a box after the turn: the size, the ports, the margin and the shape turn. The position stays. */\nexport function turnBox(box: LayoutBox): LayoutBox {\n return {\n ...box,\n w: box.h,\n h: box.w,\n ...(box.ports === undefined ? {} : { ports: box.ports.map((p) => turnPort(p, box.h)) }),\n ...(box.margin === undefined ? {} : { margin: turnMargin(box.margin) }),\n ...(box.shape === undefined ? {} : { shape: turnRegion(box.shape, box.h) }),\n };\n}\n","import { boundsOf, translate } from \"./geometry.ts\";\nimport type { LayoutInput } from \"./input.ts\";\nimport { turnBox } from \"./turn.ts\";\n\n/** The position of one item. `turn` is 90 when the packer turned a turnable item. */\nexport interface Placement {\n readonly id: string;\n readonly x: number;\n readonly y: number;\n readonly turn?: 0 | 90;\n}\n\n/** The facts of one stage of a strategy, for the records and the site. */\nexport interface StageTrace {\n readonly id: string;\n readonly ms?: number;\n readonly measures?: Readonly<Record<string, number>>;\n}\n\n/** The output of a packer. It does not change the input. */\nexport interface PackOutput {\n readonly placements: readonly Placement[];\n /** The ids of the items that the packer did not place. */\n readonly overflow: readonly string[];\n /** The size of the container after the pack. For a free size, the size that the search found. */\n readonly size: { readonly w: number; readonly h: number };\n /** The new top-left corner of the bounding box of each obstacle that moved. */\n readonly moved: readonly { readonly id: string; readonly x: number; readonly y: number }[];\n readonly trace?: readonly StageTrace[];\n}\n\n/**\n * This function gives the input with the output of a packer applied. Each placed box gets its position.\n * A turned box gets its turned size, ports, margin and shape. Each moved obstacle moves.\n * The container gets the size of the output. The router reads this result. It does not read `turn`.\n */\nexport function applyPack(input: LayoutInput, output: PackOutput): LayoutInput {\n const at = new Map(output.placements.map((p) => [p.id, p]));\n const moved = new Map(output.moved.map((m) => [m.id, m]));\n const boxes = input.boxes.map((box) => {\n const p = at.get(box.id);\n if (p === undefined) return box;\n const turned = p.turn === 90 ? turnBox(box) : box;\n return { ...turned, x: p.x, y: p.y };\n });\n const obstacles = input.obstacles?.map((o) => {\n const m = moved.get(o.id);\n if (m === undefined) return o;\n const b = boundsOf(o.region);\n return { ...o, region: translate(o.region, m.x - b.x, m.y - b.y) };\n });\n return {\n ...input,\n container: { ...(input.container ?? { fixed: \"none\" }), w: output.size.w, h: output.size.h },\n boxes,\n ...(obstacles === undefined ? {} : { obstacles }),\n };\n}\n","import type { Tolerance } from \"./tolerance.ts\";\nimport type { LayoutInput } from \"./input.ts\";\n\n/** The stage of a record: the packer, the router, or both together. */\nexport type Stage = \"pack\" | \"route\" | \"joint\";\n\n/** One run of one strategy on one input and seed: the format `layout-record/1`. A run writes one line of JSON Lines. */\nexport interface LayoutRecord {\n readonly schema: \"layout-record/1\";\n readonly stage: Stage;\n readonly step: string;\n readonly strategy: string;\n /** The options in full, with the defaults. */\n readonly options: Readonly<Record<string, unknown>>;\n readonly corpus: string;\n /** The id of the input. */\n readonly input: string;\n /** The `hash` of the input file. */\n readonly inputHash: string;\n readonly set: string;\n readonly seed: number;\n readonly nodes: number;\n readonly edges: number;\n /** The value of each measure, by its name: `pack.*`, `route.*` or `joint.*`. */\n readonly measures: Readonly<Record<string, number>>;\n /** The count of the breaks of each hard rule. A good run has 0 for each rule. */\n readonly hard: Readonly<Record<string, number>>;\n /** The tolerance of each hard rule of the run. */\n readonly tolerance?: Readonly<Partial<Tolerance>>;\n /** `true` when two runs with the same seed give the same positions. */\n readonly deterministic: boolean;\n /** The id of the prediction that was written before the run. */\n readonly prediction?: string;\n /** The median of `msRuns`, or the time of the one run. */\n readonly ms: number;\n /** The time of each timed repeat, in milliseconds. */\n readonly msRuns?: readonly number[];\n /**\n * The first 16 hex characters of the SHA-256 of the canonical output of the stage.\n * The packer hashes its placements by the order of the ids. The router hashes its routes by the order of the edge ids.\n */\n readonly outputHash?: string;\n /** The facts of the computer of the run. */\n readonly env?: RunEnv;\n /** The reason when the strategy did not run, for example an input over its `maxNodes`. Then the record has no measures. */\n readonly skipped?: string;\n readonly commit?: string;\n}\n\n/**\n * The values that a strategy supports, for each dimension of a taxonomy.\n * The dimension names are in `docs/FORMAT.md` of `packing` and `docs/LAYOUT-RECORDS.md` of `highways`.\n */\nexport type Supports = Readonly<Record<string, readonly string[]>>;\n\n/** The facts of the computer of a run. */\nexport interface RunEnv {\n readonly node: string;\n readonly os: string;\n readonly arch: string;\n /** The name of the runner, for example `ubuntu-latest` or `local`. */\n readonly runner: string;\n /** The model of the processor. */\n readonly cpu: string;\n /** The count of the logical processors. */\n readonly cpus: number;\n}\n\n/** The facts of a run that the input does not give. */\nexport type RunFacts = Omit<LayoutRecord, \"schema\" | \"input\" | \"inputHash\" | \"set\" | \"nodes\" | \"edges\">;\n\n/** This function gives the record of a run. The input gives its id, its hash, its set and the counts of the nodes and the edges. */\nexport function toLayoutRecord(input: LayoutInput, run: RunFacts): LayoutRecord {\n return {\n schema: \"layout-record/1\",\n ...run,\n input: input.id,\n inputHash: input.hash ?? \"\",\n set: input.set ?? \"\",\n nodes: input.boxes.length,\n edges: input.edges?.length ?? 0,\n };\n}\n","import { boundsOf, grow, overlapOf, type Rect, type Region } from \"./geometry.ts\";\nimport type { LayoutBox, LayoutInput, Obstacle } from \"./input.ts\";\nimport { applyPack, type PackOutput } from \"./output.ts\";\nimport { DEFAULT_TOLERANCE, EPS, RECORD_EPS } from \"./tolerance.ts\";\n\n/** This function gives the area of a placed box: its shape or its rectangle, at its position. A box without a position gives `undefined`. */\nexport function placedRect(box: LayoutBox): Rect | undefined {\n if (box.x === undefined || box.y === undefined) return undefined;\n if (box.shape === undefined) return { x: box.x, y: box.y, w: box.w, h: box.h };\n const b = boundsOf(box.shape);\n return { x: box.x + b.x, y: box.y + b.y, w: b.w, h: b.h };\n}\n\n/**\n * This function counts the pairs of placed boxes whose insides, with their margins, overlap by more than `tolerance` on each axis.\n * A box with a shape counts as its bounding box. That area is larger, thus the count is safe.\n */\nexport function countOverlaps(boxes: readonly LayoutBox[], tolerance: number = DEFAULT_TOLERANCE.overlap): number {\n const rects: Rect[] = [];\n for (const box of boxes) {\n const r = placedRect(box);\n if (r !== undefined) rects.push(grow(r, box.margin));\n }\n rects.sort((a, b) => a.x - b.x);\n let count = 0;\n for (let i = 0; i < rects.length; i++) {\n const a = rects[i]!;\n for (let j = i + 1; j < rects.length; j++) {\n const b = rects[j]!;\n if (b.x >= a.x + a.w - tolerance) break;\n const o = overlapOf(a, b);\n if (o.x > tolerance && o.y > tolerance) count++;\n }\n }\n return count;\n}\n\n/** The options of the container test of `countOutside` and `packHard`. */\nexport interface ContainerTest {\n /**\n * With `true`, a box of a shaped container with the size `fixed` must stay inside the shape, not only inside its bounding box.\n * The default is `false`. The default changes to `true` at the next breaking version.\n */\n readonly exactContainer?: boolean;\n}\n\n/**\n * This function counts the placed boxes that go out of the container.\n * Each box with its margin must stay inside the container made smaller by `inset`. Only the fixed sides of the size count. A shaped container counts as its bounding box.\n *\n * With `exactContainer`, a box of a shaped container with the size `fixed` also counts when `rectInRegion` tells that it is not inside the shape.\n * For that test, the box grows by `inset` and becomes smaller by `tolerance` on each side. A shaped container with a free side keeps the bounding test only.\n * An input without a container gives 0.\n */\nexport function countOutside(input: LayoutInput, tolerance: number = DEFAULT_TOLERANCE.overlap, options: ContainerTest = {}): number {\n const c = input.container;\n if (c === undefined) return 0;\n const shape = options.exactContainer === true && c.fixed === \"size\" ? c.shape : undefined;\n const area = c.shape === undefined ? { x: 0, y: 0, w: c.w ?? Infinity, h: c.h ?? Infinity } : boundsOf(c.shape);\n const inset = c.inset ?? 0;\n const fixW = c.fixed === \"size\" || c.fixed === \"width\";\n const fixH = c.fixed === \"size\" || c.fixed === \"height\";\n let count = 0;\n for (const box of input.boxes) {\n const r0 = placedRect(box);\n if (r0 === undefined) continue;\n const r = grow(r0, box.margin);\n const outX = r.x < area.x + inset - tolerance || r.x + r.w > area.x + area.w - inset + tolerance;\n const outY = r.y < area.y + inset - tolerance || r.y + r.h > area.y + area.h - inset + tolerance;\n if ((fixW && outX) || (fixH && outY)) count++;\n else if (shape !== undefined && !rectInRegion(shape, shrink(grow(r, inset), tolerance))) count++;\n }\n return count;\n}\n\n/** This function counts the fixed ports that are not on the border of their box, with the epsilon of a written file. A port without a side does not count. */\nexport function countPortsOffBorder(boxes: readonly LayoutBox[], eps: number = RECORD_EPS): number {\n let count = 0;\n for (const box of boxes) {\n for (const p of box.ports ?? []) {\n if (p.x === undefined || p.y === undefined || p.side === undefined) continue;\n const along = p.side === \"top\" || p.side === \"bottom\" ? p.x : p.y;\n const length = p.side === \"top\" || p.side === \"bottom\" ? box.w : box.h;\n const across = { top: p.y, bottom: p.y - box.h, left: p.x, right: p.x - box.w }[p.side];\n if (Math.abs(across) > eps || along < -eps || along > length + eps) count++;\n }\n }\n return count;\n}\n\n/** The count of the breaks of each hard rule of a pack. */\nexport interface PackHard {\n readonly \"no-overlap\": number;\n readonly \"in-container\": number;\n readonly \"locked-kept\": number;\n readonly complete: number;\n}\n\n/** This function tells if the inside of `region` and the inside of `rect` have a common point. */\nexport function regionHitsRect(region: Region, rect: Rect): boolean {\n if (rect.w <= 0 || rect.h <= 0) return false;\n switch (region.kind) {\n case \"rect\": {\n const o = overlapOf(region, rect);\n return o.x > 0 && o.y > 0;\n }\n case \"circle\":\n return circleHitsRect(region.cx, region.cy, region.r, region.r, rect);\n case \"ellipse\":\n return circleHitsRect(region.cx, region.cy, region.rx, region.ry, rect);\n case \"polygon\": {\n const rings = [region.points, ...(region.holes ?? [])];\n const inside = (x: number, y: number): boolean => x > rect.x && x < rect.x + rect.w && y > rect.y && y < rect.y + rect.h;\n if (region.points.some(([x, y]) => inside(x, y))) return true;\n for (const ring of rings) {\n for (let i = 0; i < ring.length; i++) {\n const a = ring[i]!;\n const b = ring[(i + 1) % ring.length]!;\n const m = clipMid(a[0], a[1], b[0], b[1], rect);\n if (m !== undefined && inside(m[0], m[1])) return true;\n }\n }\n return pointInRings(rect.x + rect.w / 2, rect.y + rect.h / 2, rings);\n }\n }\n}\n\n/**\n * This function tells if all of `rect` is inside `region`. A point on the border counts as inside. No part of `rect` can overlap a hole.\n * The test of a circle, an ellipse or a polygon accepts an error of `EPS` on the border. A polygon can be concave.\n */\nexport function rectInRegion(region: Region, rect: Rect): boolean {\n const x1 = rect.x + rect.w;\n const y1 = rect.y + rect.h;\n const corners: readonly (readonly [number, number])[] = [\n [rect.x, rect.y],\n [x1, rect.y],\n [x1, y1],\n [rect.x, y1],\n ];\n switch (region.kind) {\n case \"rect\":\n return rect.x >= region.x && rect.y >= region.y && x1 <= region.x + region.w && y1 <= region.y + region.h;\n case \"circle\":\n return corners.every(([x, y]) => inEllipse(region.cx, region.cy, region.r, region.r, x, y));\n case \"ellipse\":\n return corners.every(([x, y]) => inEllipse(region.cx, region.cy, region.rx, region.ry, x, y));\n case \"polygon\": {\n const ring = region.points;\n if (ring.length < 3) return false;\n const points = [...corners, [rect.x + rect.w / 2, rect.y + rect.h / 2] as const];\n if (!points.every(([x, y]) => onRing(x, y, ring) || pointInRings(x, y, [ring]))) return false;\n const deep = (x: number, y: number): boolean => x > rect.x + EPS && x < x1 - EPS && y > rect.y + EPS && y < y1 - EPS;\n for (let i = 0; i < ring.length; i++) {\n const a = ring[i]!;\n const b = ring[(i + 1) % ring.length]!;\n const m = clipMid(a[0], a[1], b[0], b[1], rect);\n if (m !== undefined && deep(m[0], m[1])) return false;\n }\n return (region.holes ?? []).every((hole) => !regionHitsRect({ kind: \"polygon\", points: hole }, rect));\n }\n }\n}\n\n/** This function gives the rectangle made smaller by `d` on each side. A side does not become smaller than 0. */\nfunction shrink(r: Rect, d: number): Rect {\n const dx = Math.min(d, r.w / 2);\n const dy = Math.min(d, r.h / 2);\n return { x: r.x + dx, y: r.y + dy, w: r.w - 2 * dx, h: r.h - 2 * dy };\n}\n\n/** This function tells if a point is inside an ellipse or on its border, with an error of `EPS`. */\nfunction inEllipse(cx: number, cy: number, rx: number, ry: number, x: number, y: number): boolean {\n if (rx <= 0 || ry <= 0) return false;\n const u = (x - cx) / rx;\n const v = (y - cy) / ry;\n return u * u + v * v <= 1 + EPS;\n}\n\n/** This function tells if a point is on a ring of a polygon, with an error of `EPS`. */\nfunction onRing(x: number, y: number, ring: readonly (readonly [number, number])[]): boolean {\n for (let i = 0; i < ring.length; i++) {\n const [ax, ay] = ring[i]!;\n const [bx, by] = ring[(i + 1) % ring.length]!;\n const dx = bx - ax;\n const dy = by - ay;\n const len2 = dx * dx + dy * dy;\n const t = len2 === 0 ? 0 : Math.max(0, Math.min(1, ((x - ax) * dx + (y - ay) * dy) / len2));\n if (Math.hypot(x - (ax + t * dx), y - (ay + t * dy)) <= EPS) return true;\n }\n return false;\n}\n\n/** An ellipse with the radii `rx` and `ry` scales to a unit circle. The rectangle scales with it. */\nfunction circleHitsRect(cx: number, cy: number, rx: number, ry: number, rect: Rect): boolean {\n if (rx <= 0 || ry <= 0) return false;\n const x0 = (rect.x - cx) / rx;\n const x1 = (rect.x + rect.w - cx) / rx;\n const y0 = (rect.y - cy) / ry;\n const y1 = (rect.y + rect.h - cy) / ry;\n const dx = Math.max(x0, 0, -x1);\n const dy = Math.max(y0, 0, -y1);\n return dx * dx + dy * dy < 1;\n}\n\n/** This function gives the middle of the part of a segment inside a rectangle, or `undefined` when that part is a point or empty. */\nfunction clipMid(ax: number, ay: number, bx: number, by: number, r: Rect): readonly [number, number] | undefined {\n let t0 = 0;\n let t1 = 1;\n const dx = bx - ax;\n const dy = by - ay;\n const edges: readonly (readonly [number, number])[] = [\n [-dx, ax - r.x],\n [dx, r.x + r.w - ax],\n [-dy, ay - r.y],\n [dy, r.y + r.h - ay],\n ];\n for (const [p, q] of edges) {\n if (p === 0) {\n if (q < 0) return undefined;\n } else if (p < 0) {\n t0 = Math.max(t0, q / p);\n } else {\n t1 = Math.min(t1, q / p);\n }\n }\n if (t1 <= t0) return undefined;\n const t = (t0 + t1) / 2;\n return [ax + t * dx, ay + t * dy];\n}\n\n/** The even-odd rule over the outer ring and the holes. */\nfunction pointInRings(x: number, y: number, rings: readonly (readonly (readonly [number, number])[])[]): boolean {\n let inside = false;\n for (const ring of rings) {\n for (let i = 0, j = ring.length - 1; i < ring.length; j = i++) {\n const [xi, yi] = ring[i]!;\n const [xj, yj] = ring[j]!;\n if (yi > y !== yj > y && x < ((xj - xi) * (y - yi)) / (yj - yi) + xi) inside = !inside;\n }\n }\n return inside;\n}\n\n/**\n * This function counts the pairs of a placed box and an obstacle that overlap by more than `tolerance`.\n * The box counts with its margin. A box with a shape counts as its bounding box.\n */\nexport function countObstacleHits(\n boxes: readonly LayoutBox[],\n obstacles: readonly Obstacle[] | undefined,\n tolerance: number = DEFAULT_TOLERANCE.overlap,\n): number {\n if (obstacles === undefined || obstacles.length === 0) return 0;\n let count = 0;\n for (const box of boxes) {\n const r0 = placedRect(box);\n if (r0 === undefined) continue;\n const r = grow(r0, box.margin);\n const small = { x: r.x + tolerance, y: r.y + tolerance, w: r.w - 2 * tolerance, h: r.h - 2 * tolerance };\n for (const o of obstacles) if (regionHitsRect(o.region, small)) count++;\n }\n return count;\n}\n\n/**\n * This function gives the count of each hard rule of the output of a packer.\n * It applies the output with `applyPack`. Only the placed boxes and the locked boxes count for the overlaps and the container.\n * `no-overlap` counts the pairs of boxes and the pairs of a box and an obstacle.\n * A locked box without a placement, or with a move of more than `RECORD_EPS`, breaks `locked-kept`.\n * A locked box without a position in the input is a bad input, not a break. `checkInput` finds it.\n * Another box without a placement that is not in `overflow` breaks `complete`.\n *\n * `options` goes to `countOutside` for `in-container`.\n */\nexport function packHard(input: LayoutInput, output: PackOutput, tolerance: number = DEFAULT_TOLERANCE.overlap, options: ContainerTest = {}): PackHard {\n const after = applyPack(input, output);\n const placed = new Set(output.placements.map((p) => p.id));\n const out = new Set(output.overflow);\n const was = new Map(input.boxes.map((b) => [b.id, b]));\n let lockedMoved = 0;\n let incomplete = 0;\n const kept: LayoutBox[] = [];\n for (const box of after.boxes) {\n const old = was.get(box.id);\n if (old?.locked === true) {\n if (old.x === undefined || old.y === undefined) continue;\n const moved = Math.abs(old.x - (box.x ?? old.x)) > RECORD_EPS || Math.abs(old.y - (box.y ?? old.y)) > RECORD_EPS;\n if (!placed.has(box.id) || moved) lockedMoved++;\n kept.push(box);\n } else if (placed.has(box.id)) {\n kept.push(box);\n } else if (!out.has(box.id)) {\n incomplete++;\n }\n }\n return {\n \"no-overlap\": countOverlaps(kept, tolerance) + countObstacleHits(kept, after.obstacles, tolerance),\n \"in-container\": countOutside({ ...after, boxes: kept }, tolerance, options),\n \"locked-kept\": lockedMoved,\n complete: incomplete,\n };\n}\n\n/**\n * This function gives the problems of an input file. An empty list tells that the file is good.\n * A problem is a bad input, not a break of a hard rule. Thus an engine refuses the input.\n */\nexport function checkInput(input: LayoutInput): readonly string[] {\n const problems: string[] = [];\n const ids = new Set<string>();\n for (const box of input.boxes) {\n if (ids.has(box.id)) problems.push(`box ${box.id}: the id is not unique`);\n ids.add(box.id);\n if (!(box.w > 0 && box.h > 0 && Number.isFinite(box.w) && Number.isFinite(box.h))) problems.push(`box ${box.id}: the size is not positive and finite`);\n if (box.locked === true && (box.x === undefined || box.y === undefined)) problems.push(`box ${box.id}: a locked box has no position`);\n }\n if (countPortsOffBorder(input.boxes) > 0) problems.push(\"a fixed port is not on the border of its box\");\n for (const edge of input.edges ?? []) {\n if (!ids.has(edge.source) || !ids.has(edge.target)) problems.push(`edge ${edge.id}: a box of the edge is not in the input`);\n }\n return problems;\n}\n","import { RECORD_EPS, RECORD_SCALE } from \"./tolerance.ts\";\n\n/** The direction of a measure: the side of the better values. */\nexport type Direction = \"lower\" | \"higher\";\n\n/**\n * The facts of one measure: its unit, its direction and its range.\n * `floor` and `tol` are the parameters of the floor rule of the promotion rule (`docs/PROMOTION.md` of `highways`).\n * Each engine exports the specs of its own measures. This package exports the specs of the `joint.*` measures.\n */\nexport interface MeasureSpec<Id extends string = string> {\n readonly id: Id;\n readonly unit: string;\n readonly direction: Direction;\n /** The lowest value. */\n readonly min: number;\n /** The highest value. The value `Infinity` tells that the measure has no upper limit. */\n readonly max: number;\n /** The family of the measure in the measure note of its engine. */\n readonly family?: string;\n /** The best value. Without it, the measure has no floor. */\n readonly floor?: number;\n /** The absolute tolerance at the floor. */\n readonly tol?: number;\n /**\n * The smallest change that counts as better or worse. A number is an absolute change. `{ rel }` is a share of the larger of the two values.\n * `docs/JOINT-MEASURES.md` gives the reason of each joint value.\n */\n readonly minEffect?: number | { readonly rel: number };\n /** The role of the measure in the joint selector. */\n readonly role?: \"guard\" | \"change-guard\" | \"diagnostic\" | \"time\";\n}\n\n/** The id of a joint measure. `docs/JOINT-MEASURES.md` gives the definitions. */\nexport type JointMeasureId =\n | \"joint.fill\"\n | \"joint.aspectError\"\n | \"joint.spill\"\n | \"joint.straight.crossings\"\n | \"joint.straight.length\"\n | \"joint.stability.mean\"\n | \"joint.stability.moved\"\n | \"joint.proxy.rank\"\n | \"joint.ms\";\n\n/** The specs of the joint measures, in the order of `docs/JOINT-MEASURES.md`. */\nexport const JOINT_MEASURES: readonly MeasureSpec<JointMeasureId>[] = Object.freeze([\n { id: \"joint.fill\", minEffect: 0.001, unit: \"0 to 1\", direction: \"higher\", min: 0, max: 1, floor: 1, role: \"guard\" },\n { id: \"joint.aspectError\", minEffect: 0.01, unit: \"natural log\", direction: \"lower\", min: 0, max: Infinity, floor: 0, tol: 0.01, role: \"guard\" },\n { id: \"joint.spill\", minEffect: 0.001, unit: \"0 to 1\", direction: \"lower\", min: 0, max: 1, floor: 0, tol: 0.001, role: \"guard\" },\n { id: \"joint.straight.crossings\", minEffect: 0, unit: \"count\", direction: \"lower\", min: 0, max: Infinity, floor: 0, tol: 0, role: \"guard\" },\n { id: \"joint.straight.length\", minEffect: 0.01, unit: \"S for each edge\", direction: \"lower\", min: 0, max: Infinity, floor: 0, tol: 0.01, role: \"guard\" },\n { id: \"joint.stability.mean\", minEffect: 0.005, unit: \"W\", direction: \"lower\", min: 0, max: Infinity, floor: 0, tol: 0.005, role: \"change-guard\" },\n { id: \"joint.stability.moved\", minEffect: 0.02, unit: \"0 to 1\", direction: \"lower\", min: 0, max: 1, floor: 0, tol: 0.02, role: \"change-guard\" },\n { id: \"joint.proxy.rank\", unit: \"-1 to 1\", direction: \"higher\", min: -1, max: 1, role: \"diagnostic\" },\n { id: \"joint.ms\", unit: \"milliseconds\", direction: \"lower\", min: 0, max: Infinity, role: \"time\" },\n] as const);\n\n/** The threshold of `joint.stability.moved`, in widths `W` of the base. */\nexport const JOINT_MOVED_MIN = 0.01;\n\n/** The result of a compare of a candidate with a baseline on one measure. A tie is not better. */\nexport type Verdict = \"better\" | \"worse\" | \"tie\";\n\n/**\n * This function gives the smallest change of a measure that counts between the values `a` and `b`.\n * The value is `max(RECORD_EPS, minEffect)`, or `max(RECORD_EPS, rel * max(|a|, |b|))` for a relative `minEffect`.\n * The larger value makes the threshold the same after a swap of `a` and `b`.\n */\nexport function minEffectOf(spec: Pick<MeasureSpec, \"minEffect\">, a = 0, b = 0): number {\n const m = spec.minEffect ?? 0;\n const t = typeof m === \"number\" ? m : m.rel * Math.max(Math.abs(a), Math.abs(b));\n return Math.max(RECORD_EPS, Number.isFinite(t) ? t : 0);\n}\n\n/** The slack of the threshold in grid steps. It absorbs only the float noise of the threshold, because the change is a whole number. */\nconst STEP_NOISE = 1e-6;\n\n/**\n * This function compares the value `candidate` with the value `baseline` of one measure on one input.\n * The compare uses whole grid steps of `RECORD_EPS`. Thus a live value and its rounded record give the same verdict.\n * A change of at most the threshold of `minEffectOf` in grid steps is a tie. A swap of the two values swaps better and worse.\n * Two equal values are a tie, also two infinite values. A value `NaN` is an error.\n */\nexport function compareMeasure(candidate: number, baseline: number, spec: Pick<MeasureSpec, \"direction\" | \"minEffect\">): Verdict {\n if (Number.isNaN(candidate) || Number.isNaN(baseline)) throw new RangeError(\"compareMeasure: a value is NaN\");\n if (candidate === baseline) return \"tie\";\n const a = Math.round(candidate * RECORD_SCALE);\n const b = Math.round(baseline * RECORD_SCALE);\n let delta: number;\n if (Number.isSafeInteger(a) && Number.isSafeInteger(b)) {\n delta = a - b;\n const m = spec.minEffect ?? 0;\n const t = typeof m === \"number\" ? m * RECORD_SCALE : m.rel * Math.max(Math.abs(a), Math.abs(b));\n if (Math.abs(delta) <= Math.max(1, Number.isFinite(t) ? t : 0) + STEP_NOISE) return \"tie\";\n } else {\n delta = candidate - baseline;\n if (!(Math.abs(delta) > minEffectOf(spec, candidate, baseline))) return \"tie\";\n }\n const better = spec.direction === \"lower\" ? delta < 0 : delta > 0;\n return better ? \"better\" : \"worse\";\n}\n","/** This function gives the UTF-8 bytes of a string. The package has no runtime dependencies, thus it does not use `TextEncoder`. */\nexport function utf8(text: string): number[] {\n const bytes: number[] = [];\n for (const ch of text) {\n const c = ch.codePointAt(0)!;\n if (c < 0x80) bytes.push(c);\n else if (c < 0x800) bytes.push(0xc0 | (c >> 6), 0x80 | (c & 63));\n else if (c < 0x10000) bytes.push(0xe0 | (c >> 12), 0x80 | ((c >> 6) & 63), 0x80 | (c & 63));\n else bytes.push(0xf0 | (c >> 18), 0x80 | ((c >> 12) & 63), 0x80 | ((c >> 6) & 63), 0x80 | (c & 63));\n }\n return bytes;\n}\n","import { utf8 } from \"./utf8.ts\";\n\n/** This function gives a generator of random numbers in [0, 1). It is `mulberry32`, as in `docs/FORMAT.md` of `packing`. */\nexport function mulberry32(seed: number): () => number {\n let s = seed >>> 0;\n return () => {\n s = (s + 0x6d2b79f5) | 0;\n let t = Math.imul(s ^ (s >>> 15), 1 | s);\n t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t;\n return ((t ^ (t >>> 14)) >>> 0) / 4294967296;\n };\n}\n\n/** This function gives the FNV-1a hash of 32 bits of the UTF-8 bytes of a string. */\nexport function fnv1a32(text: string): number {\n let h = 0x811c9dc5;\n for (const b of utf8(text)) h = Math.imul(h ^ b, 0x01000193) >>> 0;\n return h;\n}\n\n/** This function gives the generator of one step of a seeded generator: `mulberry32(fnv1a32(\"<seed>:<step>\"))`. */\nexport function stepRandom(seed: number, step: string): () => number {\n return mulberry32(fnv1a32(`${seed}:${step}`));\n}\n\n/** This function gives a whole number from `lo` to `hi`, both included. */\nexport function randomInt(r: () => number, lo: number, hi: number): number {\n return lo + Math.floor(r() * (hi - lo + 1));\n}\n","import { SIDES, type Side } from \"./geometry.ts\";\nimport type { LayoutBox, LayoutEdge, LayoutGenerator, LayoutInput, Port } from \"./input.ts\";\nimport { randomInt, stepRandom } from \"./random.ts\";\n\n/**\n * The shape of the edges of `edgeStep`. The values are the cells of `edgeShape`, and `hubs`.\n * `hubs` waits for the next breaking change to become a value of `LayoutCell.edgeShape`.\n */\nexport type EdgeShape = \"random\" | \"clustered\" | \"hubChain\" | \"hubs\" | \"longRange\" | \"tree\" | \"bundled\";\n\n/** The parameters of `edgeStep`. */\nexport interface EdgeStepParams {\n readonly edgeDensity: \"sparse\" | \"medium\" | \"dense\";\n readonly edgeShape: EdgeShape;\n /** The default is `none`. */\n readonly groups?: \"none\" | \"flat\" | \"nested\";\n /** The default is `free`. */\n readonly ports?: \"free\" | \"sides\" | \"fixed\";\n /** The order of the hubs of `hubs` and `tree`: the largest box first, or a random order. The default is `area`. */\n readonly hubBy?: \"area\" | \"random\";\n}\n\n/** The mean count of the edges of each box for each value of `edgeDensity`. */\nexport const EDGE_DENSITY: Readonly<Record<EdgeStepParams[\"edgeDensity\"], number>> = Object.freeze({ sparse: 0.5, medium: 1.5, dense: 4 });\n\n/** The version of `edgeStep`. A change of its output gives a new version. */\nexport const EDGE_STEP_VERSION = 1;\n\nconst CLUSTER = 8;\nconst CHAIN = 32;\nconst INSIDE = 0.85;\nconst FAN_SHARE = 0.6;\nconst FIXED_SHARE = 0.2;\nconst COLLECTIONS = [\"users\", \"orders\", \"items\", \"events\"] as const;\n\nconst round3 = (x: number): number => Math.round(x * 1000) / 1000;\n\n/**\n * This function gives the input with edges, groups and ports from its topology alone: a joint input has no positions before the pack.\n * The random numbers come from the steps `edges` and `ports` of `seed`. The function appends its stamp to `steps`, and removes the old `hash`.\n * The rules of each shape are in `docs/JOINT-CORPUS.md`.\n */\nexport function edgeStep(input: LayoutInput, params: EdgeStepParams, seed: number = input.seed ?? 0): LayoutInput {\n if ((input.edges?.length ?? 0) > 0) throw new RangeError(\"edgeStep: the input has edges already\");\n const full: Required<EdgeStepParams> = { groups: \"none\", ports: \"free\", hubBy: \"area\", ...params };\n const n = input.boxes.length;\n const r = stepRandom(seed, \"edges\");\n\n const perm = input.boxes.map((_, i) => i);\n for (let i = n - 1; i > 0; i--) {\n const j = randomInt(r, 0, i);\n [perm[i], perm[j]] = [perm[j]!, perm[i]!];\n }\n const clusterOf: number[] = new Array<number>(n);\n perm.forEach((box, p) => (clusterOf[box] = Math.floor(p / CLUSTER)));\n const clusters = Math.ceil(n / CLUSTER);\n const members = (c: number): readonly number[] => perm.slice(c * CLUSTER, (c + 1) * CLUSTER);\n const collectionOf =\n full.edgeShape === \"bundled\"\n ? clusterOf.map((c) => `${COLLECTIONS[c % COLLECTIONS.length]!}-${c}`)\n : input.boxes.map(() => COLLECTIONS[randomInt(r, 0, COLLECTIONS.length - 1)]!);\n const area = (i: number): number => input.boxes[i]!.w * input.boxes[i]!.h;\n const rank = full.hubBy === \"area\" ? input.boxes.map((_, i) => i).sort((a, b) => area(b) - area(a) || a - b) : perm;\n\n const pairs: [number, number][] = [];\n const seen = new Set<string>();\n const add = (u: number, v: number): void => {\n const key = u < v ? `${u}-${v}` : `${v}-${u}`;\n if (u === v || seen.has(key)) return;\n seen.add(key);\n pairs.push([u, v]);\n };\n const anyBox = (): number => randomInt(r, 0, n - 1);\n const inCluster = (c: number): number => {\n const m = members(c);\n return m[randomInt(r, 0, m.length - 1)]!;\n };\n const otherCluster = (c: number): number => {\n const o = randomInt(r, 0, clusters - 2);\n return o >= c ? o + 1 : o;\n };\n const target = Math.min(Math.round(n * EDGE_DENSITY[full.edgeDensity]), (n * (n - 1)) / 2);\n const fill = (pick: () => [number, number]): void => {\n for (let tries = 0; pairs.length < target && tries < target * 30; tries++) add(...pick());\n };\n const clustered = (): [number, number] => {\n const u = anyBox();\n return [u, r() < INSIDE ? inCluster(clusterOf[u]!) : anyBox()];\n };\n\n if (n >= 2) {\n switch (full.edgeShape) {\n case \"random\":\n fill(() => [anyBox(), anyBox()]);\n break;\n case \"clustered\":\n fill(clustered);\n break;\n case \"longRange\":\n fill(() => {\n const u = anyBox();\n return [u, clusters > 1 ? inCluster(otherCluster(clusterOf[u]!)) : anyBox()];\n });\n break;\n case \"hubs\":\n fill(() => [anyBox(), rank[Math.floor(n * r() ** 3)]!]);\n break;\n case \"tree\":\n for (let i = 1; i < n; i++) add(rank[randomInt(r, 0, i - 1)]!, rank[i]!);\n break;\n case \"hubChain\": {\n const k = Math.ceil(n / CHAIN);\n const length = Math.ceil(n / k);\n const chains = Array.from({ length: k }, (_, c) => perm.slice(c * length, (c + 1) * length));\n for (const chain of chains) for (let i = 0; i + 1 < chain.length; i++) add(chain[i]!, chain[i + 1]!);\n const skips = Math.max(0, target - pairs.length);\n for (let s = 0; s < skips; s++) {\n const c = k > 1 ? randomInt(r, 0, k - 2) : 0;\n const from = chains[c]!;\n const to = chains[k > 1 ? c + 1 : 0]!;\n const i = randomInt(r, 0, from.length - 1);\n const j = i + Math.floor(from.length / 8) + randomInt(r, 0, Math.floor(from.length / 2));\n if (j < to.length) add(from[i]!, to[j]!);\n }\n break;\n }\n case \"bundled\":\n for (let rounds = 0; pairs.length < target * FAN_SHARE && clusters > 1 && rounds < target; rounds++) {\n const u = anyBox();\n const c = otherCluster(clusterOf[u]!);\n const fan = randomInt(r, 4, 15);\n for (let f = 0; f < fan && pairs.length < target; f++) add(u, inCluster(c));\n }\n fill(clustered);\n break;\n }\n }\n\n const rp = stepRandom(seed, \"ports\");\n const ports: Port[][] = input.boxes.map((b) => [...(b.ports ?? [])]);\n const portOn = (box: LayoutBox, id: string, side: Side, fixed: boolean): Port => {\n if (!fixed) return { id, side };\n const along = round3(rp() * (side === \"top\" || side === \"bottom\" ? box.w : box.h));\n const at = { top: [along, 0], bottom: [along, box.h], left: [0, along], right: [box.w, along] }[side];\n return { id, side, x: at[0]!, y: at[1]! };\n };\n const out = new Set<number>();\n if (full.ports === \"fixed\") {\n input.boxes.forEach((box, i) => {\n if (rp() >= FIXED_SHARE) return;\n const side = SIDES[randomInt(rp, 0, 3)]!;\n ports[i]!.push(portOn(box, \"out\", side, true));\n out.add(i);\n });\n }\n const edges: LayoutEdge[] = pairs.map(([u, v], k) => {\n const id = `e${k}`;\n const s = input.boxes[u]!;\n const t = input.boxes[v]!;\n let ends: { sourcePort?: string; targetPort?: string } = {};\n if (full.ports === \"sides\") {\n ports[u]!.push(portOn(s, `${id}.s`, SIDES[randomInt(rp, 0, 3)]!, false));\n ports[v]!.push(portOn(t, `${id}.t`, SIDES[randomInt(rp, 0, 3)]!, false));\n ends = { sourcePort: `${id}.s`, targetPort: `${id}.t` };\n } else if (out.has(u)) {\n ends = { sourcePort: \"out\" };\n }\n return { id, source: s.id, target: t.id, ...ends, data: { collection: collectionOf[v]! } };\n });\n\n const boxes = input.boxes.map((box, i): LayoutBox => {\n const c = clusterOf[i]!;\n const group = full.groups === \"none\" ? undefined : `g${c}`;\n const path = full.groups === \"nested\" ? `G${Math.floor(c / 4)}/g${c}` : group;\n return {\n ...box,\n ...(group === undefined ? {} : { group, data: { ...box.data, group: path } }),\n ...(ports[i]!.length === 0 ? {} : { ports: ports[i]! }),\n };\n });\n const stamp: LayoutGenerator = { name: \"edges\", version: EDGE_STEP_VERSION, params: { ...full }, seed };\n const { hash: _old, ...rest } = input;\n return { ...rest, boxes, edges, steps: [...(input.steps ?? []), stamp] };\n}\n","import { RECORD_EPS } from \"./tolerance.ts\";\nimport { utf8 } from \"./utf8.ts\";\n\n/** The round constants of SHA-256. */\nconst K: readonly number[] = [\n 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe,\n 0x9bdc06a7, 0xc19bf174, 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7,\n 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, 0xa2bfe8a1, 0xa81a664b,\n 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,\n 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2,\n];\n\n/**\n * This function gives the SHA-256 digest of the UTF-8 bytes of a string, as 64 lowercase hex characters.\n * It uses no API of Node or of the browser.\n */\nexport function sha256Hex(text: string): string {\n const bytes = utf8(text);\n const bits = bytes.length * 8;\n const total = Math.ceil((bytes.length + 9) / 64) * 64;\n const data = new Uint8Array(total);\n data.set(bytes);\n data[bytes.length] = 0x80;\n const view = new DataView(data.buffer);\n view.setUint32(total - 8, Math.floor(bits / 0x100000000));\n view.setUint32(total - 4, bits >>> 0);\n const h = [0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19];\n const w = new Uint32Array(64);\n const rotr = (x: number, n: number): number => (x >>> n) | (x << (32 - n));\n for (let off = 0; off < total; off += 64) {\n for (let i = 0; i < 16; i++) w[i] = view.getUint32(off + 4 * i);\n for (let i = 16; i < 64; i++) {\n const a = w[i - 15]!;\n const b = w[i - 2]!;\n const s0 = rotr(a, 7) ^ rotr(a, 18) ^ (a >>> 3);\n const s1 = rotr(b, 17) ^ rotr(b, 19) ^ (b >>> 10);\n w[i] = (w[i - 16]! + s0 + w[i - 7]! + s1) >>> 0;\n }\n let [a, b, c, d, e, f, g, k] = h as [number, number, number, number, number, number, number, number];\n for (let i = 0; i < 64; i++) {\n const s1 = rotr(e, 6) ^ rotr(e, 11) ^ rotr(e, 25);\n const ch = (e & f) ^ (~e & g);\n const t1 = (k + s1 + ch + K[i]! + w[i]!) >>> 0;\n const s0 = rotr(a, 2) ^ rotr(a, 13) ^ rotr(a, 22);\n const maj = (a & b) ^ (a & c) ^ (b & c);\n const t2 = (s0 + maj) >>> 0;\n k = g;\n g = f;\n f = e;\n e = (d + t1) >>> 0;\n d = c;\n c = b;\n b = a;\n a = (t1 + t2) >>> 0;\n }\n h[0] = (h[0]! + a) >>> 0;\n h[1] = (h[1]! + b) >>> 0;\n h[2] = (h[2]! + c) >>> 0;\n h[3] = (h[3]! + d) >>> 0;\n h[4] = (h[4]! + e) >>> 0;\n h[5] = (h[5]! + f) >>> 0;\n h[6] = (h[6]! + g) >>> 0;\n h[7] = (h[7]! + k) >>> 0;\n }\n return h.map((x) => x.toString(16).padStart(8, \"0\")).join(\"\");\n}\n\n/**\n * This function gives the canonical form of a value: sorted keys and no whitespace, with the numbers of `JSON.stringify`.\n * A key with the value `undefined` is not in the form. An `undefined` in an array becomes `null`.\n */\nexport function canonicalJson(value: unknown): string {\n if (value === null || typeof value !== \"object\") return JSON.stringify(value) ?? \"null\";\n if (Array.isArray(value)) return `[${value.map((v: unknown) => (v === undefined ? \"null\" : canonicalJson(v))).join(\",\")}]`;\n const o = value as Record<string, unknown>;\n const keys = Object.keys(o)\n .filter((k) => o[k] !== undefined)\n .sort();\n return `{${keys.map((k) => `${JSON.stringify(k)}:${canonicalJson(o[k])}`).join(\",\")}}`;\n}\n\n/** The options of `outputHash` and `documentHash`. */\nexport interface HashOptions {\n /**\n * The step of the grid of the numbers. The default is `RECORD_EPS`, so a number keeps 3 decimals.\n * The value `0` keeps the exact numbers. A negative value or a value that is not finite causes a `RangeError`.\n */\n readonly grid?: number;\n}\n\n/** This function gives the factor of a grid: `1 / grid`, or `undefined` for the exact numbers. */\nfunction gridFactor(options: HashOptions): number | undefined {\n const grid = options.grid ?? RECORD_EPS;\n if (!Number.isFinite(grid) || grid < 0) throw new RangeError(`The grid ${grid} is not a finite number of 0 or more.`);\n return grid === 0 ? undefined : 1 / grid;\n}\n\n/**\n * This function gives a copy of a value with each number on the grid. The value `-0` becomes `0`.\n * It throws a `RangeError` for a number that is not finite.\n */\nfunction onGrid(value: unknown, path: string, k: number | undefined): unknown {\n if (typeof value === \"number\") {\n if (!Number.isFinite(value)) throw new RangeError(`The value has the number ${value} at ${path}. JSON has no form for it.`);\n if (k === undefined) return value;\n const r = Math.round(value * k) / k;\n if (!Number.isFinite(r)) throw new RangeError(`The number at ${path} is too large for the grid.`);\n return r === 0 ? 0 : r;\n }\n if (value === null || typeof value !== \"object\") return value;\n if (Array.isArray(value)) return value.map((v: unknown, i) => onGrid(v, `${path}[${i}]`, k));\n const o = value as Record<string, unknown>;\n const out: Record<string, unknown> = {};\n for (const key of Object.keys(o)) out[key] = onGrid(o[key], `${path}.${key}`, k);\n return out;\n}\n\n/**\n * This function gives the hash of an output: the first 16 hex characters of the SHA-256 of its canonical form.\n * Before the canonical form, each number goes to the nearest point of the grid, and `-0` becomes `0`.\n * With the default grid, the rounding is `round3` of `packing`: `Math.round(x * 1000) / 1000`.\n * The function throws a `RangeError` for `NaN` and for an infinite number.\n *\n * The grid can split two outputs. Two numbers near a rounding boundary can go to two different points.\n * The grid can also merge two outputs whose numbers go to the same points. This merge is intentional: it removes the noise of floating-point numbers.\n */\nexport function outputHash(value: unknown, options: HashOptions = {}): string {\n return sha256Hex(canonicalJson(onGrid(value, \"$\", gridFactor(options)))).slice(0, 16);\n}\n\n/**\n * This function gives the hash of a document. It uses the rule of `outputHash`, but the form does not include the field `hash` of the document.\n * With the default grid, it is the input hash of `docs/FORMAT.md` of `packing`.\n */\nexport function documentHash(doc: object, options: HashOptions = {}): string {\n const { hash: _hash, ...rest } = doc as { readonly hash?: unknown };\n return outputHash(rest, options);\n}\n\n/** One output group: the candidates with the same output hash on each decision input. */\nexport interface OutputGroup {\n /** The id of the group: its first member. */\n readonly id: string;\n /** The ids of the candidates of the group, in sorted order. */\n readonly members: readonly string[];\n}\n\n/**\n * This function gives the output groups of the candidates. The key of `hashes` is the id of a candidate.\n * Its value is the list of the output hashes of the candidate, in the order of the decision inputs.\n * Candidates with equal lists make one group. The groups are in the order of their ids.\n * The function throws a `RangeError` when two lists have different lengths.\n */\nexport function outputGroups(hashes: Readonly<Record<string, readonly string[]>>): OutputGroup[] {\n const byList = new Map<string, string[]>();\n let first: string | undefined;\n for (const id of Object.keys(hashes)) {\n const list = hashes[id]!;\n if (first === undefined) first = id;\n else if (list.length !== hashes[first]!.length)\n throw new RangeError(`The candidate \"${id}\" has ${list.length} hashes, but \"${first}\" has ${hashes[first]!.length}.`);\n const key = JSON.stringify(list);\n const members = byList.get(key);\n if (members) members.push(id);\n else byList.set(key, [id]);\n }\n const groups = [...byList.values()].map((members): OutputGroup => {\n const sorted = [...members].sort();\n return { id: sorted[0]!, members: sorted };\n });\n return groups.sort((a, b) => (a.id < b.id ? -1 : a.id > b.id ? 1 : 0));\n}\n\n/** The evidence that a candidate is exercised on its decision inputs. */\nexport interface ExerciseEvidence {\n /** The move counts of the candidate, by name. A record keeps each one as the trace measure `move.<name>`. */\n readonly moves?: Readonly<Record<string, number>>;\n /** The output hashes of the candidate, in the order of the decision inputs. */\n readonly hashes?: readonly string[];\n /** The output hashes of the base of the candidate, in the same order. */\n readonly baseHashes?: readonly string[];\n}\n\n/**\n * This function tells if a candidate is exercised. It gives `true` when a move count is more than 0.\n * It also gives `true` when `hashes` and `baseHashes` are different at one place or more.\n * Without evidence, it gives `false`.\n * The function throws a `RangeError` when only one of the two lists is given, or when their lengths are different.\n */\nexport function exercised(evidence: ExerciseEvidence): boolean {\n const { moves, hashes, baseHashes } = evidence;\n if ((hashes === undefined) !== (baseHashes === undefined)) throw new RangeError(\"The evidence must have both hashes and baseHashes, or neither of them.\");\n if (hashes && baseHashes && hashes.length !== baseHashes.length)\n throw new RangeError(`The candidate has ${hashes.length} hashes, but its base has ${baseHashes.length}.`);\n if (moves && Object.values(moves).some((n) => n > 0)) return true;\n if (hashes && baseHashes) return hashes.some((h, i) => h !== baseHashes[i]);\n return false;\n}\n","import { outputHash } from \"./hash.ts\";\nimport { compareMeasure, type MeasureSpec } from \"./measures.ts\";\n\n/** The part of a `MeasureSpec` that a pick uses: the direction and the `minEffect`. */\nexport type PickSpec = Pick<MeasureSpec, \"direction\" | \"minEffect\">;\n\n/** A member of a portfolio: a function with an id. A portfolio is also a member. */\nexport interface Member<I, O> {\n readonly id: string;\n /** This function gives the output of the member for an input. */\n run(input: I): O;\n}\n\n/** One level of the key of a portfolio: a measure of an output. */\nexport interface PortfolioLevel<I, O> {\n /** The id of the level. The id `hard` is reserved. */\n readonly id: string;\n readonly spec: PickSpec;\n /** This function gives the value of the measure for the output of a member. The value must be finite. */\n value(input: I, output: O): number;\n}\n\n/** The key of a portfolio: the hard level, then the other levels in order. */\nexport interface PortfolioKey<I, O> {\n /** This function gives the count of hard breaks. It is level 0, with the direction `lower` and the `minEffect` 0. */\n hard(input: I, output: O): number;\n /** The levels after the hard level, in the order of the pick. */\n readonly levels: readonly PortfolioLevel<I, O>[];\n /** This function gives the hash of an output. The default is `outputHash` with the default grid. */\n hash?(output: O): string;\n}\n\n/** The options of a portfolio. */\nexport interface PortfolioOptions {\n /** The time limit in milliseconds, 0 or more. The first member always starts. A member that starts always finishes. */\n readonly budgetMs?: number;\n /** The largest count of members that run, a whole number of 1 or more. The other members are cut. */\n readonly maxMembers?: number;\n /** The clock in milliseconds. The default is `performance.now`, or `Date.now` without `performance`. */\n readonly now?: () => number;\n /**\n * The members that get an output hash. The default `all` hashes each member with the status `ran`. A hash that throws then gives the status `error`.\n * With `pick`, only member 0 and the winner get a hash, and only when the winner is not member 0. Then a hash that throws makes `pick` throw.\n */\n readonly hashes?: \"all\" | \"pick\";\n}\n\n/** The status of a member in a pick. */\nexport type MemberStatus = \"ran\" | \"cut\" | \"error\";\n\n/** The trace of one member in a pick. */\nexport interface MemberTrace {\n readonly id: string;\n readonly status: MemberStatus;\n /** The value of each level, with the key `hard` for the hard level. Only a member with the status `ran` has values. */\n readonly values?: Readonly<Record<string, number>>;\n /** The time of the run of the member, in milliseconds. */\n readonly ms?: number;\n /**\n * The hash of the output of the member. Under the option `hashes` \"all\" (the default), each member with the status `ran` has it.\n * Under `hashes` \"pick\", it is absent, except for member 0 and the winner when the winner is not member 0.\n */\n readonly outputHash?: string;\n /** The message of the error of a member with the status `error`. */\n readonly error?: string;\n}\n\n/** The trace of one pick of a portfolio. */\nexport interface PortfolioTrace {\n /** One entry for each member, in the order of the members. A cut member is also in the list. */\n readonly members: readonly MemberTrace[];\n readonly winner: string;\n /** The index of the winner in the list of the members. */\n readonly winnerIndex: number;\n /** The value `true` tells that the winner is not member 0 and has a different output hash. */\n readonly picked: boolean;\n /** The time of the full pick, in milliseconds. */\n readonly totalMs: number;\n readonly budgetMs?: number;\n readonly maxMembers?: number;\n /** The count of the cut members. */\n readonly cut: number;\n /** The value `false` tells that the time limit cut one member or more. Then a run on a different computer can give a different pick. */\n readonly deterministic: boolean;\n /** The ids of the members that stay in after each level of `selectBest`. The first list is for the hard level. */\n readonly kept: readonly (readonly string[])[];\n}\n\n/** The result of one pick of a portfolio: the output of the winner, its id and the trace. */\nexport interface PortfolioPick<O> {\n readonly output: O;\n readonly winner: string;\n readonly trace: PortfolioTrace;\n}\n\n/** A portfolio: a member that runs its members and gives the output of the best member. */\nexport interface Portfolio<I, O> extends Member<I, O> {\n /** This function starts the members on an input and gives the output of the winner with the trace. */\n pick(input: I): PortfolioPick<O>;\n}\n\n/** A candidate of `selectBest`: an id and the value of each level. */\nexport interface SelectCandidate {\n readonly id: string;\n readonly values: Readonly<Record<string, number>>;\n}\n\n/** A level of `selectBest`: the id of a value and its spec. */\nexport interface SelectLevel {\n readonly id: string;\n readonly spec: PickSpec;\n}\n\n/** The result of `selectBest`. */\nexport interface Selection {\n readonly winner: string;\n /** The ids of the candidates that stay in after each level, in the given order. */\n readonly kept: readonly (readonly string[])[];\n}\n\n/**\n * This function picks the best candidate. For each level, it finds the best value of the candidates that stay in.\n * It keeps each candidate that is not worse than that best value by `compareMeasure`.\n * The winner is the first candidate, in the given order, that stays in after the last level.\n * Without levels, the winner is the first candidate and `kept` is empty.\n *\n * The reason for the rule: a scan that compares each candidate with the current winner is not transitive, because of the `minEffect` ties.\n * Such a scan can drift away from the best value. An example: \"a\" is lower with the `minEffect` 0.005, and \"b\" is higher.\n * The candidates A (0, 1), B (0.004, 2) and C (0.008, 3) give the winner B.\n * The scan picks C, but A is better than C on \"a\".\n *\n * The function throws a `RangeError` for an empty list of candidates, for a missing value, and for a value that is not finite.\n */\nexport function selectBest(candidates: readonly SelectCandidate[], levels: readonly SelectLevel[]): Selection {\n if (candidates.length === 0) throw new RangeError(\"selectBest: the list of candidates is empty.\");\n for (const level of levels) {\n for (const c of candidates) {\n const v = c.values[level.id];\n if (typeof v !== \"number\") throw new RangeError(`selectBest: the candidate \"${c.id}\" has no value for the level \"${level.id}\".`);\n if (!Number.isFinite(v)) throw new RangeError(`selectBest: the candidate \"${c.id}\" has the value ${v} for the level \"${level.id}\".`);\n }\n }\n let alive: readonly SelectCandidate[] = candidates;\n const kept: (readonly string[])[] = [];\n for (const level of levels) {\n const at = (c: SelectCandidate): number => c.values[level.id]!;\n let best = at(alive[0]!);\n for (const c of alive) best = level.spec.direction === \"lower\" ? Math.min(best, at(c)) : Math.max(best, at(c));\n alive = alive.filter((c) => compareMeasure(at(c), best, level.spec) !== \"worse\");\n kept.push(alive.map((c) => c.id));\n }\n return { winner: alive[0]!.id, kept };\n}\n\n/** This function gives the move `pick` of a pick: 1 when `picked` is true, else 0. A record keeps it as the trace measure `move.pick`. */\nexport function pickMoves(trace: Pick<PortfolioTrace, \"picked\">): { pick: number } {\n return { pick: trace.picked ? 1 : 0 };\n}\n\n/** This function gives the default clock: `performance.now`, or `Date.now` without `performance`. */\nfunction defaultClock(): () => number {\n const perf = (globalThis as { readonly performance?: { now(): number } }).performance;\n return perf ? () => perf.now() : () => Date.now();\n}\n\n/** This function gives the message of an error value. */\nfunction messageOf(e: unknown): string {\n return e instanceof Error ? e.message : String(e);\n}\n\n/** This function throws a `RangeError` for an empty list of members or for two members with the same id. */\nfunction checkMembers(id: string, members: readonly Member<unknown, unknown>[]): void {\n if (members.length === 0) throw new RangeError(`The portfolio \"${id}\" has no members.`);\n const seen = new Set<string>();\n for (const m of members) {\n if (seen.has(m.id)) throw new RangeError(`The portfolio \"${id}\" has two members with the id \"${m.id}\".`);\n seen.add(m.id);\n }\n}\n\n/** The result of the run of one member. */\ntype Ran<O> = { readonly ok: true; readonly output: O; readonly values: Record<string, number>; readonly hash?: string } | { readonly ok: false; readonly error: unknown };\n\n/**\n * This function makes a portfolio. Its `pick` starts the members in their order. `selectBest` picks the winner of the members with the status `ran`.\n * The first level is the hard level, then the levels of the key follow.\n * `members` is a list, or a function of the input that gives the list.\n *\n * A member that throws, or that gives a value that is not finite, gets the status `error`. It does not win.\n * When each member has an error, `pick` throws the error of the first member.\n * `docs/PORTFOLIO.md` tells the rules of the time limit, the trace and `picked`.\n *\n * The function throws a `RangeError` for a level with the id `hard`, for two levels with the same id and for a bad option.\n * It also throws a `RangeError` for an empty list of members, or for two members with the same id.\n */\nexport function portfolio<I, O>(\n id: string,\n members: readonly Member<I, O>[] | ((input: I) => readonly Member<I, O>[]),\n key: PortfolioKey<I, O>,\n options: PortfolioOptions = {},\n): Portfolio<I, O> {\n const levelIds = new Set<string>();\n for (const level of key.levels) {\n if (level.id === \"hard\") throw new RangeError(`The portfolio \"${id}\" has a level with the reserved id \"hard\".`);\n if (levelIds.has(level.id)) throw new RangeError(`The portfolio \"${id}\" has two levels with the id \"${level.id}\".`);\n levelIds.add(level.id);\n }\n const { budgetMs, maxMembers, hashes = \"all\" } = options;\n if (budgetMs !== undefined && !(budgetMs >= 0)) throw new RangeError(`The portfolio \"${id}\" has the budgetMs ${budgetMs}. It must be 0 or more.`);\n if (maxMembers !== undefined && !(Number.isInteger(maxMembers) && maxMembers >= 1))\n throw new RangeError(`The portfolio \"${id}\" has the maxMembers ${maxMembers}. It must be a whole number of 1 or more.`);\n if (hashes !== \"all\" && hashes !== \"pick\") throw new RangeError(`The portfolio \"${id}\" has the hashes ${String(hashes)}. It must be \"all\" or \"pick\".`);\n if (typeof members !== \"function\") checkMembers(id, members);\n const levels: readonly SelectLevel[] = [{ id: \"hard\", spec: { direction: \"lower\", minEffect: 0 } }, ...key.levels.map((l) => ({ id: l.id, spec: l.spec }))];\n const now = options.now ?? defaultClock();\n\n /** This function gives the hash of the output of a member. A hash that throws causes a `RangeError`. */\n const hashOf = (m: Member<I, O>, output: O): string => {\n try {\n return key.hash ? key.hash(output) : outputHash(output);\n } catch (e) {\n throw new RangeError(`The hash of the member \"${m.id}\" of the portfolio \"${id}\" throws: ${messageOf(e)}`, { cause: e });\n }\n };\n\n const evaluate = (m: Member<I, O>, input: I, output: O): Ran<O> => {\n const values: Record<string, number> = {};\n const measure = (level: string, f: () => number): void => {\n let v: number;\n try {\n v = f();\n } catch (e) {\n throw new RangeError(`The level \"${level}\" of the member \"${m.id}\" of the portfolio \"${id}\" throws: ${messageOf(e)}`, { cause: e });\n }\n if (typeof v !== \"number\" || !Number.isFinite(v))\n throw new RangeError(`The member \"${m.id}\" of the portfolio \"${id}\" has the value ${v} for the level \"${level}\".`);\n values[level] = v;\n };\n try {\n measure(\"hard\", () => key.hard(input, output));\n for (const level of key.levels) measure(level.id, () => level.value(input, output));\n if (hashes === \"pick\") return { ok: true, output, values };\n return { ok: true, output, values, hash: hashOf(m, output) };\n } catch (e) {\n return { ok: false, error: e };\n }\n };\n\n const pick = (input: I): PortfolioPick<O> => {\n const list = typeof members === \"function\" ? members(input) : members;\n if (typeof members === \"function\") checkMembers(id, list);\n const start = now();\n const traces: MemberTrace[] = [];\n const outputs = new Map<string, O>();\n const ran: SelectCandidate[] = [];\n let firstError: { readonly error: unknown } | undefined;\n let cut = 0;\n let outOfTime = false;\n for (let i = 0; i < list.length; i++) {\n const m = list[i]!;\n if (maxMembers !== undefined && i >= maxMembers) {\n traces.push({ id: m.id, status: \"cut\" });\n cut++;\n continue;\n }\n if (i > 0 && budgetMs !== undefined && (outOfTime || now() - start >= budgetMs)) {\n outOfTime = true;\n traces.push({ id: m.id, status: \"cut\" });\n cut++;\n continue;\n }\n const t0 = now();\n let result: Ran<O>;\n let ms: number;\n try {\n const output = m.run(input);\n ms = now() - t0;\n result = evaluate(m, input, output);\n } catch (e) {\n ms = now() - t0;\n result = { ok: false, error: e };\n }\n if (result.ok) {\n traces.push(\n result.hash === undefined\n ? { id: m.id, status: \"ran\", values: result.values, ms }\n : { id: m.id, status: \"ran\", values: result.values, ms, outputHash: result.hash },\n );\n outputs.set(m.id, result.output);\n ran.push({ id: m.id, values: result.values });\n } else {\n traces.push({ id: m.id, status: \"error\", ms, error: messageOf(result.error) });\n firstError ??= { error: result.error };\n }\n }\n if (ran.length === 0) throw firstError!.error;\n const { winner, kept } = selectBest(ran, levels);\n const winnerIndex = traces.findIndex((t) => t.id === winner);\n if (hashes === \"pick\" && winnerIndex > 0 && traces[0]!.status === \"ran\") {\n // Only member 0 and the winner get a hash. Their two trace entries are new objects with the hash.\n for (const i of [0, winnerIndex]) traces[i] = { ...traces[i]!, outputHash: hashOf(list[i]!, outputs.get(traces[i]!.id)!) };\n }\n const base = traces[0]!;\n const picked = winnerIndex > 0 && (base.status !== \"ran\" || traces[winnerIndex]!.outputHash !== base.outputHash);\n const trace: PortfolioTrace = {\n members: traces,\n winner,\n winnerIndex,\n picked,\n totalMs: now() - start,\n ...(budgetMs !== undefined ? { budgetMs } : {}),\n ...(maxMembers !== undefined ? { maxMembers } : {}),\n cut,\n deterministic: !outOfTime,\n kept,\n };\n return { output: outputs.get(winner)!, winner, trace };\n };\n\n return { id, pick, run: (input: I): O => pick(input).output };\n}\n","// The checks of the claims of a corpus (`docs/CORPUS-CHECKS.md`). The joint corpus, `packing` and `highways` use the same checks.\nimport { canonicalJson, sha256Hex } from \"./hash.ts\";\n\n/** One broken claim of a corpus, with the ids of the inputs that break it. */\nexport interface ClaimBreak {\n /** The name of the claim, for example `declared`, `split` or `index`. */\n readonly claim: string;\n /** The text of the break. */\n readonly detail: string;\n /** The ids of the inputs that break the claim. The list is empty when the break has no input. */\n readonly inputs: readonly string[];\n}\n\n/** The claim `claims.declared` of a manifest: the count of the inputs for each declared property. */\nexport interface DeclaredClaim {\n /** A property with fewer inputs than this count is thin. */\n readonly minCount: number;\n /** The ids of the properties with a count below `minCount`. */\n readonly thin: readonly string[];\n /** The count of the inputs for each property id. */\n readonly counts: Readonly<Record<string, number>>;\n}\n\n/** The hook that gives the ids of the properties that one input declares. */\nexport type Declares<I> = (input: I) => readonly string[];\n\n/**\n * This function gives the count of the inputs for each property id. Each id of `ids` has a count, also when the count is 0.\n * An id from `declares` that is not in `ids` comes after the ids of `ids`, in the order of the first input that declares it.\n */\nexport function declaredCounts<I>(inputs: Iterable<I>, declares: Declares<I>, ids: readonly string[] = []): Record<string, number> {\n const out: Record<string, number> = Object.fromEntries(ids.map((id) => [id, 0]));\n for (const input of inputs) for (const id of declares(input)) out[id] = (out[id] ?? 0) + 1;\n return out;\n}\n\n/** This function tells if a value is a plain object. */\nconst isObject = (value: unknown): value is Record<string, unknown> => value !== null && typeof value === \"object\" && !Array.isArray(value);\n\n/**\n * This function reads the field `claims.declared` of a manifest. A manifest without it gives `undefined`.\n * It throws an `Error` for a claim without a whole `minCount`, a list `thin` of ids and a whole count for each id.\n */\nexport function declaredClaimOf(manifest: object): DeclaredClaim | undefined {\n const claims = (manifest as Record<string, unknown>)[\"claims\"];\n if (claims === undefined) return undefined;\n if (!isObject(claims)) throw new Error(\"The field claims of a corpus file is an object.\");\n const declared = claims[\"declared\"];\n if (declared === undefined) return undefined;\n if (!isObject(declared)) throw new Error(\"The field claims.declared of a corpus file is an object.\");\n const { minCount, thin, counts } = declared;\n if (!Number.isInteger(minCount) || (minCount as number) < 0) throw new Error(\"The field claims.declared.minCount is a whole number of 0 or more.\");\n if (!Array.isArray(thin) || !thin.every((id) => typeof id === \"string\")) throw new Error(\"The field claims.declared.thin is a list of property ids.\");\n if (!isObject(counts) || !Object.values(counts).every((n) => Number.isInteger(n) && (n as number) >= 0)) {\n throw new Error(\"The field claims.declared.counts gives a whole count for each property id.\");\n }\n return { minCount: minCount as number, thin: [...(thin as string[])], counts: { ...(counts as Record<string, number>) } };\n}\n\n/**\n * This function checks the claim `claims.declared` against the inputs. It gives one break `declared` for each problem. An empty list tells that the claim is true.\n *\n * - `ids` are the property ids. The default is the ids of `claim.counts`.\n * - Each id of `ids` has a count in `claim.counts`, and `claim.counts` has no other id. Each count is the count of the inputs.\n * - An id with a count below `minCount` is in `thin`. Each id of `thin` is an id of `ids`.\n * - Each id that `declares` gives is an id of `ids`.\n */\nexport function checkDeclared<I>(inputs: Iterable<I>, declares: Declares<I>, claim: DeclaredClaim, ids: readonly string[] = Object.keys(claim.counts)): ClaimBreak[] {\n const computed = declaredCounts(inputs, declares, ids);\n const out: string[] = [];\n for (const id of ids) {\n if (!(id in claim.counts)) out.push(`the property \"${id}\" has no count`);\n else if (claim.counts[id] !== computed[id]) out.push(`the property \"${id}\" has the count ${claim.counts[id]}, but the inputs give ${computed[id]}`);\n }\n for (const id of Object.keys(claim.counts)) if (!ids.includes(id)) out.push(`\"${id}\" is not a declared property`);\n for (const id of ids) {\n const thin = (computed[id] ?? 0) < claim.minCount;\n if (thin && !claim.thin.includes(id)) out.push(`the property \"${id}\" has ${computed[id]} inputs, below minCount ${claim.minCount}, and it is not in thin`);\n }\n for (const id of claim.thin) if (!ids.includes(id)) out.push(`\"${id}\" of thin is not a declared property`);\n for (const id of Object.keys(computed)) if (!ids.includes(id)) out.push(`${computed[id]} inputs declare \"${id}\", which is not a declared property`);\n return out.map((detail) => ({ claim: \"declared\", detail, inputs: [] }));\n}\n\n/** The id and the hash of one input of a corpus. */\nexport interface CorpusEntry {\n readonly id: string;\n readonly hash: string;\n}\n\n/**\n * This function gives the hash of a corpus: the first 16 hex characters of a SHA-256. The text of the SHA-256 is `canonicalJson`\n * of the corpus id and the `[id, hash]` of each input, in the order of the manifest. A change of one input changes the hash.\n */\nexport function corpusHashOf(corpus: string, inputs: readonly CorpusEntry[]): string {\n return sha256Hex(canonicalJson({ corpus, inputs: inputs.map((i) => [i.id, i.hash]) })).slice(0, 16);\n}\n\n/** The schema of a split file. */\nexport const SPLIT_SCHEMA = \"corpus-split/1\";\n\n/** One fold of a split: the seeds that fit a selector and the seeds that score it. */\nexport interface SplitFold {\n readonly train: readonly number[];\n readonly heldOut: readonly number[];\n}\n\n/** A split file `corpus-split/1`. Its name is `<corpus id>.<corpus hash>.json`. It is beside the corpus, so the corpus does not change. */\nexport interface CorpusSplit {\n readonly schema: typeof SPLIT_SCHEMA;\n readonly corpus: string;\n /** The hash of the corpus: `corpusHashOf` of its manifest. */\n readonly corpusHash: string;\n /** The splits by name. Each split has one fold or more. */\n readonly splits: Readonly<Record<string, { readonly folds: readonly SplitFold[] }>>;\n}\n\n/** The fields of a manifest that the split check reads. */\nexport interface SplitCorpus {\n readonly corpus: string;\n readonly specs: readonly { readonly seeds: readonly number[] }[];\n readonly inputs: readonly CorpusEntry[];\n}\n\n/** This function gives the name of the split file of a corpus. */\nexport function splitFileName(corpus: string, hash: string): string {\n return `${corpus}.${hash}.json`;\n}\n\n/** This function tells if a value is a list of whole numbers. */\nconst isSeeds = (value: unknown): value is number[] => Array.isArray(value) && value.every((s) => Number.isInteger(s));\n\n/**\n * This function checks a split file against a manifest. It gives one break `split` for each problem. An empty list tells that the file is good.\n *\n * - The schema is `corpus-split/1`, the corpus is the id of the manifest and `corpusHash` is `corpusHashOf` of the manifest.\n * - Each split has one fold or more. In each fold, `train` and `heldOut` are lists of seeds, not empty and with no common seed.\n * - Each seed is a seed of a spec of the manifest.\n * - With `name`, the file has the split `name`.\n */\nexport function checkSplit(split: unknown, corpus: SplitCorpus, name?: string): ClaimBreak[] {\n const out: string[] = [];\n const done = (): ClaimBreak[] => out.map((detail) => ({ claim: \"split\", detail, inputs: [] }));\n const f = split as Partial<CorpusSplit> | null;\n if (f === null || typeof f !== \"object\") {\n out.push(\"the split file is not an object\");\n return done();\n }\n if (f.schema !== SPLIT_SCHEMA) out.push(`the schema is ${String(f.schema)}, not ${SPLIT_SCHEMA}`);\n if (f.corpus !== corpus.corpus) out.push(`the corpus is ${String(f.corpus)}, not ${corpus.corpus}`);\n const hash = corpusHashOf(corpus.corpus, corpus.inputs);\n if (f.corpusHash !== hash) out.push(`the corpusHash is ${String(f.corpusHash)}, but the corpus gives ${hash}`);\n const seeds = new Set(corpus.specs.flatMap((s) => s.seeds));\n if (f.splits === null || typeof f.splits !== \"object\") {\n out.push(\"the field splits is not an object\");\n return done();\n }\n for (const [key, value] of Object.entries(f.splits)) {\n const folds = (value as { folds?: unknown } | null)?.folds;\n if (!Array.isArray(folds) || folds.length === 0) {\n out.push(`the split ${key} has no folds`);\n continue;\n }\n folds.forEach((fold: Partial<SplitFold> | null, k) => {\n const at = `the fold ${k} of the split ${key}`;\n const { train, heldOut } = fold ?? {};\n if (!isSeeds(train) || train.length === 0) out.push(`${at} has no train seeds`);\n if (!isSeeds(heldOut) || heldOut.length === 0) out.push(`${at} has no heldOut seeds`);\n if (!isSeeds(train) || !isSeeds(heldOut)) return;\n const common = train.filter((s) => heldOut.includes(s));\n if (common.length > 0) out.push(`${at} has the seeds ${common.join(\", \")} in train and in heldOut`);\n const unknown = [...train, ...heldOut].filter((s) => !seeds.has(s));\n if (unknown.length > 0) out.push(`${at} has the seeds ${unknown.join(\", \")}, which are not in the corpus`);\n });\n }\n if (name !== undefined && !Object.hasOwn(f.splits, name)) out.push(`the split file has no split ${name}. Its splits are ${Object.keys(f.splits).join(\", \")}`);\n return done();\n}\n\n/**\n * This function gives a copy of the folds of the split `name` of a split file. `where` names the file in the text of an error.\n * It throws an `Error` for each problem of `checkSplit`, and then for an unknown split name.\n */\nexport function splitFolds(split: unknown, corpus: SplitCorpus, name: string, where: string = \"The split file\"): SplitFold[] {\n const breaks = checkSplit(split, corpus);\n if (breaks.length > 0) throw new Error(`${where} is not good: ${breaks.map((b) => b.detail).join(\"; \")}.`);\n const splits = (split as CorpusSplit).splits;\n const found = Object.hasOwn(splits, name) ? splits[name] : undefined;\n if (found === undefined) throw new Error(`${where} has no split ${name}. Its splits are ${Object.keys(splits).join(\", \")}.`);\n return found.folds.map((f) => ({ train: [...f.train], heldOut: [...f.heldOut] }));\n}\n\n/** This function gives the folds that hold out one seed each, in the order of the seeds. Each fold trains on the other seeds. */\nexport function leaveOneSeedOut(seeds: readonly number[]): SplitFold[] {\n const sorted = [...new Set(seeds)].sort((a, b) => a - b);\n return sorted.map((s) => ({ train: sorted.filter((t) => t !== s), heldOut: [s] }));\n}\n","// The strategy space of an engine (`docs/STRATEGY-SPACE.md`): its stages, their options and the ranges of their params, as data.\nimport type { ClaimBreak } from \"./corpus.ts\";\nimport { canonicalJson, sha256Hex } from \"./hash.ts\";\nimport { stepRandom } from \"./random.ts\";\n\n/** The schema of a strategy space. */\nexport const STRATEGY_SPACE_SCHEMA = \"strategy-space/1\";\n\n/** The kind of a param: a whole number, a real number, one value of a list, or `true` and `false`. */\nexport type ParamKind = \"int\" | \"real\" | \"enum\" | \"bool\";\n\n/** The value of one param in a config. */\nexport type ParamValue = number | string | boolean;\n\n/** The condition of a conditional param: the param is active only when an earlier param of the same option has one of the values `in`. */\nexport interface ParamWhen {\n /** The name of an earlier param of the same option. */\n readonly param: string;\n /** The values of that param that make this param active. */\n readonly in: readonly ParamValue[];\n}\n\n/** One param of a stage option, with its range. */\nexport interface SpaceParam {\n readonly name: string;\n readonly kind: ParamKind;\n /** The smallest value of an `int` or `real` param. */\n readonly min?: number;\n /** The largest value of an `int` or `real` param. */\n readonly max?: number;\n /** The step of the values from `min`. An `int` param has the step 1 by default. */\n readonly step?: number;\n /** The scale of the grid and of the samples. The scale `log` needs a `min` above 0. The default is `linear`. */\n readonly scale?: \"linear\" | \"log\";\n /** The values of an `enum` param. */\n readonly values?: readonly (string | number)[];\n /** The value that a config gets when it does not set the param. */\n readonly default: ParamValue;\n /** Without `when`, the param is active each time its option is chosen. */\n readonly when?: ParamWhen;\n}\n\n/** The rule of the members of a meta option: a count from `min` to `max`. Members with `ordered: false` are sorted by their `configId`. */\nexport interface MemberRule {\n readonly min: number;\n readonly max: number;\n readonly ordered: boolean;\n}\n\n/** One implementation of a stage. An option with `members` is a meta option: it chooses between whole configs, or wraps them. */\nexport interface StageOption {\n readonly id: string;\n readonly params: readonly SpaceParam[];\n readonly members?: MemberRule;\n}\n\n/** One stage of the pipeline of an engine. A config of an `optional` stage can have no option. */\nexport interface SpaceStage {\n readonly name: string;\n readonly options: readonly StageOption[];\n readonly optional?: boolean;\n}\n\n/** A reference to one option of a stage. The option `null` refers to an optional stage that a config does not use. */\nexport interface OptionRef {\n readonly stage: string;\n readonly option: string | null;\n}\n\n/** A rule that keeps out invalid combinations. A config with the option `if` also has the option `then`, or does not have the option `then.not`. */\nexport interface SpaceConstraint {\n readonly if: OptionRef;\n readonly then: OptionRef | { readonly not: OptionRef };\n}\n\n/** The strategy space of an engine: the stages, the constraints and the named configs. `docs/STRATEGY-SPACE.md` tells the rules. */\nexport interface StrategySpace {\n readonly schema: typeof STRATEGY_SPACE_SCHEMA;\n /** The name of the space. A config names the space with this value. */\n readonly engine: string;\n /** The version of the space. It is not part of a config or of its id. A record writes it. */\n readonly version: string;\n readonly stages: readonly SpaceStage[];\n readonly constraints?: readonly SpaceConstraint[];\n /** The named strategies of the engine, as points of the space. Old records stay comparable through them. */\n readonly named?: Readonly<Record<string, StrategyConfig>>;\n /** The spaces of a product space, from `productSpace`. A meta option of a part takes members of that part. */\n readonly parts?: readonly StrategySpace[];\n}\n\n/** The choice of one stage in a config: an option, its params and, for a meta option, its members. */\nexport interface StageChoice {\n readonly option: string;\n /** The values of the active params. A param that is not set gets its default. */\n readonly params?: Readonly<Record<string, ParamValue>>;\n /** The members of a meta option: configs of the same space, with no meta option. */\n readonly members?: readonly StrategyConfig[];\n}\n\n/** One point of a strategy space. The value `null` of a stage tells that the config does not use the optional stage. */\nexport interface StrategyConfig {\n /** The `engine` of the space, without its version. */\n readonly space: string;\n readonly stages: Readonly<Record<string, StageChoice | null>>;\n}\n\n/** The count of the grid points of a space. */\nexport interface SpaceSize {\n /** The count of the configs without a meta option. */\n readonly base: bigint;\n /** The count of the configs with a meta option. The value is `null` when the count is more than `maxMeta`. */\n readonly meta: bigint | null;\n}\n\n/** The options of `spaceSize`. */\nexport interface SpaceSizeOptions {\n /** The count of the levels of each numeric param, a whole number of 1 or more. */\n readonly levels: number;\n /** The largest meta count that `spaceSize` gives. The default is `10n ** 18n`. */\n readonly maxMeta?: bigint;\n}\n\n/** The options of a grid. The grid gives only the configs without a meta option. */\nexport interface GridOptions {\n readonly mode: \"grid\";\n readonly levels: number;\n /** The largest count of configs. A larger grid causes a `RangeError`. The default is 100000. */\n readonly limit?: number;\n}\n\n/** The options of a sample. */\nexport interface SampleOptions {\n readonly mode: \"sample\";\n /** The count of the configs, a whole number of 0 or more. */\n readonly n: number;\n readonly seed: number;\n /** With `skip` (the default), the sample has no meta option. With `sample`, a meta option draws its members from base samples. */\n readonly meta?: \"skip\" | \"sample\";\n /** The largest count of option draws. The default is the larger value of 1000 and `100 * n`. */\n readonly maxTries?: number;\n}\n\n/** The options of `enumerateSpace`. */\nexport type EnumerateOptions = GridOptions | SampleOptions;\n\ntype Problem = readonly [claim: string, detail: string];\ntype Choices = ReadonlyMap<string, StageOption | null>;\ntype Values = Record<string, ParamValue>;\n\nconst isObject = (value: unknown): value is Record<string, unknown> => value !== null && typeof value === \"object\" && !Array.isArray(value);\nconst show = (value: unknown): string => (typeof value === \"string\" ? `\"${value}\"` : String(value));\nconst isNumeric = (p: SpaceParam): boolean => p.kind === \"int\" || p.kind === \"real\";\nconst zero = (v: number): number => (v === 0 ? 0 : v);\n\n/** This function gives the stable form of a real number: 12 significant digits, with `-0` as `0`. */\nconst realForm = (v: number, digits = 12): number => zero(Number(v.toPrecision(digits)));\n\n/** This function gives the stable form of a value of a param. */\nfunction normalize(p: SpaceParam, v: ParamValue): ParamValue {\n if (typeof v !== \"number\") return v;\n if (p.kind !== \"real\") return zero(v);\n return Math.min(p.max ?? Infinity, Math.max(p.min ?? -Infinity, realForm(v)));\n}\n\n/** This function tells if a value is on the step of a param. */\nfunction onStep(p: SpaceParam, v: number): boolean {\n if (p.step === undefined || p.min === undefined) return true;\n const q = (v - p.min) / p.step;\n return Math.abs(q - Math.round(q)) <= 1e-9 * Math.max(1, Math.abs(q));\n}\n\n/** This function gives the problem of a value of a param, or `undefined` for a value in the range. */\nfunction valueProblem(p: SpaceParam, v: unknown): string | undefined {\n if (p.kind === \"bool\") return typeof v === \"boolean\" ? undefined : `${show(v)} is not true or false`;\n if (p.kind === \"enum\") return (p.values ?? []).some((x) => x === v) ? undefined : `${show(v)} is not one of ${(p.values ?? []).map(show).join(\", \")}`;\n if (typeof v !== \"number\" || !Number.isFinite(v)) return `${show(v)} is not a finite number`;\n if (p.kind === \"int\" && !Number.isInteger(v)) return `${v} is not a whole number`;\n if (p.min !== undefined && v < p.min) return `${v} is less than the min ${p.min}`;\n if (p.max !== undefined && v > p.max) return `${v} is more than the max ${p.max}`;\n if (!onStep(p, v)) return `${v} is not on the step ${p.step} from ${p.min}`;\n return undefined;\n}\n\n/** This function tells if a param is active for the values of the earlier params. */\nfunction isActive(p: SpaceParam, values: Values): boolean {\n if (p.when === undefined) return true;\n if (!Object.hasOwn(values, p.when.param)) return false;\n const v = values[p.when.param];\n return p.when.in.some((x) => x === v);\n}\n\n/** This function gives the part of a space that has a stage, and the prefix of the names of its stages. */\nfunction partOf(space: StrategySpace, stage: string): { readonly space: StrategySpace; readonly prefix: string } {\n for (const part of space.parts ?? []) {\n const head = `${part.engine}.`;\n if (stage.startsWith(head)) {\n const inner = partOf(part, stage.slice(head.length));\n return { space: inner.space, prefix: head + inner.prefix };\n }\n }\n return { space, prefix: \"\" };\n}\n\n/** This function gives the prefix of the innermost part of each stage. */\nconst prefixes = (space: StrategySpace): Map<string, string> => new Map(space.stages.map((s) => [s.name, partOf(space, s.name).prefix]));\n\nconst refMatches = (ref: OptionRef, choices: ReadonlyMap<string, string | null>): boolean => (choices.get(ref.stage) ?? null) === ref.option;\n\n/** This function tells if the option choices keep a constraint. */\nfunction holds(c: SpaceConstraint, choices: ReadonlyMap<string, string | null>): boolean {\n if (!refMatches(c.if, choices)) return true;\n return \"not\" in c.then ? !refMatches(c.then.not, choices) : refMatches(c.then, choices);\n}\n\nconst describe = (c: SpaceConstraint): string => {\n const ref = (r: OptionRef): string => `${r.stage}=${r.option ?? \"null\"}`;\n return \"not\" in c.then ? `if ${ref(c.if)} then not ${ref(c.then.not)}` : `if ${ref(c.if)} then ${ref(c.then)}`;\n};\n\n/** This function gives the problems of the range and the default of one param. */\nfunction paramProblems(p: SpaceParam, at: string): Problem[] {\n const out: Problem[] = [];\n if (isNumeric(p)) {\n const { min, max, step } = p;\n if (typeof min !== \"number\" || typeof max !== \"number\" || !Number.isFinite(min) || !Number.isFinite(max)) {\n out.push([\"range\", `${at} has no finite min and max`]);\n return out;\n }\n if (min > max) out.push([\"range\", `${at} has an empty range: the min ${min} is more than the max ${max}`]);\n if (p.kind === \"int\" && (!Number.isInteger(min) || !Number.isInteger(max))) out.push([\"range\", `${at} is an int with a min or a max that is not whole`]);\n if (step !== undefined && (!Number.isFinite(step) || step <= 0 || (p.kind === \"int\" && !Number.isInteger(step))))\n out.push([\"range\", `${at} has the step ${step}, which is not a ${p.kind === \"int\" ? \"whole \" : \"\"}number above 0`]);\n if (p.scale === \"log\" && min <= 0) out.push([\"scale\", `${at} has the scale log with the min ${min}, which is not above 0`]);\n } else {\n if (p.scale !== undefined) out.push([\"scale\", `${at} is a ${p.kind} param with a scale`]);\n if (p.kind === \"enum\") {\n if (!Array.isArray(p.values) || p.values.length === 0) out.push([\"values\", `${at} is an enum without values`]);\n else {\n const seen = new Set<unknown>();\n for (const v of p.values) {\n if (seen.has(v)) out.push([\"duplicate\", `${at} has the value ${show(v)} two times`]);\n seen.add(v);\n }\n }\n }\n }\n if (out.length === 0) {\n const problem = valueProblem(p, p.default);\n if (problem !== undefined) out.push([\"default\", `the default of ${at} is not in its range: ${problem}`]);\n }\n return out;\n}\n\n/** This function gives the problems of one stage option. */\nfunction optionProblems(stage: SpaceStage, o: StageOption): Problem[] {\n const out: Problem[] = [];\n const at = `the option ${stage.name}.${o.id}`;\n if (!Array.isArray(o.params)) return [[\"config\", `${at} has no list of params`]];\n const names = o.params.map((p) => p.name);\n o.params.forEach((p, i) => {\n const pat = `the param ${stage.name}.${o.id}.${p.name}`;\n if (names.indexOf(p.name) !== i) out.push([\"duplicate\", `${at} has the param ${p.name} two times`]);\n out.push(...paramProblems(p, pat));\n if (p.when === undefined) return;\n const j = names.indexOf(p.when.param);\n if (j < 0) out.push([\"unknown\", `${pat} has a when with the unknown param ${p.when.param}`]);\n else if (j >= i) out.push([\"when\", `${pat} has a when with the param ${p.when.param}, which does not come before it`]);\n else if (!Array.isArray(p.when.in) || p.when.in.length === 0) out.push([\"when\", `${pat} has a when with no values`]);\n else for (const v of p.when.in) {\n const problem = valueProblem(o.params[j]!, v);\n if (problem !== undefined) out.push([\"when\", `${pat} has a when value that is not a value of ${p.when.param}: ${problem}`]);\n }\n });\n if (o.members !== undefined) {\n const { min, max, ordered } = o.members;\n if (!Number.isInteger(min) || !Number.isInteger(max) || min < 1 || min > max || typeof ordered !== \"boolean\")\n out.push([\"members\", `${at} has a member rule without whole counts 1 <= min <= max and a boolean ordered`]);\n }\n return out;\n}\n\n/** This function gives the problems of the params of one stage choice. */\nfunction choiceParamProblems(o: StageOption, params: unknown, at: string): Problem[] {\n if (params !== undefined && !isObject(params)) return [[\"config\", `the params of ${at} are not an object`]];\n const given = (params ?? {}) as Values;\n const out: Problem[] = [];\n for (const key of Object.keys(given)) if (!o.params.some((p) => p.name === key)) out.push([\"unknown\", `${at} has the unknown param ${key}`]);\n const values: Values = {};\n for (const p of o.params) {\n const has = Object.hasOwn(given, p.name);\n if (!isActive(p, values)) {\n if (has) out.push([\"inactive\", `${at} sets the param ${p.name}, which is not active`]);\n continue;\n }\n const v = has ? given[p.name] : p.default;\n const problem = valueProblem(p, v);\n if (problem !== undefined) out.push([\"param\", `the param ${p.name} of ${at} is not in its range: ${problem}`]);\n else values[p.name] = normalize(p, v as ParamValue);\n }\n return out;\n}\n\n/** This function gives the problems of a config of a space. A member of a meta option has `member: true`. */\nfunction configProblems(space: StrategySpace, config: unknown, member: boolean): Problem[] {\n if (!isObject(config) || !isObject(config[\"stages\"])) return [[\"config\", \"the config is not an object with stages\"]];\n const out: Problem[] = [];\n const stages = config[\"stages\"];\n if (config[\"space\"] !== space.engine) out.push([\"space\", `the space of the config is ${show(config[\"space\"])}, not ${show(space.engine)}`]);\n for (const key of Object.keys(stages)) if (!space.stages.some((s) => s.name === key)) out.push([\"unknown\", `the config has the unknown stage ${key}`]);\n const optionOf = (s: SpaceStage): StageOption | undefined => {\n const c = stages[s.name];\n return isObject(c) ? s.options.find((o) => o.id === c[\"option\"]) : undefined;\n };\n const prefix = prefixes(space);\n const metaStage = new Map<string, string>();\n for (const s of space.stages) {\n if (optionOf(s)?.members === undefined) continue;\n const p = prefix.get(s.name)!;\n if (metaStage.has(p)) out.push([\"meta\", `the stages ${metaStage.get(p)} and ${s.name} both have a meta option`]);\n else metaStage.set(p, s.name);\n }\n const chosen = new Map<string, string | null>();\n for (const s of space.stages) {\n const c = Object.hasOwn(stages, s.name) ? stages[s.name] : undefined;\n const meta = metaStage.get(prefix.get(s.name)!);\n chosen.set(s.name, null);\n if (c === undefined || c === null) {\n if (!s.optional && meta === undefined) out.push([\"missing\", `the config has no option for the stage ${s.name}`]);\n continue;\n }\n if (!isObject(c) || typeof c[\"option\"] !== \"string\") {\n out.push([\"config\", `the choice of the stage ${s.name} has no option`]);\n continue;\n }\n const o = s.options.find((x) => x.id === c[\"option\"]);\n if (o === undefined) {\n out.push([\"unknown\", `the stage ${s.name} has no option ${c[\"option\"]}`]);\n continue;\n }\n chosen.set(s.name, o.id);\n const at = `the option ${s.name}.${o.id}`;\n if (meta !== undefined && meta !== s.name) out.push([\"meta\", `the stage ${s.name} is set, but the meta option of ${meta} replaces the other stages of its part`]);\n out.push(...choiceParamProblems(o, c[\"params\"], at));\n if (o.members === undefined) {\n if (c[\"members\"] !== undefined) out.push([\"members\", `${at} is not a meta option, but the config gives members`]);\n continue;\n }\n if (member) {\n out.push([\"depth\", `a member has the meta option ${s.name}.${o.id}. The depth of a meta config is 1`]);\n continue;\n }\n out.push(...memberProblems(partOf(space, s.name).space, o.members, c[\"members\"], at));\n }\n for (const c of space.constraints ?? []) if (!holds(c, chosen)) out.push([\"constraint\", `the config breaks the constraint ${describe(c)}`]);\n return out;\n}\n\n/** This function gives the problems of the members of a meta option. `part` is the space of the members. */\nfunction memberProblems(part: StrategySpace, rule: MemberRule, members: unknown, at: string): Problem[] {\n if (!Array.isArray(members)) return [[\"members\", `${at} is a meta option without a list of members`]];\n const out: Problem[] = [];\n if (members.length < rule.min || members.length > rule.max) out.push([\"members\", `${at} has ${members.length} members, not ${rule.min} to ${rule.max}`]);\n const ids = new Map<string, number>();\n members.forEach((m: unknown, k) => {\n const inner = configProblems(part, m, true);\n for (const [claim, detail] of inner) out.push([claim, `the member ${k} of ${at}: ${detail}`]);\n if (inner.length > 0) return;\n const id = idOf(canonicalOf(part, m as StrategyConfig, true));\n if (ids.has(id)) out.push([\"duplicate\", `the members ${ids.get(id)} and ${k} of ${at} are the same config ${id}`]);\n else ids.set(id, k);\n });\n return out;\n}\n\nconst toBreaks = (problems: readonly Problem[], inputs: readonly string[] = []): ClaimBreak[] => problems.map(([claim, detail]) => ({ claim, detail, inputs }));\n\n/**\n * This function checks one config of a space. It gives one break for each problem. An empty list tells that the config is good.\n * The `claim` of a break is the kind of the problem, for example `missing`, `unknown`, `inactive`, `param`, `constraint`, `members` or `depth`.\n */\nexport function checkConfig(space: StrategySpace, config: StrategyConfig): ClaimBreak[] {\n return toBreaks(configProblems(space, config, false));\n}\n\n/**\n * This function checks a space. It gives one break for each problem. An empty list tells that the space is good.\n * It finds duplicate names, empty ranges, defaults out of range, enums without values, bad log scales, unknown names and bad named configs.\n * The `inputs` of a break of a named config have the name of the config.\n */\nexport function checkSpace(space: StrategySpace): ClaimBreak[] {\n if (!isObject(space) || !Array.isArray(space.stages)) return toBreaks([[\"schema\", \"the space is not an object with stages\"]]);\n const out: Problem[] = [];\n if (space.schema !== STRATEGY_SPACE_SCHEMA) out.push([\"schema\", `the schema is ${show(space.schema)}, not ${STRATEGY_SPACE_SCHEMA}`]);\n if (typeof space.engine !== \"string\" || space.engine === \"\") out.push([\"schema\", \"the space has no engine name\"]);\n if (typeof space.version !== \"string\") out.push([\"schema\", \"the space has no version\"]);\n const names = space.stages.map((s) => s.name);\n space.stages.forEach((s, i) => {\n if (names.indexOf(s.name) !== i) out.push([\"duplicate\", `the space has the stage ${s.name} two times`]);\n const options: readonly StageOption[] = Array.isArray(s.options) ? s.options : [];\n if (options.length === 0) {\n out.push([\"options\", `the stage ${s.name} has no options`]);\n return;\n }\n const ids = options.map((o) => o.id);\n options.forEach((o, j) => {\n if (ids.indexOf(o.id) !== j) out.push([\"duplicate\", `the stage ${s.name} has the option ${o.id} two times`]);\n out.push(...optionProblems(s, o));\n });\n if (!s.optional && options.every((o) => o.members !== undefined)) out.push([\"meta\", `the stage ${s.name} is not optional and has only meta options, so no base config exists`]);\n });\n const known = (ref: OptionRef, at: string): void => {\n const s = space.stages.find((x) => x.name === ref?.stage);\n if (s === undefined) out.push([\"unknown\", `${at} has the unknown stage ${ref?.stage}`]);\n else if (ref.option === null ? !s.optional : !s.options.some((o) => o.id === ref.option))\n out.push([\"unknown\", `${at} has the unknown option ${s.name}=${ref.option ?? \"null\"}`]);\n };\n (space.constraints ?? []).forEach((c, k) => {\n known(c.if, `the constraint ${k}`);\n known(\"not\" in c.then ? c.then.not : c.then, `the constraint ${k}`);\n });\n for (const part of space.parts ?? []) for (const b of checkSpace(part)) out.push([b.claim, `the part ${part.engine}: ${b.detail}`]);\n if (space.parts !== undefined)\n for (const s of space.stages) if (partOf(space, s.name).prefix === \"\") out.push([\"parts\", `the stage ${s.name} is not a stage of a part`]);\n const breaks = toBreaks(out);\n if (breaks.length > 0) return breaks;\n for (const [name, config] of Object.entries(space.named ?? {}))\n breaks.push(...toBreaks(configProblems(space, config, false).map(([c, d]) => [c, `the named config ${name}: ${d}`] as const), [name]));\n return breaks;\n}\n\n/** This function gives the canonical form of a config that is known to be good. */\nfunction canonicalOf(space: StrategySpace, config: StrategyConfig, member: boolean): StrategyConfig {\n const stages: Record<string, StageChoice | null> = {};\n for (const s of space.stages) {\n const c = Object.hasOwn(config.stages, s.name) ? config.stages[s.name] : undefined;\n if (c === undefined || c === null) {\n stages[s.name] = null;\n continue;\n }\n const o = s.options.find((x) => x.id === c.option)!;\n const given = c.params ?? {};\n const params: Values = {};\n for (const p of o.params) if (isActive(p, params)) params[p.name] = normalize(p, Object.hasOwn(given, p.name) ? given[p.name]! : p.default);\n if (o.members === undefined || member) {\n stages[s.name] = { option: o.id, params };\n continue;\n }\n const part = partOf(space, s.name).space;\n const members = (c.members ?? []).map((m) => canonicalOf(part, m, true));\n if (!o.members.ordered) members.sort((a, b) => (idOf(a) < idOf(b) ? -1 : idOf(a) > idOf(b) ? 1 : 0));\n stages[s.name] = { option: o.id, params, members };\n }\n return { space: space.engine, stages };\n}\n\nconst idOf = (canonical: StrategyConfig): string => sha256Hex(canonicalJson(canonical)).slice(0, 16);\n\n/**\n * This function gives the canonical form of a config: each stage of the space, the active params only, the defaults, and stable numbers.\n * An unused optional stage is `null`. The members of an unordered meta option are sorted by their `configId`.\n * It throws an `Error` for a config with a break of `checkConfig`.\n */\nexport function canonicalConfig(space: StrategySpace, config: StrategyConfig): StrategyConfig {\n const problems = configProblems(space, config, false);\n if (problems.length > 0) throw new Error(`The config of the space ${space.engine} is not good: ${problems.map((p) => p[1]).join(\"; \")}.`);\n return canonicalOf(space, config, false);\n}\n\n/**\n * This function gives the id of a config: the first 16 hex characters of the SHA-256 of `canonicalJson` of `canonicalConfig`.\n * Two spellings of one config get one id. The version of the space is not part of the id.\n */\nexport function configId(space: StrategySpace, config: StrategyConfig): string {\n return idOf(canonicalConfig(space, config));\n}\n\n/** This function throws an `Error` for a space with a break of `checkSpace`. */\nfunction assertSpace(space: StrategySpace): void {\n const breaks = checkSpace(space);\n if (breaks.length > 0) throw new Error(`The space ${String(space?.engine)} is not good: ${breaks.map((b) => b.detail).join(\"; \")}.`);\n}\n\n/** This function throws a `RangeError` when a value is not a whole number of `min` or more. */\nfunction assertWhole(value: number, name: string, min: number): void {\n if (!Number.isInteger(value) || value < min) throw new RangeError(`The option ${name} is ${value}, not a whole number of ${min} or more.`);\n}\n\n/** This function gives the last point of the step grid of a numeric param. */\nfunction lastPoint(p: SpaceParam): number {\n const min = p.min!;\n const step = p.step ?? (p.kind === \"int\" ? 1 : undefined);\n if (step === undefined) return p.max!;\n return min + Math.floor((p.max! - min) / step + 1e-9) * step;\n}\n\n/** This function moves a value of a numeric param onto its step and into its range. */\nfunction snap(p: SpaceParam, x: number, digits: number): number {\n const min = p.min!;\n const step = p.step ?? (p.kind === \"int\" ? 1 : undefined);\n let v = step === undefined ? x : min + Math.round((x - min) / step) * step;\n v = Math.min(lastPoint(p), Math.max(min, v));\n return p.kind === \"int\" ? zero(Math.round(v)) : Math.min(p.max!, Math.max(min, realForm(v, digits)));\n}\n\n/** This function gives the point at the fraction `t` of the range of a numeric param, on its scale. */\nfunction at01(p: SpaceParam, t: number): number {\n const min = p.min!;\n const max = p.max!;\n if (p.scale === \"log\") return Math.exp(Math.log(min) + t * (Math.log(max) - Math.log(min)));\n return min + t * (max - min);\n}\n\n/**\n * This function gives the grid values of one param, in increasing order. An `enum` gives its values, and a `bool` gives `false` and `true`.\n * With 1 level, a numeric param gives its default. With k levels, it gives k points from `min` to `max` on its scale and step, without repeats.\n */\nexport function paramLevels(param: SpaceParam, levels: number): ParamValue[] {\n assertWhole(levels, \"levels\", 1);\n if (param.kind === \"bool\") return [false, true];\n if (param.kind === \"enum\") return [...(param.values ?? [])];\n if (levels === 1 || param.min === param.max) return [normalize(param, param.default)];\n const out: number[] = [];\n const steps = param.kind === \"int\" || param.step !== undefined ? Math.round((lastPoint(param) - param.min!) / (param.step ?? 1)) + 1 : Infinity;\n if (steps <= levels && param.scale !== \"log\") {\n for (let j = 0; j < steps; j++) out.push(snap(param, param.min! + j * (param.step ?? 1), 12));\n } else {\n for (let j = 0; j < levels; j++) out.push(snap(param, at01(param, j / (levels - 1)), 12));\n }\n return [...new Set(out)];\n}\n\n/** This function tells if a later param of the list reads a param in its `when`. */\nconst readLater = (params: readonly SpaceParam[], i: number): boolean => params.slice(i + 1).some((q) => q.when?.param === params[i]!.name);\n\n/** This function gives the count of the grid assignments of the params of an option, with only the active params. */\nfunction countParams(params: readonly SpaceParam[], levels: number, i = 0, values: Values = {}): bigint {\n if (i === params.length) return 1n;\n const p = params[i]!;\n if (!isActive(p, values)) return countParams(params, levels, i + 1, values);\n const lv = paramLevels(p, levels);\n if (!readLater(params, i)) return BigInt(lv.length) * countParams(params, levels, i + 1, values);\n let sum = 0n;\n for (const v of lv) sum += countParams(params, levels, i + 1, { ...values, [p.name]: v });\n return sum;\n}\n\n/** This function gives the grid assignments of the params of an option, in a stable order. */\nfunction* gridParams(params: readonly SpaceParam[], levels: number, i = 0, values: Values = {}): Generator<Values> {\n if (i === params.length) {\n yield { ...values };\n return;\n }\n const p = params[i]!;\n if (!isActive(p, values)) {\n yield* gridParams(params, levels, i + 1, values);\n return;\n }\n for (const v of paramLevels(p, levels)) yield* gridParams(params, levels, i + 1, { ...values, [p.name]: v });\n}\n\n/** One combination of options of a space, with its count of grid points. */\ninterface Combo {\n readonly choices: Choices;\n readonly base: boolean;\n /** The count of the grid points, or `null` when the count is more than the limit. */\n readonly weight: bigint | null;\n}\n\nconst optionIds = (choices: Choices): Map<string, string | null> => new Map([...choices].map(([k, o]) => [k, o?.id ?? null]));\nconst keeps = (space: StrategySpace, choices: Choices): boolean => (space.constraints ?? []).every((c) => holds(c, optionIds(choices)));\n\n/** This function gives the count of the member lists of a meta option from `base` base configs, or `null` above `limit`. */\nfunction memberLists(base: bigint, rule: MemberRule, limit: bigint): bigint | null {\n let sum = 0n;\n for (let m = rule.min; m <= rule.max; m++) {\n let n = 1n;\n for (let k = 0; k < m; k++) {\n n = (n * (base - BigInt(k))) / (rule.ordered ? 1n : BigInt(k + 1));\n if (n <= 0n) break;\n }\n if (n <= 0n) break;\n sum += n;\n if (sum > limit) return null;\n }\n return sum;\n}\n\n/** This function multiplies two counts. A `null` count or a product above `limit` gives `null`. */\nconst times = (a: bigint | null, b: bigint | null, limit: bigint): bigint | null => (a === null || b === null ? null : a * b > limit ? null : a * b);\n\n/**\n * This function gives the combinations of options of a space and their grid counts.\n * A product space joins the combinations of its parts. Each combination keeps the constraints.\n */\nfunction combos(space: StrategySpace, levels: number, meta: boolean, limit: bigint): Combo[] {\n if (space.parts !== undefined && space.parts.length > 0) {\n let acc: Combo[] = [{ choices: new Map(), base: true, weight: 1n }];\n for (const part of space.parts) {\n const head = `${part.engine}.`;\n const own = combos(part, levels, meta, limit);\n const next: Combo[] = [];\n for (const a of acc)\n for (const b of own) {\n const choices = new Map(a.choices);\n for (const [k, o] of b.choices) choices.set(head + k, o);\n const base = a.base && b.base;\n next.push({ choices, base, weight: base ? a.weight! * b.weight! : times(a.weight, b.weight, limit) });\n }\n acc = next;\n }\n return acc.filter((c) => keeps(space, c.choices));\n }\n const counts = new Map<StageOption, bigint>();\n const countOf = (o: StageOption): bigint => {\n if (!counts.has(o)) counts.set(o, countParams(o.params, levels));\n return counts.get(o)!;\n };\n const out: Combo[] = [];\n const stages = space.stages;\n const walk = (i: number, choices: Map<string, StageOption | null>, weight: bigint): void => {\n if (i === stages.length) {\n if (keeps(space, choices)) out.push({ choices: new Map(choices), base: true, weight });\n return;\n }\n const s = stages[i]!;\n const list: (StageOption | null)[] = s.options.filter((o) => o.members === undefined);\n if (s.optional) list.push(null);\n for (const o of list) {\n choices.set(s.name, o);\n walk(i + 1, choices, o === null ? weight : weight * countOf(o));\n }\n choices.delete(s.name);\n };\n walk(0, new Map(), 1n);\n if (!meta) return out;\n const base = out.reduce((sum, c) => sum + c.weight!, 0n);\n for (const s of stages)\n for (const o of s.options) {\n if (o.members === undefined) continue;\n const choices = new Map<string, StageOption | null>(stages.map((x) => [x.name, x === s ? o : null]));\n if (keeps(space, choices)) out.push({ choices, base: false, weight: times(countOf(o), memberLists(base, o.members, limit), limit) });\n }\n return out;\n}\n\n/**\n * This function gives the count of the grid points of a space, with `levels` levels for each numeric param.\n * It counts only the active params and the combinations that keep the constraints. It gives the meta configs apart.\n */\nexport function spaceSize(space: StrategySpace, options: SpaceSizeOptions): SpaceSize {\n assertSpace(space);\n assertWhole(options.levels, \"levels\", 1);\n const limit = options.maxMeta ?? 10n ** 18n;\n let base = 0n;\n let meta: bigint | null = 0n;\n for (const c of combos(space, options.levels, true, limit)) {\n if (c.base) base += c.weight!;\n else meta = meta === null || c.weight === null || meta + c.weight > limit ? null : meta + c.weight;\n }\n return { base, meta };\n}\n\n/** This function gives the cartesian product of lists, with the last list as the fastest. */\nfunction* product<T>(lists: readonly (readonly T[])[], i = 0, acc: T[] = []): Generator<T[]> {\n if (i === lists.length) {\n yield [...acc];\n return;\n }\n for (const x of lists[i]!) {\n acc.push(x);\n yield* product(lists, i + 1, acc);\n acc.pop();\n }\n}\n\n/** This function gives the configs of the grid of a space, without meta options. */\nfunction gridConfigs(space: StrategySpace, levels: number, limit: number): StrategyConfig[] {\n const size = spaceSize(space, { levels, maxMeta: 0n }).base;\n if (size > BigInt(limit)) throw new RangeError(`The grid of the space ${space.engine} has ${size} configs, more than the limit ${limit}.`);\n const out: StrategyConfig[] = [];\n for (const c of combos(space, levels, false, 0n)) {\n const names = [...c.choices.keys()];\n const lists = names.map((k) => {\n const o = c.choices.get(k)!;\n return o === null ? [null] : [...gridParams(o.params, levels)].map((params): StageChoice => ({ option: o.id, params }));\n });\n for (const row of product<StageChoice | null>(lists)) out.push(canonicalOf(space, { space: space.engine, stages: Object.fromEntries(names.map((k, i) => [k, row[i]!])) }, false));\n }\n return out;\n}\n\n/** This function gives a random order of the numbers from 0 to `n - 1`. */\nfunction permutation(n: number, r: () => number): number[] {\n const out = Array.from({ length: n }, (_, i) => i);\n for (let i = n - 1; i > 0; i--) {\n const j = Math.floor(r() * (i + 1));\n [out[i], out[j]] = [out[j]!, out[i]!];\n }\n return out;\n}\n\n/** This function gives the value of a param at the fraction `u` of its range. A sampled real number has 6 significant digits. */\nfunction sampleValue(p: SpaceParam, u: number): ParamValue {\n if (p.kind === \"bool\") return u >= 0.5;\n if (p.kind === \"enum\") {\n const values = p.values!;\n return values[Math.min(values.length - 1, Math.floor(u * values.length))]!;\n }\n if (p.min === p.max) return normalize(p, p.min!);\n if (p.scale !== \"log\" && (p.kind === \"int\" || p.step !== undefined)) {\n const steps = Math.round((lastPoint(p) - p.min!) / (p.step ?? 1)) + 1;\n return snap(p, p.min! + Math.min(steps - 1, Math.floor(u * steps)) * (p.step ?? 1), 6);\n }\n return snap(p, at01(p, u), 6);\n}\n\n/** This function gives a seed of 32 bits from a seed and a step name. */\nconst subSeed = (seed: number, step: string): number => Math.floor(stepRandom(seed, step)() * 4294967296);\n\n/** This function gives a sample of a space: Latin hypercube strata over the options, the params and the member counts. */\nfunction sampleConfigs(space: StrategySpace, n: number, seed: number, meta: boolean, maxTries: number): StrategyConfig[] {\n const stages = space.stages;\n const prefix = prefixes(space);\n const lists = stages.map((s) => {\n const list: (StageOption | null)[] = s.options.filter((o) => meta || o.members === undefined);\n if (s.optional) list.push(null);\n return list;\n });\n const points: Map<string, StageOption | null>[] = [];\n let tries = 0;\n for (let round = 0; points.length < n; round++) {\n const r = stepRandom(seed, `options:${round}`);\n const columns = lists.map((list) => permutation(n, r).map((p) => list[Math.floor((p * list.length) / n)]!));\n for (let i = 0; i < n && points.length < n; i++) {\n if (tries >= maxTries) throw new Error(`The constraints of the space ${space.engine} remove too many points: ${points.length} of ${n} configs after ${tries} tries.`);\n tries++;\n const choices = new Map<string, StageOption | null>(stages.map((s, k) => [s.name, columns[k]![i]!]));\n const metaPart = new Map<string, string>();\n for (const s of stages) {\n const o = choices.get(s.name);\n if (o?.members !== undefined && !metaPart.has(prefix.get(s.name)!)) metaPart.set(prefix.get(s.name)!, s.name);\n }\n for (const s of stages) {\n const m = metaPart.get(prefix.get(s.name)!);\n if (m !== undefined && m !== s.name) choices.set(s.name, null);\n }\n if (keeps(space, choices)) points.push(choices);\n }\n }\n const values: Values[][] = points.map(() => stages.map(() => ({})));\n const members: StrategyConfig[][][] = points.map(() => stages.map(() => []));\n stages.forEach((s, k) => {\n for (const o of s.options) {\n const users = points.flatMap((c, i) => (c.get(s.name) === o ? [i] : []));\n if (users.length === 0) continue;\n for (const p of o.params) {\n const active = users.filter((i) => isActive(p, values[i]![k]!));\n const r = stepRandom(seed, `param:${s.name}:${o.id}:${p.name}`);\n permutation(active.length, r).forEach((stratum, j) => {\n values[active[j]!]![k]![p.name] = sampleValue(p, (stratum + r()) / active.length);\n });\n }\n if (o.members === undefined) continue;\n const part = partOf(space, s.name).space;\n const poolSize = Math.max(n, 4 * o.members.max, 8);\n const seen = new Set<string>();\n const pool = sampleConfigs(part, poolSize, subSeed(seed, `pool:${s.name}:${o.id}`), false, Math.max(1000, 100 * poolSize)).filter((c) => {\n const id = idOf(c);\n return seen.has(id) ? false : (seen.add(id), true);\n });\n const r = stepRandom(seed, `members:${s.name}:${o.id}`);\n const { min, max } = o.members;\n permutation(users.length, r).forEach((stratum, j) => {\n const count = min + Math.min(max - min, Math.floor(((stratum + r()) / users.length) * (max - min + 1)));\n if (pool.length < count) throw new Error(`The space ${part.engine} has only ${pool.length} distinct base samples, fewer than the ${count} members of ${s.name}.${o.id}.`);\n const picked = permutation(pool.length, r).slice(0, count);\n members[users[j]!]![k] = picked.map((x) => pool[x]!);\n });\n }\n });\n return points.map((choices, i) => {\n const out: Record<string, StageChoice | null> = {};\n stages.forEach((s, k) => {\n const o = choices.get(s.name)!;\n out[s.name] = o === null ? null : o.members === undefined ? { option: o.id, params: values[i]![k]! } : { option: o.id, params: values[i]![k]!, members: members[i]![k]! };\n });\n return canonicalConfig(space, { space: space.engine, stages: out });\n });\n}\n\n/**\n * This function gives configs of a space, in their canonical form. Each config keeps the constraints. The result is deterministic.\n *\n * - The mode `grid` gives each grid point without a meta option, in a stable order. Stages, options and values go in the order of the space.\n * - The mode `sample` gives `n` configs of a seeded Latin hypercube. The options of a stage get equal strata, and each active param gets its own strata.\n * - A sample draws again when a point breaks a constraint. After `maxTries` draws, it throws an `Error`. Two sampled configs can be equal.\n */\nexport function enumerateSpace(space: StrategySpace, options: EnumerateOptions): StrategyConfig[] {\n assertSpace(space);\n if (options.mode === \"grid\") {\n assertWhole(options.levels, \"levels\", 1);\n return gridConfigs(space, options.levels, options.limit ?? 100_000);\n }\n if (options.mode !== \"sample\") throw new RangeError(`The mode ${String((options as { mode?: unknown }).mode)} is not grid or sample.`);\n assertWhole(options.n, \"n\", 0);\n if (!Number.isInteger(options.seed)) throw new RangeError(`The seed ${options.seed} is not a whole number.`);\n const meta = options.meta ?? \"skip\";\n if (meta !== \"skip\" && meta !== \"sample\") throw new RangeError(`The option meta is ${String(meta)}, not skip or sample.`);\n if (options.n === 0) return [];\n return sampleConfigs(space, options.n, options.seed, meta === \"sample\", options.maxTries ?? Math.max(1000, 100 * options.n));\n}\n\n/**\n * This function joins configs of the parts of a product space into one config of the space `space`.\n * The name of each stage gets the prefix `<space of the part>.`. The members of a meta option do not change.\n */\nexport function joinConfigs(space: string, parts: readonly StrategyConfig[]): StrategyConfig {\n const stages: Record<string, StageChoice | null> = {};\n for (const part of parts) for (const [k, c] of Object.entries(part.stages)) stages[`${part.space}.${k}`] = c;\n return { space, stages };\n}\n\n/** This function gives the config of the part `engine` of a joint config. It throws a `RangeError` when no stage has the prefix `<engine>.`. */\nexport function splitConfig(config: StrategyConfig, engine: string): StrategyConfig {\n const head = `${engine}.`;\n const entries = Object.entries(config.stages).filter(([k]) => k.startsWith(head));\n if (entries.length === 0) throw new RangeError(`The config of the space ${config.space} has no stage of the part ${engine}.`);\n return { space: engine, stages: Object.fromEntries(entries.map(([k, c]) => [k.slice(head.length), c])) };\n}\n\n/**\n * This function joins two spaces, for example a packer and a router, into the space `name`. The stages of `a` and `b` get the prefixes `<a.engine>.` and `<b.engine>.`.\n * The constraints get the same prefixes. The named configs are the pairs `<name of a>+<name of b>`. It throws a `RangeError` when the two engines have the same name.\n */\nexport function productSpace(a: StrategySpace, b: StrategySpace, name: string): StrategySpace {\n if (a.engine === b.engine) throw new RangeError(`The two spaces have the same engine ${a.engine}.`);\n if (name === \"\") throw new RangeError(\"The product space has no name.\");\n const stagesOf = (s: StrategySpace): SpaceStage[] => s.stages.map((x) => ({ ...x, name: `${s.engine}.${x.name}` }));\n const ref = (s: StrategySpace, r: OptionRef): OptionRef => ({ stage: `${s.engine}.${r.stage}`, option: r.option });\n const constraintsOf = (s: StrategySpace): SpaceConstraint[] =>\n (s.constraints ?? []).map((c) => ({ if: ref(s, c.if), then: \"not\" in c.then ? { not: ref(s, c.then.not) } : ref(s, c.then) }));\n const named: Record<string, StrategyConfig> = {};\n for (const [ka, ca] of Object.entries(a.named ?? {})) for (const [kb, cb] of Object.entries(b.named ?? {})) named[`${ka}+${kb}`] = joinConfigs(name, [ca, cb]);\n const constraints = [...constraintsOf(a), ...constraintsOf(b)];\n return {\n schema: STRATEGY_SPACE_SCHEMA,\n engine: name,\n version: `${a.engine}@${a.version}+${b.engine}@${b.version}`,\n stages: [...stagesOf(a), ...stagesOf(b)],\n ...(constraints.length > 0 ? { constraints } : {}),\n ...(Object.keys(named).length > 0 ? { named } : {}),\n parts: [a, b],\n };\n}\n"],"mappings":";;AAIA,MAAa,QAAyB;CAAC;CAAO;CAAS;CAAU;AAAM;;AAyCvE,SAAgB,YAAY,QAAmC;CAC7D,IAAI,WAAW,KAAA,GAAW,OAAO;EAAE,KAAK;EAAG,OAAO;EAAG,QAAQ;EAAG,MAAM;CAAE;CACxE,IAAI,OAAO,WAAW,UAAU,OAAO;EAAE,KAAK;EAAQ,OAAO;EAAQ,QAAQ;EAAQ,MAAM;CAAO;CAClG,OAAO;AACT;;AAGA,SAAgB,KAAK,MAAY,QAAkC;CACjE,MAAM,IAAI,YAAY,MAAM;CAC5B,OAAO;EAAE,GAAG,KAAK,IAAI,EAAE;EAAM,GAAG,KAAK,IAAI,EAAE;EAAK,GAAG,KAAK,IAAI,EAAE,OAAO,EAAE;EAAO,GAAG,KAAK,IAAI,EAAE,MAAM,EAAE;CAAO;AAC7G;;AAGA,SAAgB,SAAS,QAAsB;CAC7C,QAAQ,OAAO,MAAf;EACE,KAAK,QACH,OAAO;GAAE,GAAG,OAAO;GAAG,GAAG,OAAO;GAAG,GAAG,OAAO;GAAG,GAAG,OAAO;EAAE;EAC9D,KAAK,UACH,OAAO;GAAE,GAAG,OAAO,KAAK,OAAO;GAAG,GAAG,OAAO,KAAK,OAAO;GAAG,GAAG,IAAI,OAAO;GAAG,GAAG,IAAI,OAAO;EAAE;EAC9F,KAAK,WACH,OAAO;GAAE,GAAG,OAAO,KAAK,OAAO;GAAI,GAAG,OAAO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G,EAAE;EACnD,QAAQ,CAAC,GAAG,SAAS,CAAC,GAAG,GAAG,SAAS,CAAC,CAAC;EACvC,GAAI,YAAY,SAAS,IAAI,EAAE,YAAY,IAAI,CAAC;EAChD,GAAI,OAAO,KAAK,KAAK,CAAC,CAAC,SAAS,IAAI,EAAE,MAAM,IAAI,CAAC;EACjD,OAAO,CAAC,GAAG,CAAC;CACd;AACF"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["partOf","isObject"],"sources":["../src/geometry.ts","../src/tolerance.ts","../src/input.ts","../src/turn.ts","../src/output.ts","../src/record.ts","../src/rules.ts","../src/measures.ts","../src/utf8.ts","../src/random.ts","../src/edges.ts","../src/hash.ts","../src/portfolio.ts","../src/corpus.ts","../src/strategy-space.ts","../src/verdict.ts"],"sourcesContent":["/** A side of a box. The y axis points down, so `top` has the smallest y. */\nexport type Side = \"top\" | \"right\" | \"bottom\" | \"left\";\n\n/** The sides in clockwise order, from the top. */\nexport const SIDES: readonly Side[] = [\"top\", \"right\", \"bottom\", \"left\"];\n\nexport interface Point {\n readonly x: number;\n readonly y: number;\n}\n\n/** A rectangle: its top-left corner and its size. */\nexport interface Rect {\n readonly x: number;\n readonly y: number;\n readonly w: number;\n readonly h: number;\n}\n\n/** A value for each side of a box. */\nexport interface Sides {\n readonly top: number;\n readonly right: number;\n readonly bottom: number;\n readonly left: number;\n}\n\n/**\n * A region. The forms and the rules are those of `docs/FORMAT.md` of `packing`.\n * A ring of a polygon closes without a copy of its first point.\n */\nexport type Region =\n | { readonly kind: \"rect\"; readonly x: number; readonly y: number; readonly w: number; readonly h: number }\n | {\n readonly kind: \"polygon\";\n readonly points: readonly (readonly [number, number])[];\n readonly holes?: readonly (readonly (readonly [number, number])[])[];\n }\n | { readonly kind: \"circle\"; readonly cx: number; readonly cy: number; readonly r: number }\n | { readonly kind: \"ellipse\"; readonly cx: number; readonly cy: number; readonly rx: number; readonly ry: number };\n\n/** A margin: one value for the four sides, or one value for each side. */\nexport type Margin = number | Sides;\n\n/** This function gives the value of each side of a margin. No margin gives 0 on each side. */\nexport function marginSides(margin: Margin | undefined): Sides {\n if (margin === undefined) return { top: 0, right: 0, bottom: 0, left: 0 };\n if (typeof margin === \"number\") return { top: margin, right: margin, bottom: margin, left: margin };\n return margin;\n}\n\n/** This function gives the rectangle made larger by the margin on each side. */\nexport function grow(rect: Rect, margin: Margin | undefined): Rect {\n const m = marginSides(margin);\n return { x: rect.x - m.left, y: rect.y - m.top, w: rect.w + m.left + m.right, h: rect.h + m.top + m.bottom };\n}\n\n/** This function gives the bounding box of a region. */\nexport function boundsOf(region: Region): Rect {\n switch (region.kind) {\n case \"rect\":\n return { x: region.x, y: region.y, w: region.w, h: region.h };\n case \"circle\":\n return { x: region.cx - region.r, y: region.cy - region.r, w: 2 * region.r, h: 2 * region.r };\n case \"ellipse\":\n return { x: region.cx - region.rx, y: region.cy - region.ry, w: 2 * region.rx, h: 2 * region.ry };\n case \"polygon\": {\n let x0 = Infinity;\n let y0 = Infinity;\n let x1 = -Infinity;\n let y1 = -Infinity;\n for (const [x, y] of region.points) {\n x0 = Math.min(x0, x);\n y0 = Math.min(y0, y);\n x1 = Math.max(x1, x);\n y1 = Math.max(y1, y);\n }\n return { x: x0, y: y0, w: x1 - x0, h: y1 - y0 };\n }\n }\n}\n\n/** This function gives the region moved by `dx` and `dy`. */\nexport function translate(region: Region, dx: number, dy: number): Region {\n switch (region.kind) {\n case \"rect\":\n return { ...region, x: region.x + dx, y: region.y + dy };\n case \"circle\":\n case \"ellipse\":\n return { ...region, cx: region.cx + dx, cy: region.cy + dy };\n case \"polygon\": {\n const move = (ring: readonly (readonly [number, number])[]): [number, number][] => ring.map(([x, y]) => [x + dx, y + dy]);\n return region.holes === undefined\n ? { kind: \"polygon\", points: move(region.points) }\n : { kind: \"polygon\", points: move(region.points), holes: region.holes.map(move) };\n }\n }\n}\n\n/**\n * This function gives the overlap of the insides of two rectangles on each axis.\n * A value of 0 or less on an axis is no overlap. Two rectangles with a common edge have an overlap of 0.\n */\nexport function overlapOf(a: Rect, b: Rect): { readonly x: number; readonly y: number } {\n return {\n x: Math.min(a.x + a.w, b.x + b.w) - Math.max(a.x, b.x),\n y: Math.min(a.y + a.h, b.y + b.h) - Math.max(a.y, b.y),\n };\n}\n","/** The epsilon for the float compares in an engine. */\nexport const EPS = 1e-6;\n\n/**\n * The count of grid steps in one unit of a written file. A file rounds each number `v` to `Math.round(v * RECORD_SCALE) / RECORD_SCALE`.\n * Use a multiplication by this value, not a division by `RECORD_EPS`. The two differ at some half steps.\n */\nexport const RECORD_SCALE = 1000;\n\n/**\n * The epsilon for the float compares on a written file. A file rounds each number to 3 decimals,\n * so a difference of two values can move by up to 0.001. It is `1 / RECORD_SCALE`.\n */\nexport const RECORD_EPS = 1e-3;\n\n/**\n * The tolerance of each hard rule, in layout units. A record writes the tolerance that its run used,\n * in its field `tolerance`, next to `hard`.\n */\nexport interface Tolerance {\n /** Two boxes with their margins break `no-overlap` when their insides overlap by more than this on each axis. */\n readonly overlap: number;\n /** A route breaks `no-pass-through` when a part longer than this is inside a box made this much smaller. */\n readonly through: number;\n}\n\n/**\n * The default tolerance of each rule. The packer is exact, so `overlap` is one unit of the rounding.\n * Routes are sampled curves that follow the margin line, so `through` is larger.\n */\nexport const DEFAULT_TOLERANCE: Tolerance = Object.freeze({ overlap: 0.001, through: 0.5 });\n","import type { Margin, Region, Side } from \"./geometry.ts\";\n\n/**\n * A port of a box: a place where edges go into the box.\n * With `x` and `y`, the port is fixed on the border of the box, relative to its top-left corner.\n * Without them, the router places the port on its `side`. Without a side, the router picks the side.\n */\nexport interface Port {\n readonly id: string;\n readonly side?: Side;\n readonly x?: number;\n readonly y?: number;\n}\n\n/** A box of an input. In the packer, its name is item. */\nexport interface LayoutBox {\n readonly id: string;\n readonly w: number;\n readonly h: number;\n /** The packer writes the position. The router reads it. */\n readonly x?: number;\n readonly y?: number;\n /** A locked box keeps `x` and `y`. The packer reads it as an obstacle. */\n readonly locked?: boolean;\n /** The reading order. Without it, the order of the array is the rank. */\n readonly rank?: number;\n readonly parent?: string;\n readonly group?: string;\n /** A region relative to the origin of the box. Without it, the box is the rectangle `w` by `h`. */\n readonly shape?: Region;\n readonly ports?: readonly Port[];\n /** A ring around the box. No other box enters it. Only a route from a port of the box enters it, at a right angle. */\n readonly margin?: Margin;\n /** The packer can turn the box by 90 degrees. The output has the turned box and ports. */\n readonly turnable?: boolean;\n /** The free data of the node. The grouping rule `keys` of `highways` reads `data.group`. */\n readonly data?: Readonly<Record<string, unknown>>;\n}\n\n/** The packer name of a box. It is the same type. */\nexport type Item = LayoutBox;\n\n/** An edge between two boxes, with optional ports. */\nexport interface LayoutEdge {\n readonly id: string;\n readonly source: string;\n readonly target: string;\n readonly sourcePort?: string;\n readonly targetPort?: string;\n readonly data?: Readonly<Record<string, unknown>>;\n}\n\n/** The container. `fixed` tells which sides of the size stay. */\nexport interface LayoutContainer {\n readonly w?: number;\n readonly h?: number;\n readonly fixed: \"size\" | \"width\" | \"height\" | \"none\";\n /** The target aspect: the width divided by the height. The default is 1. */\n readonly aspect?: number;\n /** The weight of the aspect error in the objective. 0 gives the least area. The default is 1. */\n readonly aspectWeight?: number;\n /** The shape. Without it, the container is the rectangle from 0, 0 to `w`, `h`. */\n readonly shape?: Region;\n /** The space between the border and the boxes with their margins. */\n readonly inset?: number;\n}\n\n/** An area that boxes and routes avoid. Without `move`, it stays. With `move`, the packer can move it for `cost` times the distance. */\nexport interface Obstacle {\n readonly id: string;\n readonly region: Region;\n readonly move?: { readonly cost: number };\n}\n\n/** The generator of an input. The same name, version, parameters and seed give the same file, byte for byte. */\nexport interface LayoutGenerator {\n readonly name: string;\n readonly version: number;\n readonly params: Readonly<Record<string, unknown>>;\n readonly seed: number;\n}\n\n/** The cell of an input in the taxonomy: one value for each dimension. The dimensions are in `docs/FORMAT.md` of `packing`. */\nexport interface LayoutCell {\n readonly containerSize?: \"fixed\" | \"freeHeight\" | \"freeWidth\" | \"freeAspect\" | \"freeArea\";\n readonly containerShape?: \"rect\" | \"convex\" | \"polygon\" | \"circle\" | \"ellipse\" | \"holes\";\n readonly obstacles?: \"none\" | \"center\" | \"scattered\" | \"wall\" | \"corridors\" | \"touching\" | \"edge\";\n readonly sizes?: \"identical\" | \"uniform\" | \"heavyTail\" | \"bimodal\" | \"extremeAspect\" | \"nearIdentical\";\n readonly count?: \"1\" | \"10\" | \"100\" | \"1k\" | \"10k\";\n readonly mode?: \"offline\" | \"online\" | \"incremental\";\n readonly edgeDensity?: \"sparse\" | \"medium\" | \"dense\";\n readonly edgeShape?: \"random\" | \"clustered\" | \"hubChain\" | \"longRange\" | \"tree\" | \"bundled\";\n readonly groups?: \"none\" | \"flat\" | \"nested\";\n readonly ports?: \"free\" | \"sides\" | \"fixed\";\n}\n\n/** An input of the corpus: the format `layout-input/1`. */\nexport interface LayoutInput {\n readonly schema: \"layout-input/1\";\n readonly id: string;\n readonly set?: string;\n readonly family?: string;\n readonly seed?: number;\n /** The origin: `made-up`, `published:<set>` or `known-best:<construction>`. */\n readonly source?: string;\n /** The first 16 hex characters of the SHA-256 of the canonical file without this field. */\n readonly hash?: string;\n /** The generator of the input. `null` or no value tells that a person made the input. */\n readonly generator?: LayoutGenerator | null;\n /** The steps that changed the input after its generator, in their order. `edgeStep` adds one. */\n readonly steps?: readonly LayoutGenerator[];\n readonly cell?: LayoutCell;\n /** The place of the input in a sequence of changes. */\n readonly step?: number;\n /** A router input can have no container. */\n readonly container?: LayoutContainer;\n /** The free space between two boxes with their margins. Routes use it. */\n readonly gap?: number;\n readonly boxes: readonly LayoutBox[];\n readonly edges?: readonly LayoutEdge[];\n readonly obstacles?: readonly Obstacle[];\n /**\n * A variant names its base input and its change.\n * With `packed`, the variant is the packed output of its base input: the router routes the positions of that pack.\n */\n readonly base?: string;\n readonly change?: \"add\" | \"remove\" | \"resize\" | \"reorder\" | \"packed\";\n}\n\n/** The input of a packer: a `layout-input/1` file without the edges. */\nexport interface PackInput {\n readonly container: LayoutContainer;\n readonly items: readonly Item[];\n readonly obstacles?: readonly Obstacle[];\n readonly gap?: number;\n}\n\n/** This function gives the packer input of a file. An input without a container gets `{ fixed: \"none\" }`, so the packer picks the size. */\nexport function toPackInput(input: LayoutInput): PackInput {\n return {\n container: input.container ?? { fixed: \"none\" },\n items: input.boxes,\n ...(input.obstacles === undefined ? {} : { obstacles: input.obstacles }),\n ...(input.gap === undefined ? {} : { gap: input.gap }),\n };\n}\n","import { SIDES, marginSides, type Margin, type Region, type Side } from \"./geometry.ts\";\nimport type { LayoutBox, Port } from \"./input.ts\";\n\n/*\n * The turn: 90 degrees clockwise, with the y axis down. The turned box has `w` and `h` swapped,\n * and its top-left corner stays at the position of the box. A point (px, py) of a box of height h\n * goes to (h - py, px). Thus the top-left corner goes to the top-right corner, and each side moves\n * one step clockwise: top to right, right to bottom, bottom to left, left to top.\n */\n\n/** This function gives the side after a turn of 90 degrees clockwise. */\nexport function turnSide(side: Side): Side {\n return SIDES[(SIDES.indexOf(side) + 1) % 4]!;\n}\n\n/** This function gives a point of a box of height `h` after the turn. */\nexport function turnPoint(x: number, y: number, h: number): [number, number] {\n return [h - y, x];\n}\n\n/** This function gives a port of a box of height `h` after the turn. Each value of the port turns, also a port with only `x` or only `y`. */\nexport function turnPort(port: Port, h: number): Port {\n const { side, x, y, ...rest } = port;\n return {\n ...rest,\n ...(side === undefined ? {} : { side: turnSide(side) }),\n ...(y === undefined ? {} : { x: h - y }),\n ...(x === undefined ? {} : { y: x }),\n };\n}\n\n/** This function gives a margin after the turn: the value of each side moves one side clockwise. */\nexport function turnMargin(margin: Margin): Margin {\n if (typeof margin === \"number\") return margin;\n const m = marginSides(margin);\n return { top: m.left, right: m.top, bottom: m.right, left: m.bottom };\n}\n\n/** This function gives a region relative to the origin of a box of height `h` after the turn. */\nexport function turnRegion(region: Region, h: number): Region {\n switch (region.kind) {\n case \"rect\":\n return { kind: \"rect\", x: h - region.y - region.h, y: region.x, w: region.h, h: region.w };\n case \"circle\":\n return { ...region, cx: h - region.cy, cy: region.cx };\n case \"ellipse\":\n return { kind: \"ellipse\", cx: h - region.cy, cy: region.cx, rx: region.ry, ry: region.rx };\n case \"polygon\": {\n const turn = (ring: readonly (readonly [number, number])[]): [number, number][] => ring.map(([x, y]) => turnPoint(x, y, h));\n return region.holes === undefined\n ? { kind: \"polygon\", points: turn(region.points) }\n : { kind: \"polygon\", points: turn(region.points), holes: region.holes.map(turn) };\n }\n }\n}\n\n/** This function gives a box after the turn: the size, the ports, the margin and the shape turn. The position stays. */\nexport function turnBox(box: LayoutBox): LayoutBox {\n return {\n ...box,\n w: box.h,\n h: box.w,\n ...(box.ports === undefined ? {} : { ports: box.ports.map((p) => turnPort(p, box.h)) }),\n ...(box.margin === undefined ? {} : { margin: turnMargin(box.margin) }),\n ...(box.shape === undefined ? {} : { shape: turnRegion(box.shape, box.h) }),\n };\n}\n","import { boundsOf, translate } from \"./geometry.ts\";\nimport type { LayoutInput } from \"./input.ts\";\nimport { turnBox } from \"./turn.ts\";\n\n/** The position of one item. `turn` is 90 when the packer turned a turnable item. */\nexport interface Placement {\n readonly id: string;\n readonly x: number;\n readonly y: number;\n readonly turn?: 0 | 90;\n}\n\n/** The facts of one stage of a strategy, for the records and the site. */\nexport interface StageTrace {\n readonly id: string;\n readonly ms?: number;\n readonly measures?: Readonly<Record<string, number>>;\n}\n\n/** The output of a packer. It does not change the input. */\nexport interface PackOutput {\n readonly placements: readonly Placement[];\n /** The ids of the items that the packer did not place. */\n readonly overflow: readonly string[];\n /** The size of the container after the pack. For a free size, the size that the search found. */\n readonly size: { readonly w: number; readonly h: number };\n /** The new top-left corner of the bounding box of each obstacle that moved. */\n readonly moved: readonly { readonly id: string; readonly x: number; readonly y: number }[];\n readonly trace?: readonly StageTrace[];\n}\n\n/**\n * This function gives the input with the output of a packer applied. Each placed box gets its position.\n * A turned box gets its turned size, ports, margin and shape. Each moved obstacle moves.\n * The container gets the size of the output. The router reads this result. It does not read `turn`.\n */\nexport function applyPack(input: LayoutInput, output: PackOutput): LayoutInput {\n const at = new Map(output.placements.map((p) => [p.id, p]));\n const moved = new Map(output.moved.map((m) => [m.id, m]));\n const boxes = input.boxes.map((box) => {\n const p = at.get(box.id);\n if (p === undefined) return box;\n const turned = p.turn === 90 ? turnBox(box) : box;\n return { ...turned, x: p.x, y: p.y };\n });\n const obstacles = input.obstacles?.map((o) => {\n const m = moved.get(o.id);\n if (m === undefined) return o;\n const b = boundsOf(o.region);\n return { ...o, region: translate(o.region, m.x - b.x, m.y - b.y) };\n });\n return {\n ...input,\n container: { ...(input.container ?? { fixed: \"none\" }), w: output.size.w, h: output.size.h },\n boxes,\n ...(obstacles === undefined ? {} : { obstacles }),\n };\n}\n","import type { Tolerance } from \"./tolerance.ts\";\nimport type { LayoutInput } from \"./input.ts\";\n\n/** The stage of a record: the packer, the router, or both together. */\nexport type Stage = \"pack\" | \"route\" | \"joint\";\n\n/** One run of one strategy on one input and seed: the format `layout-record/1`. A run writes one line of JSON Lines. */\nexport interface LayoutRecord {\n readonly schema: \"layout-record/1\";\n readonly stage: Stage;\n readonly step: string;\n readonly strategy: string;\n /** The options in full, with the defaults. */\n readonly options: Readonly<Record<string, unknown>>;\n readonly corpus: string;\n /** The id of the input. */\n readonly input: string;\n /** The `hash` of the input file. */\n readonly inputHash: string;\n readonly set: string;\n readonly seed: number;\n readonly nodes: number;\n readonly edges: number;\n /** The value of each measure, by its name: `pack.*`, `route.*` or `joint.*`. */\n readonly measures: Readonly<Record<string, number>>;\n /** The count of the breaks of each hard rule. A good run has 0 for each rule. */\n readonly hard: Readonly<Record<string, number>>;\n /** The tolerance of each hard rule of the run. */\n readonly tolerance?: Readonly<Partial<Tolerance>>;\n /** `true` when two runs with the same seed give the same positions. */\n readonly deterministic: boolean;\n /** The id of the prediction that was written before the run. */\n readonly prediction?: string;\n /** The median of `msRuns`, or the time of the one run. */\n readonly ms: number;\n /** The time of each timed repeat, in milliseconds. */\n readonly msRuns?: readonly number[];\n /**\n * The first 16 hex characters of the SHA-256 of the canonical output of the stage.\n * The packer hashes its placements by the order of the ids. The router hashes its routes by the order of the edge ids.\n */\n readonly outputHash?: string;\n /** The facts of the computer of the run. */\n readonly env?: RunEnv;\n /** The reason when the strategy did not run, for example an input over its `maxNodes`. Then the record has no measures. */\n readonly skipped?: string;\n readonly commit?: string;\n}\n\n/**\n * The values that a strategy supports, for each dimension of a taxonomy.\n * The dimension names are in `docs/FORMAT.md` of `packing` and `docs/LAYOUT-RECORDS.md` of `highways`.\n */\nexport type Supports = Readonly<Record<string, readonly string[]>>;\n\n/** The facts of the computer of a run. */\nexport interface RunEnv {\n readonly node: string;\n readonly os: string;\n readonly arch: string;\n /** The name of the runner, for example `ubuntu-latest` or `local`. */\n readonly runner: string;\n /** The model of the processor. */\n readonly cpu: string;\n /** The count of the logical processors. */\n readonly cpus: number;\n}\n\n/** The facts of a run that the input does not give. */\nexport type RunFacts = Omit<LayoutRecord, \"schema\" | \"input\" | \"inputHash\" | \"set\" | \"nodes\" | \"edges\">;\n\n/** This function gives the record of a run. The input gives its id, its hash, its set and the counts of the nodes and the edges. */\nexport function toLayoutRecord(input: LayoutInput, run: RunFacts): LayoutRecord {\n return {\n schema: \"layout-record/1\",\n ...run,\n input: input.id,\n inputHash: input.hash ?? \"\",\n set: input.set ?? \"\",\n nodes: input.boxes.length,\n edges: input.edges?.length ?? 0,\n };\n}\n","import { boundsOf, grow, overlapOf, type Rect, type Region } from \"./geometry.ts\";\nimport type { LayoutBox, LayoutInput, Obstacle } from \"./input.ts\";\nimport { applyPack, type PackOutput } from \"./output.ts\";\nimport { DEFAULT_TOLERANCE, EPS, RECORD_EPS } from \"./tolerance.ts\";\n\n/** This function gives the area of a placed box: its shape or its rectangle, at its position. A box without a position gives `undefined`. */\nexport function placedRect(box: LayoutBox): Rect | undefined {\n if (box.x === undefined || box.y === undefined) return undefined;\n if (box.shape === undefined) return { x: box.x, y: box.y, w: box.w, h: box.h };\n const b = boundsOf(box.shape);\n return { x: box.x + b.x, y: box.y + b.y, w: b.w, h: b.h };\n}\n\n/**\n * This function counts the pairs of placed boxes whose insides, with their margins, overlap by more than `tolerance` on each axis.\n * A box with a shape counts as its bounding box. That area is larger, thus the count is safe.\n */\nexport function countOverlaps(boxes: readonly LayoutBox[], tolerance: number = DEFAULT_TOLERANCE.overlap): number {\n const rects: Rect[] = [];\n for (const box of boxes) {\n const r = placedRect(box);\n if (r !== undefined) rects.push(grow(r, box.margin));\n }\n rects.sort((a, b) => a.x - b.x);\n let count = 0;\n for (let i = 0; i < rects.length; i++) {\n const a = rects[i]!;\n for (let j = i + 1; j < rects.length; j++) {\n const b = rects[j]!;\n if (b.x >= a.x + a.w - tolerance) break;\n const o = overlapOf(a, b);\n if (o.x > tolerance && o.y > tolerance) count++;\n }\n }\n return count;\n}\n\n/** The options of the container test of `countOutside` and `packHard`. */\nexport interface ContainerTest {\n /**\n * With `true`, a box of a shaped container with the size `fixed` must stay inside the shape, not only inside its bounding box.\n * The default is `false`. The default changes to `true` at the next breaking version.\n */\n readonly exactContainer?: boolean;\n}\n\n/**\n * This function counts the placed boxes that go out of the container.\n * Each box with its margin must stay inside the container made smaller by `inset`. Only the fixed sides of the size count. A shaped container counts as its bounding box.\n *\n * With `exactContainer`, a box of a shaped container with the size `fixed` also counts when `rectInRegion` tells that it is not inside the shape.\n * For that test, the box grows by `inset` and becomes smaller by `tolerance` on each side. A shaped container with a free side keeps the bounding test only.\n * An input without a container gives 0.\n */\nexport function countOutside(input: LayoutInput, tolerance: number = DEFAULT_TOLERANCE.overlap, options: ContainerTest = {}): number {\n const c = input.container;\n if (c === undefined) return 0;\n const shape = options.exactContainer === true && c.fixed === \"size\" ? c.shape : undefined;\n const area = c.shape === undefined ? { x: 0, y: 0, w: c.w ?? Infinity, h: c.h ?? Infinity } : boundsOf(c.shape);\n const inset = c.inset ?? 0;\n const fixW = c.fixed === \"size\" || c.fixed === \"width\";\n const fixH = c.fixed === \"size\" || c.fixed === \"height\";\n let count = 0;\n for (const box of input.boxes) {\n const r0 = placedRect(box);\n if (r0 === undefined) continue;\n const r = grow(r0, box.margin);\n const outX = r.x < area.x + inset - tolerance || r.x + r.w > area.x + area.w - inset + tolerance;\n const outY = r.y < area.y + inset - tolerance || r.y + r.h > area.y + area.h - inset + tolerance;\n if ((fixW && outX) || (fixH && outY)) count++;\n else if (shape !== undefined && !rectInRegion(shape, shrink(grow(r, inset), tolerance))) count++;\n }\n return count;\n}\n\n/** This function counts the fixed ports that are not on the border of their box, with the epsilon of a written file. A port without a side does not count. */\nexport function countPortsOffBorder(boxes: readonly LayoutBox[], eps: number = RECORD_EPS): number {\n let count = 0;\n for (const box of boxes) {\n for (const p of box.ports ?? []) {\n if (p.x === undefined || p.y === undefined || p.side === undefined) continue;\n const along = p.side === \"top\" || p.side === \"bottom\" ? p.x : p.y;\n const length = p.side === \"top\" || p.side === \"bottom\" ? box.w : box.h;\n const across = { top: p.y, bottom: p.y - box.h, left: p.x, right: p.x - box.w }[p.side];\n if (Math.abs(across) > eps || along < -eps || along > length + eps) count++;\n }\n }\n return count;\n}\n\n/** The count of the breaks of each hard rule of a pack. */\nexport interface PackHard {\n readonly \"no-overlap\": number;\n readonly \"in-container\": number;\n readonly \"locked-kept\": number;\n readonly complete: number;\n}\n\n/** This function tells if the inside of `region` and the inside of `rect` have a common point. */\nexport function regionHitsRect(region: Region, rect: Rect): boolean {\n if (rect.w <= 0 || rect.h <= 0) return false;\n switch (region.kind) {\n case \"rect\": {\n const o = overlapOf(region, rect);\n return o.x > 0 && o.y > 0;\n }\n case \"circle\":\n return circleHitsRect(region.cx, region.cy, region.r, region.r, rect);\n case \"ellipse\":\n return circleHitsRect(region.cx, region.cy, region.rx, region.ry, rect);\n case \"polygon\": {\n const rings = [region.points, ...(region.holes ?? [])];\n const inside = (x: number, y: number): boolean => x > rect.x && x < rect.x + rect.w && y > rect.y && y < rect.y + rect.h;\n if (region.points.some(([x, y]) => inside(x, y))) return true;\n for (const ring of rings) {\n for (let i = 0; i < ring.length; i++) {\n const a = ring[i]!;\n const b = ring[(i + 1) % ring.length]!;\n const m = clipMid(a[0], a[1], b[0], b[1], rect);\n if (m !== undefined && inside(m[0], m[1])) return true;\n }\n }\n return pointInRings(rect.x + rect.w / 2, rect.y + rect.h / 2, rings);\n }\n }\n}\n\n/**\n * This function tells if all of `rect` is inside `region`. A point on the border counts as inside. No part of `rect` can overlap a hole.\n * The test of a circle, an ellipse or a polygon accepts an error of `EPS` on the border. A polygon can be concave.\n */\nexport function rectInRegion(region: Region, rect: Rect): boolean {\n const x1 = rect.x + rect.w;\n const y1 = rect.y + rect.h;\n const corners: readonly (readonly [number, number])[] = [\n [rect.x, rect.y],\n [x1, rect.y],\n [x1, y1],\n [rect.x, y1],\n ];\n switch (region.kind) {\n case \"rect\":\n return rect.x >= region.x && rect.y >= region.y && x1 <= region.x + region.w && y1 <= region.y + region.h;\n case \"circle\":\n return corners.every(([x, y]) => inEllipse(region.cx, region.cy, region.r, region.r, x, y));\n case \"ellipse\":\n return corners.every(([x, y]) => inEllipse(region.cx, region.cy, region.rx, region.ry, x, y));\n case \"polygon\": {\n const ring = region.points;\n if (ring.length < 3) return false;\n const points = [...corners, [rect.x + rect.w / 2, rect.y + rect.h / 2] as const];\n if (!points.every(([x, y]) => onRing(x, y, ring) || pointInRings(x, y, [ring]))) return false;\n const deep = (x: number, y: number): boolean => x > rect.x + EPS && x < x1 - EPS && y > rect.y + EPS && y < y1 - EPS;\n for (let i = 0; i < ring.length; i++) {\n const a = ring[i]!;\n const b = ring[(i + 1) % ring.length]!;\n const m = clipMid(a[0], a[1], b[0], b[1], rect);\n if (m !== undefined && deep(m[0], m[1])) return false;\n }\n return (region.holes ?? []).every((hole) => !regionHitsRect({ kind: \"polygon\", points: hole }, rect));\n }\n }\n}\n\n/** This function gives the rectangle made smaller by `d` on each side. A side does not become smaller than 0. */\nfunction shrink(r: Rect, d: number): Rect {\n const dx = Math.min(d, r.w / 2);\n const dy = Math.min(d, r.h / 2);\n return { x: r.x + dx, y: r.y + dy, w: r.w - 2 * dx, h: r.h - 2 * dy };\n}\n\n/** This function tells if a point is inside an ellipse or on its border, with an error of `EPS`. */\nfunction inEllipse(cx: number, cy: number, rx: number, ry: number, x: number, y: number): boolean {\n if (rx <= 0 || ry <= 0) return false;\n const u = (x - cx) / rx;\n const v = (y - cy) / ry;\n return u * u + v * v <= 1 + EPS;\n}\n\n/** This function tells if a point is on a ring of a polygon, with an error of `EPS`. */\nfunction onRing(x: number, y: number, ring: readonly (readonly [number, number])[]): boolean {\n for (let i = 0; i < ring.length; i++) {\n const [ax, ay] = ring[i]!;\n const [bx, by] = ring[(i + 1) % ring.length]!;\n const dx = bx - ax;\n const dy = by - ay;\n const len2 = dx * dx + dy * dy;\n const t = len2 === 0 ? 0 : Math.max(0, Math.min(1, ((x - ax) * dx + (y - ay) * dy) / len2));\n if (Math.hypot(x - (ax + t * dx), y - (ay + t * dy)) <= EPS) return true;\n }\n return false;\n}\n\n/** An ellipse with the radii `rx` and `ry` scales to a unit circle. The rectangle scales with it. */\nfunction circleHitsRect(cx: number, cy: number, rx: number, ry: number, rect: Rect): boolean {\n if (rx <= 0 || ry <= 0) return false;\n const x0 = (rect.x - cx) / rx;\n const x1 = (rect.x + rect.w - cx) / rx;\n const y0 = (rect.y - cy) / ry;\n const y1 = (rect.y + rect.h - cy) / ry;\n const dx = Math.max(x0, 0, -x1);\n const dy = Math.max(y0, 0, -y1);\n return dx * dx + dy * dy < 1;\n}\n\n/** This function gives the middle of the part of a segment inside a rectangle, or `undefined` when that part is a point or empty. */\nfunction clipMid(ax: number, ay: number, bx: number, by: number, r: Rect): readonly [number, number] | undefined {\n let t0 = 0;\n let t1 = 1;\n const dx = bx - ax;\n const dy = by - ay;\n const edges: readonly (readonly [number, number])[] = [\n [-dx, ax - r.x],\n [dx, r.x + r.w - ax],\n [-dy, ay - r.y],\n [dy, r.y + r.h - ay],\n ];\n for (const [p, q] of edges) {\n if (p === 0) {\n if (q < 0) return undefined;\n } else if (p < 0) {\n t0 = Math.max(t0, q / p);\n } else {\n t1 = Math.min(t1, q / p);\n }\n }\n if (t1 <= t0) return undefined;\n const t = (t0 + t1) / 2;\n return [ax + t * dx, ay + t * dy];\n}\n\n/** The even-odd rule over the outer ring and the holes. */\nfunction pointInRings(x: number, y: number, rings: readonly (readonly (readonly [number, number])[])[]): boolean {\n let inside = false;\n for (const ring of rings) {\n for (let i = 0, j = ring.length - 1; i < ring.length; j = i++) {\n const [xi, yi] = ring[i]!;\n const [xj, yj] = ring[j]!;\n if (yi > y !== yj > y && x < ((xj - xi) * (y - yi)) / (yj - yi) + xi) inside = !inside;\n }\n }\n return inside;\n}\n\n/**\n * This function counts the pairs of a placed box and an obstacle that overlap by more than `tolerance`.\n * The box counts with its margin. A box with a shape counts as its bounding box.\n */\nexport function countObstacleHits(\n boxes: readonly LayoutBox[],\n obstacles: readonly Obstacle[] | undefined,\n tolerance: number = DEFAULT_TOLERANCE.overlap,\n): number {\n if (obstacles === undefined || obstacles.length === 0) return 0;\n let count = 0;\n for (const box of boxes) {\n const r0 = placedRect(box);\n if (r0 === undefined) continue;\n const r = grow(r0, box.margin);\n const small = { x: r.x + tolerance, y: r.y + tolerance, w: r.w - 2 * tolerance, h: r.h - 2 * tolerance };\n for (const o of obstacles) if (regionHitsRect(o.region, small)) count++;\n }\n return count;\n}\n\n/**\n * This function gives the count of each hard rule of the output of a packer.\n * It applies the output with `applyPack`. Only the placed boxes and the locked boxes count for the overlaps and the container.\n * `no-overlap` counts the pairs of boxes and the pairs of a box and an obstacle.\n * A locked box without a placement, or with a move of more than `RECORD_EPS`, breaks `locked-kept`.\n * A locked box without a position in the input is a bad input, not a break. `checkInput` finds it.\n * Another box without a placement that is not in `overflow` breaks `complete`.\n *\n * `options` goes to `countOutside` for `in-container`.\n */\nexport function packHard(input: LayoutInput, output: PackOutput, tolerance: number = DEFAULT_TOLERANCE.overlap, options: ContainerTest = {}): PackHard {\n const after = applyPack(input, output);\n const placed = new Set(output.placements.map((p) => p.id));\n const out = new Set(output.overflow);\n const was = new Map(input.boxes.map((b) => [b.id, b]));\n let lockedMoved = 0;\n let incomplete = 0;\n const kept: LayoutBox[] = [];\n for (const box of after.boxes) {\n const old = was.get(box.id);\n if (old?.locked === true) {\n if (old.x === undefined || old.y === undefined) continue;\n const moved = Math.abs(old.x - (box.x ?? old.x)) > RECORD_EPS || Math.abs(old.y - (box.y ?? old.y)) > RECORD_EPS;\n if (!placed.has(box.id) || moved) lockedMoved++;\n kept.push(box);\n } else if (placed.has(box.id)) {\n kept.push(box);\n } else if (!out.has(box.id)) {\n incomplete++;\n }\n }\n return {\n \"no-overlap\": countOverlaps(kept, tolerance) + countObstacleHits(kept, after.obstacles, tolerance),\n \"in-container\": countOutside({ ...after, boxes: kept }, tolerance, options),\n \"locked-kept\": lockedMoved,\n complete: incomplete,\n };\n}\n\n/**\n * This function gives the problems of an input file. An empty list tells that the file is good.\n * A problem is a bad input, not a break of a hard rule. Thus an engine refuses the input.\n */\nexport function checkInput(input: LayoutInput): readonly string[] {\n const problems: string[] = [];\n const ids = new Set<string>();\n for (const box of input.boxes) {\n if (ids.has(box.id)) problems.push(`box ${box.id}: the id is not unique`);\n ids.add(box.id);\n if (!(box.w > 0 && box.h > 0 && Number.isFinite(box.w) && Number.isFinite(box.h))) problems.push(`box ${box.id}: the size is not positive and finite`);\n if (box.locked === true && (box.x === undefined || box.y === undefined)) problems.push(`box ${box.id}: a locked box has no position`);\n }\n if (countPortsOffBorder(input.boxes) > 0) problems.push(\"a fixed port is not on the border of its box\");\n for (const edge of input.edges ?? []) {\n if (!ids.has(edge.source) || !ids.has(edge.target)) problems.push(`edge ${edge.id}: a box of the edge is not in the input`);\n }\n return problems;\n}\n","import { RECORD_EPS, RECORD_SCALE } from \"./tolerance.ts\";\n\n/** The direction of a measure: the side of the better values. */\nexport type Direction = \"lower\" | \"higher\";\n\n/**\n * The facts of one measure: its unit, its direction and its range.\n * `floor` and `tol` are the parameters of the floor rule of the promotion rule (`docs/PROMOTION.md` of `highways`).\n * Each engine exports the specs of its own measures. This package exports the specs of the `joint.*` measures.\n */\nexport interface MeasureSpec<Id extends string = string> {\n readonly id: Id;\n readonly unit: string;\n readonly direction: Direction;\n /** The lowest value. */\n readonly min: number;\n /** The highest value. The value `Infinity` tells that the measure has no upper limit. */\n readonly max: number;\n /** The family of the measure in the measure note of its engine. */\n readonly family?: string;\n /** The best value. Without it, the measure has no floor. */\n readonly floor?: number;\n /** The absolute tolerance at the floor. */\n readonly tol?: number;\n /**\n * The smallest change that counts as better or worse. A number is an absolute change. `{ rel }` is a share of the larger of the two values.\n * `docs/JOINT-MEASURES.md` gives the reason of each joint value.\n */\n readonly minEffect?: number | { readonly rel: number };\n /** The role of the measure in the joint selector. */\n readonly role?: \"guard\" | \"change-guard\" | \"diagnostic\" | \"time\";\n}\n\n/** The id of a joint measure. `docs/JOINT-MEASURES.md` gives the definitions. */\nexport type JointMeasureId =\n | \"joint.fill\"\n | \"joint.aspectError\"\n | \"joint.spill\"\n | \"joint.straight.crossings\"\n | \"joint.straight.length\"\n | \"joint.stability.mean\"\n | \"joint.stability.moved\"\n | \"joint.proxy.rank\"\n | \"joint.ms\";\n\n/** The specs of the joint measures, in the order of `docs/JOINT-MEASURES.md`. */\nexport const JOINT_MEASURES: readonly MeasureSpec<JointMeasureId>[] = Object.freeze([\n { id: \"joint.fill\", minEffect: 0.001, unit: \"0 to 1\", direction: \"higher\", min: 0, max: 1, floor: 1, role: \"guard\" },\n { id: \"joint.aspectError\", minEffect: 0.01, unit: \"natural log\", direction: \"lower\", min: 0, max: Infinity, floor: 0, tol: 0.01, role: \"guard\" },\n { id: \"joint.spill\", minEffect: 0.001, unit: \"0 to 1\", direction: \"lower\", min: 0, max: 1, floor: 0, tol: 0.001, role: \"guard\" },\n { id: \"joint.straight.crossings\", minEffect: 0, unit: \"count\", direction: \"lower\", min: 0, max: Infinity, floor: 0, tol: 0, role: \"guard\" },\n { id: \"joint.straight.length\", minEffect: 0.01, unit: \"S for each edge\", direction: \"lower\", min: 0, max: Infinity, floor: 0, tol: 0.01, role: \"guard\" },\n { id: \"joint.stability.mean\", minEffect: 0.005, unit: \"W\", direction: \"lower\", min: 0, max: Infinity, floor: 0, tol: 0.005, role: \"change-guard\" },\n { id: \"joint.stability.moved\", minEffect: 0.02, unit: \"0 to 1\", direction: \"lower\", min: 0, max: 1, floor: 0, tol: 0.02, role: \"change-guard\" },\n { id: \"joint.proxy.rank\", unit: \"-1 to 1\", direction: \"higher\", min: -1, max: 1, role: \"diagnostic\" },\n { id: \"joint.ms\", unit: \"milliseconds\", direction: \"lower\", min: 0, max: Infinity, role: \"time\" },\n] as const);\n\n/** The threshold of `joint.stability.moved`, in widths `W` of the base. */\nexport const JOINT_MOVED_MIN = 0.01;\n\n/** The result of a compare of a candidate with a baseline on one measure. A tie is not better. */\nexport type Verdict = \"better\" | \"worse\" | \"tie\";\n\n/**\n * This function gives the smallest change of a measure that counts between the values `a` and `b`.\n * The value is `max(RECORD_EPS, minEffect)`, or `max(RECORD_EPS, rel * max(|a|, |b|))` for a relative `minEffect`.\n * The larger value makes the threshold the same after a swap of `a` and `b`.\n */\nexport function minEffectOf(spec: Pick<MeasureSpec, \"minEffect\">, a = 0, b = 0): number {\n const m = spec.minEffect ?? 0;\n const t = typeof m === \"number\" ? m : m.rel * Math.max(Math.abs(a), Math.abs(b));\n return Math.max(RECORD_EPS, Number.isFinite(t) ? t : 0);\n}\n\n/** The slack of the threshold in grid steps. It absorbs only the float noise of the threshold, because the change is a whole number. */\nconst STEP_NOISE = 1e-6;\n\n/**\n * This function compares the value `candidate` with the value `baseline` of one measure on one input.\n * The compare uses whole grid steps of `RECORD_EPS`. Thus a live value and its rounded record give the same verdict.\n * A change of at most the threshold of `minEffectOf` in grid steps is a tie. A swap of the two values swaps better and worse.\n * Two equal values are a tie, also two infinite values. A value `NaN` is an error.\n */\nexport function compareMeasure(candidate: number, baseline: number, spec: Pick<MeasureSpec, \"direction\" | \"minEffect\">): Verdict {\n if (Number.isNaN(candidate) || Number.isNaN(baseline)) throw new RangeError(\"compareMeasure: a value is NaN\");\n if (candidate === baseline) return \"tie\";\n const a = Math.round(candidate * RECORD_SCALE);\n const b = Math.round(baseline * RECORD_SCALE);\n let delta: number;\n if (Number.isSafeInteger(a) && Number.isSafeInteger(b)) {\n delta = a - b;\n const m = spec.minEffect ?? 0;\n const t = typeof m === \"number\" ? m * RECORD_SCALE : m.rel * Math.max(Math.abs(a), Math.abs(b));\n if (Math.abs(delta) <= Math.max(1, Number.isFinite(t) ? t : 0) + STEP_NOISE) return \"tie\";\n } else {\n delta = candidate - baseline;\n if (!(Math.abs(delta) > minEffectOf(spec, candidate, baseline))) return \"tie\";\n }\n const better = spec.direction === \"lower\" ? delta < 0 : delta > 0;\n return better ? \"better\" : \"worse\";\n}\n","/** This function gives the UTF-8 bytes of a string. The package has no runtime dependencies, thus it does not use `TextEncoder`. */\nexport function utf8(text: string): number[] {\n const bytes: number[] = [];\n for (const ch of text) {\n const c = ch.codePointAt(0)!;\n if (c < 0x80) bytes.push(c);\n else if (c < 0x800) bytes.push(0xc0 | (c >> 6), 0x80 | (c & 63));\n else if (c < 0x10000) bytes.push(0xe0 | (c >> 12), 0x80 | ((c >> 6) & 63), 0x80 | (c & 63));\n else bytes.push(0xf0 | (c >> 18), 0x80 | ((c >> 12) & 63), 0x80 | ((c >> 6) & 63), 0x80 | (c & 63));\n }\n return bytes;\n}\n","import { utf8 } from \"./utf8.ts\";\n\n/** This function gives a generator of random numbers in [0, 1). It is `mulberry32`, as in `docs/FORMAT.md` of `packing`. */\nexport function mulberry32(seed: number): () => number {\n let s = seed >>> 0;\n return () => {\n s = (s + 0x6d2b79f5) | 0;\n let t = Math.imul(s ^ (s >>> 15), 1 | s);\n t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t;\n return ((t ^ (t >>> 14)) >>> 0) / 4294967296;\n };\n}\n\n/** This function gives the FNV-1a hash of 32 bits of the UTF-8 bytes of a string. */\nexport function fnv1a32(text: string): number {\n let h = 0x811c9dc5;\n for (const b of utf8(text)) h = Math.imul(h ^ b, 0x01000193) >>> 0;\n return h;\n}\n\n/** This function gives the generator of one step of a seeded generator: `mulberry32(fnv1a32(\"<seed>:<step>\"))`. */\nexport function stepRandom(seed: number, step: string): () => number {\n return mulberry32(fnv1a32(`${seed}:${step}`));\n}\n\n/** This function gives a whole number from `lo` to `hi`, both included. */\nexport function randomInt(r: () => number, lo: number, hi: number): number {\n return lo + Math.floor(r() * (hi - lo + 1));\n}\n","import { SIDES, type Side } from \"./geometry.ts\";\nimport type { LayoutBox, LayoutEdge, LayoutGenerator, LayoutInput, Port } from \"./input.ts\";\nimport { randomInt, stepRandom } from \"./random.ts\";\n\n/**\n * The shape of the edges of `edgeStep`. The values are the cells of `edgeShape`, and `hubs`.\n * `hubs` waits for the next breaking change to become a value of `LayoutCell.edgeShape`.\n */\nexport type EdgeShape = \"random\" | \"clustered\" | \"hubChain\" | \"hubs\" | \"longRange\" | \"tree\" | \"bundled\";\n\n/** The parameters of `edgeStep`. */\nexport interface EdgeStepParams {\n readonly edgeDensity: \"sparse\" | \"medium\" | \"dense\";\n readonly edgeShape: EdgeShape;\n /** The default is `none`. */\n readonly groups?: \"none\" | \"flat\" | \"nested\";\n /** The default is `free`. */\n readonly ports?: \"free\" | \"sides\" | \"fixed\";\n /** The order of the hubs of `hubs` and `tree`: the largest box first, or a random order. The default is `area`. */\n readonly hubBy?: \"area\" | \"random\";\n}\n\n/** The mean count of the edges of each box for each value of `edgeDensity`. */\nexport const EDGE_DENSITY: Readonly<Record<EdgeStepParams[\"edgeDensity\"], number>> = Object.freeze({ sparse: 0.5, medium: 1.5, dense: 4 });\n\n/** The version of `edgeStep`. A change of its output gives a new version. */\nexport const EDGE_STEP_VERSION = 1;\n\nconst CLUSTER = 8;\nconst CHAIN = 32;\nconst INSIDE = 0.85;\nconst FAN_SHARE = 0.6;\nconst FIXED_SHARE = 0.2;\nconst COLLECTIONS = [\"users\", \"orders\", \"items\", \"events\"] as const;\n\nconst round3 = (x: number): number => Math.round(x * 1000) / 1000;\n\n/**\n * This function gives the input with edges, groups and ports from its topology alone: a joint input has no positions before the pack.\n * The random numbers come from the steps `edges` and `ports` of `seed`. The function appends its stamp to `steps`, and removes the old `hash`.\n * The rules of each shape are in `docs/JOINT-CORPUS.md`.\n */\nexport function edgeStep(input: LayoutInput, params: EdgeStepParams, seed: number = input.seed ?? 0): LayoutInput {\n if ((input.edges?.length ?? 0) > 0) throw new RangeError(\"edgeStep: the input has edges already\");\n const full: Required<EdgeStepParams> = { groups: \"none\", ports: \"free\", hubBy: \"area\", ...params };\n const n = input.boxes.length;\n const r = stepRandom(seed, \"edges\");\n\n const perm = input.boxes.map((_, i) => i);\n for (let i = n - 1; i > 0; i--) {\n const j = randomInt(r, 0, i);\n [perm[i], perm[j]] = [perm[j]!, perm[i]!];\n }\n const clusterOf: number[] = new Array<number>(n);\n perm.forEach((box, p) => (clusterOf[box] = Math.floor(p / CLUSTER)));\n const clusters = Math.ceil(n / CLUSTER);\n const members = (c: number): readonly number[] => perm.slice(c * CLUSTER, (c + 1) * CLUSTER);\n const collectionOf =\n full.edgeShape === \"bundled\"\n ? clusterOf.map((c) => `${COLLECTIONS[c % COLLECTIONS.length]!}-${c}`)\n : input.boxes.map(() => COLLECTIONS[randomInt(r, 0, COLLECTIONS.length - 1)]!);\n const area = (i: number): number => input.boxes[i]!.w * input.boxes[i]!.h;\n const rank = full.hubBy === \"area\" ? input.boxes.map((_, i) => i).sort((a, b) => area(b) - area(a) || a - b) : perm;\n\n const pairs: [number, number][] = [];\n const seen = new Set<string>();\n const add = (u: number, v: number): void => {\n const key = u < v ? `${u}-${v}` : `${v}-${u}`;\n if (u === v || seen.has(key)) return;\n seen.add(key);\n pairs.push([u, v]);\n };\n const anyBox = (): number => randomInt(r, 0, n - 1);\n const inCluster = (c: number): number => {\n const m = members(c);\n return m[randomInt(r, 0, m.length - 1)]!;\n };\n const otherCluster = (c: number): number => {\n const o = randomInt(r, 0, clusters - 2);\n return o >= c ? o + 1 : o;\n };\n const target = Math.min(Math.round(n * EDGE_DENSITY[full.edgeDensity]), (n * (n - 1)) / 2);\n const fill = (pick: () => [number, number]): void => {\n for (let tries = 0; pairs.length < target && tries < target * 30; tries++) add(...pick());\n };\n const clustered = (): [number, number] => {\n const u = anyBox();\n return [u, r() < INSIDE ? inCluster(clusterOf[u]!) : anyBox()];\n };\n\n if (n >= 2) {\n switch (full.edgeShape) {\n case \"random\":\n fill(() => [anyBox(), anyBox()]);\n break;\n case \"clustered\":\n fill(clustered);\n break;\n case \"longRange\":\n fill(() => {\n const u = anyBox();\n return [u, clusters > 1 ? inCluster(otherCluster(clusterOf[u]!)) : anyBox()];\n });\n break;\n case \"hubs\":\n fill(() => [anyBox(), rank[Math.floor(n * r() ** 3)]!]);\n break;\n case \"tree\":\n for (let i = 1; i < n; i++) add(rank[randomInt(r, 0, i - 1)]!, rank[i]!);\n break;\n case \"hubChain\": {\n const k = Math.ceil(n / CHAIN);\n const length = Math.ceil(n / k);\n const chains = Array.from({ length: k }, (_, c) => perm.slice(c * length, (c + 1) * length));\n for (const chain of chains) for (let i = 0; i + 1 < chain.length; i++) add(chain[i]!, chain[i + 1]!);\n const skips = Math.max(0, target - pairs.length);\n for (let s = 0; s < skips; s++) {\n const c = k > 1 ? randomInt(r, 0, k - 2) : 0;\n const from = chains[c]!;\n const to = chains[k > 1 ? c + 1 : 0]!;\n const i = randomInt(r, 0, from.length - 1);\n const j = i + Math.floor(from.length / 8) + randomInt(r, 0, Math.floor(from.length / 2));\n if (j < to.length) add(from[i]!, to[j]!);\n }\n break;\n }\n case \"bundled\":\n for (let rounds = 0; pairs.length < target * FAN_SHARE && clusters > 1 && rounds < target; rounds++) {\n const u = anyBox();\n const c = otherCluster(clusterOf[u]!);\n const fan = randomInt(r, 4, 15);\n for (let f = 0; f < fan && pairs.length < target; f++) add(u, inCluster(c));\n }\n fill(clustered);\n break;\n }\n }\n\n const rp = stepRandom(seed, \"ports\");\n const ports: Port[][] = input.boxes.map((b) => [...(b.ports ?? [])]);\n const portOn = (box: LayoutBox, id: string, side: Side, fixed: boolean): Port => {\n if (!fixed) return { id, side };\n const along = round3(rp() * (side === \"top\" || side === \"bottom\" ? box.w : box.h));\n const at = { top: [along, 0], bottom: [along, box.h], left: [0, along], right: [box.w, along] }[side];\n return { id, side, x: at[0]!, y: at[1]! };\n };\n const out = new Set<number>();\n if (full.ports === \"fixed\") {\n input.boxes.forEach((box, i) => {\n if (rp() >= FIXED_SHARE) return;\n const side = SIDES[randomInt(rp, 0, 3)]!;\n ports[i]!.push(portOn(box, \"out\", side, true));\n out.add(i);\n });\n }\n const edges: LayoutEdge[] = pairs.map(([u, v], k) => {\n const id = `e${k}`;\n const s = input.boxes[u]!;\n const t = input.boxes[v]!;\n let ends: { sourcePort?: string; targetPort?: string } = {};\n if (full.ports === \"sides\") {\n ports[u]!.push(portOn(s, `${id}.s`, SIDES[randomInt(rp, 0, 3)]!, false));\n ports[v]!.push(portOn(t, `${id}.t`, SIDES[randomInt(rp, 0, 3)]!, false));\n ends = { sourcePort: `${id}.s`, targetPort: `${id}.t` };\n } else if (out.has(u)) {\n ends = { sourcePort: \"out\" };\n }\n return { id, source: s.id, target: t.id, ...ends, data: { collection: collectionOf[v]! } };\n });\n\n const boxes = input.boxes.map((box, i): LayoutBox => {\n const c = clusterOf[i]!;\n const group = full.groups === \"none\" ? undefined : `g${c}`;\n const path = full.groups === \"nested\" ? `G${Math.floor(c / 4)}/g${c}` : group;\n return {\n ...box,\n ...(group === undefined ? {} : { group, data: { ...box.data, group: path } }),\n ...(ports[i]!.length === 0 ? {} : { ports: ports[i]! }),\n };\n });\n const stamp: LayoutGenerator = { name: \"edges\", version: EDGE_STEP_VERSION, params: { ...full }, seed };\n const { hash: _old, ...rest } = input;\n return { ...rest, boxes, edges, steps: [...(input.steps ?? []), stamp] };\n}\n","import { RECORD_EPS } from \"./tolerance.ts\";\nimport { utf8 } from \"./utf8.ts\";\n\n/** The round constants of SHA-256. */\nconst K: readonly number[] = [\n 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe,\n 0x9bdc06a7, 0xc19bf174, 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7,\n 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, 0xa2bfe8a1, 0xa81a664b,\n 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,\n 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2,\n];\n\n/**\n * This function gives the SHA-256 digest of the UTF-8 bytes of a string, as 64 lowercase hex characters.\n * It uses no API of Node or of the browser.\n */\nexport function sha256Hex(text: string): string {\n const bytes = utf8(text);\n const bits = bytes.length * 8;\n const total = Math.ceil((bytes.length + 9) / 64) * 64;\n const data = new Uint8Array(total);\n data.set(bytes);\n data[bytes.length] = 0x80;\n const view = new DataView(data.buffer);\n view.setUint32(total - 8, Math.floor(bits / 0x100000000));\n view.setUint32(total - 4, bits >>> 0);\n const h = [0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19];\n const w = new Uint32Array(64);\n const rotr = (x: number, n: number): number => (x >>> n) | (x << (32 - n));\n for (let off = 0; off < total; off += 64) {\n for (let i = 0; i < 16; i++) w[i] = view.getUint32(off + 4 * i);\n for (let i = 16; i < 64; i++) {\n const a = w[i - 15]!;\n const b = w[i - 2]!;\n const s0 = rotr(a, 7) ^ rotr(a, 18) ^ (a >>> 3);\n const s1 = rotr(b, 17) ^ rotr(b, 19) ^ (b >>> 10);\n w[i] = (w[i - 16]! + s0 + w[i - 7]! + s1) >>> 0;\n }\n let [a, b, c, d, e, f, g, k] = h as [number, number, number, number, number, number, number, number];\n for (let i = 0; i < 64; i++) {\n const s1 = rotr(e, 6) ^ rotr(e, 11) ^ rotr(e, 25);\n const ch = (e & f) ^ (~e & g);\n const t1 = (k + s1 + ch + K[i]! + w[i]!) >>> 0;\n const s0 = rotr(a, 2) ^ rotr(a, 13) ^ rotr(a, 22);\n const maj = (a & b) ^ (a & c) ^ (b & c);\n const t2 = (s0 + maj) >>> 0;\n k = g;\n g = f;\n f = e;\n e = (d + t1) >>> 0;\n d = c;\n c = b;\n b = a;\n a = (t1 + t2) >>> 0;\n }\n h[0] = (h[0]! + a) >>> 0;\n h[1] = (h[1]! + b) >>> 0;\n h[2] = (h[2]! + c) >>> 0;\n h[3] = (h[3]! + d) >>> 0;\n h[4] = (h[4]! + e) >>> 0;\n h[5] = (h[5]! + f) >>> 0;\n h[6] = (h[6]! + g) >>> 0;\n h[7] = (h[7]! + k) >>> 0;\n }\n return h.map((x) => x.toString(16).padStart(8, \"0\")).join(\"\");\n}\n\n/**\n * This function gives the canonical form of a value: sorted keys and no whitespace, with the numbers of `JSON.stringify`.\n * A key with the value `undefined` is not in the form. An `undefined` in an array becomes `null`.\n */\nexport function canonicalJson(value: unknown): string {\n if (value === null || typeof value !== \"object\") return JSON.stringify(value) ?? \"null\";\n if (Array.isArray(value)) return `[${value.map((v: unknown) => (v === undefined ? \"null\" : canonicalJson(v))).join(\",\")}]`;\n const o = value as Record<string, unknown>;\n const keys = Object.keys(o)\n .filter((k) => o[k] !== undefined)\n .sort();\n return `{${keys.map((k) => `${JSON.stringify(k)}:${canonicalJson(o[k])}`).join(\",\")}}`;\n}\n\n/** The options of `outputHash` and `documentHash`. */\nexport interface HashOptions {\n /**\n * The step of the grid of the numbers. The default is `RECORD_EPS`, so a number keeps 3 decimals.\n * The value `0` keeps the exact numbers. A negative value or a value that is not finite causes a `RangeError`.\n */\n readonly grid?: number;\n}\n\n/** This function gives the factor of a grid: `1 / grid`, or `undefined` for the exact numbers. */\nfunction gridFactor(options: HashOptions): number | undefined {\n const grid = options.grid ?? RECORD_EPS;\n if (!Number.isFinite(grid) || grid < 0) throw new RangeError(`The grid ${grid} is not a finite number of 0 or more.`);\n return grid === 0 ? undefined : 1 / grid;\n}\n\n/**\n * This function gives a copy of a value with each number on the grid. The value `-0` becomes `0`.\n * It throws a `RangeError` for a number that is not finite.\n */\nfunction onGrid(value: unknown, path: string, k: number | undefined): unknown {\n if (typeof value === \"number\") {\n if (!Number.isFinite(value)) throw new RangeError(`The value has the number ${value} at ${path}. JSON has no form for it.`);\n if (k === undefined) return value;\n const r = Math.round(value * k) / k;\n if (!Number.isFinite(r)) throw new RangeError(`The number at ${path} is too large for the grid.`);\n return r === 0 ? 0 : r;\n }\n if (value === null || typeof value !== \"object\") return value;\n if (Array.isArray(value)) return value.map((v: unknown, i) => onGrid(v, `${path}[${i}]`, k));\n const o = value as Record<string, unknown>;\n const out: Record<string, unknown> = {};\n for (const key of Object.keys(o)) out[key] = onGrid(o[key], `${path}.${key}`, k);\n return out;\n}\n\n/**\n * This function gives the hash of an output: the first 16 hex characters of the SHA-256 of its canonical form.\n * Before the canonical form, each number goes to the nearest point of the grid, and `-0` becomes `0`.\n * With the default grid, the rounding is `round3` of `packing`: `Math.round(x * 1000) / 1000`.\n * The function throws a `RangeError` for `NaN` and for an infinite number.\n *\n * The grid can split two outputs. Two numbers near a rounding boundary can go to two different points.\n * The grid can also merge two outputs whose numbers go to the same points. This merge is intentional: it removes the noise of floating-point numbers.\n */\nexport function outputHash(value: unknown, options: HashOptions = {}): string {\n return sha256Hex(canonicalJson(onGrid(value, \"$\", gridFactor(options)))).slice(0, 16);\n}\n\n/**\n * This function gives the hash of a document. It uses the rule of `outputHash`, but the form does not include the field `hash` of the document.\n * With the default grid, it is the input hash of `docs/FORMAT.md` of `packing`.\n */\nexport function documentHash(doc: object, options: HashOptions = {}): string {\n const { hash: _hash, ...rest } = doc as { readonly hash?: unknown };\n return outputHash(rest, options);\n}\n\n/** One output group: the candidates with the same output hash on each decision input. */\nexport interface OutputGroup {\n /** The id of the group: its first member. */\n readonly id: string;\n /** The ids of the candidates of the group, in sorted order. */\n readonly members: readonly string[];\n}\n\n/**\n * This function gives the output groups of the candidates. The key of `hashes` is the id of a candidate.\n * Its value is the list of the output hashes of the candidate, in the order of the decision inputs.\n * Candidates with equal lists make one group. The groups are in the order of their ids.\n * The function throws a `RangeError` when two lists have different lengths.\n */\nexport function outputGroups(hashes: Readonly<Record<string, readonly string[]>>): OutputGroup[] {\n const byList = new Map<string, string[]>();\n let first: string | undefined;\n for (const id of Object.keys(hashes)) {\n const list = hashes[id]!;\n if (first === undefined) first = id;\n else if (list.length !== hashes[first]!.length)\n throw new RangeError(`The candidate \"${id}\" has ${list.length} hashes, but \"${first}\" has ${hashes[first]!.length}.`);\n const key = JSON.stringify(list);\n const members = byList.get(key);\n if (members) members.push(id);\n else byList.set(key, [id]);\n }\n const groups = [...byList.values()].map((members): OutputGroup => {\n const sorted = [...members].sort();\n return { id: sorted[0]!, members: sorted };\n });\n return groups.sort((a, b) => (a.id < b.id ? -1 : a.id > b.id ? 1 : 0));\n}\n\n/** The evidence that a candidate is exercised on its decision inputs. */\nexport interface ExerciseEvidence {\n /** The move counts of the candidate, by name. A record keeps each one as the trace measure `move.<name>`. */\n readonly moves?: Readonly<Record<string, number>>;\n /** The output hashes of the candidate, in the order of the decision inputs. */\n readonly hashes?: readonly string[];\n /** The output hashes of the base of the candidate, in the same order. */\n readonly baseHashes?: readonly string[];\n}\n\n/**\n * This function tells if a candidate is exercised. It gives `true` when a move count is more than 0.\n * It also gives `true` when `hashes` and `baseHashes` are different at one place or more.\n * Without evidence, it gives `false`.\n * The function throws a `RangeError` when only one of the two lists is given, or when their lengths are different.\n */\nexport function exercised(evidence: ExerciseEvidence): boolean {\n const { moves, hashes, baseHashes } = evidence;\n if ((hashes === undefined) !== (baseHashes === undefined)) throw new RangeError(\"The evidence must have both hashes and baseHashes, or neither of them.\");\n if (hashes && baseHashes && hashes.length !== baseHashes.length)\n throw new RangeError(`The candidate has ${hashes.length} hashes, but its base has ${baseHashes.length}.`);\n if (moves && Object.values(moves).some((n) => n > 0)) return true;\n if (hashes && baseHashes) return hashes.some((h, i) => h !== baseHashes[i]);\n return false;\n}\n","import { outputHash } from \"./hash.ts\";\nimport { compareMeasure, type MeasureSpec } from \"./measures.ts\";\n\n/** The part of a `MeasureSpec` that a pick uses: the direction and the `minEffect`. */\nexport type PickSpec = Pick<MeasureSpec, \"direction\" | \"minEffect\">;\n\n/** A member of a portfolio: a function with an id. A portfolio is also a member. */\nexport interface Member<I, O> {\n readonly id: string;\n /** This function gives the output of the member for an input. */\n run(input: I): O;\n}\n\n/** One level of the key of a portfolio: a measure of an output. */\nexport interface PortfolioLevel<I, O> {\n /** The id of the level. The id `hard` is reserved. */\n readonly id: string;\n readonly spec: PickSpec;\n /** This function gives the value of the measure for the output of a member. The value must be finite. */\n value(input: I, output: O): number;\n}\n\n/** The key of a portfolio: the hard level, then the other levels in order. */\nexport interface PortfolioKey<I, O> {\n /** This function gives the count of hard breaks. It is level 0, with the direction `lower` and the `minEffect` 0. */\n hard(input: I, output: O): number;\n /** The levels after the hard level, in the order of the pick. */\n readonly levels: readonly PortfolioLevel<I, O>[];\n /** This function gives the hash of an output. The default is `outputHash` with the default grid. */\n hash?(output: O): string;\n}\n\n/** The options of a portfolio. */\nexport interface PortfolioOptions {\n /** The time limit in milliseconds, 0 or more. The first member always starts. A member that starts always finishes. */\n readonly budgetMs?: number;\n /** The largest count of members that run, a whole number of 1 or more. The other members are cut. */\n readonly maxMembers?: number;\n /** The clock in milliseconds. The default is `performance.now`, or `Date.now` without `performance`. */\n readonly now?: () => number;\n /**\n * The members that get an output hash. The default `all` hashes each member with the status `ran`. A hash that throws then gives the status `error`.\n * With `pick`, only member 0 and the winner get a hash, and only when the winner is not member 0. Then a hash that throws makes `pick` throw.\n */\n readonly hashes?: \"all\" | \"pick\";\n}\n\n/** The status of a member in a pick. */\nexport type MemberStatus = \"ran\" | \"cut\" | \"error\";\n\n/** The trace of one member in a pick. */\nexport interface MemberTrace {\n readonly id: string;\n readonly status: MemberStatus;\n /** The value of each level, with the key `hard` for the hard level. Only a member with the status `ran` has values. */\n readonly values?: Readonly<Record<string, number>>;\n /** The time of the run of the member, in milliseconds. */\n readonly ms?: number;\n /**\n * The hash of the output of the member. Under the option `hashes` \"all\" (the default), each member with the status `ran` has it.\n * Under `hashes` \"pick\", it is absent, except for member 0 and the winner when the winner is not member 0.\n */\n readonly outputHash?: string;\n /** The message of the error of a member with the status `error`. */\n readonly error?: string;\n}\n\n/** The trace of one pick of a portfolio. */\nexport interface PortfolioTrace {\n /** One entry for each member, in the order of the members. A cut member is also in the list. */\n readonly members: readonly MemberTrace[];\n readonly winner: string;\n /** The index of the winner in the list of the members. */\n readonly winnerIndex: number;\n /** The value `true` tells that the winner is not member 0 and has a different output hash. */\n readonly picked: boolean;\n /** The time of the full pick, in milliseconds. */\n readonly totalMs: number;\n readonly budgetMs?: number;\n readonly maxMembers?: number;\n /** The count of the cut members. */\n readonly cut: number;\n /** The value `false` tells that the time limit cut one member or more. Then a run on a different computer can give a different pick. */\n readonly deterministic: boolean;\n /** The ids of the members that stay in after each level of `selectBest`. The first list is for the hard level. */\n readonly kept: readonly (readonly string[])[];\n}\n\n/** The result of one pick of a portfolio: the output of the winner, its id and the trace. */\nexport interface PortfolioPick<O> {\n readonly output: O;\n readonly winner: string;\n readonly trace: PortfolioTrace;\n}\n\n/** A portfolio: a member that runs its members and gives the output of the best member. */\nexport interface Portfolio<I, O> extends Member<I, O> {\n /** This function starts the members on an input and gives the output of the winner with the trace. */\n pick(input: I): PortfolioPick<O>;\n}\n\n/** A candidate of `selectBest`: an id and the value of each level. */\nexport interface SelectCandidate {\n readonly id: string;\n readonly values: Readonly<Record<string, number>>;\n}\n\n/** A level of `selectBest`: the id of a value and its spec. */\nexport interface SelectLevel {\n readonly id: string;\n readonly spec: PickSpec;\n}\n\n/** The result of `selectBest`. */\nexport interface Selection {\n readonly winner: string;\n /** The ids of the candidates that stay in after each level, in the given order. */\n readonly kept: readonly (readonly string[])[];\n}\n\n/**\n * This function picks the best candidate. For each level, it finds the best value of the candidates that stay in.\n * It keeps each candidate that is not worse than that best value by `compareMeasure`.\n * The winner is the first candidate, in the given order, that stays in after the last level.\n * Without levels, the winner is the first candidate and `kept` is empty.\n *\n * The reason for the rule: a scan that compares each candidate with the current winner is not transitive, because of the `minEffect` ties.\n * Such a scan can drift away from the best value. An example: \"a\" is lower with the `minEffect` 0.005, and \"b\" is higher.\n * The candidates A (0, 1), B (0.004, 2) and C (0.008, 3) give the winner B.\n * The scan picks C, but A is better than C on \"a\".\n *\n * The function throws a `RangeError` for an empty list of candidates, for a missing value, and for a value that is not finite.\n */\nexport function selectBest(candidates: readonly SelectCandidate[], levels: readonly SelectLevel[]): Selection {\n if (candidates.length === 0) throw new RangeError(\"selectBest: the list of candidates is empty.\");\n for (const level of levels) {\n for (const c of candidates) {\n const v = c.values[level.id];\n if (typeof v !== \"number\") throw new RangeError(`selectBest: the candidate \"${c.id}\" has no value for the level \"${level.id}\".`);\n if (!Number.isFinite(v)) throw new RangeError(`selectBest: the candidate \"${c.id}\" has the value ${v} for the level \"${level.id}\".`);\n }\n }\n let alive: readonly SelectCandidate[] = candidates;\n const kept: (readonly string[])[] = [];\n for (const level of levels) {\n const at = (c: SelectCandidate): number => c.values[level.id]!;\n let best = at(alive[0]!);\n for (const c of alive) best = level.spec.direction === \"lower\" ? Math.min(best, at(c)) : Math.max(best, at(c));\n alive = alive.filter((c) => compareMeasure(at(c), best, level.spec) !== \"worse\");\n kept.push(alive.map((c) => c.id));\n }\n return { winner: alive[0]!.id, kept };\n}\n\n/** This function gives the move `pick` of a pick: 1 when `picked` is true, else 0. A record keeps it as the trace measure `move.pick`. */\nexport function pickMoves(trace: Pick<PortfolioTrace, \"picked\">): { pick: number } {\n return { pick: trace.picked ? 1 : 0 };\n}\n\n/** This function gives the default clock: `performance.now`, or `Date.now` without `performance`. */\nfunction defaultClock(): () => number {\n const perf = (globalThis as { readonly performance?: { now(): number } }).performance;\n return perf ? () => perf.now() : () => Date.now();\n}\n\n/** This function gives the message of an error value. */\nfunction messageOf(e: unknown): string {\n return e instanceof Error ? e.message : String(e);\n}\n\n/** This function throws a `RangeError` for an empty list of members or for two members with the same id. */\nfunction checkMembers(id: string, members: readonly Member<unknown, unknown>[]): void {\n if (members.length === 0) throw new RangeError(`The portfolio \"${id}\" has no members.`);\n const seen = new Set<string>();\n for (const m of members) {\n if (seen.has(m.id)) throw new RangeError(`The portfolio \"${id}\" has two members with the id \"${m.id}\".`);\n seen.add(m.id);\n }\n}\n\n/** The result of the run of one member. */\ntype Ran<O> = { readonly ok: true; readonly output: O; readonly values: Record<string, number>; readonly hash?: string } | { readonly ok: false; readonly error: unknown };\n\n/**\n * This function makes a portfolio. Its `pick` starts the members in their order. `selectBest` picks the winner of the members with the status `ran`.\n * The first level is the hard level, then the levels of the key follow.\n * `members` is a list, or a function of the input that gives the list.\n *\n * A member that throws, or that gives a value that is not finite, gets the status `error`. It does not win.\n * When each member has an error, `pick` throws the error of the first member.\n * `docs/PORTFOLIO.md` tells the rules of the time limit, the trace and `picked`.\n *\n * The function throws a `RangeError` for a level with the id `hard`, for two levels with the same id and for a bad option.\n * It also throws a `RangeError` for an empty list of members, or for two members with the same id.\n */\nexport function portfolio<I, O>(\n id: string,\n members: readonly Member<I, O>[] | ((input: I) => readonly Member<I, O>[]),\n key: PortfolioKey<I, O>,\n options: PortfolioOptions = {},\n): Portfolio<I, O> {\n const levelIds = new Set<string>();\n for (const level of key.levels) {\n if (level.id === \"hard\") throw new RangeError(`The portfolio \"${id}\" has a level with the reserved id \"hard\".`);\n if (levelIds.has(level.id)) throw new RangeError(`The portfolio \"${id}\" has two levels with the id \"${level.id}\".`);\n levelIds.add(level.id);\n }\n const { budgetMs, maxMembers, hashes = \"all\" } = options;\n if (budgetMs !== undefined && !(budgetMs >= 0)) throw new RangeError(`The portfolio \"${id}\" has the budgetMs ${budgetMs}. It must be 0 or more.`);\n if (maxMembers !== undefined && !(Number.isInteger(maxMembers) && maxMembers >= 1))\n throw new RangeError(`The portfolio \"${id}\" has the maxMembers ${maxMembers}. It must be a whole number of 1 or more.`);\n if (hashes !== \"all\" && hashes !== \"pick\") throw new RangeError(`The portfolio \"${id}\" has the hashes ${String(hashes)}. It must be \"all\" or \"pick\".`);\n if (typeof members !== \"function\") checkMembers(id, members);\n const levels: readonly SelectLevel[] = [{ id: \"hard\", spec: { direction: \"lower\", minEffect: 0 } }, ...key.levels.map((l) => ({ id: l.id, spec: l.spec }))];\n const now = options.now ?? defaultClock();\n\n /** This function gives the hash of the output of a member. A hash that throws causes a `RangeError`. */\n const hashOf = (m: Member<I, O>, output: O): string => {\n try {\n return key.hash ? key.hash(output) : outputHash(output);\n } catch (e) {\n throw new RangeError(`The hash of the member \"${m.id}\" of the portfolio \"${id}\" throws: ${messageOf(e)}`, { cause: e });\n }\n };\n\n const evaluate = (m: Member<I, O>, input: I, output: O): Ran<O> => {\n const values: Record<string, number> = {};\n const measure = (level: string, f: () => number): void => {\n let v: number;\n try {\n v = f();\n } catch (e) {\n throw new RangeError(`The level \"${level}\" of the member \"${m.id}\" of the portfolio \"${id}\" throws: ${messageOf(e)}`, { cause: e });\n }\n if (typeof v !== \"number\" || !Number.isFinite(v))\n throw new RangeError(`The member \"${m.id}\" of the portfolio \"${id}\" has the value ${v} for the level \"${level}\".`);\n values[level] = v;\n };\n try {\n measure(\"hard\", () => key.hard(input, output));\n for (const level of key.levels) measure(level.id, () => level.value(input, output));\n if (hashes === \"pick\") return { ok: true, output, values };\n return { ok: true, output, values, hash: hashOf(m, output) };\n } catch (e) {\n return { ok: false, error: e };\n }\n };\n\n const pick = (input: I): PortfolioPick<O> => {\n const list = typeof members === \"function\" ? members(input) : members;\n if (typeof members === \"function\") checkMembers(id, list);\n const start = now();\n const traces: MemberTrace[] = [];\n const outputs = new Map<string, O>();\n const ran: SelectCandidate[] = [];\n let firstError: { readonly error: unknown } | undefined;\n let cut = 0;\n let outOfTime = false;\n for (let i = 0; i < list.length; i++) {\n const m = list[i]!;\n if (maxMembers !== undefined && i >= maxMembers) {\n traces.push({ id: m.id, status: \"cut\" });\n cut++;\n continue;\n }\n if (i > 0 && budgetMs !== undefined && (outOfTime || now() - start >= budgetMs)) {\n outOfTime = true;\n traces.push({ id: m.id, status: \"cut\" });\n cut++;\n continue;\n }\n const t0 = now();\n let result: Ran<O>;\n let ms: number;\n try {\n const output = m.run(input);\n ms = now() - t0;\n result = evaluate(m, input, output);\n } catch (e) {\n ms = now() - t0;\n result = { ok: false, error: e };\n }\n if (result.ok) {\n traces.push(\n result.hash === undefined\n ? { id: m.id, status: \"ran\", values: result.values, ms }\n : { id: m.id, status: \"ran\", values: result.values, ms, outputHash: result.hash },\n );\n outputs.set(m.id, result.output);\n ran.push({ id: m.id, values: result.values });\n } else {\n traces.push({ id: m.id, status: \"error\", ms, error: messageOf(result.error) });\n firstError ??= { error: result.error };\n }\n }\n if (ran.length === 0) throw firstError!.error;\n const { winner, kept } = selectBest(ran, levels);\n const winnerIndex = traces.findIndex((t) => t.id === winner);\n if (hashes === \"pick\" && winnerIndex > 0 && traces[0]!.status === \"ran\") {\n // Only member 0 and the winner get a hash. Their two trace entries are new objects with the hash.\n for (const i of [0, winnerIndex]) traces[i] = { ...traces[i]!, outputHash: hashOf(list[i]!, outputs.get(traces[i]!.id)!) };\n }\n const base = traces[0]!;\n const picked = winnerIndex > 0 && (base.status !== \"ran\" || traces[winnerIndex]!.outputHash !== base.outputHash);\n const trace: PortfolioTrace = {\n members: traces,\n winner,\n winnerIndex,\n picked,\n totalMs: now() - start,\n ...(budgetMs !== undefined ? { budgetMs } : {}),\n ...(maxMembers !== undefined ? { maxMembers } : {}),\n cut,\n deterministic: !outOfTime,\n kept,\n };\n return { output: outputs.get(winner)!, winner, trace };\n };\n\n return { id, pick, run: (input: I): O => pick(input).output };\n}\n","// The checks of the claims of a corpus (`docs/CORPUS-CHECKS.md`). The joint corpus, `packing` and `highways` use the same checks.\nimport { canonicalJson, sha256Hex } from \"./hash.ts\";\n\n/** One broken claim of a corpus, with the ids of the inputs that break it. */\nexport interface ClaimBreak {\n /** The name of the claim, for example `declared`, `split` or `index`. */\n readonly claim: string;\n /** The text of the break. */\n readonly detail: string;\n /** The ids of the inputs that break the claim. The list is empty when the break has no input. */\n readonly inputs: readonly string[];\n}\n\n/** The claim `claims.declared` of a manifest: the count of the inputs for each declared property. */\nexport interface DeclaredClaim {\n /** A property with fewer inputs than this count is thin. */\n readonly minCount: number;\n /** The ids of the properties with a count below `minCount`. */\n readonly thin: readonly string[];\n /** The count of the inputs for each property id. */\n readonly counts: Readonly<Record<string, number>>;\n /** The key of the family of an input. `familyOf` gives the key of one cell. The family is the unit of a verdict. */\n readonly familyBy?: FamilyBy;\n /** The minimum count of the inputs of each family. Without it, `checkDeclared` does not count the families. */\n readonly familyMin?: number;\n}\n\n/**\n * The key of the family of a cell (`docs/CORPUS-CHECKS.md`).\n *\n * - The flat form is a list of dimensions. The key is the values of these dimensions of the cell, in order, with `/` between them.\n * - The map form chooses an entry by the field `kind` of the cell, or the entry `\"*\"`. The key is the kind, then the values of the dimensions of the entry.\n */\nexport type FamilyBy = readonly string[] | { readonly [kind: string]: readonly string[] };\n\n/** A cell of an input: one value for each dimension. The map form of `FamilyBy` also reads the field `kind`. */\nexport type FamilyCell = Readonly<Record<string, unknown>>;\n\n/** The entry of the map form of `FamilyBy` for each kind without its own entry. */\nexport const FAMILY_ANY_KIND = \"*\";\n\n/** The separator of the parts of a family key. */\nconst FAMILY_SEP = \"/\";\n\n/** The parts of the key of one cell, or the text of the problem. */\ntype FamilyParts = { readonly parts: readonly string[] } | { readonly problem: string };\n\n/** This function gives the text of a dimension value. A missing value, or a value that is not a string, a number or a boolean, gives `undefined`. */\nfunction partOf(value: unknown): string | undefined {\n if (typeof value === \"string\") return value;\n if (typeof value === \"number\" || typeof value === \"boolean\") return String(value);\n return undefined;\n}\n\n/** This function gives the parts of the family key of a cell. A missing dimension, a missing kind or a kind without an entry gives a problem. */\nfunction familyParts(cell: FamilyCell, familyBy: FamilyBy): FamilyParts {\n let dims: readonly string[];\n let kind: string | undefined;\n const parts: string[] = [];\n if (Array.isArray(familyBy)) {\n dims = familyBy as readonly string[];\n } else {\n const map = familyBy as Readonly<Record<string, readonly string[]>>;\n kind = partOf(cell[\"kind\"]);\n if (kind === undefined) return { problem: \"a cell without kind, which the map form of familyBy needs\" };\n const entry = Object.hasOwn(map, kind) ? map[kind] : Object.hasOwn(map, FAMILY_ANY_KIND) ? map[FAMILY_ANY_KIND] : undefined;\n if (entry === undefined) return { problem: `the kind \"${kind}\", which has no entry in familyBy and no entry \"${FAMILY_ANY_KIND}\"` };\n dims = entry;\n parts.push(kind);\n }\n for (const dim of dims) {\n const part = partOf(cell[dim]);\n if (part === undefined) return { problem: `a cell${kind === undefined ? \"\" : ` of the kind \"${kind}\"`} without the dimension \"${dim}\" of familyBy` };\n parts.push(part);\n }\n return { parts };\n}\n\n/**\n * This function gives the family key of a cell. It throws a `RangeError` when the cell does not have a dimension of the key.\n * In the map form, it also throws for a cell without `kind`, and for a kind with no entry and no entry `\"*\"`.\n * For example, `{ \"rect-grid\": [\"obstacles\"], \"*\": [] }` gives `rect-grid/wall` for a `rect-grid` cell and `gallery` for a `gallery` cell.\n */\nexport function familyOf(cell: FamilyCell, familyBy: FamilyBy): string {\n const found = familyParts(cell, familyBy);\n if (\"problem\" in found) throw new RangeError(`familyOf: ${found.problem}.`);\n return found.parts.join(FAMILY_SEP);\n}\n\n/** This function tells if a value is a `FamilyBy`: a list of dimensions, or a map from a kind to a list of dimensions. */\nfunction isFamilyBy(value: unknown): value is FamilyBy {\n const isDims = (v: unknown): boolean => Array.isArray(v) && v.every((d) => typeof d === \"string\");\n return isDims(value) || (isObject(value) && Object.values(value).every(isDims));\n}\n\n/** The hook that gives the ids of the properties that one input declares. */\nexport type Declares<I> = (input: I) => readonly string[];\n\n/**\n * This function gives the count of the inputs for each property id. Each id of `ids` has a count, also when the count is 0.\n * An id from `declares` that is not in `ids` comes after the ids of `ids`, in the order of the first input that declares it.\n */\nexport function declaredCounts<I>(inputs: Iterable<I>, declares: Declares<I>, ids: readonly string[] = []): Record<string, number> {\n const out: Record<string, number> = Object.fromEntries(ids.map((id) => [id, 0]));\n for (const input of inputs) for (const id of declares(input)) out[id] = (out[id] ?? 0) + 1;\n return out;\n}\n\n/** This function tells if a value is a plain object. */\nconst isObject = (value: unknown): value is Record<string, unknown> => value !== null && typeof value === \"object\" && !Array.isArray(value);\n\n/**\n * This function reads the field `claims.declared` of a manifest. A manifest without it gives `undefined`.\n * It throws an `Error` for a claim without a whole `minCount`, a list `thin` of ids and a whole count for each id.\n */\nexport function declaredClaimOf(manifest: object): DeclaredClaim | undefined {\n const claims = (manifest as Record<string, unknown>)[\"claims\"];\n if (claims === undefined) return undefined;\n if (!isObject(claims)) throw new Error(\"The field claims of a corpus file is an object.\");\n const declared = claims[\"declared\"];\n if (declared === undefined) return undefined;\n if (!isObject(declared)) throw new Error(\"The field claims.declared of a corpus file is an object.\");\n const { minCount, thin, counts } = declared;\n if (!Number.isInteger(minCount) || (minCount as number) < 0) throw new Error(\"The field claims.declared.minCount is a whole number of 0 or more.\");\n if (!Array.isArray(thin) || !thin.every((id) => typeof id === \"string\")) throw new Error(\"The field claims.declared.thin is a list of property ids.\");\n if (!isObject(counts) || !Object.values(counts).every((n) => Number.isInteger(n) && (n as number) >= 0)) {\n throw new Error(\"The field claims.declared.counts gives a whole count for each property id.\");\n }\n const { familyBy, familyMin } = declared;\n if (familyBy !== undefined && !isFamilyBy(familyBy)) throw new Error(\"The field claims.declared.familyBy is a list of dimensions, or a map from a kind to a list of dimensions.\");\n if (familyMin !== undefined && (!Number.isInteger(familyMin) || (familyMin as number) < 0)) throw new Error(\"The field claims.declared.familyMin is a whole number of 0 or more.\");\n return {\n minCount: minCount as number,\n thin: [...(thin as string[])],\n counts: { ...(counts as Record<string, number>) },\n ...(familyBy === undefined ? {} : { familyBy: Array.isArray(familyBy) ? [...familyBy] : { ...(familyBy as Record<string, readonly string[]>) } }),\n ...(familyMin === undefined ? {} : { familyMin: familyMin as number }),\n };\n}\n\n/**\n * This function checks the claim `claims.declared` against the inputs. It gives one break `declared` for each problem. An empty list tells that the claim is true.\n *\n * - `ids` are the property ids. The default is the ids of `claim.counts`.\n * - Each id of `ids` has a count in `claim.counts`, and `claim.counts` has no other id. Each count is the count of the inputs.\n * - An id with a count below `minCount` is in `thin`. Each id of `thin` is an id of `ids`.\n * - Each id that `declares` gives is an id of `ids`.\n *\n * With `claim.familyBy`, the hook `cellOf` gives the cell of each input. The default reads the field `cell` of the input.\n *\n * - Each cell has each dimension of its key. In the map form, each cell has a `kind`, and the kind has an entry or the entry `\"*\"` is there.\n * - Two cells with different dimension values do not give the same key.\n * - With `claim.familyMin`, each family has `familyMin` inputs or more.\n */\nexport function checkDeclared<I>(\n inputs: Iterable<I>,\n declares: Declares<I>,\n claim: DeclaredClaim,\n ids: readonly string[] = Object.keys(claim.counts),\n cellOf: (input: I) => FamilyCell | undefined = cellField,\n): ClaimBreak[] {\n const list = [...inputs];\n const computed = declaredCounts(list, declares, ids);\n const out: string[] = [];\n for (const id of ids) {\n if (!(id in claim.counts)) out.push(`the property \"${id}\" has no count`);\n else if (claim.counts[id] !== computed[id]) out.push(`the property \"${id}\" has the count ${claim.counts[id]}, but the inputs give ${computed[id]}`);\n }\n for (const id of Object.keys(claim.counts)) if (!ids.includes(id)) out.push(`\"${id}\" is not a declared property`);\n for (const id of ids) {\n const thin = (computed[id] ?? 0) < claim.minCount;\n if (thin && !claim.thin.includes(id)) out.push(`the property \"${id}\" has ${computed[id]} inputs, below minCount ${claim.minCount}, and it is not in thin`);\n }\n for (const id of claim.thin) if (!ids.includes(id)) out.push(`\"${id}\" of thin is not a declared property`);\n for (const id of Object.keys(computed)) if (!ids.includes(id)) out.push(`${computed[id]} inputs declare \"${id}\", which is not a declared property`);\n const breaks: ClaimBreak[] = out.map((detail) => ({ claim: \"declared\", detail, inputs: [] }));\n if (claim.familyBy !== undefined) breaks.push(...checkFamilies(list, claim.familyBy, claim.familyMin, cellOf));\n return breaks;\n}\n\n/** This function gives the field `cell` of an input, when it is an object. */\nfunction cellField(input: unknown): FamilyCell | undefined {\n const cell = isObject(input) ? input[\"cell\"] : undefined;\n return isObject(cell) ? cell : undefined;\n}\n\n/** This function gives the field `id` of an input, or its place in the list. */\nfunction inputId(input: unknown, at: number): string {\n const id = isObject(input) ? input[\"id\"] : undefined;\n return typeof id === \"string\" ? id : `#${at}`;\n}\n\n/** This function gives the breaks of the family keys of the inputs: the problems of each key, the collisions and the thin families. */\nfunction checkFamilies<I>(inputs: readonly I[], familyBy: FamilyBy, familyMin: number | undefined, cellOf: (input: I) => FamilyCell | undefined): ClaimBreak[] {\n const problems = new Map<string, string[]>();\n const members = new Map<string, { readonly tuples: Map<string, string[]>; readonly ids: string[] }>();\n inputs.forEach((input, at) => {\n const id = inputId(input, at);\n const cell = cellOf(input);\n const found: FamilyParts = cell === undefined ? { problem: \"no cell, which familyBy needs\" } : familyParts(cell, familyBy);\n if (\"problem\" in found) {\n problems.set(found.problem, [...(problems.get(found.problem) ?? []), id]);\n return;\n }\n const key = found.parts.join(FAMILY_SEP);\n const family = members.get(key) ?? { tuples: new Map<string, string[]>(), ids: [] };\n const tuple = JSON.stringify(found.parts);\n family.tuples.set(tuple, [...(family.tuples.get(tuple) ?? []), id]);\n family.ids.push(id);\n members.set(key, family);\n });\n const breaks: ClaimBreak[] = [];\n const add = (detail: string, ids: readonly string[]): void => void breaks.push({ claim: \"declared\", detail, inputs: [...ids] });\n for (const [problem, ids] of problems) add(`${ids.length} inputs have ${problem}`, ids);\n for (const [key, family] of members) {\n if (family.tuples.size > 1) {\n const forms = [...family.tuples.keys()].join(\" and \");\n add(`the family \"${key}\" comes from different dimension values: ${forms}`, family.ids);\n }\n if (familyMin !== undefined && family.ids.length < familyMin) add(`the family \"${key}\" has ${family.ids.length} inputs, below familyMin ${familyMin}`, family.ids);\n }\n return breaks;\n}\n\n/** The id and the hash of one input of a corpus. */\nexport interface CorpusEntry {\n readonly id: string;\n readonly hash: string;\n}\n\n/**\n * This function gives the hash of a corpus: the first 16 hex characters of a SHA-256. The text of the SHA-256 is `canonicalJson`\n * of the corpus id and the `[id, hash]` of each input, in the order of the manifest. A change of one input changes the hash.\n */\nexport function corpusHashOf(corpus: string, inputs: readonly CorpusEntry[]): string {\n return sha256Hex(canonicalJson({ corpus, inputs: inputs.map((i) => [i.id, i.hash]) })).slice(0, 16);\n}\n\n/** The schema of a split file. */\nexport const SPLIT_SCHEMA = \"corpus-split/1\";\n\n/** One fold of a split: the seeds that fit a selector and the seeds that score it. */\nexport interface SplitFold {\n readonly train: readonly number[];\n readonly heldOut: readonly number[];\n}\n\n/** A split file `corpus-split/1`. Its name is `<corpus id>.<corpus hash>.json`. It is beside the corpus, so the corpus does not change. */\nexport interface CorpusSplit {\n readonly schema: typeof SPLIT_SCHEMA;\n readonly corpus: string;\n /** The hash of the corpus: `corpusHashOf` of its manifest. */\n readonly corpusHash: string;\n /** The splits by name. Each split has one fold or more. */\n readonly splits: Readonly<Record<string, { readonly folds: readonly SplitFold[] }>>;\n}\n\n/** The fields of a manifest that the split check reads. */\nexport interface SplitCorpus {\n readonly corpus: string;\n readonly specs: readonly { readonly seeds: readonly number[] }[];\n readonly inputs: readonly CorpusEntry[];\n}\n\n/** This function gives the name of the split file of a corpus. */\nexport function splitFileName(corpus: string, hash: string): string {\n return `${corpus}.${hash}.json`;\n}\n\n/** This function tells if a value is a list of whole numbers. */\nconst isSeeds = (value: unknown): value is number[] => Array.isArray(value) && value.every((s) => Number.isInteger(s));\n\n/**\n * This function checks a split file against a manifest. It gives one break `split` for each problem. An empty list tells that the file is good.\n *\n * - The schema is `corpus-split/1`, the corpus is the id of the manifest and `corpusHash` is `corpusHashOf` of the manifest.\n * - Each split has one fold or more. In each fold, `train` and `heldOut` are lists of seeds, not empty and with no common seed.\n * - Each seed is a seed of a spec of the manifest.\n * - With `name`, the file has the split `name`.\n */\nexport function checkSplit(split: unknown, corpus: SplitCorpus, name?: string): ClaimBreak[] {\n const out: string[] = [];\n const done = (): ClaimBreak[] => out.map((detail) => ({ claim: \"split\", detail, inputs: [] }));\n const f = split as Partial<CorpusSplit> | null;\n if (f === null || typeof f !== \"object\") {\n out.push(\"the split file is not an object\");\n return done();\n }\n if (f.schema !== SPLIT_SCHEMA) out.push(`the schema is ${String(f.schema)}, not ${SPLIT_SCHEMA}`);\n if (f.corpus !== corpus.corpus) out.push(`the corpus is ${String(f.corpus)}, not ${corpus.corpus}`);\n const hash = corpusHashOf(corpus.corpus, corpus.inputs);\n if (f.corpusHash !== hash) out.push(`the corpusHash is ${String(f.corpusHash)}, but the corpus gives ${hash}`);\n const seeds = new Set(corpus.specs.flatMap((s) => s.seeds));\n if (f.splits === null || typeof f.splits !== \"object\") {\n out.push(\"the field splits is not an object\");\n return done();\n }\n for (const [key, value] of Object.entries(f.splits)) {\n const folds = (value as { folds?: unknown } | null)?.folds;\n if (!Array.isArray(folds) || folds.length === 0) {\n out.push(`the split ${key} has no folds`);\n continue;\n }\n folds.forEach((fold: Partial<SplitFold> | null, k) => {\n const at = `the fold ${k} of the split ${key}`;\n const { train, heldOut } = fold ?? {};\n if (!isSeeds(train) || train.length === 0) out.push(`${at} has no train seeds`);\n if (!isSeeds(heldOut) || heldOut.length === 0) out.push(`${at} has no heldOut seeds`);\n if (!isSeeds(train) || !isSeeds(heldOut)) return;\n const common = train.filter((s) => heldOut.includes(s));\n if (common.length > 0) out.push(`${at} has the seeds ${common.join(\", \")} in train and in heldOut`);\n const unknown = [...train, ...heldOut].filter((s) => !seeds.has(s));\n if (unknown.length > 0) out.push(`${at} has the seeds ${unknown.join(\", \")}, which are not in the corpus`);\n });\n }\n if (name !== undefined && !Object.hasOwn(f.splits, name)) out.push(`the split file has no split ${name}. Its splits are ${Object.keys(f.splits).join(\", \")}`);\n return done();\n}\n\n/**\n * This function gives a copy of the folds of the split `name` of a split file. `where` names the file in the text of an error.\n * It throws an `Error` for each problem of `checkSplit`, and then for an unknown split name.\n */\nexport function splitFolds(split: unknown, corpus: SplitCorpus, name: string, where: string = \"The split file\"): SplitFold[] {\n const breaks = checkSplit(split, corpus);\n if (breaks.length > 0) throw new Error(`${where} is not good: ${breaks.map((b) => b.detail).join(\"; \")}.`);\n const splits = (split as CorpusSplit).splits;\n const found = Object.hasOwn(splits, name) ? splits[name] : undefined;\n if (found === undefined) throw new Error(`${where} has no split ${name}. Its splits are ${Object.keys(splits).join(\", \")}.`);\n return found.folds.map((f) => ({ train: [...f.train], heldOut: [...f.heldOut] }));\n}\n\n/** This function gives the folds that hold out one seed each, in the order of the seeds. Each fold trains on the other seeds. */\nexport function leaveOneSeedOut(seeds: readonly number[]): SplitFold[] {\n const sorted = [...new Set(seeds)].sort((a, b) => a - b);\n return sorted.map((s) => ({ train: sorted.filter((t) => t !== s), heldOut: [s] }));\n}\n","// The strategy space of an engine (`docs/STRATEGY-SPACE.md`): its stages, their options and the ranges of their params, as data.\nimport type { ClaimBreak } from \"./corpus.ts\";\nimport { canonicalJson, sha256Hex } from \"./hash.ts\";\nimport { stepRandom } from \"./random.ts\";\n\n/** The schema of a strategy space. */\nexport const STRATEGY_SPACE_SCHEMA = \"strategy-space/1\";\n\n/** The kind of a param: a whole number, a real number, one value of a list, or `true` and `false`. */\nexport type ParamKind = \"int\" | \"real\" | \"enum\" | \"bool\";\n\n/** The value of one param in a config. */\nexport type ParamValue = number | string | boolean;\n\n/** The condition of a conditional param: the param is active only when an earlier param of the same option has one of the values `in`. */\nexport interface ParamWhen {\n /** The name of an earlier param of the same option. */\n readonly param: string;\n /** The values of that param that make this param active. */\n readonly in: readonly ParamValue[];\n}\n\n/** One param of a stage option, with its range. */\nexport interface SpaceParam {\n readonly name: string;\n readonly kind: ParamKind;\n /** The smallest value of an `int` or `real` param. */\n readonly min?: number;\n /** The largest value of an `int` or `real` param. */\n readonly max?: number;\n /** The step of the values from `min`. An `int` param has the step 1 by default. */\n readonly step?: number;\n /** The scale of the grid and of the samples. The scale `log` needs a `min` above 0. The default is `linear`. */\n readonly scale?: \"linear\" | \"log\";\n /** The values of an `enum` param. */\n readonly values?: readonly (string | number)[];\n /** The value that a config gets when it does not set the param. */\n readonly default: ParamValue;\n /** Without `when`, the param is active each time its option is chosen. */\n readonly when?: ParamWhen;\n}\n\n/** The rule of the members of a meta option: a count from `min` to `max`. Members with `ordered: false` are sorted by their `configId`. */\nexport interface MemberRule {\n readonly min: number;\n readonly max: number;\n readonly ordered: boolean;\n}\n\n/** One implementation of a stage. An option with `members` is a meta option: it chooses between whole configs, or wraps them. */\nexport interface StageOption {\n readonly id: string;\n readonly params: readonly SpaceParam[];\n readonly members?: MemberRule;\n}\n\n/** One stage of the pipeline of an engine. A config of an `optional` stage can have no option. */\nexport interface SpaceStage {\n readonly name: string;\n readonly options: readonly StageOption[];\n readonly optional?: boolean;\n}\n\n/** A reference to one option of a stage. The option `null` refers to an optional stage that a config does not use. */\nexport interface OptionRef {\n readonly stage: string;\n readonly option: string | null;\n}\n\n/** A rule that keeps out invalid combinations. A config with the option `if` also has the option `then`, or does not have the option `then.not`. */\nexport interface SpaceConstraint {\n readonly if: OptionRef;\n readonly then: OptionRef | { readonly not: OptionRef };\n}\n\n/** The strategy space of an engine: the stages, the constraints and the named configs. `docs/STRATEGY-SPACE.md` tells the rules. */\nexport interface StrategySpace {\n readonly schema: typeof STRATEGY_SPACE_SCHEMA;\n /** The name of the space. A config names the space with this value. */\n readonly engine: string;\n /** The version of the space. It is not part of a config or of its id. A record writes it. */\n readonly version: string;\n readonly stages: readonly SpaceStage[];\n readonly constraints?: readonly SpaceConstraint[];\n /** The named strategies of the engine, as points of the space. Old records stay comparable through them. */\n readonly named?: Readonly<Record<string, StrategyConfig>>;\n /** The spaces of a product space, from `productSpace`. A meta option of a part takes members of that part. */\n readonly parts?: readonly StrategySpace[];\n}\n\n/** The choice of one stage in a config: an option, its params and, for a meta option, its members. */\nexport interface StageChoice {\n readonly option: string;\n /** The values of the active params. A param that is not set gets its default. */\n readonly params?: Readonly<Record<string, ParamValue>>;\n /** The members of a meta option: configs of the same space, with no meta option. */\n readonly members?: readonly StrategyConfig[];\n}\n\n/** One point of a strategy space. The value `null` of a stage tells that the config does not use the optional stage. */\nexport interface StrategyConfig {\n /** The `engine` of the space, without its version. */\n readonly space: string;\n readonly stages: Readonly<Record<string, StageChoice | null>>;\n}\n\n/** The count of the grid points of a space. */\nexport interface SpaceSize {\n /** The count of the configs without a meta option. */\n readonly base: bigint;\n /** The count of the configs with a meta option. The value is `null` when the count is more than `maxMeta`. */\n readonly meta: bigint | null;\n}\n\n/** The options of `spaceSize`. */\nexport interface SpaceSizeOptions {\n /** The count of the levels of each numeric param, a whole number of 1 or more. */\n readonly levels: number;\n /** The largest meta count that `spaceSize` gives. The default is `10n ** 18n`. */\n readonly maxMeta?: bigint;\n}\n\n/** The options of a grid. The grid gives only the configs without a meta option. */\nexport interface GridOptions {\n readonly mode: \"grid\";\n readonly levels: number;\n /** The largest count of configs. A larger grid causes a `RangeError`. The default is 100000. */\n readonly limit?: number;\n}\n\n/** The options of a sample. */\nexport interface SampleOptions {\n readonly mode: \"sample\";\n /** The count of the configs, a whole number of 0 or more. */\n readonly n: number;\n readonly seed: number;\n /** With `skip` (the default), the sample has no meta option. With `sample`, a meta option draws its members from base samples. */\n readonly meta?: \"skip\" | \"sample\";\n /** The largest count of option draws. The default is the larger value of 1000 and `100 * n`. */\n readonly maxTries?: number;\n}\n\n/** The options of `enumerateSpace`. */\nexport type EnumerateOptions = GridOptions | SampleOptions;\n\ntype Problem = readonly [claim: string, detail: string];\ntype Choices = ReadonlyMap<string, StageOption | null>;\ntype Values = Record<string, ParamValue>;\n\nconst isObject = (value: unknown): value is Record<string, unknown> => value !== null && typeof value === \"object\" && !Array.isArray(value);\nconst show = (value: unknown): string => (typeof value === \"string\" ? `\"${value}\"` : String(value));\nconst isNumeric = (p: SpaceParam): boolean => p.kind === \"int\" || p.kind === \"real\";\nconst zero = (v: number): number => (v === 0 ? 0 : v);\n\n/** This function gives the stable form of a real number: 12 significant digits, with `-0` as `0`. */\nconst realForm = (v: number, digits = 12): number => zero(Number(v.toPrecision(digits)));\n\n/** This function gives the stable form of a value of a param. */\nfunction normalize(p: SpaceParam, v: ParamValue): ParamValue {\n if (typeof v !== \"number\") return v;\n if (p.kind !== \"real\") return zero(v);\n return Math.min(p.max ?? Infinity, Math.max(p.min ?? -Infinity, realForm(v)));\n}\n\n/** This function tells if a value is on the step of a param. */\nfunction onStep(p: SpaceParam, v: number): boolean {\n if (p.step === undefined || p.min === undefined) return true;\n const q = (v - p.min) / p.step;\n return Math.abs(q - Math.round(q)) <= 1e-9 * Math.max(1, Math.abs(q));\n}\n\n/** This function gives the problem of a value of a param, or `undefined` for a value in the range. */\nfunction valueProblem(p: SpaceParam, v: unknown): string | undefined {\n if (p.kind === \"bool\") return typeof v === \"boolean\" ? undefined : `${show(v)} is not true or false`;\n if (p.kind === \"enum\") return (p.values ?? []).some((x) => x === v) ? undefined : `${show(v)} is not one of ${(p.values ?? []).map(show).join(\", \")}`;\n if (typeof v !== \"number\" || !Number.isFinite(v)) return `${show(v)} is not a finite number`;\n if (p.kind === \"int\" && !Number.isInteger(v)) return `${v} is not a whole number`;\n if (p.min !== undefined && v < p.min) return `${v} is less than the min ${p.min}`;\n if (p.max !== undefined && v > p.max) return `${v} is more than the max ${p.max}`;\n if (!onStep(p, v)) return `${v} is not on the step ${p.step} from ${p.min}`;\n return undefined;\n}\n\n/** This function tells if a param is active for the values of the earlier params. */\nfunction isActive(p: SpaceParam, values: Values): boolean {\n if (p.when === undefined) return true;\n if (!Object.hasOwn(values, p.when.param)) return false;\n const v = values[p.when.param];\n return p.when.in.some((x) => x === v);\n}\n\n/** This function gives the part of a space that has a stage, and the prefix of the names of its stages. */\nfunction partOf(space: StrategySpace, stage: string): { readonly space: StrategySpace; readonly prefix: string } {\n for (const part of space.parts ?? []) {\n const head = `${part.engine}.`;\n if (stage.startsWith(head)) {\n const inner = partOf(part, stage.slice(head.length));\n return { space: inner.space, prefix: head + inner.prefix };\n }\n }\n return { space, prefix: \"\" };\n}\n\n/** This function gives the prefix of the innermost part of each stage. */\nconst prefixes = (space: StrategySpace): Map<string, string> => new Map(space.stages.map((s) => [s.name, partOf(space, s.name).prefix]));\n\nconst refMatches = (ref: OptionRef, choices: ReadonlyMap<string, string | null>): boolean => (choices.get(ref.stage) ?? null) === ref.option;\n\n/** This function tells if the option choices keep a constraint. */\nfunction holds(c: SpaceConstraint, choices: ReadonlyMap<string, string | null>): boolean {\n if (!refMatches(c.if, choices)) return true;\n return \"not\" in c.then ? !refMatches(c.then.not, choices) : refMatches(c.then, choices);\n}\n\nconst describe = (c: SpaceConstraint): string => {\n const ref = (r: OptionRef): string => `${r.stage}=${r.option ?? \"null\"}`;\n return \"not\" in c.then ? `if ${ref(c.if)} then not ${ref(c.then.not)}` : `if ${ref(c.if)} then ${ref(c.then)}`;\n};\n\n/** This function gives the problems of the range and the default of one param. */\nfunction paramProblems(p: SpaceParam, at: string): Problem[] {\n const out: Problem[] = [];\n if (isNumeric(p)) {\n const { min, max, step } = p;\n if (typeof min !== \"number\" || typeof max !== \"number\" || !Number.isFinite(min) || !Number.isFinite(max)) {\n out.push([\"range\", `${at} has no finite min and max`]);\n return out;\n }\n if (min > max) out.push([\"range\", `${at} has an empty range: the min ${min} is more than the max ${max}`]);\n if (p.kind === \"int\" && (!Number.isInteger(min) || !Number.isInteger(max))) out.push([\"range\", `${at} is an int with a min or a max that is not whole`]);\n if (step !== undefined && (!Number.isFinite(step) || step <= 0 || (p.kind === \"int\" && !Number.isInteger(step))))\n out.push([\"range\", `${at} has the step ${step}, which is not a ${p.kind === \"int\" ? \"whole \" : \"\"}number above 0`]);\n if (p.scale === \"log\" && min <= 0) out.push([\"scale\", `${at} has the scale log with the min ${min}, which is not above 0`]);\n } else {\n if (p.scale !== undefined) out.push([\"scale\", `${at} is a ${p.kind} param with a scale`]);\n if (p.kind === \"enum\") {\n if (!Array.isArray(p.values) || p.values.length === 0) out.push([\"values\", `${at} is an enum without values`]);\n else {\n const seen = new Set<unknown>();\n for (const v of p.values) {\n if (seen.has(v)) out.push([\"duplicate\", `${at} has the value ${show(v)} two times`]);\n seen.add(v);\n }\n }\n }\n }\n if (out.length === 0) {\n const problem = valueProblem(p, p.default);\n if (problem !== undefined) out.push([\"default\", `the default of ${at} is not in its range: ${problem}`]);\n }\n return out;\n}\n\n/** This function gives the problems of one stage option. */\nfunction optionProblems(stage: SpaceStage, o: StageOption): Problem[] {\n const out: Problem[] = [];\n const at = `the option ${stage.name}.${o.id}`;\n if (!Array.isArray(o.params)) return [[\"config\", `${at} has no list of params`]];\n const names = o.params.map((p) => p.name);\n o.params.forEach((p, i) => {\n const pat = `the param ${stage.name}.${o.id}.${p.name}`;\n if (names.indexOf(p.name) !== i) out.push([\"duplicate\", `${at} has the param ${p.name} two times`]);\n out.push(...paramProblems(p, pat));\n if (p.when === undefined) return;\n const j = names.indexOf(p.when.param);\n if (j < 0) out.push([\"unknown\", `${pat} has a when with the unknown param ${p.when.param}`]);\n else if (j >= i) out.push([\"when\", `${pat} has a when with the param ${p.when.param}, which does not come before it`]);\n else if (!Array.isArray(p.when.in) || p.when.in.length === 0) out.push([\"when\", `${pat} has a when with no values`]);\n else for (const v of p.when.in) {\n const problem = valueProblem(o.params[j]!, v);\n if (problem !== undefined) out.push([\"when\", `${pat} has a when value that is not a value of ${p.when.param}: ${problem}`]);\n }\n });\n if (o.members !== undefined) {\n const { min, max, ordered } = o.members;\n if (!Number.isInteger(min) || !Number.isInteger(max) || min < 1 || min > max || typeof ordered !== \"boolean\")\n out.push([\"members\", `${at} has a member rule without whole counts 1 <= min <= max and a boolean ordered`]);\n }\n return out;\n}\n\n/** This function gives the problems of the params of one stage choice. */\nfunction choiceParamProblems(o: StageOption, params: unknown, at: string): Problem[] {\n if (params !== undefined && !isObject(params)) return [[\"config\", `the params of ${at} are not an object`]];\n const given = (params ?? {}) as Values;\n const out: Problem[] = [];\n for (const key of Object.keys(given)) if (!o.params.some((p) => p.name === key)) out.push([\"unknown\", `${at} has the unknown param ${key}`]);\n const values: Values = {};\n for (const p of o.params) {\n const has = Object.hasOwn(given, p.name);\n if (!isActive(p, values)) {\n if (has) out.push([\"inactive\", `${at} sets the param ${p.name}, which is not active`]);\n continue;\n }\n const v = has ? given[p.name] : p.default;\n const problem = valueProblem(p, v);\n if (problem !== undefined) out.push([\"param\", `the param ${p.name} of ${at} is not in its range: ${problem}`]);\n else values[p.name] = normalize(p, v as ParamValue);\n }\n return out;\n}\n\n/** This function gives the problems of a config of a space. A member of a meta option has `member: true`. */\nfunction configProblems(space: StrategySpace, config: unknown, member: boolean): Problem[] {\n if (!isObject(config) || !isObject(config[\"stages\"])) return [[\"config\", \"the config is not an object with stages\"]];\n const out: Problem[] = [];\n const stages = config[\"stages\"];\n if (config[\"space\"] !== space.engine) out.push([\"space\", `the space of the config is ${show(config[\"space\"])}, not ${show(space.engine)}`]);\n for (const key of Object.keys(stages)) if (!space.stages.some((s) => s.name === key)) out.push([\"unknown\", `the config has the unknown stage ${key}`]);\n const optionOf = (s: SpaceStage): StageOption | undefined => {\n const c = stages[s.name];\n return isObject(c) ? s.options.find((o) => o.id === c[\"option\"]) : undefined;\n };\n const prefix = prefixes(space);\n const metaStage = new Map<string, string>();\n for (const s of space.stages) {\n if (optionOf(s)?.members === undefined) continue;\n const p = prefix.get(s.name)!;\n if (metaStage.has(p)) out.push([\"meta\", `the stages ${metaStage.get(p)} and ${s.name} both have a meta option`]);\n else metaStage.set(p, s.name);\n }\n const chosen = new Map<string, string | null>();\n for (const s of space.stages) {\n const c = Object.hasOwn(stages, s.name) ? stages[s.name] : undefined;\n const meta = metaStage.get(prefix.get(s.name)!);\n chosen.set(s.name, null);\n if (c === undefined || c === null) {\n if (!s.optional && meta === undefined) out.push([\"missing\", `the config has no option for the stage ${s.name}`]);\n continue;\n }\n if (!isObject(c) || typeof c[\"option\"] !== \"string\") {\n out.push([\"config\", `the choice of the stage ${s.name} has no option`]);\n continue;\n }\n const o = s.options.find((x) => x.id === c[\"option\"]);\n if (o === undefined) {\n out.push([\"unknown\", `the stage ${s.name} has no option ${c[\"option\"]}`]);\n continue;\n }\n chosen.set(s.name, o.id);\n const at = `the option ${s.name}.${o.id}`;\n if (meta !== undefined && meta !== s.name) out.push([\"meta\", `the stage ${s.name} is set, but the meta option of ${meta} replaces the other stages of its part`]);\n out.push(...choiceParamProblems(o, c[\"params\"], at));\n if (o.members === undefined) {\n if (c[\"members\"] !== undefined) out.push([\"members\", `${at} is not a meta option, but the config gives members`]);\n continue;\n }\n if (member) {\n out.push([\"depth\", `a member has the meta option ${s.name}.${o.id}. The depth of a meta config is 1`]);\n continue;\n }\n out.push(...memberProblems(partOf(space, s.name).space, o.members, c[\"members\"], at));\n }\n for (const c of space.constraints ?? []) if (!holds(c, chosen)) out.push([\"constraint\", `the config breaks the constraint ${describe(c)}`]);\n return out;\n}\n\n/** This function gives the problems of the members of a meta option. `part` is the space of the members. */\nfunction memberProblems(part: StrategySpace, rule: MemberRule, members: unknown, at: string): Problem[] {\n if (!Array.isArray(members)) return [[\"members\", `${at} is a meta option without a list of members`]];\n const out: Problem[] = [];\n if (members.length < rule.min || members.length > rule.max) out.push([\"members\", `${at} has ${members.length} members, not ${rule.min} to ${rule.max}`]);\n const ids = new Map<string, number>();\n members.forEach((m: unknown, k) => {\n const inner = configProblems(part, m, true);\n for (const [claim, detail] of inner) out.push([claim, `the member ${k} of ${at}: ${detail}`]);\n if (inner.length > 0) return;\n const id = idOf(canonicalOf(part, m as StrategyConfig, true));\n if (ids.has(id)) out.push([\"duplicate\", `the members ${ids.get(id)} and ${k} of ${at} are the same config ${id}`]);\n else ids.set(id, k);\n });\n return out;\n}\n\nconst toBreaks = (problems: readonly Problem[], inputs: readonly string[] = []): ClaimBreak[] => problems.map(([claim, detail]) => ({ claim, detail, inputs }));\n\n/**\n * This function checks one config of a space. It gives one break for each problem. An empty list tells that the config is good.\n * The `claim` of a break is the kind of the problem, for example `missing`, `unknown`, `inactive`, `param`, `constraint`, `members` or `depth`.\n */\nexport function checkConfig(space: StrategySpace, config: StrategyConfig): ClaimBreak[] {\n return toBreaks(configProblems(space, config, false));\n}\n\n/**\n * This function checks a space. It gives one break for each problem. An empty list tells that the space is good.\n * It finds duplicate names, empty ranges, defaults out of range, enums without values, bad log scales, unknown names and bad named configs.\n * The `inputs` of a break of a named config have the name of the config.\n */\nexport function checkSpace(space: StrategySpace): ClaimBreak[] {\n if (!isObject(space) || !Array.isArray(space.stages)) return toBreaks([[\"schema\", \"the space is not an object with stages\"]]);\n const out: Problem[] = [];\n if (space.schema !== STRATEGY_SPACE_SCHEMA) out.push([\"schema\", `the schema is ${show(space.schema)}, not ${STRATEGY_SPACE_SCHEMA}`]);\n if (typeof space.engine !== \"string\" || space.engine === \"\") out.push([\"schema\", \"the space has no engine name\"]);\n if (typeof space.version !== \"string\") out.push([\"schema\", \"the space has no version\"]);\n const names = space.stages.map((s) => s.name);\n space.stages.forEach((s, i) => {\n if (names.indexOf(s.name) !== i) out.push([\"duplicate\", `the space has the stage ${s.name} two times`]);\n const options: readonly StageOption[] = Array.isArray(s.options) ? s.options : [];\n if (options.length === 0) {\n out.push([\"options\", `the stage ${s.name} has no options`]);\n return;\n }\n const ids = options.map((o) => o.id);\n options.forEach((o, j) => {\n if (ids.indexOf(o.id) !== j) out.push([\"duplicate\", `the stage ${s.name} has the option ${o.id} two times`]);\n out.push(...optionProblems(s, o));\n });\n if (!s.optional && options.every((o) => o.members !== undefined)) out.push([\"meta\", `the stage ${s.name} is not optional and has only meta options, so no base config exists`]);\n });\n const known = (ref: OptionRef, at: string): void => {\n const s = space.stages.find((x) => x.name === ref?.stage);\n if (s === undefined) out.push([\"unknown\", `${at} has the unknown stage ${ref?.stage}`]);\n else if (ref.option === null ? !s.optional : !s.options.some((o) => o.id === ref.option))\n out.push([\"unknown\", `${at} has the unknown option ${s.name}=${ref.option ?? \"null\"}`]);\n };\n (space.constraints ?? []).forEach((c, k) => {\n known(c.if, `the constraint ${k}`);\n known(\"not\" in c.then ? c.then.not : c.then, `the constraint ${k}`);\n });\n for (const part of space.parts ?? []) for (const b of checkSpace(part)) out.push([b.claim, `the part ${part.engine}: ${b.detail}`]);\n if (space.parts !== undefined)\n for (const s of space.stages) if (partOf(space, s.name).prefix === \"\") out.push([\"parts\", `the stage ${s.name} is not a stage of a part`]);\n const breaks = toBreaks(out);\n if (breaks.length > 0) return breaks;\n for (const [name, config] of Object.entries(space.named ?? {}))\n breaks.push(...toBreaks(configProblems(space, config, false).map(([c, d]) => [c, `the named config ${name}: ${d}`] as const), [name]));\n return breaks;\n}\n\n/** This function gives the canonical form of a config that is known to be good. */\nfunction canonicalOf(space: StrategySpace, config: StrategyConfig, member: boolean): StrategyConfig {\n const stages: Record<string, StageChoice | null> = {};\n for (const s of space.stages) {\n const c = Object.hasOwn(config.stages, s.name) ? config.stages[s.name] : undefined;\n if (c === undefined || c === null) {\n stages[s.name] = null;\n continue;\n }\n const o = s.options.find((x) => x.id === c.option)!;\n const given = c.params ?? {};\n const params: Values = {};\n for (const p of o.params) if (isActive(p, params)) params[p.name] = normalize(p, Object.hasOwn(given, p.name) ? given[p.name]! : p.default);\n if (o.members === undefined || member) {\n stages[s.name] = { option: o.id, params };\n continue;\n }\n const part = partOf(space, s.name).space;\n const members = (c.members ?? []).map((m) => canonicalOf(part, m, true));\n if (!o.members.ordered) members.sort((a, b) => (idOf(a) < idOf(b) ? -1 : idOf(a) > idOf(b) ? 1 : 0));\n stages[s.name] = { option: o.id, params, members };\n }\n return { space: space.engine, stages };\n}\n\nconst idOf = (canonical: StrategyConfig): string => sha256Hex(canonicalJson(canonical)).slice(0, 16);\n\n/**\n * This function gives the canonical form of a config: each stage of the space, the active params only, the defaults, and stable numbers.\n * An unused optional stage is `null`. The members of an unordered meta option are sorted by their `configId`.\n * It throws an `Error` for a config with a break of `checkConfig`.\n */\nexport function canonicalConfig(space: StrategySpace, config: StrategyConfig): StrategyConfig {\n const problems = configProblems(space, config, false);\n if (problems.length > 0) throw new Error(`The config of the space ${space.engine} is not good: ${problems.map((p) => p[1]).join(\"; \")}.`);\n return canonicalOf(space, config, false);\n}\n\n/**\n * This function gives the id of a config: the first 16 hex characters of the SHA-256 of `canonicalJson` of `canonicalConfig`.\n * Two spellings of one config get one id. The version of the space is not part of the id.\n */\nexport function configId(space: StrategySpace, config: StrategyConfig): string {\n return idOf(canonicalConfig(space, config));\n}\n\n/** This function throws an `Error` for a space with a break of `checkSpace`. */\nfunction assertSpace(space: StrategySpace): void {\n const breaks = checkSpace(space);\n if (breaks.length > 0) throw new Error(`The space ${String(space?.engine)} is not good: ${breaks.map((b) => b.detail).join(\"; \")}.`);\n}\n\n/** This function throws a `RangeError` when a value is not a whole number of `min` or more. */\nfunction assertWhole(value: number, name: string, min: number): void {\n if (!Number.isInteger(value) || value < min) throw new RangeError(`The option ${name} is ${value}, not a whole number of ${min} or more.`);\n}\n\n/** This function gives the last point of the step grid of a numeric param. */\nfunction lastPoint(p: SpaceParam): number {\n const min = p.min!;\n const step = p.step ?? (p.kind === \"int\" ? 1 : undefined);\n if (step === undefined) return p.max!;\n return min + Math.floor((p.max! - min) / step + 1e-9) * step;\n}\n\n/** This function moves a value of a numeric param onto its step and into its range. */\nfunction snap(p: SpaceParam, x: number, digits: number): number {\n const min = p.min!;\n const step = p.step ?? (p.kind === \"int\" ? 1 : undefined);\n let v = step === undefined ? x : min + Math.round((x - min) / step) * step;\n v = Math.min(lastPoint(p), Math.max(min, v));\n return p.kind === \"int\" ? zero(Math.round(v)) : Math.min(p.max!, Math.max(min, realForm(v, digits)));\n}\n\n/** This function gives the point at the fraction `t` of the range of a numeric param, on its scale. */\nfunction at01(p: SpaceParam, t: number): number {\n const min = p.min!;\n const max = p.max!;\n if (p.scale === \"log\") return Math.exp(Math.log(min) + t * (Math.log(max) - Math.log(min)));\n return min + t * (max - min);\n}\n\n/**\n * This function gives the grid values of one param, in increasing order. An `enum` gives its values, and a `bool` gives `false` and `true`.\n * With 1 level, a numeric param gives its default. With k levels, it gives k points from `min` to `max` on its scale and step, without repeats.\n */\nexport function paramLevels(param: SpaceParam, levels: number): ParamValue[] {\n assertWhole(levels, \"levels\", 1);\n if (param.kind === \"bool\") return [false, true];\n if (param.kind === \"enum\") return [...(param.values ?? [])];\n if (levels === 1 || param.min === param.max) return [normalize(param, param.default)];\n const out: number[] = [];\n const steps = param.kind === \"int\" || param.step !== undefined ? Math.round((lastPoint(param) - param.min!) / (param.step ?? 1)) + 1 : Infinity;\n if (steps <= levels && param.scale !== \"log\") {\n for (let j = 0; j < steps; j++) out.push(snap(param, param.min! + j * (param.step ?? 1), 12));\n } else {\n for (let j = 0; j < levels; j++) out.push(snap(param, at01(param, j / (levels - 1)), 12));\n }\n return [...new Set(out)];\n}\n\n/** This function tells if a later param of the list reads a param in its `when`. */\nconst readLater = (params: readonly SpaceParam[], i: number): boolean => params.slice(i + 1).some((q) => q.when?.param === params[i]!.name);\n\n/** This function gives the count of the grid assignments of the params of an option, with only the active params. */\nfunction countParams(params: readonly SpaceParam[], levels: number, i = 0, values: Values = {}): bigint {\n if (i === params.length) return 1n;\n const p = params[i]!;\n if (!isActive(p, values)) return countParams(params, levels, i + 1, values);\n const lv = paramLevels(p, levels);\n if (!readLater(params, i)) return BigInt(lv.length) * countParams(params, levels, i + 1, values);\n let sum = 0n;\n for (const v of lv) sum += countParams(params, levels, i + 1, { ...values, [p.name]: v });\n return sum;\n}\n\n/** This function gives the grid assignments of the params of an option, in a stable order. */\nfunction* gridParams(params: readonly SpaceParam[], levels: number, i = 0, values: Values = {}): Generator<Values> {\n if (i === params.length) {\n yield { ...values };\n return;\n }\n const p = params[i]!;\n if (!isActive(p, values)) {\n yield* gridParams(params, levels, i + 1, values);\n return;\n }\n for (const v of paramLevels(p, levels)) yield* gridParams(params, levels, i + 1, { ...values, [p.name]: v });\n}\n\n/** One combination of options of a space, with its count of grid points. */\ninterface Combo {\n readonly choices: Choices;\n readonly base: boolean;\n /** The count of the grid points, or `null` when the count is more than the limit. */\n readonly weight: bigint | null;\n}\n\nconst optionIds = (choices: Choices): Map<string, string | null> => new Map([...choices].map(([k, o]) => [k, o?.id ?? null]));\nconst keeps = (space: StrategySpace, choices: Choices): boolean => (space.constraints ?? []).every((c) => holds(c, optionIds(choices)));\n\n/** This function gives the count of the member lists of a meta option from `base` base configs, or `null` above `limit`. */\nfunction memberLists(base: bigint, rule: MemberRule, limit: bigint): bigint | null {\n let sum = 0n;\n for (let m = rule.min; m <= rule.max; m++) {\n let n = 1n;\n for (let k = 0; k < m; k++) {\n n = (n * (base - BigInt(k))) / (rule.ordered ? 1n : BigInt(k + 1));\n if (n <= 0n) break;\n }\n if (n <= 0n) break;\n sum += n;\n if (sum > limit) return null;\n }\n return sum;\n}\n\n/** This function multiplies two counts. A `null` count or a product above `limit` gives `null`. */\nconst times = (a: bigint | null, b: bigint | null, limit: bigint): bigint | null => (a === null || b === null ? null : a * b > limit ? null : a * b);\n\n/**\n * This function gives the combinations of options of a space and their grid counts.\n * A product space joins the combinations of its parts. Each combination keeps the constraints.\n */\nfunction combos(space: StrategySpace, levels: number, meta: boolean, limit: bigint): Combo[] {\n if (space.parts !== undefined && space.parts.length > 0) {\n let acc: Combo[] = [{ choices: new Map(), base: true, weight: 1n }];\n for (const part of space.parts) {\n const head = `${part.engine}.`;\n const own = combos(part, levels, meta, limit);\n const next: Combo[] = [];\n for (const a of acc)\n for (const b of own) {\n const choices = new Map(a.choices);\n for (const [k, o] of b.choices) choices.set(head + k, o);\n const base = a.base && b.base;\n next.push({ choices, base, weight: base ? a.weight! * b.weight! : times(a.weight, b.weight, limit) });\n }\n acc = next;\n }\n return acc.filter((c) => keeps(space, c.choices));\n }\n const counts = new Map<StageOption, bigint>();\n const countOf = (o: StageOption): bigint => {\n if (!counts.has(o)) counts.set(o, countParams(o.params, levels));\n return counts.get(o)!;\n };\n const out: Combo[] = [];\n const stages = space.stages;\n const walk = (i: number, choices: Map<string, StageOption | null>, weight: bigint): void => {\n if (i === stages.length) {\n if (keeps(space, choices)) out.push({ choices: new Map(choices), base: true, weight });\n return;\n }\n const s = stages[i]!;\n const list: (StageOption | null)[] = s.options.filter((o) => o.members === undefined);\n if (s.optional) list.push(null);\n for (const o of list) {\n choices.set(s.name, o);\n walk(i + 1, choices, o === null ? weight : weight * countOf(o));\n }\n choices.delete(s.name);\n };\n walk(0, new Map(), 1n);\n if (!meta) return out;\n const base = out.reduce((sum, c) => sum + c.weight!, 0n);\n for (const s of stages)\n for (const o of s.options) {\n if (o.members === undefined) continue;\n const choices = new Map<string, StageOption | null>(stages.map((x) => [x.name, x === s ? o : null]));\n if (keeps(space, choices)) out.push({ choices, base: false, weight: times(countOf(o), memberLists(base, o.members, limit), limit) });\n }\n return out;\n}\n\n/**\n * This function gives the count of the grid points of a space, with `levels` levels for each numeric param.\n * It counts only the active params and the combinations that keep the constraints. It gives the meta configs apart.\n */\nexport function spaceSize(space: StrategySpace, options: SpaceSizeOptions): SpaceSize {\n assertSpace(space);\n assertWhole(options.levels, \"levels\", 1);\n const limit = options.maxMeta ?? 10n ** 18n;\n let base = 0n;\n let meta: bigint | null = 0n;\n for (const c of combos(space, options.levels, true, limit)) {\n if (c.base) base += c.weight!;\n else meta = meta === null || c.weight === null || meta + c.weight > limit ? null : meta + c.weight;\n }\n return { base, meta };\n}\n\n/** This function gives the cartesian product of lists, with the last list as the fastest. */\nfunction* product<T>(lists: readonly (readonly T[])[], i = 0, acc: T[] = []): Generator<T[]> {\n if (i === lists.length) {\n yield [...acc];\n return;\n }\n for (const x of lists[i]!) {\n acc.push(x);\n yield* product(lists, i + 1, acc);\n acc.pop();\n }\n}\n\n/** This function gives the configs of the grid of a space, without meta options. */\nfunction gridConfigs(space: StrategySpace, levels: number, limit: number): StrategyConfig[] {\n const size = spaceSize(space, { levels, maxMeta: 0n }).base;\n if (size > BigInt(limit)) throw new RangeError(`The grid of the space ${space.engine} has ${size} configs, more than the limit ${limit}.`);\n const out: StrategyConfig[] = [];\n for (const c of combos(space, levels, false, 0n)) {\n const names = [...c.choices.keys()];\n const lists = names.map((k) => {\n const o = c.choices.get(k)!;\n return o === null ? [null] : [...gridParams(o.params, levels)].map((params): StageChoice => ({ option: o.id, params }));\n });\n for (const row of product<StageChoice | null>(lists)) out.push(canonicalOf(space, { space: space.engine, stages: Object.fromEntries(names.map((k, i) => [k, row[i]!])) }, false));\n }\n return out;\n}\n\n/** This function gives a random order of the numbers from 0 to `n - 1`. */\nfunction permutation(n: number, r: () => number): number[] {\n const out = Array.from({ length: n }, (_, i) => i);\n for (let i = n - 1; i > 0; i--) {\n const j = Math.floor(r() * (i + 1));\n [out[i], out[j]] = [out[j]!, out[i]!];\n }\n return out;\n}\n\n/** This function gives the value of a param at the fraction `u` of its range. A sampled real number has 6 significant digits. */\nfunction sampleValue(p: SpaceParam, u: number): ParamValue {\n if (p.kind === \"bool\") return u >= 0.5;\n if (p.kind === \"enum\") {\n const values = p.values!;\n return values[Math.min(values.length - 1, Math.floor(u * values.length))]!;\n }\n if (p.min === p.max) return normalize(p, p.min!);\n if (p.scale !== \"log\" && (p.kind === \"int\" || p.step !== undefined)) {\n const steps = Math.round((lastPoint(p) - p.min!) / (p.step ?? 1)) + 1;\n return snap(p, p.min! + Math.min(steps - 1, Math.floor(u * steps)) * (p.step ?? 1), 6);\n }\n return snap(p, at01(p, u), 6);\n}\n\n/** This function gives a seed of 32 bits from a seed and a step name. */\nconst subSeed = (seed: number, step: string): number => Math.floor(stepRandom(seed, step)() * 4294967296);\n\n/** This function gives a sample of a space: Latin hypercube strata over the options, the params and the member counts. */\nfunction sampleConfigs(space: StrategySpace, n: number, seed: number, meta: boolean, maxTries: number): StrategyConfig[] {\n const stages = space.stages;\n const prefix = prefixes(space);\n const lists = stages.map((s) => {\n const list: (StageOption | null)[] = s.options.filter((o) => meta || o.members === undefined);\n if (s.optional) list.push(null);\n return list;\n });\n const points: Map<string, StageOption | null>[] = [];\n let tries = 0;\n for (let round = 0; points.length < n; round++) {\n const r = stepRandom(seed, `options:${round}`);\n const columns = lists.map((list) => permutation(n, r).map((p) => list[Math.floor((p * list.length) / n)]!));\n for (let i = 0; i < n && points.length < n; i++) {\n if (tries >= maxTries) throw new Error(`The constraints of the space ${space.engine} remove too many points: ${points.length} of ${n} configs after ${tries} tries.`);\n tries++;\n const choices = new Map<string, StageOption | null>(stages.map((s, k) => [s.name, columns[k]![i]!]));\n const metaPart = new Map<string, string>();\n for (const s of stages) {\n const o = choices.get(s.name);\n if (o?.members !== undefined && !metaPart.has(prefix.get(s.name)!)) metaPart.set(prefix.get(s.name)!, s.name);\n }\n for (const s of stages) {\n const m = metaPart.get(prefix.get(s.name)!);\n if (m !== undefined && m !== s.name) choices.set(s.name, null);\n }\n if (keeps(space, choices)) points.push(choices);\n }\n }\n const values: Values[][] = points.map(() => stages.map(() => ({})));\n const members: StrategyConfig[][][] = points.map(() => stages.map(() => []));\n stages.forEach((s, k) => {\n for (const o of s.options) {\n const users = points.flatMap((c, i) => (c.get(s.name) === o ? [i] : []));\n if (users.length === 0) continue;\n for (const p of o.params) {\n const active = users.filter((i) => isActive(p, values[i]![k]!));\n const r = stepRandom(seed, `param:${s.name}:${o.id}:${p.name}`);\n permutation(active.length, r).forEach((stratum, j) => {\n values[active[j]!]![k]![p.name] = sampleValue(p, (stratum + r()) / active.length);\n });\n }\n if (o.members === undefined) continue;\n const part = partOf(space, s.name).space;\n const poolSize = Math.max(n, 4 * o.members.max, 8);\n const seen = new Set<string>();\n const pool = sampleConfigs(part, poolSize, subSeed(seed, `pool:${s.name}:${o.id}`), false, Math.max(1000, 100 * poolSize)).filter((c) => {\n const id = idOf(c);\n return seen.has(id) ? false : (seen.add(id), true);\n });\n const r = stepRandom(seed, `members:${s.name}:${o.id}`);\n const { min, max } = o.members;\n permutation(users.length, r).forEach((stratum, j) => {\n const count = min + Math.min(max - min, Math.floor(((stratum + r()) / users.length) * (max - min + 1)));\n if (pool.length < count) throw new Error(`The space ${part.engine} has only ${pool.length} distinct base samples, fewer than the ${count} members of ${s.name}.${o.id}.`);\n const picked = permutation(pool.length, r).slice(0, count);\n members[users[j]!]![k] = picked.map((x) => pool[x]!);\n });\n }\n });\n return points.map((choices, i) => {\n const out: Record<string, StageChoice | null> = {};\n stages.forEach((s, k) => {\n const o = choices.get(s.name)!;\n out[s.name] = o === null ? null : o.members === undefined ? { option: o.id, params: values[i]![k]! } : { option: o.id, params: values[i]![k]!, members: members[i]![k]! };\n });\n return canonicalConfig(space, { space: space.engine, stages: out });\n });\n}\n\n/**\n * This function gives configs of a space, in their canonical form. Each config keeps the constraints. The result is deterministic.\n *\n * - The mode `grid` gives each grid point without a meta option, in a stable order. Stages, options and values go in the order of the space.\n * - The mode `sample` gives `n` configs of a seeded Latin hypercube. The options of a stage get equal strata, and each active param gets its own strata.\n * - A sample draws again when a point breaks a constraint. After `maxTries` draws, it throws an `Error`. Two sampled configs can be equal.\n */\nexport function enumerateSpace(space: StrategySpace, options: EnumerateOptions): StrategyConfig[] {\n assertSpace(space);\n if (options.mode === \"grid\") {\n assertWhole(options.levels, \"levels\", 1);\n return gridConfigs(space, options.levels, options.limit ?? 100_000);\n }\n if (options.mode !== \"sample\") throw new RangeError(`The mode ${String((options as { mode?: unknown }).mode)} is not grid or sample.`);\n assertWhole(options.n, \"n\", 0);\n if (!Number.isInteger(options.seed)) throw new RangeError(`The seed ${options.seed} is not a whole number.`);\n const meta = options.meta ?? \"skip\";\n if (meta !== \"skip\" && meta !== \"sample\") throw new RangeError(`The option meta is ${String(meta)}, not skip or sample.`);\n if (options.n === 0) return [];\n return sampleConfigs(space, options.n, options.seed, meta === \"sample\", options.maxTries ?? Math.max(1000, 100 * options.n));\n}\n\n/**\n * This function joins configs of the parts of a product space into one config of the space `space`.\n * The name of each stage gets the prefix `<space of the part>.`. The members of a meta option do not change.\n */\nexport function joinConfigs(space: string, parts: readonly StrategyConfig[]): StrategyConfig {\n const stages: Record<string, StageChoice | null> = {};\n for (const part of parts) for (const [k, c] of Object.entries(part.stages)) stages[`${part.space}.${k}`] = c;\n return { space, stages };\n}\n\n/** This function gives the config of the part `engine` of a joint config. It throws a `RangeError` when no stage has the prefix `<engine>.`. */\nexport function splitConfig(config: StrategyConfig, engine: string): StrategyConfig {\n const head = `${engine}.`;\n const entries = Object.entries(config.stages).filter(([k]) => k.startsWith(head));\n if (entries.length === 0) throw new RangeError(`The config of the space ${config.space} has no stage of the part ${engine}.`);\n return { space: engine, stages: Object.fromEntries(entries.map(([k, c]) => [k.slice(head.length), c])) };\n}\n\n/**\n * This function joins two spaces, for example a packer and a router, into the space `name`. The stages of `a` and `b` get the prefixes `<a.engine>.` and `<b.engine>.`.\n * The constraints get the same prefixes. The named configs are the pairs `<name of a>+<name of b>`. It throws a `RangeError` when the two engines have the same name.\n */\nexport function productSpace(a: StrategySpace, b: StrategySpace, name: string): StrategySpace {\n if (a.engine === b.engine) throw new RangeError(`The two spaces have the same engine ${a.engine}.`);\n if (name === \"\") throw new RangeError(\"The product space has no name.\");\n const stagesOf = (s: StrategySpace): SpaceStage[] => s.stages.map((x) => ({ ...x, name: `${s.engine}.${x.name}` }));\n const ref = (s: StrategySpace, r: OptionRef): OptionRef => ({ stage: `${s.engine}.${r.stage}`, option: r.option });\n const constraintsOf = (s: StrategySpace): SpaceConstraint[] =>\n (s.constraints ?? []).map((c) => ({ if: ref(s, c.if), then: \"not\" in c.then ? { not: ref(s, c.then.not) } : ref(s, c.then) }));\n const named: Record<string, StrategyConfig> = {};\n for (const [ka, ca] of Object.entries(a.named ?? {})) for (const [kb, cb] of Object.entries(b.named ?? {})) named[`${ka}+${kb}`] = joinConfigs(name, [ca, cb]);\n const constraints = [...constraintsOf(a), ...constraintsOf(b)];\n return {\n schema: STRATEGY_SPACE_SCHEMA,\n engine: name,\n version: `${a.engine}@${a.version}+${b.engine}@${b.version}`,\n stages: [...stagesOf(a), ...stagesOf(b)],\n ...(constraints.length > 0 ? { constraints } : {}),\n ...(Object.keys(named).length > 0 ? { named } : {}),\n parts: [a, b],\n };\n}\n","// The verdict over families (`docs/VERDICT.md`). highways, packing and the joint bench use the same rule, so they give the same verdict.\nimport { compareMeasure, type MeasureSpec } from \"./measures.ts\";\nimport { stepRandom } from \"./random.ts\";\nimport type { LayoutRecord } from \"./record.ts\";\n\n/**\n * The largest count of inputs for the exact permutation test. Up to this count, the test enumerates all `2^n` sign sets.\n * At 16 inputs, that is 65 536 sign sets, approximately 3 times the default draws. Above it, the cost doubles with each input, so the test uses seeded draws.\n */\nexport const VERDICT_EXACT_MAX = 16;\n\n/** The largest value of the option `exactMax`. At 20 inputs, the exact test has approximately 1 million sign sets. */\nexport const VERDICT_EXACT_CAP = 20;\n\n/** The default count of the samples of each bootstrap. It is the parameter `bootstrapRuns` of `docs/PROMOTION.md`. */\nexport const VERDICT_RUNS = 10000;\n\n/** The default count of the random sign sets of the permutation test above `VERDICT_EXACT_MAX` inputs. */\nexport const VERDICT_DRAWS = 20000;\n\n/** The default seed of the bootstraps and of the random sign sets. */\nexport const VERDICT_SEED = 1;\n\n/** The fields of a record that the verdict reads. */\nexport type VerdictRecord = Pick<LayoutRecord, \"strategy\" | \"input\" | \"seed\" | \"measures\"> & { readonly skipped?: string };\n\n/** One side of a verdict: a strategy id, or a test that selects the records of the side. */\nexport type VerdictSide<R extends VerdictRecord = VerdictRecord> = string | ((record: R) => boolean);\n\n/** The arguments of `verdict`. `tie` and `level` have no default. */\nexport interface VerdictOptions<R extends VerdictRecord = VerdictRecord> {\n /** The unit of the verdict. The family is the only unit. */\n readonly by: \"family\";\n /** The hook that gives the family of a record, for example `familyOf` of the cell of its input. */\n readonly family: (record: R) => string;\n /** The measure. Its direction tells which side is better. */\n readonly measure: Pick<MeasureSpec, \"id\" | \"direction\">;\n /** The baseline side. */\n readonly a: VerdictSide<R>;\n /** The candidate side. A positive difference tells that `b` is better than `a`. */\n readonly b: VerdictSide<R>;\n /**\n * The minimum effect of the sign of a family, as `minEffect` of `MeasureSpec`. A smaller change of the family mean is a tie.\n * `compareMeasure` compares the two family means, so the smallest tie is one grid step of `RECORD_EPS`.\n */\n readonly tie: number | { readonly rel: number };\n /** The significance level, from 0 to 1. The permutation p must be below it. The intervals have the level `1 - level`. */\n readonly level: number;\n /** The count of the samples of each bootstrap. The default is `VERDICT_RUNS`. */\n readonly runs?: number;\n /** The count of the random sign sets above the exact limit. The default is `VERDICT_DRAWS`. */\n readonly draws?: number;\n /** The seed of the bootstraps and of the random sign sets. The default is `VERDICT_SEED`. */\n readonly seed?: number;\n /** The largest count of inputs for the exact test. The default is `VERDICT_EXACT_MAX`. The value 0 always uses draws. */\n readonly exactMax?: number;\n}\n\n/** A mean with its bootstrap interval. The interval is clear of 0 when `lo > 0` or `hi < 0`. */\nexport interface VerdictInterval {\n readonly mean: number;\n readonly lo: number;\n readonly hi: number;\n}\n\n/** The difference of one family: the count of its inputs, the mean of their differences and its sign. */\nexport interface FamilyVerdict {\n readonly family: string;\n readonly n: number;\n readonly mean: number;\n /** The value 1 tells that `b` is better, -1 that `b` is worse, and 0 a tie by `tie`. */\n readonly sign: -1 | 0 | 1;\n}\n\n/** The stratified paired permutation test. With `exact`, `draws` is the count of all the sign sets. */\nexport interface VerdictPermutation {\n readonly p: number;\n readonly exact: boolean;\n readonly draws: number;\n readonly seed: number;\n}\n\n/** The two-sided exact sign test of the family signs. It is a report only. Ties do not count. */\nexport interface VerdictSignTest {\n readonly wins: number;\n readonly losses: number;\n readonly ties: number;\n readonly p: number;\n}\n\n/** The label of a verdict. `better` and `worse` tell the side of `b`. */\nexport type VerdictLabel = \"better\" | \"worse\" | \"depends on the mix\" | \"no verdict\";\n\n/**\n * The scope of a verdict. The test keeps the families of the corpus as fixed, so its claim is about these families only.\n * It is not a claim about a new kind of input.\n */\nexport type VerdictScope = \"these families\";\n\n/**\n * The breadth of a verdict: the count of the families against its side.\n * The side is the side of the label. For `depends on the mix` and `no verdict`, it is the sign of the stratified mean.\n */\nexport interface VerdictBreadth {\n /** The count of the families with a sign against the side. A stratified mean of exactly 0 has no side, so this count is 0. */\n readonly against: number;\n /** The count of the families. */\n readonly of: number;\n /** The count of the families with the sign 0. */\n readonly ties: number;\n}\n\n/** The result of `verdict`. */\nexport interface VerdictResult {\n readonly measure: string;\n /** The count of the paired inputs. */\n readonly n: number;\n /** The mean of the family means, with a bootstrap of the seeds inside each family. */\n readonly stratified: VerdictInterval;\n /** The mean of the inputs, with a bootstrap of the inputs. */\n readonly pooled: VerdictInterval;\n readonly permutation: VerdictPermutation;\n /** The families, in sort order. */\n readonly families: readonly FamilyVerdict[];\n readonly signTest: VerdictSignTest;\n /** `true` only when the two means have the same sign, the two intervals are clear of 0 and the permutation p is below `level`. */\n readonly agree: boolean;\n readonly label: VerdictLabel;\n /** The scope of the claim: the families of the corpus, not a new kind of input. */\n readonly scope: VerdictScope;\n /** The count of the families against the side of the verdict, of all the families and of the ties. */\n readonly breadth: VerdictBreadth;\n /** The label, the scope and the breadth in one line, for example `better on these families, worse on 2 of 6 (1 tie)`. */\n readonly summary: string;\n /** The inputs without a pair: one side has no record, a skipped record or no value of the measure. */\n readonly dropped: readonly string[];\n}\n\n/** One paired input: its key, its family, the two values and the difference in the direction of the measure. */\ninterface Pair {\n readonly key: string;\n readonly family: string;\n readonly a: number;\n readonly b: number;\n readonly d: number;\n}\n\n/** This function gives the mean of a list that is not empty. */\nconst meanOf = (values: readonly number[]): number => values.reduce((s, v) => s + v, 0) / values.length;\n\n/** This function gives the `q` quantile of sorted values, with linear interpolation. */\nfunction quantileOf(sorted: readonly number[], q: number): number {\n const at = (sorted.length - 1) * q;\n const lo = Math.floor(at);\n const hi = Math.ceil(at);\n return sorted[lo]! + (sorted[hi]! - sorted[lo]!) * (at - lo);\n}\n\n/** This function gives the interval of the samples of a bootstrap at the level `1 - level`. */\nfunction intervalOf(mean: number, samples: number[], level: number): VerdictInterval {\n samples.sort((x, y) => x - y);\n return { mean, lo: quantileOf(samples, level / 2), hi: quantileOf(samples, 1 - level / 2) };\n}\n\n/** This function tells if an interval is clear of 0 on the side of the sign `sign`. */\nconst clearOn = (i: VerdictInterval, sign: number): boolean => (sign > 0 ? i.lo > 0 : sign < 0 ? i.hi < 0 : false);\n\n/** This function gives the two-sided p of the exact binomial sign test, with `p = 0.5`. No count gives 1. */\nfunction signP(wins: number, losses: number): number {\n const n = wins + losses;\n if (n === 0) return 1;\n const k = Math.min(wins, losses);\n let tail = 0;\n let c = 1;\n for (let i = 0; i <= k; i++) {\n tail += c;\n c = (c * (n - i)) / (i + 1);\n }\n return Math.min(1, (2 * tail) / 2 ** n);\n}\n\n/** This function gives the breadth of a verdict with the side `side`: 1, -1, or 0 for no side. */\nfunction breadthOf(families: readonly FamilyVerdict[], side: number): VerdictBreadth {\n const ties = families.filter((f) => f.sign === 0).length;\n const against = side === 0 ? 0 : families.filter((f) => f.sign === -side).length;\n return { against, of: families.length, ties };\n}\n\n/** This function gives the line of a verdict: its label, its scope and its breadth (`docs/VERDICT.md`). */\nfunction summaryOf(label: VerdictLabel, side: number, breadth: VerdictBreadth): string {\n const ties = breadth.ties === 0 ? \"\" : ` (${breadth.ties} ${breadth.ties === 1 ? \"tie\" : \"ties\"})`;\n const word = side > 0 ? \"better\" : \"worse\";\n const other = side > 0 ? \"worse\" : \"better\";\n const count = breadth.against === 0 ? \"none\" : String(breadth.against);\n if (label === \"better\" || label === \"worse\") return `${label} on these families, ${other} on ${count} of ${breadth.of}${ties}`;\n if (side === 0) return `${label}: the family mean is 0, on ${breadth.of} families${ties}`;\n return `${label}: ${word} on the family mean, ${other} on ${count} of ${breadth.of}${ties}`;\n}\n\n/** This function tells if a value is a positive whole number. */\nconst isCount = (v: number): boolean => Number.isInteger(v) && v > 0;\n\n/** This function gives the test of one side. */\nfunction sideTest<R extends VerdictRecord>(side: VerdictSide<R>): (record: R) => boolean {\n return typeof side === \"string\" ? (r) => r.strategy === side : side;\n}\n\n/** This function pairs the records of `a` and `b` by input and seed, and gives the pairs in the order of family and key. */\nfunction pairsOf<R extends VerdictRecord>(records: Iterable<R>, options: VerdictOptions<R>): { pairs: Pair[]; dropped: string[] } {\n const isA = sideTest(options.a);\n const isB = sideTest(options.b);\n const sides = new Map<string, { a?: R; b?: R }>();\n for (const r of records) {\n const inA = isA(r);\n const inB = isB(r);\n if (inA && inB) throw new RangeError(`verdict: the record of the input \"${r.input}\" is in the two sides`);\n if (!inA && !inB) continue;\n const key = `${r.input}#${r.seed}`;\n const entry = sides.get(key) ?? {};\n const side = inA ? \"a\" : \"b\";\n if (entry[side] !== undefined) throw new RangeError(`verdict: the side ${side} has two records of the input \"${r.input}\" and the seed ${r.seed}`);\n entry[side] = r;\n sides.set(key, entry);\n }\n const pairs: Pair[] = [];\n const dropped: string[] = [];\n const id = options.measure.id;\n for (const [key, { a, b }] of sides) {\n const va = a?.skipped === undefined ? a?.measures[id] : undefined;\n const vb = b?.skipped === undefined ? b?.measures[id] : undefined;\n if (a === undefined || b === undefined || va === undefined || vb === undefined) {\n dropped.push(key);\n continue;\n }\n if (!Number.isFinite(va) || !Number.isFinite(vb)) throw new RangeError(`verdict: the measure ${id} of the input \"${a.input}\" is not finite`);\n const family = options.family(a);\n if (options.family(b) !== family) throw new RangeError(`verdict: the two records of the input \"${a.input}\" have different families`);\n pairs.push({ key, family, a: va, b: vb, d: options.measure.direction === \"higher\" ? vb - va : va - vb });\n }\n pairs.sort((x, y) => (x.family < y.family ? -1 : x.family > y.family ? 1 : x.key < y.key ? -1 : x.key > y.key ? 1 : 0));\n dropped.sort();\n return { pairs, dropped };\n}\n\n/**\n * This function gives the verdict of the candidate `b` against the baseline `a` on one measure, with the family as the unit (`docs/VERDICT.md`).\n *\n * - It pairs the records by input and seed. The difference of a pair is `b - a` for a measure where more is better, else `a - b`.\n * - `stratified` is the mean of the family means. Its bootstrap draws the seeds inside each family. `pooled` is the mean of the inputs.\n * - The permutation test changes the sign of each difference inside its family. Its statistic is the mean of the family means.\n * - The label is `better` or `worse` only when `agree` is `true`. Opposite signs of the two means give `depends on the mix`.\n * - `scope`, `breadth` and `summary` tell that the claim is about these families, and how many families are against it.\n *\n * It throws a `RangeError` for a missing `tie` or `level`, and for no pair. Two records of one side and input, or a value that is not finite, also cause a `RangeError`.\n */\nexport function verdict<R extends VerdictRecord>(records: Iterable<R>, options: VerdictOptions<R>): VerdictResult {\n const { tie, level, measure } = options;\n if (options.by !== \"family\") throw new RangeError(`verdict: the unit is \"family\", not \"${String(options.by)}\"`);\n if (tie === undefined || (typeof tie === \"number\" ? !(tie >= 0) : !(tie.rel >= 0))) throw new RangeError(\"verdict: tie is a required number of 0 or more, or { rel } of 0 or more\");\n if (level === undefined || !(level > 0 && level < 1)) throw new RangeError(\"verdict: level is a required number between 0 and 1\");\n const runs = options.runs ?? VERDICT_RUNS;\n const draws = options.draws ?? VERDICT_DRAWS;\n const seed = options.seed ?? VERDICT_SEED;\n const exactMax = options.exactMax ?? VERDICT_EXACT_MAX;\n if (!isCount(runs) || !isCount(draws)) throw new RangeError(\"verdict: runs and draws are whole numbers above 0\");\n if (!Number.isInteger(exactMax) || exactMax < 0 || exactMax > VERDICT_EXACT_CAP) throw new RangeError(`verdict: exactMax is a whole number from 0 to ${VERDICT_EXACT_CAP}`);\n\n const { pairs, dropped } = pairsOf(records, options);\n const n = pairs.length;\n if (n === 0) throw new RangeError(`verdict: the records give no pair of the measure ${measure.id}`);\n\n const groups = new Map<string, Pair[]>();\n for (const p of pairs) groups.set(p.family, [...(groups.get(p.family) ?? []), p]);\n const lists = [...groups.values()];\n const spec = { direction: measure.direction, minEffect: tie };\n const families: FamilyVerdict[] = lists.map((list) => {\n const verdictOf = compareMeasure(meanOf(list.map((p) => p.b)), meanOf(list.map((p) => p.a)), spec);\n return { family: list[0]!.family, n: list.length, mean: meanOf(list.map((p) => p.d)), sign: verdictOf === \"better\" ? 1 : verdictOf === \"worse\" ? -1 : 0 };\n });\n\n // The stratified bootstrap draws the seeds of each family with replacement. The pooled bootstrap draws all the inputs.\n const stratMean = meanOf(families.map((f) => f.mean));\n const rs = stepRandom(seed, \"verdict.stratified\");\n const stratSamples: number[] = [];\n for (let run = 0; run < runs; run++) {\n let sum = 0;\n for (const list of lists) {\n let s = 0;\n for (let j = 0; j < list.length; j++) s += list[Math.floor(rs() * list.length)]!.d;\n sum += s / list.length;\n }\n stratSamples.push(sum / lists.length);\n }\n const stratified = intervalOf(stratMean, stratSamples, level);\n\n const pooledMean = meanOf(pairs.map((p) => p.d));\n const rp = stepRandom(seed, \"verdict.pooled\");\n const pooledSamples: number[] = [];\n for (let run = 0; run < runs; run++) {\n let s = 0;\n for (let j = 0; j < n; j++) s += pairs[Math.floor(rp() * n)]!.d;\n pooledSamples.push(s / n);\n }\n const pooled = intervalOf(pooledMean, pooledSamples, level);\n\n // The statistic is a weighted sum: the weight of an input is 1 / (the count of families × the count of its family).\n const terms = lists.flatMap((list) => list.map((p) => p.d / (lists.length * list.length)));\n const observed = Math.abs(terms.reduce((s, t) => s + t, 0));\n const slack = 1e-12 * terms.reduce((s, t) => s + Math.abs(t), 0);\n const exact = n <= exactMax;\n let hits = 0;\n let total: number;\n if (exact) {\n total = 2 ** n;\n for (let mask = 0; mask < total; mask++) {\n let t = 0;\n for (let i = 0; i < n; i++) t += mask & (1 << i) ? -terms[i]! : terms[i]!;\n if (Math.abs(t) >= observed - slack) hits++;\n }\n } else {\n total = draws;\n const rf = stepRandom(seed, \"verdict.permutation\");\n for (let k = 0; k < draws; k++) {\n let t = 0;\n for (let i = 0; i < n; i++) t += rf() < 0.5 ? -terms[i]! : terms[i]!;\n if (Math.abs(t) >= observed - slack) hits++;\n }\n }\n // A drawn p counts the observed sign set as one draw, so it is always above 0.\n const permutation: VerdictPermutation = { p: exact ? hits / total : (hits + 1) / (total + 1), exact, draws: total, seed };\n\n const wins = families.filter((f) => f.sign === 1).length;\n const losses = families.filter((f) => f.sign === -1).length;\n const signTest: VerdictSignTest = { wins, losses, ties: families.length - wins - losses, p: signP(wins, losses) };\n\n const sign = Math.sign(stratified.mean);\n const agree = sign !== 0 && sign === Math.sign(pooled.mean) && clearOn(stratified, sign) && clearOn(pooled, sign) && permutation.p < level;\n const label: VerdictLabel = agree ? (sign > 0 ? \"better\" : \"worse\") : sign * Math.sign(pooled.mean) < 0 ? \"depends on the mix\" : \"no verdict\";\n const breadth = breadthOf(families, sign);\n const summary = summaryOf(label, sign, breadth);\n return { measure: measure.id, n, stratified, pooled, permutation, families, signTest, agree, label, scope: \"these families\", breadth, summary, dropped };\n}\n"],"mappings":";;AAIA,MAAa,QAAyB;CAAC;CAAO;CAAS;CAAU;AAAM;;AAyCvE,SAAgB,YAAY,QAAmC;CAC7D,IAAI,WAAW,KAAA,GAAW,OAAO;EAAE,KAAK;EAAG,OAAO;EAAG,QAAQ;EAAG,MAAM;CAAE;CACxE,IAAI,OAAO,WAAW,UAAU,OAAO;EAAE,KAAK;EAAQ,OAAO;EAAQ,QAAQ;EAAQ,MAAM;CAAO;CAClG,OAAO;AACT;;AAGA,SAAgB,KAAK,MAAY,QAAkC;CACjE,MAAM,IAAI,YAAY,MAAM;CAC5B,OAAO;EAAE,GAAG,KAAK,IAAI,EAAE;EAAM,GAAG,KAAK,IAAI,EAAE;EAAK,GAAG,KAAK,IAAI,EAAE,OAAO,EAAE;EAAO,GAAG,KAAK,IAAI,EAAE,MAAM,EAAE;CAAO;AAC7G;;AAGA,SAAgB,SAAS,QAAsB;CAC7C,QAAQ,OAAO,MAAf;EACE,KAAK,QACH,OAAO;GAAE,GAAG,OAAO;GAAG,G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