@mark1russell7/layout-contract 0.5.3 → 0.5.5
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/build/index.d.ts +38 -1
- package/build/index.d.ts.map +1 -1
- package/build/index.js +154 -12
- package/build/index.js.map +1 -1
- package/package.json +1 -1
- package/src/hash.ts +74 -5
- package/src/space-walk.ts +13 -4
- package/src/strategy-space.ts +86 -4
package/build/index.d.ts
CHANGED
|
@@ -481,17 +481,45 @@ export interface HashOptions {
|
|
|
481
481
|
* The value `0` keeps the exact numbers. A negative value or a value that is not finite causes a `RangeError`.
|
|
482
482
|
*/
|
|
483
483
|
readonly grid?: number;
|
|
484
|
+
/**
|
|
485
|
+
* The names of the fields that the hash does not read, at each depth. Use it for report fields, for example a trace or a time.
|
|
486
|
+
* A field with one of these names is out of the form in each object of the value, also in an object in a list.
|
|
487
|
+
*/
|
|
488
|
+
readonly skip?: readonly string[];
|
|
484
489
|
}
|
|
485
490
|
/**
|
|
486
491
|
* This function gives the hash of an output: the first 16 hex characters of the SHA-256 of its canonical form.
|
|
487
492
|
* Before the canonical form, each number goes to the nearest point of the grid, and `-0` becomes `0`.
|
|
488
493
|
* With the default grid, the rounding is `round3` of `packing`: `Math.round(x * 1000) / 1000`.
|
|
489
|
-
* The function throws a `RangeError` for `NaN` and for an infinite number.
|
|
494
|
+
* The function throws a `RangeError` for `NaN` and for an infinite number. The fields of `options.skip` are out of the form.
|
|
490
495
|
*
|
|
491
496
|
* The grid can split two outputs. Two numbers near a rounding boundary can go to two different points.
|
|
492
497
|
* 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.
|
|
493
498
|
*/
|
|
494
499
|
export declare function outputHash(value: unknown, options?: HashOptions): string;
|
|
500
|
+
/**
|
|
501
|
+
* This function gives the normal form of the output of a packer, for a fingerprint.
|
|
502
|
+
* The form has the placements, the overflow, the size and the moved obstacles. It does not have the trace.
|
|
503
|
+
* The placements, the moved obstacles and the overflow are in the order of their ids. A placement without `turn` gets `turn: 0`.
|
|
504
|
+
* Thus two packers with the same result in a different order have the same form.
|
|
505
|
+
* The function throws a `RangeError` when `placements`, `overflow` or `moved` has an id two times.
|
|
506
|
+
*/
|
|
507
|
+
export declare function packOutputForm(output: PackOutput): unknown;
|
|
508
|
+
/** The hash of a probe that the strategy refused or does not support. It has no reason text, so a new text of a refusal does not change a fingerprint. */
|
|
509
|
+
export declare const REFUSED_PROBE = "refused";
|
|
510
|
+
/**
|
|
511
|
+
* This function gives the hash of one probe of a strategy. It calls `run` and gives `outputHash` of its result, with exact numbers by default.
|
|
512
|
+
* When `run` throws an error that `refused` accepts, the function gives `REFUSED_PROBE`. It throws each other error again.
|
|
513
|
+
* The option `grid` of `options` puts the numbers on a grid. Its default here is `0`, so a change in a number changes the hash.
|
|
514
|
+
*/
|
|
515
|
+
export declare function probeHash(run: () => unknown, refused: (error: unknown) => boolean, options?: HashOptions): string;
|
|
516
|
+
/**
|
|
517
|
+
* This function gives the fingerprint of the outputs of one strategy: one hash of the hashes of its probes.
|
|
518
|
+
* The key of `hashes` is the id of a probe, and its value is the hash of the probe, from `probeHash`.
|
|
519
|
+
* The order of the keys does not change the fingerprint. A new probe, a probe less or a changed hash changes it.
|
|
520
|
+
* The function throws a `RangeError` when there is no probe.
|
|
521
|
+
*/
|
|
522
|
+
export declare function fingerprintOf(hashes: Readonly<Record<string, string>>): string;
|
|
495
523
|
/**
|
|
496
524
|
* 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.
|
|
497
525
|
* With the default grid, it is the input hash of `docs/FORMAT.md` of `packing`.
|
|
@@ -813,11 +841,19 @@ export interface SampleOptions extends ShapeFilter {
|
|
|
813
841
|
/**
|
|
814
842
|
* How a point keeps the constraints. With `reject` (the default), a point that breaks a constraint draws again.
|
|
815
843
|
* With `walk`, a point draws its stages from the largest to the smallest. Each stage draws only from the options that keep the constraints with the stages before it.
|
|
844
|
+
* The stages of `fixed` draw before the other stages.
|
|
816
845
|
* A space whose constraints reject most draws gets its sample with `walk`. The two values give different configs for one seed.
|
|
817
846
|
* A sample of `walk` is not uniform over the valid configs. Each option of the largest stage gets an equal share, whatever count of valid configs it has.
|
|
818
847
|
* Thus a mean over this sample is not a mean of the space.
|
|
819
848
|
*/
|
|
820
849
|
readonly draw?: "reject" | "walk";
|
|
850
|
+
/**
|
|
851
|
+
* The options that each config of the sample has. A key is the name of a stage, and its value is the id of one option of that stage. The other stages draw as before.
|
|
852
|
+
* A stage of a product space has the name of its part before its own name, for example `pack.placement`.
|
|
853
|
+
* A fixed meta option needs `meta: "sample"`. A meta option of another stage of the same part goes out, because such an option replaces the fixed stage.
|
|
854
|
+
* A fixed option that the shape filter removes, or that the constraints forbid, gets a `RangeError` with the reason.
|
|
855
|
+
*/
|
|
856
|
+
readonly fixed?: Readonly<Record<string, string>>;
|
|
821
857
|
}
|
|
822
858
|
/** The options of `enumerateSpace`. */
|
|
823
859
|
export type EnumerateOptions = GridOptions | SampleOptions;
|
|
@@ -877,6 +913,7 @@ export declare function spaceSize(space: StrategySpace, options: SpaceSizeOption
|
|
|
877
913
|
* - A meta option with a `pool` gives only the entries of its pool. With `shapes`, only the entries whose members support each kind count.
|
|
878
914
|
* - A sample draws again when a point chooses a meta option without a member list. `spaceSize` gives such an option 0.
|
|
879
915
|
* - 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.
|
|
916
|
+
* - With `fixed`, each config has the fixed option at each named stage. A fixed option that the space, the shape filter or the constraints do not permit gets a `RangeError` with the reason.
|
|
880
917
|
*/
|
|
881
918
|
export declare function enumerateSpace(space: StrategySpace, options: EnumerateOptions): StrategyConfig[];
|
|
882
919
|
/**
|
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/tolerance.ts","../src/output.ts","../src/record.ts","../src/rules.ts","../src/turn.ts","../src/balance.ts","../src/strategy.ts","../src/random.ts","../src/edges.ts","../src/hash.ts","../src/portfolio.ts","../src/strategy-space.ts","../src/strategy-options.ts","../src/strategy-catalog.ts","../src/verdict.ts","../src/families.ts"],"mappings":";;qBACa;;qBAGA;;;;;qBAMA;;;;;qBAMA;;;;;iBAMI;;WAEN;;WAEA;;;;;;qBAOE,mBAAmB;;iBC5Bf;WACN;WACA;WACA;WACA;;;iBAIM;WACN;WACA;WACA,WAAW,SAAS;;;iBAId;WACN,qBAAqB;;WAErB;;WAEA;aAAiB;aAAoB;;;WAErC;aAA2B;aAAqB;aAAoB;;WACpE,iBAAiB;;;;;;;wBAQZ,UAAU,OAAO,aAAa,QAAQ,aAAa;;YC/BvD;;iBAGK;WACN;WACA,OAAO;WACP;WACA;;WAEA,SAAS,SAAS;WAClB;;WAEA;;WAEA;WACA;WACA;WACA;WACA;;WAEA,kBAAkB;;WAElB,UAAU,SAAS;;WAEnB,MAAM,SAAS;;WAEf,YAAY,SAAS,QAAQ;;WAE7B;;;;;;;WAOA;;WAEA;;WAEA;;WAEA;;;;;;WAMA;;WAEA;;WAEA;;WAEA;;;;;WAKA;;WAEA,MAAM;;WAEN;WACA;;;;;;YAOC,WAAW,SAAS;;iBAGf;WACN;WACA;WACA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;;YAIC,WAAW,KAAK;;;;;wBAMZ,eAAe,OAAO,aAAa,KAAK,WAAW;;;;;wBAkDnD,WAAW,QAAQ,KAAK;;;;;;wBASxB,kBAAkB;;;;;;wBAmClB,kBAAkB,iBAAiB;;wBC5LnC,WAAW,KAAK,YAAY;;;;;;;qBAa/B;;iBAGI;WACN;WACA;WACA;;;wBAIK,aAAa,KAAK,YAAY;;;;;;;;;wBA2B9B,cAAc,GAAG,WAAW,GAAG,WAAW,oBAA+C;;;;;;;;wBA4BzF,cAAc,gBAAgB,aAAa,oBAA+C,oBAAoB;;;;;;;;;wBA+B9G,eAAe,gBAAgB,aAAa,oBAA+C,oBAAoB,WAAW;;iBAs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ErD;;WAEA;;WAEA;;WAEA,UAAU;;WAEV,UAAU;;WAEV;;;;;;wBCXK,WAAW;;;;;wBAQX,QAAQ;;wBAOR,WAAW,cAAc;;wBAKzB,UAAU,iBAAiB,YAAY;;;;;YCnB3C;;iBAGK;WACN;WACA,WAAW;;WAEX;;WAEA;;WAEA;;;;;;;;YASC;;iBAGK;WACN,SAAS;;;qBAIP,cAAc,SAAS,OAAO;;qBAG9B;;qBAGA;;;;;;wBAoCG,SAAS,OAAO,aAAa,QAAQ,gBAAgB,gBAAiC;;;;;;;;wBAiJtF,YAAY,OAAO,aAAa,QAAQ,eAAe,gBAAiC;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/tolerance.ts","../src/output.ts","../src/record.ts","../src/rules.ts","../src/turn.ts","../src/balance.ts","../src/strategy.ts","../src/random.ts","../src/edges.ts","../src/hash.ts","../src/portfolio.ts","../src/strategy-space.ts","../src/strategy-options.ts","../src/strategy-catalog.ts","../src/verdict.ts","../src/families.ts"],"mappings":";;qBACa;;qBAGA;;;;;qBAMA;;;;;qBAMA;;;;;iBAMI;;WAEN;;WAEA;;;;;;qBAOE,mBAAmB;;iBC5Bf;WACN;WACA;WACA;WACA;;;iBAIM;WACN;WACA;WACA,WAAW,SAAS;;;iBAId;WACN,qBAAqB;;WAErB;;WAEA;aAAiB;aAAoB;;;WAErC;aAA2B;aAAqB;aAAoB;;WACpE,iBAAiB;;;;;;;wBAQZ,UAAU,OAAO,aAAa,QAAQ,aAAa;;YC/BvD;;iBAGK;WACN;WACA,OAAO;WACP;WACA;;WAEA,SAAS,SAAS;WAClB;;WAEA;;WAEA;WACA;WACA;WACA;WACA;;WAEA,kBAAkB;;WAElB,UAAU,SAAS;;WAEnB,MAAM,SAAS;;WAEf,YAAY,SAAS,QAAQ;;WAE7B;;;;;;;WAOA;;WAEA;;WAEA;;WAEA;;;;;;WAMA;;WAEA;;WAEA;;WAEA;;;;;WAKA;;WAEA,MAAM;;WAEN;WACA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iBAAiB;;;;;;;;wBAsChD,kBACd,qBAAqB,mBACrB,OAAM,SAAS,eAAe,cAC9B,gBACA,cACC;;wBA8Ha,qBAAqB,IAAI,aAAa,WAAU,SAAS,aAAa,MAAW,eAAe;;iBA2G/F;WACN;WACA;;WAEA;WACA;;WAEA,qBAAqB;;WAErB;WACA,aAAa;;WAEb,cAAc,MAAM;;EAE7B,MAAM,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;;;;qBA0BZ,eAAe;;;;;;;;;qBAuBf,kBAAkB,aAAa;;;;;;qBAqD/B,gBAAgB,aAAa"}
|
package/build/index.js
CHANGED
|
@@ -2339,7 +2339,7 @@ function gridFactor(options) {
|
|
|
2339
2339
|
* This function gives a copy of a value with each number on the grid. The value `-0` becomes `0`.
|
|
2340
2340
|
* It throws a `RangeError` for a number that is not finite.
|
|
2341
2341
|
*/
|
|
2342
|
-
function onGrid(value, path, k) {
|
|
2342
|
+
function onGrid(value, path, k, skip) {
|
|
2343
2343
|
if (typeof value === "number") {
|
|
2344
2344
|
if (!Number.isFinite(value)) throw new RangeError(`The value has the number ${value} at ${path}. JSON has no form for it.`);
|
|
2345
2345
|
if (k === void 0) return value;
|
|
@@ -2348,23 +2348,95 @@ function onGrid(value, path, k) {
|
|
|
2348
2348
|
return r === 0 ? 0 : r;
|
|
2349
2349
|
}
|
|
2350
2350
|
if (value === null || typeof value !== "object") return value;
|
|
2351
|
-
if (Array.isArray(value)) return value.map((v, i) => onGrid(v, `${path}[${i}]`, k));
|
|
2351
|
+
if (Array.isArray(value)) return value.map((v, i) => onGrid(v, `${path}[${i}]`, k, skip));
|
|
2352
2352
|
const o = value;
|
|
2353
2353
|
const out = {};
|
|
2354
|
-
for (const key of Object.keys(o)) out[key] = onGrid(o[key], `${path}.${key}`, k);
|
|
2354
|
+
for (const key of Object.keys(o)) if (!skip.has(key)) out[key] = onGrid(o[key], `${path}.${key}`, k, skip);
|
|
2355
2355
|
return out;
|
|
2356
2356
|
}
|
|
2357
2357
|
/**
|
|
2358
2358
|
* This function gives the hash of an output: the first 16 hex characters of the SHA-256 of its canonical form.
|
|
2359
2359
|
* Before the canonical form, each number goes to the nearest point of the grid, and `-0` becomes `0`.
|
|
2360
2360
|
* With the default grid, the rounding is `round3` of `packing`: `Math.round(x * 1000) / 1000`.
|
|
2361
|
-
* The function throws a `RangeError` for `NaN` and for an infinite number.
|
|
2361
|
+
* The function throws a `RangeError` for `NaN` and for an infinite number. The fields of `options.skip` are out of the form.
|
|
2362
2362
|
*
|
|
2363
2363
|
* The grid can split two outputs. Two numbers near a rounding boundary can go to two different points.
|
|
2364
2364
|
* 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.
|
|
2365
2365
|
*/
|
|
2366
2366
|
function outputHash(value, options = {}) {
|
|
2367
|
-
return sha256Hex(canonicalJson(onGrid(value, "$", gridFactor(options)))).slice(0, 16);
|
|
2367
|
+
return sha256Hex(canonicalJson(onGrid(value, "$", gridFactor(options), new Set(options.skip ?? [])))).slice(0, 16);
|
|
2368
|
+
}
|
|
2369
|
+
/** This function throws a `RangeError` when a list of the output has an id two times. A packer with this output has a bug. */
|
|
2370
|
+
function uniqueIds(list, ids) {
|
|
2371
|
+
const seen = /* @__PURE__ */ new Set();
|
|
2372
|
+
for (const id of ids) {
|
|
2373
|
+
if (seen.has(id)) throw new RangeError(`The list ${list} of the output has the id "${id}" two times.`);
|
|
2374
|
+
seen.add(id);
|
|
2375
|
+
}
|
|
2376
|
+
}
|
|
2377
|
+
/** The order of two ids by their UTF-16 code units. It does not change with the locale. */
|
|
2378
|
+
function byId(a, b) {
|
|
2379
|
+
return a.id < b.id ? -1 : a.id > b.id ? 1 : 0;
|
|
2380
|
+
}
|
|
2381
|
+
/**
|
|
2382
|
+
* This function gives the normal form of the output of a packer, for a fingerprint.
|
|
2383
|
+
* The form has the placements, the overflow, the size and the moved obstacles. It does not have the trace.
|
|
2384
|
+
* The placements, the moved obstacles and the overflow are in the order of their ids. A placement without `turn` gets `turn: 0`.
|
|
2385
|
+
* Thus two packers with the same result in a different order have the same form.
|
|
2386
|
+
* The function throws a `RangeError` when `placements`, `overflow` or `moved` has an id two times.
|
|
2387
|
+
*/
|
|
2388
|
+
function packOutputForm(output) {
|
|
2389
|
+
uniqueIds("placements", output.placements.map((p) => p.id));
|
|
2390
|
+
uniqueIds("overflow", output.overflow);
|
|
2391
|
+
uniqueIds("moved", output.moved.map((m) => m.id));
|
|
2392
|
+
return {
|
|
2393
|
+
placements: output.placements.map((p) => ({
|
|
2394
|
+
id: p.id,
|
|
2395
|
+
x: p.x,
|
|
2396
|
+
y: p.y,
|
|
2397
|
+
turn: p.turn ?? 0
|
|
2398
|
+
})).sort(byId),
|
|
2399
|
+
overflow: [...output.overflow].sort(),
|
|
2400
|
+
size: {
|
|
2401
|
+
w: output.size.w,
|
|
2402
|
+
h: output.size.h
|
|
2403
|
+
},
|
|
2404
|
+
moved: output.moved.map((m) => ({
|
|
2405
|
+
id: m.id,
|
|
2406
|
+
x: m.x,
|
|
2407
|
+
y: m.y
|
|
2408
|
+
})).sort(byId)
|
|
2409
|
+
};
|
|
2410
|
+
}
|
|
2411
|
+
/** The hash of a probe that the strategy refused or does not support. It has no reason text, so a new text of a refusal does not change a fingerprint. */
|
|
2412
|
+
const REFUSED_PROBE = "refused";
|
|
2413
|
+
/**
|
|
2414
|
+
* This function gives the hash of one probe of a strategy. It calls `run` and gives `outputHash` of its result, with exact numbers by default.
|
|
2415
|
+
* When `run` throws an error that `refused` accepts, the function gives `REFUSED_PROBE`. It throws each other error again.
|
|
2416
|
+
* The option `grid` of `options` puts the numbers on a grid. Its default here is `0`, so a change in a number changes the hash.
|
|
2417
|
+
*/
|
|
2418
|
+
function probeHash(run, refused, options = {}) {
|
|
2419
|
+
let value;
|
|
2420
|
+
try {
|
|
2421
|
+
value = run();
|
|
2422
|
+
} catch (error) {
|
|
2423
|
+
if (refused(error)) return REFUSED_PROBE;
|
|
2424
|
+
throw error;
|
|
2425
|
+
}
|
|
2426
|
+
return outputHash(value, {
|
|
2427
|
+
...options,
|
|
2428
|
+
grid: options.grid ?? 0
|
|
2429
|
+
});
|
|
2430
|
+
}
|
|
2431
|
+
/**
|
|
2432
|
+
* This function gives the fingerprint of the outputs of one strategy: one hash of the hashes of its probes.
|
|
2433
|
+
* The key of `hashes` is the id of a probe, and its value is the hash of the probe, from `probeHash`.
|
|
2434
|
+
* The order of the keys does not change the fingerprint. A new probe, a probe less or a changed hash changes it.
|
|
2435
|
+
* The function throws a `RangeError` when there is no probe.
|
|
2436
|
+
*/
|
|
2437
|
+
function fingerprintOf(hashes) {
|
|
2438
|
+
if (Object.keys(hashes).length === 0) throw new RangeError("A fingerprint needs one probe or more.");
|
|
2439
|
+
return sha256Hex(canonicalJson(hashes)).slice(0, 16);
|
|
2368
2440
|
}
|
|
2369
2441
|
/**
|
|
2370
2442
|
* 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.
|
|
@@ -2918,13 +2990,16 @@ function fitsWalk(constraints, fixed, stage, id) {
|
|
|
2918
2990
|
fixed.delete(stage);
|
|
2919
2991
|
return ok;
|
|
2920
2992
|
}
|
|
2921
|
-
/**
|
|
2922
|
-
function
|
|
2993
|
+
/**
|
|
2994
|
+
* This function gives the plan of a walk. Stages of equal size keep the order of the space.
|
|
2995
|
+
* The stages of `first` go first, for example the stages of the sample option `fixed`. Thus the other stages draw only from the options that keep the constraints with them.
|
|
2996
|
+
*/
|
|
2997
|
+
function walkPlan(stages, lists, constraints, n, first = /* @__PURE__ */ new Set()) {
|
|
2923
2998
|
return {
|
|
2924
2999
|
stages,
|
|
2925
3000
|
lists,
|
|
2926
3001
|
n,
|
|
2927
|
-
order: stages.map((_, k) => k).sort((a, b) => lists[b].length - lists[a].length || a - b),
|
|
3002
|
+
order: stages.map((_, k) => k).sort((a, b) => Number(first.has(stages[b].name)) - Number(first.has(stages[a].name)) || lists[b].length - lists[a].length || a - b),
|
|
2928
3003
|
naming: stages.map((s) => constraints.filter((c) => c.if.stage === s.name || otherStage(c) === s.name))
|
|
2929
3004
|
};
|
|
2930
3005
|
}
|
|
@@ -3611,6 +3686,68 @@ function noSample(space, kept, shapes, meta) {
|
|
|
3611
3686
|
if (empty.length === 0 && removed.length === 0) text += " The constraints remove each config.";
|
|
3612
3687
|
return new RangeError(text);
|
|
3613
3688
|
}
|
|
3689
|
+
/** This function gives a constraint in words, for the reason of an error. */
|
|
3690
|
+
function constraintText(c) {
|
|
3691
|
+
const ref = (r) => `${r.stage} ${r.option === null ? "has no option" : `is ${r.option}`}`;
|
|
3692
|
+
return "not" in c.then ? `if ${ref(c.if)}, then not ${ref(c.then.not)}` : `if ${ref(c.if)}, then ${ref(c.then)}`;
|
|
3693
|
+
}
|
|
3694
|
+
/**
|
|
3695
|
+
* This function throws a `RangeError` for a bad `fixed` option of a sample. A stage or an option that the space does not have is bad.
|
|
3696
|
+
* A meta option without `meta: "sample"` is bad, and so are two fixed options that a constraint forbids.
|
|
3697
|
+
*/
|
|
3698
|
+
function assertFixed(space, fixed, meta) {
|
|
3699
|
+
for (const [stage, id] of Object.entries(fixed)) {
|
|
3700
|
+
const s = space.stages.find((x) => x.name === stage);
|
|
3701
|
+
if (s === void 0) throw new RangeError(`The option fixed names the stage ${stage}, and the space ${space.engine} has no such stage.`);
|
|
3702
|
+
const o = s.options.find((x) => x.id === id);
|
|
3703
|
+
if (o === void 0) throw new RangeError(`The option fixed names the option ${String(id)} of the stage ${stage}, and the stage has no such option.`);
|
|
3704
|
+
if (o.members !== void 0 && !meta) throw new RangeError(`The option fixed names the meta option ${stage}.${id}, and a sample with meta skip has no meta option. Set meta to "sample".`);
|
|
3705
|
+
}
|
|
3706
|
+
const ids = new Map(Object.entries(fixed));
|
|
3707
|
+
const other = (c) => "not" in c.then ? c.then.not.stage : c.then.stage;
|
|
3708
|
+
const broken = (space.constraints ?? []).filter((c) => ids.has(c.if.stage) && ids.has(other(c)) && !holds(c, ids));
|
|
3709
|
+
if (broken.length > 0) {
|
|
3710
|
+
const names = Object.entries(fixed).map(([stage, id]) => `${stage}.${id}`);
|
|
3711
|
+
throw new RangeError(`The constraints of the space ${space.engine} forbid the fixed options ${names.join(", ")}. The broken constraints: ${broken.map(constraintText).join("; ")}.`);
|
|
3712
|
+
}
|
|
3713
|
+
}
|
|
3714
|
+
/**
|
|
3715
|
+
* This function gives the restricted space `kept` with only the fixed option at each fixed stage. A fixed stage that was optional stops being optional.
|
|
3716
|
+
* A meta option of another stage of the part of a fixed stage goes out. A sample gives no option to the other stages of the part of its meta option.
|
|
3717
|
+
*/
|
|
3718
|
+
function fixStages(space, kept, fixed, shapes) {
|
|
3719
|
+
const prefix = prefixes(kept);
|
|
3720
|
+
const parts = new Set(Object.keys(fixed).map((stage) => prefix.get(stage)));
|
|
3721
|
+
const stages = kept.stages.map((s) => {
|
|
3722
|
+
const id = fixed[s.name];
|
|
3723
|
+
if (id === void 0) return parts.has(prefix.get(s.name)) ? {
|
|
3724
|
+
...s,
|
|
3725
|
+
options: s.options.filter((o) => o.members === void 0)
|
|
3726
|
+
} : s;
|
|
3727
|
+
const options = s.options.filter((o) => o.id === id).map((o) => o.members === void 0 ? o : withMemberSpace(o, memberSpaces.get(o) ?? partOf(kept, s.name).space));
|
|
3728
|
+
if (options.length === 0) throw new RangeError(`The fixed option ${s.name}.${id} of the space ${space.engine} does not support the shape kinds ${(shapes ?? []).join(", ")}.`);
|
|
3729
|
+
return {
|
|
3730
|
+
...s,
|
|
3731
|
+
options,
|
|
3732
|
+
optional: false
|
|
3733
|
+
};
|
|
3734
|
+
});
|
|
3735
|
+
return {
|
|
3736
|
+
...kept,
|
|
3737
|
+
stages
|
|
3738
|
+
};
|
|
3739
|
+
}
|
|
3740
|
+
/** This function gives a copy of a meta option whose members come from `members`. */
|
|
3741
|
+
function withMemberSpace(o, members) {
|
|
3742
|
+
const copy = { ...o };
|
|
3743
|
+
memberSpaces.set(copy, members);
|
|
3744
|
+
return copy;
|
|
3745
|
+
}
|
|
3746
|
+
/** This function gives the error of a sample whose fixed options keep each constraint between them. The constraints with the other stages remove each config. */
|
|
3747
|
+
function noFixedSample(space, fixed) {
|
|
3748
|
+
const names = Object.entries(fixed).map(([stage, id]) => `${stage}.${id}`);
|
|
3749
|
+
return /* @__PURE__ */ new RangeError(`The space ${space.engine} has no config with the fixed options ${names.join(", ")}. No constraint between two fixed options breaks, so the constraints with the other stages remove each config.`);
|
|
3750
|
+
}
|
|
3614
3751
|
/** This function gives the count of the base configs of a space that is known to be good. */
|
|
3615
3752
|
const baseCount = (space, levels, limit) => combos(space, levels, false, limit).reduce((sum, c) => sum + c.weight, 0n);
|
|
3616
3753
|
/** This function throws a `RangeError` for a list of shape kinds with a kind that is not declared. */
|
|
@@ -3693,7 +3830,7 @@ const subSeed = (seed, step) => Math.floor(stepRandom(seed, step)() * 4294967296
|
|
|
3693
3830
|
* This function gives a sample of a space: Latin hypercube strata over the options, the params and the member counts.
|
|
3694
3831
|
* `canon` is the space of `canonicalConfig`: the space before a shape filter. A member of an option with `view: "bounds"` can have an option that the filter removed.
|
|
3695
3832
|
*/
|
|
3696
|
-
function sampleConfigs(space, n, seed, meta, maxTries, canon = space, walk = false) {
|
|
3833
|
+
function sampleConfigs(space, n, seed, meta, maxTries, canon = space, walk = false, first = /* @__PURE__ */ new Set()) {
|
|
3697
3834
|
const stages = space.stages;
|
|
3698
3835
|
const prefix = prefixes(space);
|
|
3699
3836
|
const bounded = new Set(stages.filter((s) => meta && s.options.some((o) => memberSpaces.has(o) || o.members?.max === 0)).map((s) => prefix.get(s.name)));
|
|
@@ -3710,7 +3847,7 @@ function sampleConfigs(space, n, seed, meta, maxTries, canon = space, walk = fal
|
|
|
3710
3847
|
if (!usable.has(o)) usable.set(o, hasMembers(space, s.name, o));
|
|
3711
3848
|
return usable.get(o);
|
|
3712
3849
|
};
|
|
3713
|
-
const plan = walk ? walkPlan(stages, lists, space.constraints ?? [], n) : null;
|
|
3850
|
+
const plan = walk ? walkPlan(stages, lists, space.constraints ?? [], n, first) : null;
|
|
3714
3851
|
const points = [];
|
|
3715
3852
|
let tries = 0;
|
|
3716
3853
|
for (let round = 0; points.length < n; round++) {
|
|
@@ -3799,6 +3936,7 @@ function sampleConfigs(space, n, seed, meta, maxTries, canon = space, walk = fal
|
|
|
3799
3936
|
* - A meta option with a `pool` gives only the entries of its pool. With `shapes`, only the entries whose members support each kind count.
|
|
3800
3937
|
* - A sample draws again when a point chooses a meta option without a member list. `spaceSize` gives such an option 0.
|
|
3801
3938
|
* - 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.
|
|
3939
|
+
* - With `fixed`, each config has the fixed option at each named stage. A fixed option that the space, the shape filter or the constraints do not permit gets a `RangeError` with the reason.
|
|
3802
3940
|
*/
|
|
3803
3941
|
function enumerateSpace(space, options) {
|
|
3804
3942
|
assertSpace(space);
|
|
@@ -3814,12 +3952,16 @@ function enumerateSpace(space, options) {
|
|
|
3814
3952
|
if (meta !== "skip" && meta !== "sample") throw new RangeError(`The option meta is ${String(meta)}, not skip or sample.`);
|
|
3815
3953
|
const draw = options.draw ?? "reject";
|
|
3816
3954
|
if (draw !== "reject" && draw !== "walk") throw new RangeError(`The option draw is ${String(draw)}, not reject or walk.`);
|
|
3955
|
+
const fixed = options.fixed;
|
|
3956
|
+
if (fixed !== void 0) assertFixed(space, fixed, meta === "sample");
|
|
3817
3957
|
if (options.n === 0) return [];
|
|
3818
3958
|
const kept = restrict(space, options.shapes);
|
|
3959
|
+
const drawn = fixed === void 0 ? kept : fixStages(space, kept, fixed, options.shapes);
|
|
3819
3960
|
try {
|
|
3820
|
-
return sampleConfigs(
|
|
3961
|
+
return sampleConfigs(drawn, options.n, options.seed, meta === "sample", options.maxTries ?? Math.max(1e3, 100 * options.n), space, draw === "walk", new Set(Object.keys(fixed ?? {})));
|
|
3821
3962
|
} catch (error) {
|
|
3822
3963
|
if (options.shapes !== void 0 && !hasConfig(kept, meta === "sample")) throw noSample(space, kept, options.shapes, meta === "sample");
|
|
3964
|
+
if (fixed !== void 0 && !hasConfig(drawn, meta === "sample")) throw noFixedSample(space, fixed);
|
|
3823
3965
|
throw error;
|
|
3824
3966
|
}
|
|
3825
3967
|
}
|
|
@@ -6103,6 +6245,6 @@ const RECT_SCATTERED = /* @__PURE__ */ Object.freeze({
|
|
|
6103
6245
|
};
|
|
6104
6246
|
}
|
|
6105
6247
|
});
|
|
6106
|
-
export { BALANCE_MEASURE_SUFFIXES, BALANCE_SIDE_DEPTH, CIRCLE_SCATTERED, CORPUS_DIMENSIONS, DEFAULT_FAMILY_BY, DEFAULT_RNG, DEFAULT_SHAPES, DEFAULT_TOLERANCE, EDGES_STEP, EDGE_DENSITY, EDGE_KEY_STEP, EDGE_KEY_STEP_VERSION, EDGE_STEP_VERSION, EPS, EPS_STEPS, FAMILY_ANY_KIND, HARD_RULE_VERSION, INVALIDATED_FIELD, JOINT_MEASURES, JOINT_MOVED_MIN, NODE_POSITIONS_DIMENSION, OUTPUT_CLASS_MIN_INPUTS, OUTPUT_GRID_PROPERTIES, OUTPUT_NEAR_WHOLE, PACK_HARD_RULES, RECORD_EPS, RECORD_SCALE, RECT_SCATTERED, SHAPE_KINDS, SHAPE_KIND_IDS, SIDES, SPLIT_SCHEMA, STRATEGY_CATALOG_SCHEMA, STRATEGY_CATALOG_SCHEMAS, STRATEGY_SPACE_SCHEMA, VERDICT_DRAWS, VERDICT_EXACT_CAP, VERDICT_EXACT_MAX, VERDICT_RUNS, VERDICT_SEED, applyPack, balanceMeasureSpecs, balanceMeasures, balanceOf, boundsOf, boxArea, canonicalConfig, canonicalInput, canonicalJson, catalogChoices, catalogDefaults, catalogKey, catalogOptions, checkCatalog, checkConfig, checkDeclared, checkInput, checkLayoutRecord, checkOptions, checkSchema, checkShapes, checkSpace, checkSplit, circleOverlaps, circlesOutside, clampOptions, compareMeasure, composeFamily, configId, corpusHashOf, countLinksThroughShapes, countObstacleHits, countOutside, countOverlaps, countPortsOffBorder, createFamilyRegistry, crossingPoint, declarationIssues, declaredClaimOf, declaredCounts, decodeOptionValue, dimensionAt, dimensionSupports, dimensionUnit, documentHash, edgeKeyStep, edgeStep, encodeOptionValue, enumerateSpace, exercised, familyKind, familyOf, fnv1a32, grow, hardRuleOf, inputShapeLevel, isShapeKind, itemShapeOf, joinConfigs, leaveOneSeedOut, levelsOf, listOptions, marginSides, minEffectOf, mulberry32, nearestGaps, optionDefaults, optionIssue, outputGridClass, outputGroups, outputHash, overlapOf, ownerDimension, packHard, packLinks, paramActive, paramLevels, paramProblem, paramValue, parseLayoutRecord, parseStrategyCatalog, perChange, pickMoves, placedCircle, placedRect, pointSegmentDistance, portPoint, portfolio, procrustesOf, productSpace, randomInt, rectInRegion, regionArea, regionHitsRect, resolveDimensions, ruleLevel, segmentThroughShape, segmentsCross, selectBest, sha256Hex, shapeKindOf, shapeKindProblem, shapeKindsOf, shapeLevel, shapeSupportProblems, shapesOf, shapesOverlap, sharedDimension, spaceShapeKinds, spaceSize, splitConfig, splitFileName, splitFolds, stepRandom, sweepGrid, sweepOf, sweepValues, toLayoutRecord, toPackInput, toRect, toSizedRect, translate, turnBox, turnMargin, turnPoint, turnPort, turnRegion, turnSide, verdict, writeStrategyCatalog };
|
|
6248
|
+
export { BALANCE_MEASURE_SUFFIXES, BALANCE_SIDE_DEPTH, CIRCLE_SCATTERED, CORPUS_DIMENSIONS, DEFAULT_FAMILY_BY, DEFAULT_RNG, DEFAULT_SHAPES, DEFAULT_TOLERANCE, EDGES_STEP, EDGE_DENSITY, EDGE_KEY_STEP, EDGE_KEY_STEP_VERSION, EDGE_STEP_VERSION, EPS, EPS_STEPS, FAMILY_ANY_KIND, HARD_RULE_VERSION, INVALIDATED_FIELD, JOINT_MEASURES, JOINT_MOVED_MIN, NODE_POSITIONS_DIMENSION, OUTPUT_CLASS_MIN_INPUTS, OUTPUT_GRID_PROPERTIES, OUTPUT_NEAR_WHOLE, PACK_HARD_RULES, RECORD_EPS, RECORD_SCALE, RECT_SCATTERED, REFUSED_PROBE, SHAPE_KINDS, SHAPE_KIND_IDS, SIDES, SPLIT_SCHEMA, STRATEGY_CATALOG_SCHEMA, STRATEGY_CATALOG_SCHEMAS, STRATEGY_SPACE_SCHEMA, VERDICT_DRAWS, VERDICT_EXACT_CAP, VERDICT_EXACT_MAX, VERDICT_RUNS, VERDICT_SEED, applyPack, balanceMeasureSpecs, balanceMeasures, balanceOf, boundsOf, boxArea, canonicalConfig, canonicalInput, canonicalJson, catalogChoices, catalogDefaults, catalogKey, catalogOptions, checkCatalog, checkConfig, checkDeclared, checkInput, checkLayoutRecord, checkOptions, checkSchema, checkShapes, checkSpace, checkSplit, circleOverlaps, circlesOutside, clampOptions, compareMeasure, composeFamily, configId, corpusHashOf, countLinksThroughShapes, countObstacleHits, countOutside, countOverlaps, countPortsOffBorder, createFamilyRegistry, crossingPoint, declarationIssues, declaredClaimOf, declaredCounts, decodeOptionValue, dimensionAt, dimensionSupports, dimensionUnit, documentHash, edgeKeyStep, edgeStep, encodeOptionValue, enumerateSpace, exercised, familyKind, familyOf, fingerprintOf, fnv1a32, grow, hardRuleOf, inputShapeLevel, isShapeKind, itemShapeOf, joinConfigs, leaveOneSeedOut, levelsOf, listOptions, marginSides, minEffectOf, mulberry32, nearestGaps, optionDefaults, optionIssue, outputGridClass, outputGroups, outputHash, overlapOf, ownerDimension, packHard, packLinks, packOutputForm, paramActive, paramLevels, paramProblem, paramValue, parseLayoutRecord, parseStrategyCatalog, perChange, pickMoves, placedCircle, placedRect, pointSegmentDistance, portPoint, portfolio, probeHash, procrustesOf, productSpace, randomInt, rectInRegion, regionArea, regionHitsRect, resolveDimensions, ruleLevel, segmentThroughShape, segmentsCross, selectBest, sha256Hex, shapeKindOf, shapeKindProblem, shapeKindsOf, shapeLevel, shapeSupportProblems, shapesOf, shapesOverlap, sharedDimension, spaceShapeKinds, spaceSize, splitConfig, splitFileName, splitFolds, stepRandom, sweepGrid, sweepOf, sweepValues, toLayoutRecord, toPackInput, toRect, toSizedRect, translate, turnBox, turnMargin, turnPoint, turnPort, turnRegion, turnSide, verdict, writeStrategyCatalog };
|
|
6107
6249
|
|
|
6108
6250
|
//# sourceMappingURL=index.js.map
|