@mark1russell7/stack-endurance 0.8.12 → 0.8.14
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 +1 -0
- package/build/add-on.js +1 -1
- package/build/index.d.ts +20 -0
- package/build/index.d.ts.map +1 -1
- package/build/index.js +41 -14
- package/build/index.js.map +1 -1
- package/build/{join-BJJdchyI.js → join-Cc6JzE5G.js} +13 -4
- package/build/join-Cc6JzE5G.js.map +1 -0
- package/build/schema.d.ts.map +1 -1
- package/build/schema.js +4 -0
- package/build/schema.js.map +1 -1
- package/package.json +2 -2
- package/build/join-BJJdchyI.js.map +0 -1
package/README.md
CHANGED
|
@@ -85,6 +85,7 @@ Two groups of cuts that share no minimal set are independent, so the independent
|
|
|
85
85
|
- Each value has one number for each curve of `stopCurves`: `event`, `independent` and `upper`.
|
|
86
86
|
- The chance of `upper` is not more than the true chance, for each dependence of the cuts. Thus the range from `upper` to the other two shows the doubt of the dependence.
|
|
87
87
|
- `holds` names the draws whose supply the case does not stop. `unread` names the draws whose stop has no curve.
|
|
88
|
+
- `band` gives the same values with each cut at the low end of its band (`shorter`) and at the high end (`longer`). The days do not change. Each end holds only at each day, so the two values are a range of the sampling error, not a joint interval. A draw has no `band` when a cut of its stop has a curve and no band. Since 0.8.14.
|
|
88
89
|
|
|
89
90
|
## The joint days
|
|
90
91
|
|
package/build/add-on.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as checkEndurance, t as joinEndurance } from "./join-
|
|
1
|
+
import { r as checkEndurance, t as joinEndurance } from "./join-Cc6JzE5G.js";
|
|
2
2
|
import { t as ENDURANCE_SCHEMA } from "./layer-a3Fr70Uh.js";
|
|
3
3
|
import { parseEndurance } from "./schema.js";
|
|
4
4
|
// src/add-on.ts
|
package/build/index.d.ts
CHANGED
|
@@ -411,6 +411,20 @@ export interface CurveValues {
|
|
|
411
411
|
/** The value of the upper curve: the safe side for each dependence of the cuts. */
|
|
412
412
|
readonly upper: number;
|
|
413
413
|
}
|
|
414
|
+
/** The chance and the shortfall of a draw at one end of the sampling bands of its cuts. Since 0.8.14. */
|
|
415
|
+
export interface BandValues {
|
|
416
|
+
readonly lasts: CurveValues;
|
|
417
|
+
readonly shortfall: CurveValues;
|
|
418
|
+
}
|
|
419
|
+
/**
|
|
420
|
+
* The values of a draw at the two ends of the sampling bands of its cuts (`Cut.band`). Since 0.8.14.
|
|
421
|
+
* `shorter` puts each cut at the low end of its band, and `longer` puts each cut at the high end.
|
|
422
|
+
* Each end holds only pointwise, so the two values are a range of the sampling error, not a joint interval.
|
|
423
|
+
*/
|
|
424
|
+
export interface DrawBand {
|
|
425
|
+
readonly shorter: BandValues;
|
|
426
|
+
readonly longer: BandValues;
|
|
427
|
+
}
|
|
414
428
|
/** The outlook of one draw in one event of a case. */
|
|
415
429
|
export interface DrawOutlook {
|
|
416
430
|
readonly need: string;
|
|
@@ -433,6 +447,11 @@ export interface DrawOutlook {
|
|
|
433
447
|
readonly bound: CutBound$1;
|
|
434
448
|
/** This is true when the upper curve is coarse (`StopCurves.coarse`). */
|
|
435
449
|
readonly coarse: boolean;
|
|
450
|
+
/**
|
|
451
|
+
* The values at the two ends of the sampling bands of the cuts, with the same days. Since 0.8.14.
|
|
452
|
+
* It is missing when a cut that can be part of the stop has a curve and no band. Then the sampling error has no read.
|
|
453
|
+
*/
|
|
454
|
+
readonly band?: DrawBand | undefined;
|
|
436
455
|
}
|
|
437
456
|
/** The outlook of one event of a case: the days, the chance and the shortfall of each draw. */
|
|
438
457
|
export interface CaseOutlook {
|
|
@@ -458,6 +477,7 @@ export interface CaseOutlook {
|
|
|
458
477
|
* - The days come from the share of the stores: `enduranceOf` for `take`, `bestEndurance` with the horizon for `best`.
|
|
459
478
|
* - The chance and the shortfall use the curves of `stopCurves`. They count the stop only up to the horizon.
|
|
460
479
|
* - `upper` is the safe side: its chance is not more, and its shortfall is not less, than the true value for each dependence.
|
|
480
|
+
* - `band` gives the same values with each cut at each end of its sampling band (`Cut.band`). The days do not change.
|
|
461
481
|
*
|
|
462
482
|
* @param layer - The endurance layer
|
|
463
483
|
* @param caseCuts - The case
|
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":["CutBound"],"sources":["../src/endurance.ts","../src/joint.ts","../src/best.ts","../src/shortfall.ts","../src/check.ts","../src/join.ts","../src/sample.ts"],"mappings":";;;iBAUiB;;WAEN,IAAI;;WAEJ,QAAQ;;WAER;;;;;;wBAOK,YAAY,UAAU,UAAU,SAAS,KAAK,iCAAiC;;;;;;;wBAoB/E,aAAa,OAAO,gBAAgB,IAAI,SAAS,eAAc,sBAAkC;;wBAYjG,WAAW,MAAM,MAAM,UAAU;;;;;wBAQjC,UAAU,OAAO,gBAAgB,UAAU,UAAU,cAAc,sBAAsB;;wBAWzF,SAAS,WAAW;;wBAKpB,aAAa,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAuLxB,YAAY,OAAO,gBAAgB,UAAU,UAAU,SAAS,cAAc;;iBC3P7E;WACN;WACA,IAAI;;;;;WAKJ;;WAEA;;WAEA;;;;;;WAMA,OAAO,SAAS,eAAe,SAAS;;;;;WAKxC;;WAEA,MAAM,SAAS;;;;;;WAMf;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBA+BK,UAAU,OAAO,gBAAgB,UAAU,UAAU,SAAS,aAAa,2BAA2B;;iBC/CrG,oBAAoB;;;;;;WAM1B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAyDK,cAAc,OAAO,gBAAgB,UAAU,UAAU,SAAS,cAAc;;;;;;wBCvEhF,SAAS,OAAO,UAAU,cAAc;;;;;;;;;;iBAqBvC,yBAAyB,KAAK,gCAAgC,KAAK;;WAEzE;;iBAGM,yBAAyB;;WAE/B;;;;;;wBAqBK,iBAAiB,OAAO,UAAU;;wBAWlC,WAAW,OAAO;;wBAKlB,SAAS,OAAO;;;;;;;;;;;;;;;;wBAoDhB,UAAU,iBAAiB,YAAY,QAAQ,sCAAsC;;;;;;;;wBAiBrF,YAAY,iBAAiB,aAAa;;;;;qBAU7C;;;;;wBAMG,aAAa,eAAe,QAAQ;;;;;;;;;;wBA8BpC,UAAU,iBAAiB,YAAY,mDAAmD;;qBAiB7F;;;;;;qBAOA;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBA6BG,gBAAgB,iBAAiB,YAAY,kDAAkD,mBAAyC;;;;;iBAiKvI;WACN,OAAO;;WAEP,aAAa;WACb,OAAO;;;;;WAKP;;WAEA;;;;;;WAMA,OAAOA;;;;;;;;;;;;;;;;wBAmEF,WAAW,UAAU,UAAU,MAAM,MAAM,UAAS,mBAAwB;;iBAM3E;;;;;WAKN,QAAQ,SAAS;;WAEjB,aAAa,SAAS;;WAEtB,OAAO,SAAS;;;;;WAKhB;;WAEA;;WAEA;;;;;;;;;WASA,OAAOA;;;;;;;;;;;;wBAiBF,cAAc,OAAO,gBAAgB,UAAU,UAAU,WAAW,WAAW,UAAS,mBAAwB;;;;;YAiCpH;;qBAGC,iBAAiB;;iBAeb,6BAA6B,aAAa;;;;;;WAMhD,QAAQ;;;iBAIF,sBAAsB;WAC5B;;WAEA;aAA2B;aAAuB;aAAuB,WAAW;aAAoB,WAAW;;;;;;;;;;;;;;;;;;;wBAmB9G,cAAc,OAAO,gBAAgB,eAAe,SAAS,uBAAuB;;YA+BxF,iBAAiB;;iBAGZ;;WAEN;;WAEA;;WAEA;;;iBAIM;WACN;WACA;WACA;WACA;;WAEA;;WAEA;;;;;;WAMA,OAAO;;WAEP,WAAW;;WAEX,OAAOA;;WAEP;;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":["CutBound"],"sources":["../src/endurance.ts","../src/joint.ts","../src/best.ts","../src/shortfall.ts","../src/check.ts","../src/join.ts","../src/sample.ts"],"mappings":";;;iBAUiB;;WAEN,IAAI;;WAEJ,QAAQ;;WAER;;;;;;wBAOK,YAAY,UAAU,UAAU,SAAS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import { t as ENDURANCE_SCHEMA } from "./layer-a3Fr70Uh.js";
|
|
2
|
-
import { S as exact, _ as fewestRow, a as hasEnduranceError, b as addTo, c as drawDemand, d as giftResource, f as storeAmounts, g as drawBlock, h as deviceUse, i as curveFault, l as enduranceOf, m as caseParts, n as ENDURANCE_CODES, o as caseDraws, p as Program, r as checkEndurance, s as caseStopped, t as joinEndurance, u as giftNeed, v as reachOf, x as dense, y as valueAt } from "./join-
|
|
2
|
+
import { S as exact, _ as fewestRow, a as hasEnduranceError, b as addTo, c as drawDemand, d as giftResource, f as storeAmounts, g as drawBlock, h as deviceUse, i as curveFault, l as enduranceOf, m as caseParts, n as ENDURANCE_CODES, o as caseDraws, p as Program, r as checkEndurance, s as caseStopped, t as joinEndurance, u as giftNeed, v as reachOf, x as dense, y as valueAt } from "./join-Cc6JzE5G.js";
|
|
3
3
|
import { DEFAULT_MAX_SETS, STACK_SCHEMA, neededParts, stopSets, survivalAt, weakestBound } from "@mark1russell7/system-stack";
|
|
4
4
|
import { ONE, ZERO, add, div, equals, mul, neg, sign, sub, toNumber } from "@mark1russell7/rational";
|
|
5
5
|
import { solveLexicographic } from "@mark1russell7/linear";
|
|
@@ -77,8 +77,11 @@ function jointDays(layer, caseCuts, options, needs) {
|
|
|
77
77
|
}
|
|
78
78
|
for (const resource of parts.stocked) {
|
|
79
79
|
const row = /* @__PURE__ */ new Map();
|
|
80
|
-
for (const block of blocks)
|
|
81
|
-
|
|
80
|
+
for (const block of blocks) {
|
|
81
|
+
const index = block.shares.get(resource);
|
|
82
|
+
if (index !== void 0) addTo(row, index, ONE);
|
|
83
|
+
}
|
|
84
|
+
if (row.size > 0) program.push(row, "<=", exact(stock.get(resource) ?? 0));
|
|
82
85
|
}
|
|
83
86
|
const most = /* @__PURE__ */ new Map([[days, ONE]]);
|
|
84
87
|
const least = /* @__PURE__ */ new Map();
|
|
@@ -972,6 +975,7 @@ function yearShortfall(layer, place, options) {
|
|
|
972
975
|
* - The days come from the share of the stores: `enduranceOf` for `take`, `bestEndurance` with the horizon for `best`.
|
|
973
976
|
* - The chance and the shortfall use the curves of `stopCurves`. They count the stop only up to the horizon.
|
|
974
977
|
* - `upper` is the safe side: its chance is not more, and its shortfall is not less, than the true value for each dependence.
|
|
978
|
+
* - `band` gives the same values with each cut at each end of its sampling band (`Cut.band`). The days do not change.
|
|
975
979
|
*
|
|
976
980
|
* @param layer - The endurance layer
|
|
977
981
|
* @param caseCuts - The case
|
|
@@ -986,6 +990,19 @@ function caseOutlook(layer, caseCuts, options) {
|
|
|
986
990
|
const stopped = caseDraws(layer, caseCuts, caseStopped(caseCuts, options));
|
|
987
991
|
const stoppedNeeds = new Set(stopped.map((draw) => draw.need));
|
|
988
992
|
const stoppedOf = stoppedMemo(caseCuts, options);
|
|
993
|
+
const banded = caseCuts.cuts.some((cut) => cut.band !== void 0);
|
|
994
|
+
const endCuts = (end) => ({
|
|
995
|
+
...caseCuts,
|
|
996
|
+
cuts: caseCuts.cuts.map(({ duration: _, band, ...cut }) => band === void 0 ? cut : {
|
|
997
|
+
...cut,
|
|
998
|
+
duration: band[end],
|
|
999
|
+
band
|
|
1000
|
+
})
|
|
1001
|
+
});
|
|
1002
|
+
const ends = banded ? {
|
|
1003
|
+
shorter: endCuts("low"),
|
|
1004
|
+
longer: endCuts("high")
|
|
1005
|
+
} : void 0;
|
|
989
1006
|
const draws = [];
|
|
990
1007
|
const unread = [];
|
|
991
1008
|
const bounds = [];
|
|
@@ -999,6 +1016,24 @@ function caseOutlook(layer, caseCuts, options) {
|
|
|
999
1016
|
const users = draw.users ?? 1;
|
|
1000
1017
|
const lasts = (curve) => held.days >= horizon ? 1 : 1 - survivalAt(curve, held.days);
|
|
1001
1018
|
const short = (curve) => tailDays(curve, held.days, horizon) * users;
|
|
1019
|
+
const values = (stop) => ({
|
|
1020
|
+
lasts: {
|
|
1021
|
+
event: lasts(stop.event),
|
|
1022
|
+
independent: lasts(stop.independent),
|
|
1023
|
+
upper: lasts(stop.upper)
|
|
1024
|
+
},
|
|
1025
|
+
shortfall: {
|
|
1026
|
+
event: short(stop.event),
|
|
1027
|
+
independent: short(stop.independent),
|
|
1028
|
+
upper: short(stop.upper)
|
|
1029
|
+
}
|
|
1030
|
+
});
|
|
1031
|
+
const shorter = ends === void 0 ? void 0 : stopCurvesWith(ends.shorter, draw, options, stoppedOf);
|
|
1032
|
+
const longer = ends === void 0 ? void 0 : stopCurvesWith(ends.longer, draw, options, stoppedOf);
|
|
1033
|
+
const band = shorter === void 0 || longer === void 0 ? {} : { band: {
|
|
1034
|
+
shorter: values(shorter),
|
|
1035
|
+
longer: values(longer)
|
|
1036
|
+
} };
|
|
1002
1037
|
bounds.push(curves.bound);
|
|
1003
1038
|
draws.push({
|
|
1004
1039
|
need: draw.need,
|
|
@@ -1007,18 +1042,10 @@ function caseOutlook(layer, caseCuts, options) {
|
|
|
1007
1042
|
users,
|
|
1008
1043
|
days: held.days,
|
|
1009
1044
|
...held.atHorizon === true ? { atHorizon: true } : {},
|
|
1010
|
-
|
|
1011
|
-
event: lasts(curves.event),
|
|
1012
|
-
independent: lasts(curves.independent),
|
|
1013
|
-
upper: lasts(curves.upper)
|
|
1014
|
-
},
|
|
1015
|
-
shortfall: {
|
|
1016
|
-
event: short(curves.event),
|
|
1017
|
-
independent: short(curves.independent),
|
|
1018
|
-
upper: short(curves.upper)
|
|
1019
|
-
},
|
|
1045
|
+
...values(curves),
|
|
1020
1046
|
bound: curves.bound,
|
|
1021
|
-
coarse: curves.coarse
|
|
1047
|
+
coarse: curves.coarse,
|
|
1048
|
+
...band
|
|
1022
1049
|
});
|
|
1023
1050
|
}
|
|
1024
1051
|
const holds = layer.draws.filter((draw) => !stoppedNeeds.has(draw.need)).map((draw) => draw.need);
|