@mark1russell7/stack-endurance 0.8.11 → 0.8.13
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 +11 -0
- package/build/add-on.js +1 -1
- package/build/index.d.ts +67 -2
- package/build/index.d.ts.map +1 -1
- package/build/index.js +90 -9
- package/build/index.js.map +1 -1
- package/build/{join-BJJdchyI.js → join-BwVV5q6r.js} +9 -3
- package/build/join-BwVV5q6r.js.map +1 -0
- package/package.json +1 -1
- package/build/join-BJJdchyI.js.map +0 -1
package/README.md
CHANGED
|
@@ -75,6 +75,17 @@ Only the cuts of the supply, and of the parts that it needs through the stack, c
|
|
|
75
75
|
|
|
76
76
|
Two groups of cuts that share no minimal set are independent, so the independent stop takes the product over the groups. In a group of up to 12 cuts, it adds the chance of each state of the cuts. In a larger group, it uses the Shannon expansion of `pathSetReliability` (`@mark1russell7/collections`). The expansion merges two states with the same sets left, so sets with few shared cuts give a small expansion. The expansion is exponential in the worst case. The groups share one budget, `INDEPENDENT_MAX_WORK`, and the option `maxWork` changes it. When the expansions pass the budget, `independent` is `upper`, and `independentUpper` names the need.
|
|
77
77
|
|
|
78
|
+
## The outlook of a case
|
|
79
|
+
|
|
80
|
+
`caseOutlook(layer, caseCuts, options)` gives the outlook of one event of a case, for each draw. A page of a place can show it for each case of its region.
|
|
81
|
+
|
|
82
|
+
- `days` are the days that the stores give the draw. The option `share` sets the share, as for `yearShortfall`.
|
|
83
|
+
- `lasts` is the chance that the draw gets its need through the event: `P(min(D, h) <= T)`. A draw that holds to the horizon has the chance 1.
|
|
84
|
+
- `shortfall` is the user-days of one event, `E[max(0, min(D, h) - T)] * users`. The sum of each level is the value of `caseShortfall`.
|
|
85
|
+
- Each value has one number for each curve of `stopCurves`: `event`, `independent` and `upper`.
|
|
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
|
+
- `holds` names the draws whose supply the case does not stop. `unread` names the draws whose stop has no curve.
|
|
88
|
+
|
|
78
89
|
## The joint days
|
|
79
90
|
|
|
80
91
|
`jointDays(layer, caseCuts, options, needs)` gives the joint days of a set of draws. These are the largest count of days `d` at which each draw of the set holds `d` days together.
|
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-BwVV5q6r.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
|
@@ -392,14 +392,79 @@ export interface YearShortfall extends Shortfall {
|
|
|
392
392
|
* - `unread` is the union of the needs that a case cannot read, in the order of the cases. `coarse` and `independentUpper` are unions too.
|
|
393
393
|
* - `bound` is the weakest bound of the cases in the sum. A case with no prior, or with an expected count of 0, adds 0, so it does not change the bound.
|
|
394
394
|
*
|
|
395
|
-
* @param layer - The endurance layer, with its cases and priors
|
|
396
|
-
* @param place - The place of the priors
|
|
397
395
|
* - With `share: "best"`, the endurance of each case comes from `bestEndurance` with the horizon of the shortfall.
|
|
398
396
|
*
|
|
397
|
+
* @param layer - The endurance layer, with its cases and priors
|
|
398
|
+
* @param place - The place of the priors
|
|
399
399
|
* @param options - The date, the stack or the parts that are also down, the horizon and the share
|
|
400
400
|
* @throws RangeError for a bad date, horizon, `maxSets` or share: refer to `caseShortfall` and `enduranceOf`
|
|
401
401
|
*/
|
|
402
402
|
export declare function yearShortfall(layer: EnduranceLayer, place: string, options: YearShortfallOptions): YearShortfall;
|
|
403
|
+
/** The options of `caseOutlook`: the date, the stack or the parts that are also down, the horizon and the share. */
|
|
404
|
+
export type OutlookOptions = YearShortfallOptions;
|
|
405
|
+
/** A value for each curve of the stop of a draw (`StopCurves`). */
|
|
406
|
+
export interface CurveValues {
|
|
407
|
+
/** The value when one event makes each cut longer together. */
|
|
408
|
+
readonly event: number;
|
|
409
|
+
/** The value when the cuts are independent. */
|
|
410
|
+
readonly independent: number;
|
|
411
|
+
/** The value of the upper curve: the safe side for each dependence of the cuts. */
|
|
412
|
+
readonly upper: number;
|
|
413
|
+
}
|
|
414
|
+
/** The outlook of one draw in one event of a case. */
|
|
415
|
+
export interface DrawOutlook {
|
|
416
|
+
readonly need: string;
|
|
417
|
+
readonly level: string;
|
|
418
|
+
readonly supply: string;
|
|
419
|
+
readonly users: number;
|
|
420
|
+
/** The days that the stores give the draw (`DrawEndurance.days`). */
|
|
421
|
+
readonly days: number;
|
|
422
|
+
/** This is true when the draw holds to the horizon of a best share. */
|
|
423
|
+
readonly atHorizon?: true;
|
|
424
|
+
/**
|
|
425
|
+
* The chance that the draw gets its need through the event: `P(min(D, h) <= T)`, for each curve of the stop.
|
|
426
|
+
* `D` is the duration of the stop, `T` is `days` and `h` is the horizon. A draw that holds to the horizon has the chance 1.
|
|
427
|
+
* The chance of `upper` is not more than the true chance, for each dependence of the cuts.
|
|
428
|
+
*/
|
|
429
|
+
readonly lasts: CurveValues;
|
|
430
|
+
/** The user-days of the shortfall in one event, `E[max(0, min(D, h) - T)] * users`, for each curve. */
|
|
431
|
+
readonly shortfall: CurveValues;
|
|
432
|
+
/** The bound of the curves of the stop (`StopCurves.bound`). */
|
|
433
|
+
readonly bound: CutBound$1;
|
|
434
|
+
/** This is true when the upper curve is coarse (`StopCurves.coarse`). */
|
|
435
|
+
readonly coarse: boolean;
|
|
436
|
+
}
|
|
437
|
+
/** The outlook of one event of a case: the days, the chance and the shortfall of each draw. */
|
|
438
|
+
export interface CaseOutlook {
|
|
439
|
+
readonly case: string;
|
|
440
|
+
readonly title: string;
|
|
441
|
+
readonly at: string;
|
|
442
|
+
readonly share: Share;
|
|
443
|
+
/** The horizon in days, or `undefined` for no horizon. */
|
|
444
|
+
readonly horizon: number | undefined;
|
|
445
|
+
/** Each draw whose supply the case stops and whose stop has a curve, in the order of the layer. */
|
|
446
|
+
readonly draws: readonly DrawOutlook[];
|
|
447
|
+
/** The needs of the draws whose supply the case does not stop. They get their need through the event. */
|
|
448
|
+
readonly holds: readonly string[];
|
|
449
|
+
/** The needs of the draws whose stop has no curve (`stopCurves`). They are no read, not a pass. */
|
|
450
|
+
readonly unread: readonly string[];
|
|
451
|
+
/** The weakest bound of the curves of `draws`. */
|
|
452
|
+
readonly bound: CutBound$1;
|
|
453
|
+
}
|
|
454
|
+
/**
|
|
455
|
+
* This function gives the outlook of one event of a case. For each draw, it gives the days, the chance that the
|
|
456
|
+
* stores last through the stop, and the shortfall. A page of a place can show it for each case of its region.
|
|
457
|
+
*
|
|
458
|
+
* - The days come from the share of the stores: `enduranceOf` for `take`, `bestEndurance` with the horizon for `best`.
|
|
459
|
+
* - The chance and the shortfall use the curves of `stopCurves`. They count the stop only up to the horizon.
|
|
460
|
+
* - `upper` is the safe side: its chance is not more, and its shortfall is not less, than the true value for each dependence.
|
|
461
|
+
*
|
|
462
|
+
* @param layer - The endurance layer
|
|
463
|
+
* @param caseCuts - The case
|
|
464
|
+
* @param options - The date, the stack or the parts that are also down, the horizon and the share
|
|
465
|
+
* @throws RangeError for a bad date, horizon, `maxSets` or share: refer to `caseShortfall` and `enduranceOf`
|
|
466
|
+
*/
|
|
467
|
+
export declare function caseOutlook(layer: EnduranceLayer, caseCuts: CaseCuts, options: OutlookOptions): CaseOutlook;
|
|
403
468
|
/**
|
|
404
469
|
* These are the codes of the gate. Each code is an error, except `endurance-device-mix`, `endurance-no-way` and `endurance-cut-no-curve`, which are warnings.
|
|
405
470
|
*
|
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,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;;;;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;;
|
|
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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WACA;WACA,OAAO;;WAEP;;WAEA,gBAAgB;;WAEhB;;WAEA;;WAEA,OAAOA;;;;;;;;;;;;;;;wBAgBF,YAAY,OAAO,gBAAgB,UAAU,UAAU,SAAS,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;qBCzrBpF;;YAmCD,wBAAwB;;iBAGnB,uBAAuB;WAC7B,MAAM;;;;;;;;;;;wBAcD,eAAe,OAAO,gBAAgB,QAAQ,QAAQ;;wBAiJtD,kBAAkB,iBAAiB;;;;;;;;;;;;;;;;;wBC7MnC,cAAc,iBAAiB,WAAW,oBAAoB,WAAW;;qBCf5E,wBAAwB;;;;;;;;;qBAkBxB,kBAAkB"}
|
package/build/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
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-BwVV5q6r.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();
|
|
@@ -895,6 +898,16 @@ function caseShortfall(layer, caseCuts, endurance, options = {}) {
|
|
|
895
898
|
}
|
|
896
899
|
/** The shares, with the default first. */
|
|
897
900
|
const SHARES = ["take", "best"];
|
|
901
|
+
/** This function gives the share of the options. The default is `take`. */
|
|
902
|
+
function shareOf(options) {
|
|
903
|
+
const share = options.share ?? "take";
|
|
904
|
+
if (!SHARES.includes(share)) throw new RangeError(`The share ${String(options.share)} is not ${SHARES.join(" or ")}.`);
|
|
905
|
+
return share;
|
|
906
|
+
}
|
|
907
|
+
/** This function gives the endurance of a case with a share: `enduranceOf` for `take`, `bestEndurance` with the horizon for `best`. */
|
|
908
|
+
function shareEndurance(layer, caseCuts, options, share) {
|
|
909
|
+
return share === "best" ? bestEndurance(layer, caseCuts, options) : enduranceOf(layer, caseCuts, options);
|
|
910
|
+
}
|
|
898
911
|
/**
|
|
899
912
|
* This function gives the shortfall of one year at one place.
|
|
900
913
|
* It is the sum over the cases of the layer of the expected count of the events of each case times its shortfall.
|
|
@@ -904,18 +917,17 @@ const SHARES = ["take", "best"];
|
|
|
904
917
|
* - `unread` is the union of the needs that a case cannot read, in the order of the cases. `coarse` and `independentUpper` are unions too.
|
|
905
918
|
* - `bound` is the weakest bound of the cases in the sum. A case with no prior, or with an expected count of 0, adds 0, so it does not change the bound.
|
|
906
919
|
*
|
|
907
|
-
* @param layer - The endurance layer, with its cases and priors
|
|
908
|
-
* @param place - The place of the priors
|
|
909
920
|
* - With `share: "best"`, the endurance of each case comes from `bestEndurance` with the horizon of the shortfall.
|
|
910
921
|
*
|
|
922
|
+
* @param layer - The endurance layer, with its cases and priors
|
|
923
|
+
* @param place - The place of the priors
|
|
911
924
|
* @param options - The date, the stack or the parts that are also down, the horizon and the share
|
|
912
925
|
* @throws RangeError for a bad date, horizon, `maxSets` or share: refer to `caseShortfall` and `enduranceOf`
|
|
913
926
|
*/
|
|
914
927
|
function yearShortfall(layer, place, options) {
|
|
915
928
|
horizonOf(options);
|
|
916
929
|
budgetsOf(options);
|
|
917
|
-
const share = options
|
|
918
|
-
if (!SHARES.includes(share)) throw new RangeError(`The share ${String(options.share)} is not ${SHARES.join(" or ")}.`);
|
|
930
|
+
const share = shareOf(options);
|
|
919
931
|
const levels = zeroLevels(layer);
|
|
920
932
|
const independent = zeroLevels(layer);
|
|
921
933
|
const upper = zeroLevels(layer);
|
|
@@ -928,7 +940,7 @@ function yearShortfall(layer, place, options) {
|
|
|
928
940
|
const prior = (layer.priors ?? []).find((item) => item.case === caseCuts.case && item.place === place);
|
|
929
941
|
if (prior === void 0) continue;
|
|
930
942
|
const rate = yearRate(prior);
|
|
931
|
-
const endurance =
|
|
943
|
+
const endurance = shareEndurance(layer, caseCuts, options, share);
|
|
932
944
|
const shortfall = caseShortfall(layer, caseCuts, endurance, options);
|
|
933
945
|
for (const [level, days] of Object.entries(shortfall.levels)) levels[level] = (levels[level] ?? 0) + rate * days;
|
|
934
946
|
for (const [level, days] of Object.entries(shortfall.independent)) independent[level] = (independent[level] ?? 0) + rate * days;
|
|
@@ -956,6 +968,75 @@ function yearShortfall(layer, place, options) {
|
|
|
956
968
|
cases
|
|
957
969
|
};
|
|
958
970
|
}
|
|
971
|
+
/**
|
|
972
|
+
* This function gives the outlook of one event of a case. For each draw, it gives the days, the chance that the
|
|
973
|
+
* stores last through the stop, and the shortfall. A page of a place can show it for each case of its region.
|
|
974
|
+
*
|
|
975
|
+
* - The days come from the share of the stores: `enduranceOf` for `take`, `bestEndurance` with the horizon for `best`.
|
|
976
|
+
* - The chance and the shortfall use the curves of `stopCurves`. They count the stop only up to the horizon.
|
|
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
|
+
*
|
|
979
|
+
* @param layer - The endurance layer
|
|
980
|
+
* @param caseCuts - The case
|
|
981
|
+
* @param options - The date, the stack or the parts that are also down, the horizon and the share
|
|
982
|
+
* @throws RangeError for a bad date, horizon, `maxSets` or share: refer to `caseShortfall` and `enduranceOf`
|
|
983
|
+
*/
|
|
984
|
+
function caseOutlook(layer, caseCuts, options) {
|
|
985
|
+
const horizon = horizonOf(options);
|
|
986
|
+
budgetsOf(options);
|
|
987
|
+
const share = shareOf(options);
|
|
988
|
+
const endurance = shareEndurance(layer, caseCuts, options, share);
|
|
989
|
+
const stopped = caseDraws(layer, caseCuts, caseStopped(caseCuts, options));
|
|
990
|
+
const stoppedNeeds = new Set(stopped.map((draw) => draw.need));
|
|
991
|
+
const stoppedOf = stoppedMemo(caseCuts, options);
|
|
992
|
+
const draws = [];
|
|
993
|
+
const unread = [];
|
|
994
|
+
const bounds = [];
|
|
995
|
+
for (const draw of stopped) {
|
|
996
|
+
const held = endurance.needs[draw.need];
|
|
997
|
+
const curves = stopCurvesWith(caseCuts, draw, options, stoppedOf);
|
|
998
|
+
if (held === void 0 || curves === void 0) {
|
|
999
|
+
unread.push(draw.need);
|
|
1000
|
+
continue;
|
|
1001
|
+
}
|
|
1002
|
+
const users = draw.users ?? 1;
|
|
1003
|
+
const lasts = (curve) => held.days >= horizon ? 1 : 1 - survivalAt(curve, held.days);
|
|
1004
|
+
const short = (curve) => tailDays(curve, held.days, horizon) * users;
|
|
1005
|
+
bounds.push(curves.bound);
|
|
1006
|
+
draws.push({
|
|
1007
|
+
need: draw.need,
|
|
1008
|
+
level: draw.level,
|
|
1009
|
+
supply: draw.supply,
|
|
1010
|
+
users,
|
|
1011
|
+
days: held.days,
|
|
1012
|
+
...held.atHorizon === true ? { atHorizon: true } : {},
|
|
1013
|
+
lasts: {
|
|
1014
|
+
event: lasts(curves.event),
|
|
1015
|
+
independent: lasts(curves.independent),
|
|
1016
|
+
upper: lasts(curves.upper)
|
|
1017
|
+
},
|
|
1018
|
+
shortfall: {
|
|
1019
|
+
event: short(curves.event),
|
|
1020
|
+
independent: short(curves.independent),
|
|
1021
|
+
upper: short(curves.upper)
|
|
1022
|
+
},
|
|
1023
|
+
bound: curves.bound,
|
|
1024
|
+
coarse: curves.coarse
|
|
1025
|
+
});
|
|
1026
|
+
}
|
|
1027
|
+
const holds = layer.draws.filter((draw) => !stoppedNeeds.has(draw.need)).map((draw) => draw.need);
|
|
1028
|
+
return {
|
|
1029
|
+
case: caseCuts.case,
|
|
1030
|
+
title: caseCuts.title,
|
|
1031
|
+
at: endurance.at,
|
|
1032
|
+
share,
|
|
1033
|
+
horizon: Number.isFinite(horizon) ? horizon : void 0,
|
|
1034
|
+
draws,
|
|
1035
|
+
holds,
|
|
1036
|
+
unread,
|
|
1037
|
+
bound: weakestBound(bounds)
|
|
1038
|
+
};
|
|
1039
|
+
}
|
|
959
1040
|
// src/sample.ts
|
|
960
1041
|
/** The base stack of the sample: the supplies of the building and a camp stove. */
|
|
961
1042
|
const SAMPLE_ENDURANCE_STACK = {
|
|
@@ -1180,6 +1261,6 @@ const SAMPLE_ENDURANCE = {
|
|
|
1180
1261
|
asOf: "2025-12-01"
|
|
1181
1262
|
}]
|
|
1182
1263
|
};
|
|
1183
|
-
export { ENDURANCE_CODES, ENDURANCE_SCHEMA, INDEPENDENT_MAX_WORK, INDEPENDENT_TOLERANCE, MINIMAL_STOP_CUTS, SAMPLE_ENDURANCE, SAMPLE_ENDURANCE_STACK, SHARES, bestEndurance, caseDraws, caseShortfall, caseStopped, checkEndurance, curveFault, drawDemand, enduranceOf, eventStop, giftNeed, giftResource, hasEnduranceError, independentStop, joinEndurance, jointDays, longestStop, minimalStops, stopCurves, storeAmounts, survivalAt, survivalQuantile, tailDays, upperStop, yearChance, yearRate, yearShortfall };
|
|
1264
|
+
export { ENDURANCE_CODES, ENDURANCE_SCHEMA, INDEPENDENT_MAX_WORK, INDEPENDENT_TOLERANCE, MINIMAL_STOP_CUTS, SAMPLE_ENDURANCE, SAMPLE_ENDURANCE_STACK, SHARES, bestEndurance, caseDraws, caseOutlook, caseShortfall, caseStopped, checkEndurance, curveFault, drawDemand, enduranceOf, eventStop, giftNeed, giftResource, hasEnduranceError, independentStop, joinEndurance, jointDays, longestStop, minimalStops, stopCurves, storeAmounts, survivalAt, survivalQuantile, tailDays, upperStop, yearChance, yearRate, yearShortfall };
|
|
1184
1265
|
|
|
1185
1266
|
//# sourceMappingURL=index.js.map
|