@mark1russell7/layout-contract 0.2.16 → 0.2.18
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 +22 -4
- package/build/index.d.ts +51 -6
- package/build/index.d.ts.map +1 -1
- package/build/index.js +78 -14
- package/build/index.js.map +1 -1
- package/package.json +1 -1
- package/src/measures.ts +6 -1
- package/src/shapes.ts +73 -14
- package/src/strategy-space.ts +52 -2
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@ The package has no runtime dependencies.
|
|
|
9
9
|
| Part | Exports |
|
|
10
10
|
|---|---|
|
|
11
11
|
| Geometry | `Point`, `Rect`, `Region`, `Side`, `Sides`, `Margin`, `marginSides`, `grow`, `boundsOf`, `regionArea`, `translate`, `overlapOf` |
|
|
12
|
-
| The shape kinds | `ShapeKind`, `SHAPE_KINDS`, `SHAPE_KIND_IDS`, `ShapeKindSpec`, `ShapeGeometry`, `DEFAULT_SHAPES`, `ShapeSupport`, `RuleLevel`, `ShapeCheck`, `isShapeKind`, `shapeKindOf`, `shapeKindsOf`, `itemShapeOf`, `shapeKindProblem`, `shapesOf`, `ruleLevel`, `shapeSupportProblems`, `boxArea`, `checkShapes` |
|
|
12
|
+
| The shape kinds | `ShapeKind`, `SHAPE_KINDS`, `SHAPE_KIND_IDS`, `ShapeKindSpec`, `ShapeGeometry`, `DEFAULT_SHAPES`, `ShapeSupport`, `ShapeBound`, `RuleLevel`, `ShapeLevel`, `ShapeCheck`, `isShapeKind`, `shapeKindOf`, `shapeKindsOf`, `itemShapeOf`, `shapeKindProblem`, `shapesOf`, `ruleLevel`, `shapeLevel`, `shapeSupportProblems`, `boxArea`, `checkShapes` |
|
|
13
13
|
| The input `layout-input/1` | `LayoutInput`, `LayoutBox` (`Item` for the packer), `Port`, `portPoint`, `LayoutEdge`, `LayoutContainer`, `Obstacle`, `LayoutCell`, `LayoutGenerator`, `PairGap`, `canonicalInput` |
|
|
14
14
|
| The packer | `PackInput`, `toPackInput`, `Placement`, `PackOutput`, `StageTrace`, `applyPack` |
|
|
15
15
|
| The record `layout-record/1` | `LayoutRecord`, `Stage`, `Supports`, `RunFacts`, `RunEnv`, `toLayoutRecord` |
|
|
@@ -57,8 +57,12 @@ The package has no runtime dependencies.
|
|
|
57
57
|
- `regionArea(region)` gives the exact area of a region. `boxArea(box)` gives the exact area of a box, or `undefined` for a `free` box. A box with an ellipse shape is `free`.
|
|
58
58
|
- `ShapeSupport.safe` lists the kinds with a safe count: an upper bound that does not miss a break. `ruleLevel(rule, kind)` gives `exact`, `safe` or `none`.
|
|
59
59
|
- `no-overlap` and `in-container` are safe on `polygon`, `circle` and `free`. `checkShapes` accepts a safe kind only with `{ level: "safe" }`.
|
|
60
|
-
- `
|
|
60
|
+
- `MeasureSpec.bound` lists the kinds where the value of a measure is a bound of the true value, with its side `upper` or `lower`.
|
|
61
|
+
- `shapeLevel(use, kind)` gives `exact`, `safe`, `bound` or `none`. `checkShapes` accepts a bound kind only with `{ level: "bound" }`. The level `safe` refuses it.
|
|
62
|
+
- A bound value proves only one side of a compare. `docs/SHAPES.md` tells what it proves for each `direction`.
|
|
63
|
+
- `shapeSupportProblems(uses)` refuses a kind in two of the lists `shapes`, `safe` and `bound.shapes`.
|
|
61
64
|
- `MemberRule.view: "bounds"` gives the members of a meta option the bounding box of each item. A shape filter then checks the members with `rect`.
|
|
65
|
+
- A sample with a shape filter skips a meta option without a member list. It throws a `RangeError` only when the space has no config for the kinds.
|
|
62
66
|
- **The corpus dimensions.** `CorpusDimension.precision` is the count of decimal places of a numeric value of a family. The registry rounds the value and the default to it before the `invalidates` compare. `docs/CORPUS.md` tells the rules.
|
|
63
67
|
- **The output hash.** `outputHash` gives the first 16 hex characters of the SHA-256 of the canonical JSON of an output. Each number goes to the grid of `RECORD_EPS` first.
|
|
64
68
|
- **The corpus checks.** `checkDeclared` and `checkSplit` give a list of `ClaimBreak`. An empty list tells that each claim is true. `corpusHashOf` gives the corpus hash of `packing`.
|
|
@@ -82,6 +86,20 @@ const placed = applyPack(input, output);
|
|
|
82
86
|
const hard = packHard(input, output);
|
|
83
87
|
```
|
|
84
88
|
|
|
85
|
-
|
|
89
|
+
## The docs
|
|
86
90
|
|
|
87
|
-
The
|
|
91
|
+
The comments of the source name each doc as `docs/<NAME>.md`. The docs are in the repository, not in the npm package:
|
|
92
|
+
|
|
93
|
+
| Doc | The subject |
|
|
94
|
+
|---|---|
|
|
95
|
+
| [`docs/CORPUS.md`](https://github.com/mark1russell7/layout-contract/blob/main/docs/CORPUS.md) | The shared corpus registry, its dimensions and families |
|
|
96
|
+
| [`docs/CORPUS-CHECKS.md`](https://github.com/mark1russell7/layout-contract/blob/main/docs/CORPUS-CHECKS.md) | The corpus checks and the split files |
|
|
97
|
+
| [`docs/JOINT-CORPUS.md`](https://github.com/mark1russell7/layout-contract/blob/main/docs/JOINT-CORPUS.md) | The joint corpus |
|
|
98
|
+
| [`docs/JOINT-MEASURES.md`](https://github.com/mark1russell7/layout-contract/blob/main/docs/JOINT-MEASURES.md) | The joint measures |
|
|
99
|
+
| [`docs/PORTFOLIO.md`](https://github.com/mark1russell7/layout-contract/blob/main/docs/PORTFOLIO.md) | The portfolio and its pick rule |
|
|
100
|
+
| [`docs/PROMOTION.md`](https://github.com/mark1russell7/layout-contract/blob/main/docs/PROMOTION.md) | The promotion guards |
|
|
101
|
+
| [`docs/SHAPES.md`](https://github.com/mark1russell7/layout-contract/blob/main/docs/SHAPES.md) | The shape kinds, the levels of a rule and what a bound value proves |
|
|
102
|
+
| [`docs/STRATEGY-SPACE.md`](https://github.com/mark1russell7/layout-contract/blob/main/docs/STRATEGY-SPACE.md) | The strategy space |
|
|
103
|
+
| [`docs/VERDICT.md`](https://github.com/mark1russell7/layout-contract/blob/main/docs/VERDICT.md) | The verdict over families |
|
|
104
|
+
|
|
105
|
+
The formats are in `docs/FORMAT.md` of `packing` and `docs/LAYOUT-RECORDS.md` of `highways`. The TSDoc of `ShapeBound` also has the table of what a bound value proves.
|
package/build/index.d.ts
CHANGED
|
@@ -410,14 +410,50 @@ export interface ShapeSupport<Id extends string = string> {
|
|
|
410
410
|
* Thus a safe count of 0 tells that the rule has no break. A kind is in `shapes` or in `safe`, not in the two lists.
|
|
411
411
|
*/
|
|
412
412
|
readonly safe?: readonly ShapeKind[];
|
|
413
|
+
/**
|
|
414
|
+
* The kinds where the value of a measure is a bound of the true value, not the exact value. `ShapeBound` tells the side.
|
|
415
|
+
* A kind is in one list only: `shapes`, `safe` or `bound.shapes`. `docs/SHAPES.md` tells what a bound value proves.
|
|
416
|
+
*/
|
|
417
|
+
readonly bound?: ShapeBound;
|
|
418
|
+
}
|
|
419
|
+
/**
|
|
420
|
+
* The kinds where a measure gives a bound of the true value, and the side of the bound.
|
|
421
|
+
* With `upper`, the value is the true value or more. With `lower`, the value is the true value or less.
|
|
422
|
+
*
|
|
423
|
+
* @remarks
|
|
424
|
+
* The side and the `direction` of the measure tell what a bound value `v` proves about a threshold `t`.
|
|
425
|
+
* A bound is optimistic on the better side of the true value, and pessimistic on the worse side.
|
|
426
|
+
*
|
|
427
|
+
* | `direction` | `side` | The bound | The proof | No proof |
|
|
428
|
+
* |---|---|---|---|---|
|
|
429
|
+
* | `higher` | `upper` | optimistic | `v < t`: the true value is less than `t`. | `v >= t` |
|
|
430
|
+
* | `higher` | `lower` | pessimistic | `v >= t`: the true value is `t` or more. | `v < t` |
|
|
431
|
+
* | `lower` | `upper` | pessimistic | `v <= t`: the true value is `t` or less. | `v > t` |
|
|
432
|
+
* | `lower` | `lower` | optimistic | `v > t`: the true value is more than `t`. | `v <= t` |
|
|
433
|
+
*
|
|
434
|
+
* For a floor or a guard, a pessimistic bound proves a pass, and an optimistic bound proves a fail.
|
|
435
|
+
* `compareMeasure` on two bound values proves nothing. A tie with a bound value proves nothing.
|
|
436
|
+
* Against an exact baseline, an optimistic candidate proves only `worse`, and a pessimistic candidate proves only `better`.
|
|
437
|
+
*/
|
|
438
|
+
export interface ShapeBound {
|
|
439
|
+
readonly shapes: readonly ShapeKind[];
|
|
440
|
+
readonly side: "upper" | "lower";
|
|
413
441
|
}
|
|
414
442
|
/** The level of a rule on a shape kind: an exact count, a safe count (an upper bound), or no support. */
|
|
415
443
|
export type RuleLevel = "exact" | "safe" | "none";
|
|
416
|
-
/** This function gives the level of a rule on a shape kind. A kind of `shapesOf` is `exact`, a kind of `safe` is `safe`, and another kind is `none`. */
|
|
444
|
+
/** This function gives the level of a rule on a shape kind. A kind of `shapesOf` is `exact`, a kind of `safe` is `safe`, and another kind is `none`. It does not read `bound`. */
|
|
417
445
|
export declare function ruleLevel(rule: Pick<ShapeSupport, "shapes" | "safe">, kind: ShapeKind): RuleLevel;
|
|
446
|
+
/** The level of a measure or a rule on a shape kind. The level `bound` is a value on one side of the true value (`ShapeBound`). */
|
|
447
|
+
export type ShapeLevel = RuleLevel | "bound";
|
|
448
|
+
/**
|
|
449
|
+
* This function gives the level of a measure or a rule on a shape kind. It joins the lists `shapes`, `safe` and `bound.shapes`.
|
|
450
|
+
* A kind of `shapesOf` is `exact`, a kind of `safe` is `safe`, a kind of `bound.shapes` is `bound`, and another kind is `none`.
|
|
451
|
+
*/
|
|
452
|
+
export declare function shapeLevel(use: Pick<ShapeSupport, "shapes" | "safe" | "bound">, kind: ShapeKind): ShapeLevel;
|
|
418
453
|
/**
|
|
419
454
|
* This function gives the problems of a list of measures and rules. An empty list tells that the list is good.
|
|
420
|
-
* It refuses an unknown kind, a kind two times in one list, and a kind in
|
|
455
|
+
* It refuses an unknown kind, a kind two times in one list, and a kind in more than one of `shapesOf`, `safe` and `bound.shapes`.
|
|
456
|
+
* It also refuses a `bound` without a list of kinds, and a `side` that is not `upper` or `lower`.
|
|
421
457
|
*/
|
|
422
458
|
export declare function shapeSupportProblems(uses: readonly ShapeSupport[]): string[];
|
|
423
459
|
/** This function tells if a value is a declared shape kind. */
|
|
@@ -445,15 +481,17 @@ export declare function shapesOf(use: Pick<ShapeSupport, "shapes">): readonly Sh
|
|
|
445
481
|
/** The options of `checkShapes`. */
|
|
446
482
|
export interface ShapeCheck {
|
|
447
483
|
/**
|
|
448
|
-
* The lowest level
|
|
449
|
-
* The value `safe` also accepts a kind of `safe
|
|
484
|
+
* The lowest level that `checkShapes` accepts. The default `exact` refuses a kind with only a safe count or a bound value.
|
|
485
|
+
* The value `safe` also accepts a kind of `safe`, as in 0.2.16. Use it only when the run claims that a rule has no break.
|
|
486
|
+
* The value `bound` also accepts a kind of `safe` and a kind of `bound.shapes`. Use it only when the run reads each bound value for the proofs of its side (`docs/SHAPES.md`).
|
|
450
487
|
*/
|
|
451
|
-
readonly level?: "exact" | "safe";
|
|
488
|
+
readonly level?: "exact" | "safe" | "bound";
|
|
452
489
|
}
|
|
453
490
|
/**
|
|
454
491
|
* This function checks that each measure and each rule of a run supports each shape kind of the input. An empty list tells that the run is good.
|
|
455
492
|
* Each break has the claim `shape`, the id of the input, and the first 5 ids of the boxes of the kind.
|
|
456
|
-
* By default, a kind of `safe` is a break, because the
|
|
493
|
+
* By default, a kind of `safe` or of `bound.shapes` is a break, because the result is not exact.
|
|
494
|
+
* With the level `safe`, a kind of `safe` is not a break. With the level `bound`, a kind of `safe` and a kind of `bound.shapes` are not a break.
|
|
457
495
|
*/
|
|
458
496
|
export declare function checkShapes(input: Pick<LayoutInput, "id" | "boxes">, uses: readonly ShapeSupport[], options?: ShapeCheck): ClaimBreak[];
|
|
459
497
|
/** The epsilon for the float compares in an engine. */
|
|
@@ -712,6 +750,11 @@ export interface MeasureSpec<Id extends string = string> {
|
|
|
712
750
|
readonly role?: "guard" | "change-guard" | "diagnostic" | "time";
|
|
713
751
|
/** The shape kinds of the boxes that the measure supports. Without it, the measure supports only `rect`. `checkShapes` refuses the other kinds. */
|
|
714
752
|
readonly shapes?: readonly ShapeKind[];
|
|
753
|
+
/**
|
|
754
|
+
* The kinds where the value is a bound of the true value, and its side. A kind is in `shapes` or in `bound.shapes`, not in the two lists.
|
|
755
|
+
* `checkShapes` refuses a bound kind by default and with `{ level: "safe" }`. With `{ level: "bound" }`, it accepts it. `docs/SHAPES.md` tells what a bound value proves for each `direction`.
|
|
756
|
+
*/
|
|
757
|
+
readonly bound?: ShapeBound;
|
|
715
758
|
}
|
|
716
759
|
/** The id of a joint measure. `docs/JOINT-MEASURES.md` gives the definitions. */
|
|
717
760
|
export type JointMeasureId = "joint.fill" | "joint.aspectError" | "joint.spill" | "joint.straight.crossings" | "joint.straight.length" | "joint.stability.mean" | "joint.stability.moved" | "joint.proxy.rank" | "joint.ms";
|
|
@@ -1188,6 +1231,8 @@ export declare function spaceSize(space: StrategySpace, options: SpaceSizeOption
|
|
|
1188
1231
|
* - A sample draws again when a point breaks a constraint. After `maxTries` draws, it throws an `Error`. Two sampled configs can be equal.
|
|
1189
1232
|
* - With `shapes`, only the options that support each kind of the list count. Without `shapes`, the result does not change.
|
|
1190
1233
|
* - A meta option with a `pool` gives only the entries of its pool. With `shapes`, only the entries whose members support each kind count.
|
|
1234
|
+
* - A sample draws again when a point chooses a meta option without a member list. `spaceSize` gives such an option 0.
|
|
1235
|
+
* - With `shapes`, a sample throws a `RangeError` when the space has no config for the kinds. The error names the stages without an option and the meta options without members.
|
|
1191
1236
|
*/
|
|
1192
1237
|
export declare function enumerateSpace(space: StrategySpace, options: EnumerateOptions): StrategyConfig[];
|
|
1193
1238
|
/**
|
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/geometry.ts","../src/corpus.ts","../src/input.ts","../src/shapes.ts","../src/tolerance.ts","../src/output.ts","../src/record.ts","../src/rules.ts","../src/turn.ts","../src/measures.ts","../src/strategy.ts","../src/random.ts","../src/edges.ts","../src/hash.ts","../src/portfolio.ts","../src/strategy-space.ts","../src/verdict.ts","../src/families.ts"],"mappings":";YACY;;qBAGC,gBAAgB;iBAEZ;WACN;WACA;;;iBAIM;WACN;WACA;WACA;WACA;;;iBAIM;WACN;WACA;WACA;WACA;;;;;;YAOC;W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K,uBAAuB,MAAM,OAAO;;iBAgBvD;WACN;WACA;WACA;;WAEA;WACA;;WAEA;;WAEA;WACA;WACA;;WAEA,QAAQ;;;;;WAKR,YAAY;WACZ,iBAAiB;;WAEjB,SAAS;;WAET;;WAEA,OAAO,SAAS;;;YAIf,OAAO;;iBAGF;WACN;WACA;WACA;WACA;WACA;WACA,OAAO,SAAS;;;iBAIV;WACN;WACA;WACA;;WAEA;;WAEA;;WAEA,QAAQ;;WAER;;;iBAIM;WACN;WACA,QAAQ;WACR;aAAkB;;;;iBAIZ;WACN;WACA;WACA,QAAQ,SAAS;WACjB;;;;;;iBAOM;WACN;WACA;;WAEA;;WAEA;;;iBAIM;WACN;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;WAEA,YAAY;;;iBAIN;WACN;WACA;WACA;WACA;WACA;;WAEA;;WAEA;;WAEA,YAAY;;WAEZ,iBAAiB;WACjB,OAAO;;WAEP;;WAEA,YAAY;;WAEZ;;WAEA,oBAAoB;WACpB,gBAAgB;WAChB,iBAAiB;WACjB,qBAAqB;;;;;WAKrB;WACA;;;;;WAKA;;;iBAIM;WACN,WAAW;WACX,gBAAgB;WAChB,qBAAqB;WACrB;WACA,oBAAoB;;;wBAIf,YAAY,OAAO,cAAc;;;;;;wBAkBjC,eAAe,UAAU,aAAa,OAAO,IAAI;;;;;YC3MrD;;iBAGK;;WAEN;;WAEA;;WAEA;;WAEA;;;iBAIM;WACN,IAAI;;WAEJ;;WAEA,kBAAkB;WAClB,UAAU;;;;;;qBAOR,sBAAsB;;qBAQtB,yBAAyB;;qBAGzB,yBAAyB;;iBAGrB,aAAa;WACnB,IAAI;;WAEJ,kBAAkB;;;;;WAKlB,gBAAgB;;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/geometry.ts","../src/corpus.ts","../src/input.ts","../src/shapes.ts","../src/tolerance.ts","../src/output.ts","../src/record.ts","../src/rules.ts","../src/turn.ts","../src/measures.ts","../src/strategy.ts","../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AAM,OAAO,aAAa,cAAc,MAAM,kBAAkB;;;iBAIjD;;WAEN;;WAEA;WACA;;WAEA,QAAQ,OAAO;;;;;;;wBAWV,cAAc,MAAM,aAAa,cAAc,gBAAgB,cAAc,UAAS,iBAAsB,aAAa;;;;;qBA+D5H,YAAY;;;;;;qBAoBZ,gBAAgB,aAAa"}
|
package/build/index.js
CHANGED
|
@@ -200,22 +200,40 @@ const SHAPE_KINDS = Object.freeze([
|
|
|
200
200
|
const SHAPE_KIND_IDS = Object.freeze(SHAPE_KINDS.map((k) => k.id));
|
|
201
201
|
/** The shape kinds of a measure or a rule without `shapes`. The contract measured only rectangles before L46. */
|
|
202
202
|
const DEFAULT_SHAPES = Object.freeze(["rect"]);
|
|
203
|
-
/** This function gives the level of a rule on a shape kind. A kind of `shapesOf` is `exact`, a kind of `safe` is `safe`, and another kind is `none`. */
|
|
203
|
+
/** This function gives the level of a rule on a shape kind. A kind of `shapesOf` is `exact`, a kind of `safe` is `safe`, and another kind is `none`. It does not read `bound`. */
|
|
204
204
|
function ruleLevel(rule, kind) {
|
|
205
205
|
if (shapesOf(rule).includes(kind)) return "exact";
|
|
206
206
|
return rule.safe?.includes(kind) === true ? "safe" : "none";
|
|
207
207
|
}
|
|
208
208
|
/**
|
|
209
|
+
* This function gives the level of a measure or a rule on a shape kind. It joins the lists `shapes`, `safe` and `bound.shapes`.
|
|
210
|
+
* A kind of `shapesOf` is `exact`, a kind of `safe` is `safe`, a kind of `bound.shapes` is `bound`, and another kind is `none`.
|
|
211
|
+
*/
|
|
212
|
+
function shapeLevel(use, kind) {
|
|
213
|
+
const level = ruleLevel(use, kind);
|
|
214
|
+
if (level !== "none") return level;
|
|
215
|
+
return use.bound?.shapes.includes(kind) === true ? "bound" : "none";
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
209
218
|
* This function gives the problems of a list of measures and rules. An empty list tells that the list is good.
|
|
210
|
-
* It refuses an unknown kind, a kind two times in one list, and a kind in
|
|
219
|
+
* It refuses an unknown kind, a kind two times in one list, and a kind in more than one of `shapesOf`, `safe` and `bound.shapes`.
|
|
220
|
+
* It also refuses a `bound` without a list of kinds, and a `side` that is not `upper` or `lower`.
|
|
211
221
|
*/
|
|
212
222
|
function shapeSupportProblems(uses) {
|
|
213
223
|
const out = [];
|
|
214
224
|
for (const use of uses) {
|
|
215
|
-
|
|
216
|
-
|
|
225
|
+
const bound = use.bound;
|
|
226
|
+
const isBound = typeof bound === "object" && bound !== null && !Array.isArray(bound);
|
|
227
|
+
if (bound !== void 0 && !isBound) out.push(`${use.id}: the bound value is not an object with shapes and a side`);
|
|
228
|
+
const boundShapes = isBound ? bound.shapes : void 0;
|
|
229
|
+
for (const [name, list] of [
|
|
230
|
+
["shapes", use.shapes],
|
|
231
|
+
["safe", use.safe],
|
|
232
|
+
["bound", boundShapes]
|
|
233
|
+
]) {
|
|
234
|
+
if (list === void 0 && (name !== "bound" || !isBound)) continue;
|
|
217
235
|
if (!Array.isArray(list)) {
|
|
218
|
-
out.push(`${use.id}: the ${name} value is not a list of shape kinds`);
|
|
236
|
+
out.push(`${use.id}: the ${name === "bound" ? "bound shapes" : name} value is not a list of shape kinds`);
|
|
219
237
|
continue;
|
|
220
238
|
}
|
|
221
239
|
list.forEach((k, i) => {
|
|
@@ -223,9 +241,19 @@ function shapeSupportProblems(uses) {
|
|
|
223
241
|
else if (list.indexOf(k) !== i) out.push(`${use.id}: the ${name} list has the kind ${k} two times`);
|
|
224
242
|
});
|
|
225
243
|
}
|
|
226
|
-
if (!Array.isArray(use.safe)) continue;
|
|
227
244
|
const exact = use.shapes === void 0 ? DEFAULT_SHAPES : Array.isArray(use.shapes) ? use.shapes : [];
|
|
228
|
-
|
|
245
|
+
if (Array.isArray(use.safe)) {
|
|
246
|
+
for (const k of new Set(use.safe)) if (exact.includes(k)) out.push(`${use.id}: the kind ${String(k)} is in shapes and in safe`);
|
|
247
|
+
}
|
|
248
|
+
if (!isBound) continue;
|
|
249
|
+
const side = bound.side;
|
|
250
|
+
if (side !== "upper" && side !== "lower") out.push(`${use.id}: the bound side ${String(side)} is not upper or lower`);
|
|
251
|
+
if (!Array.isArray(boundShapes)) continue;
|
|
252
|
+
const safe = Array.isArray(use.safe) ? use.safe : [];
|
|
253
|
+
for (const k of new Set(boundShapes)) {
|
|
254
|
+
if (exact.includes(k)) out.push(`${use.id}: the kind ${String(k)} is in shapes and in bound`);
|
|
255
|
+
if (safe.includes(k)) out.push(`${use.id}: the kind ${String(k)} is in safe and in bound`);
|
|
256
|
+
}
|
|
229
257
|
}
|
|
230
258
|
return out;
|
|
231
259
|
}
|
|
@@ -285,7 +313,8 @@ function shapesOf(use) {
|
|
|
285
313
|
/**
|
|
286
314
|
* This function checks that each measure and each rule of a run supports each shape kind of the input. An empty list tells that the run is good.
|
|
287
315
|
* Each break has the claim `shape`, the id of the input, and the first 5 ids of the boxes of the kind.
|
|
288
|
-
* By default, a kind of `safe` is a break, because the
|
|
316
|
+
* By default, a kind of `safe` or of `bound.shapes` is a break, because the result is not exact.
|
|
317
|
+
* With the level `safe`, a kind of `safe` is not a break. With the level `bound`, a kind of `safe` and a kind of `bound.shapes` are not a break.
|
|
289
318
|
*/
|
|
290
319
|
function checkShapes(input, uses, options = {}) {
|
|
291
320
|
const kinds = shapeKindsOf(input);
|
|
@@ -293,11 +322,11 @@ function checkShapes(input, uses, options = {}) {
|
|
|
293
322
|
for (const use of uses) {
|
|
294
323
|
const shapes = shapesOf(use);
|
|
295
324
|
for (const kind of kinds) {
|
|
296
|
-
const level =
|
|
297
|
-
if (level === "exact" || level === "safe" && options.level === "safe") continue;
|
|
325
|
+
const level = shapeLevel(use, kind);
|
|
326
|
+
if (level === "exact" || level === "safe" && (options.level === "safe" || options.level === "bound") || level === "bound" && options.level === "bound") continue;
|
|
298
327
|
const ids = input.boxes.filter((b) => shapeKindOf(b) === kind).map((b) => b.id);
|
|
299
328
|
const shown = ids.slice(0, 5).join(", ") + (ids.length > 5 ? `, and ${ids.length - 5} more` : "");
|
|
300
|
-
const safe = level === "safe" ? `. The count of ${use.id} on ${kind} is only safe` : "";
|
|
329
|
+
const safe = level === "safe" ? `. The count of ${use.id} on ${kind} is only safe` : level === "bound" ? `. The value of ${use.id} is only ${use.bound.side === "upper" ? "an upper" : "a lower"} bound for ${kind}` : "";
|
|
301
330
|
out.push({
|
|
302
331
|
claim: "shape",
|
|
303
332
|
detail: `${use.id} supports only the shape kinds ${shapes.join(", ") || "(none)"}, but the input ${input.id} has ${kind} boxes: ${shown}${safe}`,
|
|
@@ -2660,6 +2689,27 @@ function restrict(space, shapes) {
|
|
|
2660
2689
|
}
|
|
2661
2690
|
/** The space of the members of a meta option of a restricted space, when it is not the part of the option. Only `view: "bounds"` makes such a space. */
|
|
2662
2691
|
const memberSpaces = /* @__PURE__ */ new WeakMap();
|
|
2692
|
+
/**
|
|
2693
|
+
* This function tells if an option of a restricted space has a member list. A base option and a meta option with a `pool` have one.
|
|
2694
|
+
* A different meta option has one when its members have a base config. `restrict` keeps only the pool entries that fit.
|
|
2695
|
+
*/
|
|
2696
|
+
const hasMembers = (space, stage, o) => o.members === void 0 || o.members.pool !== void 0 || combos(memberSpaces.get(o) ?? partOf(space, stage).space, 1, false, 0n).length > 0;
|
|
2697
|
+
/** This function tells if a restricted space has a config. A base config counts. With `meta`, a meta config counts when each of its meta options has a member list. */
|
|
2698
|
+
const hasConfig = (space, meta) => combos(space, 1, meta, 0n).some((c) => c.base || [...c.choices].every(([stage, o]) => o === null || hasMembers(space, stage, o)));
|
|
2699
|
+
/** This function gives the error of a sample of a space that has no config for the shape kinds `shapes`. `kept` is the restricted space. */
|
|
2700
|
+
function noSample(space, kept, shapes, meta) {
|
|
2701
|
+
const list = (names, one, more) => names.length === 1 ? `${one} ${names[0]}` : `${more} ${names.join(", ")}`;
|
|
2702
|
+
const empty = kept.stages.filter((s) => !s.optional && !s.options.some((o) => meta || o.members === void 0)).map((s) => s.name);
|
|
2703
|
+
const removed = !meta ? [] : space.stages.flatMap((s) => s.options.filter((o) => o.members !== void 0 && o.members.view !== "bounds" && supportsShapes(o, shapes)).filter((o) => {
|
|
2704
|
+
const own = kept.stages.find((x) => x.name === s.name)?.options.find((x) => x.id === o.id);
|
|
2705
|
+
return own === void 0 || !hasMembers(kept, s.name, own);
|
|
2706
|
+
}).map((o) => `${s.name}.${o.id}`));
|
|
2707
|
+
let text = `The space ${space.engine} has no config for a sample with the shape kinds ${shapes.join(", ")}.`;
|
|
2708
|
+
if (empty.length > 0) text += ` ${list(empty, "The stage", "The stages")} ${empty.length === 1 ? "has" : "have"} no option for these kinds.`;
|
|
2709
|
+
if (removed.length > 0) text += ` ${list(removed, "The meta option", "The meta options")} ${removed.length === 1 ? "has" : "have"} no member config for these kinds. Set members.view to "bounds" when the members see only the bounding boxes.`;
|
|
2710
|
+
if (empty.length === 0 && removed.length === 0) text += " The constraints remove each config.";
|
|
2711
|
+
return new RangeError(text);
|
|
2712
|
+
}
|
|
2663
2713
|
/** This function gives the count of the base configs of a space that is known to be good. */
|
|
2664
2714
|
const baseCount = (space, levels, limit) => combos(space, levels, false, limit).reduce((sum, c) => sum + c.weight, 0n);
|
|
2665
2715
|
/** This function throws a `RangeError` for a list of shape kinds with a kind that is not declared. */
|
|
@@ -2753,6 +2803,12 @@ function sampleConfigs(space, n, seed, meta, maxTries, canon = space) {
|
|
|
2753
2803
|
if (list.length === 0) throw new Error(`The stage ${s.name} of the space ${space.engine} has no option for a sample. A shape filter can remove all of its options.`);
|
|
2754
2804
|
return list;
|
|
2755
2805
|
});
|
|
2806
|
+
const usable = /* @__PURE__ */ new Map();
|
|
2807
|
+
const withMembers = (s, o) => {
|
|
2808
|
+
if (o === null || o === void 0 || o.members === void 0) return true;
|
|
2809
|
+
if (!usable.has(o)) usable.set(o, hasMembers(space, s.name, o));
|
|
2810
|
+
return usable.get(o);
|
|
2811
|
+
};
|
|
2756
2812
|
const points = [];
|
|
2757
2813
|
let tries = 0;
|
|
2758
2814
|
for (let round = 0; points.length < n; round++) {
|
|
@@ -2768,7 +2824,7 @@ function sampleConfigs(space, n, seed, meta, maxTries, canon = space) {
|
|
|
2768
2824
|
const m = metaPart.get(prefix.get(s.name));
|
|
2769
2825
|
if (m !== void 0 && m !== s.name) choices.set(s.name, null);
|
|
2770
2826
|
}
|
|
2771
|
-
if (stages.every((s) => s.optional === true || choices.get(s.name) !== null || metaPart.has(prefix.get(s.name))) && keeps(space, choices)) points.push(choices);
|
|
2827
|
+
if (stages.every((s) => s.optional === true || choices.get(s.name) !== null || metaPart.has(prefix.get(s.name))) && keeps(space, choices) && stages.every((s) => withMembers(s, choices.get(s.name)))) points.push(choices);
|
|
2772
2828
|
}
|
|
2773
2829
|
}
|
|
2774
2830
|
const values = points.map(() => stages.map(() => ({})));
|
|
@@ -2837,6 +2893,8 @@ function sampleConfigs(space, n, seed, meta, maxTries, canon = space) {
|
|
|
2837
2893
|
* - A sample draws again when a point breaks a constraint. After `maxTries` draws, it throws an `Error`. Two sampled configs can be equal.
|
|
2838
2894
|
* - With `shapes`, only the options that support each kind of the list count. Without `shapes`, the result does not change.
|
|
2839
2895
|
* - A meta option with a `pool` gives only the entries of its pool. With `shapes`, only the entries whose members support each kind count.
|
|
2896
|
+
* - A sample draws again when a point chooses a meta option without a member list. `spaceSize` gives such an option 0.
|
|
2897
|
+
* - With `shapes`, a sample throws a `RangeError` when the space has no config for the kinds. The error names the stages without an option and the meta options without members.
|
|
2840
2898
|
*/
|
|
2841
2899
|
function enumerateSpace(space, options) {
|
|
2842
2900
|
assertSpace(space);
|
|
@@ -2851,7 +2909,13 @@ function enumerateSpace(space, options) {
|
|
|
2851
2909
|
const meta = options.meta ?? "skip";
|
|
2852
2910
|
if (meta !== "skip" && meta !== "sample") throw new RangeError(`The option meta is ${String(meta)}, not skip or sample.`);
|
|
2853
2911
|
if (options.n === 0) return [];
|
|
2854
|
-
|
|
2912
|
+
const kept = restrict(space, options.shapes);
|
|
2913
|
+
try {
|
|
2914
|
+
return sampleConfigs(kept, options.n, options.seed, meta === "sample", options.maxTries ?? Math.max(1e3, 100 * options.n), space);
|
|
2915
|
+
} catch (error) {
|
|
2916
|
+
if (options.shapes !== void 0 && !hasConfig(kept, meta === "sample")) throw noSample(space, kept, options.shapes, meta === "sample");
|
|
2917
|
+
throw error;
|
|
2918
|
+
}
|
|
2855
2919
|
}
|
|
2856
2920
|
/**
|
|
2857
2921
|
* This function gives the shape kinds that a space accepts, in the order of `SHAPE_KINDS`. The value comes from the `supports` of the options.
|
|
@@ -3927,6 +3991,6 @@ const RECT_SCATTERED = Object.freeze({
|
|
|
3927
3991
|
};
|
|
3928
3992
|
}
|
|
3929
3993
|
});
|
|
3930
|
-
export { CORPUS_DIMENSIONS, DEFAULT_FAMILY_BY, DEFAULT_RNG, DEFAULT_SHAPES, DEFAULT_TOLERANCE, EDGES_STEP, EDGE_DENSITY, EDGE_STEP_VERSION, EPS, FAMILY_ANY_KIND, INVALIDATED_FIELD, JOINT_MEASURES, JOINT_MOVED_MIN, PACK_HARD_RULES, RECORD_EPS, RECORD_SCALE, RECT_SCATTERED, SHAPE_KINDS, SHAPE_KIND_IDS, SIDES, SPLIT_SCHEMA, STRATEGY_SPACE_SCHEMA, VERDICT_DRAWS, VERDICT_EXACT_CAP, VERDICT_EXACT_MAX, VERDICT_RUNS, VERDICT_SEED, applyPack, boundsOf, boxArea, canonicalConfig, canonicalInput, canonicalJson, checkConfig, checkDeclared, checkInput, checkShapes, checkSpace, checkSplit, compareMeasure, composeFamily, configId, corpusHashOf, countObstacleHits, countOutside, countOverlaps, countPortsOffBorder, createFamilyRegistry, declaredClaimOf, declaredCounts, dimensionAt, dimensionSupports, dimensionUnit, documentHash, edgeStep, enumerateSpace, exercised, familyKind, familyOf, fnv1a32, grow, isShapeKind, itemShapeOf, joinConfigs, leaveOneSeedOut, levelsOf, marginSides, minEffectOf, mulberry32, outputGroups, outputHash, overlapOf, ownerDimension, packHard, paramActive, paramLevels, paramProblem, paramValue, pickMoves, placedRect, portPoint, portfolio, productSpace, randomInt, rectInRegion, regionArea, regionHitsRect, resolveDimensions, ruleLevel, selectBest, sha256Hex, shapeKindOf, shapeKindProblem, shapeKindsOf, shapeSupportProblems, shapesOf, sharedDimension, spaceShapeKinds, spaceSize, splitConfig, splitFileName, splitFolds, stepRandom, toLayoutRecord, toPackInput, translate, turnBox, turnMargin, turnPoint, turnPort, turnRegion, turnSide, verdict };
|
|
3994
|
+
export { CORPUS_DIMENSIONS, DEFAULT_FAMILY_BY, DEFAULT_RNG, DEFAULT_SHAPES, DEFAULT_TOLERANCE, EDGES_STEP, EDGE_DENSITY, EDGE_STEP_VERSION, EPS, FAMILY_ANY_KIND, INVALIDATED_FIELD, JOINT_MEASURES, JOINT_MOVED_MIN, PACK_HARD_RULES, RECORD_EPS, RECORD_SCALE, RECT_SCATTERED, SHAPE_KINDS, SHAPE_KIND_IDS, SIDES, SPLIT_SCHEMA, STRATEGY_SPACE_SCHEMA, VERDICT_DRAWS, VERDICT_EXACT_CAP, VERDICT_EXACT_MAX, VERDICT_RUNS, VERDICT_SEED, applyPack, boundsOf, boxArea, canonicalConfig, canonicalInput, canonicalJson, checkConfig, checkDeclared, checkInput, checkShapes, checkSpace, checkSplit, compareMeasure, composeFamily, configId, corpusHashOf, countObstacleHits, countOutside, countOverlaps, countPortsOffBorder, createFamilyRegistry, declaredClaimOf, declaredCounts, dimensionAt, dimensionSupports, dimensionUnit, documentHash, edgeStep, enumerateSpace, exercised, familyKind, familyOf, fnv1a32, grow, isShapeKind, itemShapeOf, joinConfigs, leaveOneSeedOut, levelsOf, marginSides, minEffectOf, mulberry32, outputGroups, outputHash, overlapOf, ownerDimension, packHard, paramActive, paramLevels, paramProblem, paramValue, pickMoves, placedRect, portPoint, portfolio, productSpace, randomInt, rectInRegion, regionArea, regionHitsRect, resolveDimensions, ruleLevel, selectBest, sha256Hex, shapeKindOf, shapeKindProblem, shapeKindsOf, shapeLevel, shapeSupportProblems, shapesOf, sharedDimension, spaceShapeKinds, spaceSize, splitConfig, splitFileName, splitFolds, stepRandom, toLayoutRecord, toPackInput, translate, turnBox, turnMargin, turnPoint, turnPort, turnRegion, turnSide, verdict };
|
|
3931
3995
|
|
|
3932
3996
|
//# sourceMappingURL=index.js.map
|