@mark1russell7/layout-contract 0.5.1 → 0.5.2
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 +9 -0
- package/build/index.d.ts.map +1 -1
- package/build/index.js +53 -12
- package/build/index.js.map +1 -1
- package/package.json +1 -1
- package/src/space-walk.ts +63 -0
- package/src/strategy-space.ts +20 -14
package/build/index.d.ts
CHANGED
|
@@ -807,6 +807,14 @@ export interface SampleOptions extends ShapeFilter {
|
|
|
807
807
|
readonly meta?: "skip" | "sample";
|
|
808
808
|
/** The largest count of option draws. The default is the larger value of 1000 and `100 * n`. */
|
|
809
809
|
readonly maxTries?: number;
|
|
810
|
+
/**
|
|
811
|
+
* How a point keeps the constraints. With `reject` (the default), a point that breaks a constraint draws again.
|
|
812
|
+
* 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.
|
|
813
|
+
* A space whose constraints reject most draws gets its sample with `walk`. The two values give different configs for one seed.
|
|
814
|
+
* 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.
|
|
815
|
+
* Thus a mean over this sample is not a mean of the space.
|
|
816
|
+
*/
|
|
817
|
+
readonly draw?: "reject" | "walk";
|
|
810
818
|
}
|
|
811
819
|
/** The options of `enumerateSpace`. */
|
|
812
820
|
export type EnumerateOptions = GridOptions | SampleOptions;
|
|
@@ -861,6 +869,7 @@ export declare function spaceSize(space: StrategySpace, options: SpaceSizeOption
|
|
|
861
869
|
* - 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.
|
|
862
870
|
* - 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.
|
|
863
871
|
* - A sample draws again when a point breaks a constraint. After `maxTries` draws, it throws an `Error`. Two sampled configs can be equal.
|
|
872
|
+
* - With `draw: "walk"`, each stage draws only from the options that keep the constraints with the stages before it. The largest stage keeps its equal strata.
|
|
864
873
|
* - With `shapes`, only the options that support each kind of the list count. Without `shapes`, the result does not change.
|
|
865
874
|
* - A meta option with a `pool` gives only the entries of its pool. With `shapes`, only the entries whose members support each kind count.
|
|
866
875
|
* - A sample draws again when a point chooses a meta option without a member list. `spaceSize` gives such an option 0.
|
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,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C,MAAM,QAAQ;;;iBAIC;;WAEN;;WAEA;;WAEA;;;;;WAKA;;;YAIC;;iBAGK;WACN;WACA,QAAQ;;WAER,SAAS,SAAS;;WAElB;;;;;WAKA;;WAEA;;;iBAIM;;WAEN,kBAAkB;WAClB;;WAEA;;WAEA;;WAEA;WACA;WACA;;WAEA;;WAEA;;WAEA;;;iBAIM,cAAc;WACpB,QAAQ;WACR;WACA,OAAO;;;iBAID,UAAU,GAAG,WAAW,OAAO,GAAG;;EAEjD,KAAK,OAAO,IAAI,cAAc;;;iBAIf;WACN;WACA,QAAQ,SAAS;;;iBAIX;WACN;WACA,MAAM;;;iBAIA;WACN;;WAEA;;;;;;;;;;;;;;;wBAgBK,WAAW,qBAAqB,mBAAmB,iBAAiB,gBAAgB;;wBAsBpF,UAAU,OAAO,KAAK;EAA8B;;;;;;;;;;;;;;wBAwCpD,UAAU,GAAG,GAC3B,YACA,kBAAkB,OAAO,GAAG,SAAS,OAAO,eAAe,OAAO,GAAG,OACrE,KAAK,aAAa,GAAG,IACrB,UAAS,mBACR,UAAU,GAAG;;
|
|
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;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BAAiB;;;;;wBA+FxC,YAAY,KAAK,YAAY;;wBAa7B,cAAc,KAAK,YAAY;;;;;;wBAsB/B,SAAS,KAAK,iBAAiB,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
|
@@ -2903,6 +2903,48 @@ function leaveOneSeedOut(seeds) {
|
|
|
2903
2903
|
heldOut: [s]
|
|
2904
2904
|
}));
|
|
2905
2905
|
}
|
|
2906
|
+
// src/space-walk.ts
|
|
2907
|
+
const refMatches = (ref, choices) => (choices.get(ref.stage) ?? null) === ref.option;
|
|
2908
|
+
/** This function tells if the option choices keep a constraint. */
|
|
2909
|
+
function holds(c, choices) {
|
|
2910
|
+
if (!refMatches(c.if, choices)) return true;
|
|
2911
|
+
return "not" in c.then ? !refMatches(c.then.not, choices) : refMatches(c.then, choices);
|
|
2912
|
+
}
|
|
2913
|
+
const otherStage = (c) => "not" in c.then ? c.then.not.stage : c.then.stage;
|
|
2914
|
+
/** This function tells if an option of a stage keeps each constraint between that stage and the stages that a walk has fixed. */
|
|
2915
|
+
function fitsWalk(constraints, fixed, stage, id) {
|
|
2916
|
+
fixed.set(stage, id);
|
|
2917
|
+
const ok = constraints.every((c) => !fixed.has(c.if.stage === stage ? otherStage(c) : c.if.stage) || holds(c, fixed));
|
|
2918
|
+
fixed.delete(stage);
|
|
2919
|
+
return ok;
|
|
2920
|
+
}
|
|
2921
|
+
/** This function gives the plan of a walk. Stages of equal size keep the order of the space. */
|
|
2922
|
+
function walkPlan(stages, lists, constraints, n) {
|
|
2923
|
+
return {
|
|
2924
|
+
stages,
|
|
2925
|
+
lists,
|
|
2926
|
+
n,
|
|
2927
|
+
order: stages.map((_, k) => k).sort((a, b) => lists[b].length - lists[a].length || a - b),
|
|
2928
|
+
naming: stages.map((s) => constraints.filter((c) => c.if.stage === s.name || otherStage(c) === s.name))
|
|
2929
|
+
};
|
|
2930
|
+
}
|
|
2931
|
+
/**
|
|
2932
|
+
* This function gives the options of one point of a walk. It fixes the largest stage first. Thus that stage keeps its equal strata, and the constraints limit only the smaller stages.
|
|
2933
|
+
* The value `picks[k][i]` is the stratum of the stage `k` for the point `i`. A stage with no open option gets `null`, and the caller rejects that point.
|
|
2934
|
+
* The argument `fits` lets a test give a fault. The default is `fitsWalk`.
|
|
2935
|
+
*/
|
|
2936
|
+
function walkPoint(plan, picks, i, fits = fitsWalk) {
|
|
2937
|
+
const fixed = /* @__PURE__ */ new Map();
|
|
2938
|
+
const out = /* @__PURE__ */ new Map();
|
|
2939
|
+
for (const k of plan.order) {
|
|
2940
|
+
const s = plan.stages[k];
|
|
2941
|
+
const open = plan.lists[k].filter((o) => fits(plan.naming[k], fixed, s.name, o?.id ?? null));
|
|
2942
|
+
const o = open[Math.floor(picks[k][i] * open.length / plan.n)] ?? null;
|
|
2943
|
+
fixed.set(s.name, o?.id ?? null);
|
|
2944
|
+
out.set(s.name, o);
|
|
2945
|
+
}
|
|
2946
|
+
return out;
|
|
2947
|
+
}
|
|
2906
2948
|
// src/strategy-space.ts
|
|
2907
2949
|
/** The schema of a strategy space. */
|
|
2908
2950
|
const STRATEGY_SPACE_SCHEMA = "strategy-space/1";
|
|
@@ -2972,12 +3014,6 @@ function partOf(space, stage) {
|
|
|
2972
3014
|
}
|
|
2973
3015
|
/** This function gives the prefix of the innermost part of each stage. */
|
|
2974
3016
|
const prefixes = (space) => new Map(space.stages.map((s) => [s.name, partOf(space, s.name).prefix]));
|
|
2975
|
-
const refMatches = (ref, choices) => (choices.get(ref.stage) ?? null) === ref.option;
|
|
2976
|
-
/** This function tells if the option choices keep a constraint. */
|
|
2977
|
-
function holds(c, choices) {
|
|
2978
|
-
if (!refMatches(c.if, choices)) return true;
|
|
2979
|
-
return "not" in c.then ? !refMatches(c.then.not, choices) : refMatches(c.then, choices);
|
|
2980
|
-
}
|
|
2981
3017
|
const describe = (c) => {
|
|
2982
3018
|
const ref = (r) => `${r.stage}=${r.option ?? "null"}`;
|
|
2983
3019
|
return "not" in c.then ? `if ${ref(c.if)} then not ${ref(c.then.not)}` : `if ${ref(c.if)} then ${ref(c.then)}`;
|
|
@@ -3655,7 +3691,7 @@ const subSeed = (seed, step) => Math.floor(stepRandom(seed, step)() * 4294967296
|
|
|
3655
3691
|
* This function gives a sample of a space: Latin hypercube strata over the options, the params and the member counts.
|
|
3656
3692
|
* `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.
|
|
3657
3693
|
*/
|
|
3658
|
-
function sampleConfigs(space, n, seed, meta, maxTries, canon = space) {
|
|
3694
|
+
function sampleConfigs(space, n, seed, meta, maxTries, canon = space, walk = false) {
|
|
3659
3695
|
const stages = space.stages;
|
|
3660
3696
|
const prefix = prefixes(space);
|
|
3661
3697
|
const bounded = new Set(stages.filter((s) => meta && s.options.some((o) => memberSpaces.has(o))).map((s) => prefix.get(s.name)));
|
|
@@ -3672,15 +3708,17 @@ function sampleConfigs(space, n, seed, meta, maxTries, canon = space) {
|
|
|
3672
3708
|
if (!usable.has(o)) usable.set(o, hasMembers(space, s.name, o));
|
|
3673
3709
|
return usable.get(o);
|
|
3674
3710
|
};
|
|
3711
|
+
const plan = walk ? walkPlan(stages, lists, space.constraints ?? [], n) : null;
|
|
3675
3712
|
const points = [];
|
|
3676
3713
|
let tries = 0;
|
|
3677
3714
|
for (let round = 0; points.length < n; round++) {
|
|
3678
3715
|
const r = stepRandom(seed, `options:${round}`);
|
|
3679
|
-
const
|
|
3716
|
+
const picks = walk ? lists.map(() => permutation(n, r)) : [];
|
|
3717
|
+
const columns = walk ? [] : lists.map((list) => permutation(n, r).map((p) => list[Math.floor(p * list.length / n)]));
|
|
3680
3718
|
for (let i = 0; i < n && points.length < n; i++) {
|
|
3681
|
-
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
|
|
3719
|
+
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.${walk ? "" : " The option draw: \"walk\" gets a sample of a space with many constraints."}`);
|
|
3682
3720
|
tries++;
|
|
3683
|
-
const choices = new Map(stages.map((s, k) => [s.name, columns[k][i]]));
|
|
3721
|
+
const choices = plan !== null ? walkPoint(plan, picks, i) : new Map(stages.map((s, k) => [s.name, columns[k][i]]));
|
|
3684
3722
|
const metaPart = /* @__PURE__ */ new Map();
|
|
3685
3723
|
for (const s of stages) if (choices.get(s.name)?.members !== void 0 && !metaPart.has(prefix.get(s.name))) metaPart.set(prefix.get(s.name), s.name);
|
|
3686
3724
|
for (const s of stages) {
|
|
@@ -3715,7 +3753,7 @@ function sampleConfigs(space, n, seed, meta, maxTries, canon = space) {
|
|
|
3715
3753
|
const part = memberSpaces.get(o) ?? partOf(space, s.name).space;
|
|
3716
3754
|
const poolSize = Math.max(n, 4 * o.members.max, 8);
|
|
3717
3755
|
const seen = /* @__PURE__ */ new Set();
|
|
3718
|
-
const pool = sampleConfigs(part, poolSize, subSeed(seed, `pool:${s.name}:${o.id}`), false, Math.max(1e3, 100 * poolSize)).filter((c) => {
|
|
3756
|
+
const pool = sampleConfigs(part, poolSize, subSeed(seed, `pool:${s.name}:${o.id}`), false, Math.max(1e3, 100 * poolSize), part, walk).filter((c) => {
|
|
3719
3757
|
const id = idOf(c);
|
|
3720
3758
|
return seen.has(id) ? false : (seen.add(id), true);
|
|
3721
3759
|
});
|
|
@@ -3754,6 +3792,7 @@ function sampleConfigs(space, n, seed, meta, maxTries, canon = space) {
|
|
|
3754
3792
|
* - 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.
|
|
3755
3793
|
* - 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.
|
|
3756
3794
|
* - A sample draws again when a point breaks a constraint. After `maxTries` draws, it throws an `Error`. Two sampled configs can be equal.
|
|
3795
|
+
* - With `draw: "walk"`, each stage draws only from the options that keep the constraints with the stages before it. The largest stage keeps its equal strata.
|
|
3757
3796
|
* - With `shapes`, only the options that support each kind of the list count. Without `shapes`, the result does not change.
|
|
3758
3797
|
* - A meta option with a `pool` gives only the entries of its pool. With `shapes`, only the entries whose members support each kind count.
|
|
3759
3798
|
* - A sample draws again when a point chooses a meta option without a member list. `spaceSize` gives such an option 0.
|
|
@@ -3771,10 +3810,12 @@ function enumerateSpace(space, options) {
|
|
|
3771
3810
|
if (!Number.isInteger(options.seed)) throw new RangeError(`The seed ${options.seed} is not a whole number.`);
|
|
3772
3811
|
const meta = options.meta ?? "skip";
|
|
3773
3812
|
if (meta !== "skip" && meta !== "sample") throw new RangeError(`The option meta is ${String(meta)}, not skip or sample.`);
|
|
3813
|
+
const draw = options.draw ?? "reject";
|
|
3814
|
+
if (draw !== "reject" && draw !== "walk") throw new RangeError(`The option draw is ${String(draw)}, not reject or walk.`);
|
|
3774
3815
|
if (options.n === 0) return [];
|
|
3775
3816
|
const kept = restrict(space, options.shapes);
|
|
3776
3817
|
try {
|
|
3777
|
-
return sampleConfigs(kept, options.n, options.seed, meta === "sample", options.maxTries ?? Math.max(1e3, 100 * options.n), space);
|
|
3818
|
+
return sampleConfigs(kept, options.n, options.seed, meta === "sample", options.maxTries ?? Math.max(1e3, 100 * options.n), space, draw === "walk");
|
|
3778
3819
|
} catch (error) {
|
|
3779
3820
|
if (options.shapes !== void 0 && !hasConfig(kept, meta === "sample")) throw noSample(space, kept, options.shapes, meta === "sample");
|
|
3780
3821
|
throw error;
|