@mark1russell7/stack-endurance 0.8.17 → 0.8.19
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 +4 -1
- package/build/add-on.js +1 -1
- package/build/index.d.ts +40 -3
- package/build/index.d.ts.map +1 -1
- package/build/index.js +63 -7
- package/build/index.js.map +1 -1
- package/build/{join-B7THRfQS.js → join-Du2gsJJ6.js} +518 -20
- package/build/join-Du2gsJJ6.js.map +1 -0
- package/package.json +1 -1
- package/build/join-B7THRfQS.js.map +0 -1
package/README.md
CHANGED
|
@@ -50,7 +50,10 @@ A converter can have a `season`. It has a window of sow days in each year (`from
|
|
|
50
50
|
- The query reads the sowings up to the horizon (`horizon` of `enduranceOf`, default `SEASON_HORIZON_DAYS` = 730). `start` moves the event in the year, and the stores stay the stores at `at`.
|
|
51
51
|
- `days` is the first stop of a draw. `again` gives the spans after it in which a harvest feeds the draw. `harvests` lists each sowing with its runs and its amount.
|
|
52
52
|
- The shortfall leaves out the fed spans (`heldTail`). For a layer with a season, `yearShortfall` gives the mean over `starts` start dates in the year (default `YEAR_STARTS` = 12). An event can start on any day.
|
|
53
|
-
- `bestEndurance` and `jointDays`
|
|
53
|
+
- Since 0.8.18, `bestEndurance` and `jointDays` read the harvests. The days go in segments that end at each harvest day, at each spoil day and at the horizon. A segment takes only the lots that are ready and not spoiled in all of it.
|
|
54
|
+
- In `bestEndurance`, `days` is the first stop of each draw, with the same share by level and leximin. A last program gives the most fed days after the stops to each level (`again`). Two draws that use one limited device after their stops take turns on it. This is the safe side.
|
|
55
|
+
- `jointDays` gives the largest common first stop. With `atHorizon`, the plan holds the horizon.
|
|
56
|
+
- Since 0.8.19, a draw of `enduranceOf` with a shared device and a season gets the programs of `bestEndurance` for itself alone (M2-grow-share-sweep). Its stocks, harvest lots and device-days are those that the higher draws leave. It has no field `spoiled`.
|
|
54
57
|
|
|
55
58
|
## The rule of shortfall
|
|
56
59
|
|
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-Du2gsJJ6.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
|
@@ -53,6 +53,28 @@ export declare function giftResource(converter: Converter): string | undefined;
|
|
|
53
53
|
* @throws RangeError when the start is not `YYYY-MM-DD`, or the horizon is not more than 0.
|
|
54
54
|
*/
|
|
55
55
|
export declare function sowDays(season: Pick<Season, "from" | "to">, start: IsoDate, horizon: number): number[];
|
|
56
|
+
/** A lot of a harvest that the draws can take: its resource, its day, its spoil day (Infinity for none) and its amount. */
|
|
57
|
+
export interface HarvestLot {
|
|
58
|
+
readonly resource: string;
|
|
59
|
+
readonly day: number;
|
|
60
|
+
readonly spoils: number;
|
|
61
|
+
readonly amount: number;
|
|
62
|
+
}
|
|
63
|
+
/** The supply of a case with a season: the stocks after the sowings, the sowings, and the lots of the harvests before the horizon. */
|
|
64
|
+
export interface SeasonSupply {
|
|
65
|
+
/** The stock of each resource of the stores at `at`, less the inputs of the sowings. */
|
|
66
|
+
readonly stock: Map<string, number>;
|
|
67
|
+
readonly harvests: Harvest[];
|
|
68
|
+
/** The rest of each harvest after the later sowings, in the order of its day. Each lot has a day before the horizon and an amount more than 0. */
|
|
69
|
+
readonly lots: readonly HarvestLot[];
|
|
70
|
+
/** The horizon in days (`horizon` of the options, default `SEASON_HORIZON_DAYS`). */
|
|
71
|
+
readonly horizon: number;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* This function gives the supply of a case with a season (M2-grow-share). `enduranceOf`, `bestEndurance` and `jointDays`
|
|
75
|
+
* use it, so they read the same sowings. It throws a `RangeError` for a horizon that is not more than 0, or a date that is not `YYYY-MM-DD`.
|
|
76
|
+
*/
|
|
77
|
+
export declare function seasonSupply(layer: EnduranceLayer, stoppedParts: ReadonlySet<string>, options: CaseOptions): SeasonSupply;
|
|
56
78
|
/** This function tells if a layer has a converter with a season that can run in a case. */
|
|
57
79
|
export declare function hasSeason(layer: EnduranceLayer, stoppedParts: ReadonlySet<string>): boolean;
|
|
58
80
|
/**
|
|
@@ -81,7 +103,8 @@ export declare function hasSeason(layer: EnduranceLayer, stoppedParts: ReadonlyS
|
|
|
81
103
|
* - With a season, each draw takes its stocks over spans from harvest to harvest. `days` is the first stop of the
|
|
82
104
|
* draw. A later harvest can feed the draw again: `again` gives these spans, and `takes` is the sum to the horizon.
|
|
83
105
|
* A lower draw gets the stocks that the higher draws leave, the earliest stocks first taken. This is the safe side.
|
|
84
|
-
* - A draw with a shared device and a season gets
|
|
106
|
+
* - A draw with a shared device and a season gets the programs of `bestEndurance` for itself alone (M2-grow-share-sweep). Its stocks,
|
|
107
|
+
* its harvest lots and its device-days are those that the higher draws leave. It has no field `spoiled`.
|
|
85
108
|
*
|
|
86
109
|
* The function is pure, but for an internal count of the tries of its fits for the tests. It throws a `RangeError` for a date that is not `YYYY-MM-DD`. The gate `checkEndurance` examines the layer before.
|
|
87
110
|
*
|
|
@@ -123,6 +146,8 @@ export interface JointDays {
|
|
|
123
146
|
* The list is empty when `days` is `Infinity` or 0. Else it has each converter of the plan with a limit of 0.
|
|
124
147
|
*/
|
|
125
148
|
readonly capped: readonly string[];
|
|
149
|
+
/** True when a layer with a season holds the plan to the horizon (M2-grow-share). `days` is then the horizon. */
|
|
150
|
+
readonly atHorizon?: true | undefined;
|
|
126
151
|
}
|
|
127
152
|
/**
|
|
128
153
|
* This function gives the joint days of a set of draws. These are the largest count of days `d` at which each draw holds `d` days.
|
|
@@ -145,12 +170,15 @@ export interface JointDays {
|
|
|
145
170
|
*
|
|
146
171
|
* The program uses exact rationals, so the result has no error of the method. Only the change back to a number rounds.
|
|
147
172
|
*
|
|
173
|
+
* With a converter with a season, `days` is the largest common first stop of the plan (M2-grow-share). The sowings, the lots and
|
|
174
|
+
* the segments are those of `bestEndurance`. The plan holds the horizon at most (default `SEASON_HORIZON_DAYS`), with `atHorizon`.
|
|
175
|
+
*
|
|
148
176
|
* @param layer - The endurance layer
|
|
149
177
|
* @param caseCuts - The case
|
|
150
178
|
* @param options - The date, and the stack or the parts that are also down
|
|
151
179
|
* @param needs - The codes of the needs of the draws of the set
|
|
152
180
|
* @returns The joint days, the takes of each draw, the binding resources and the runs of each converter
|
|
153
|
-
* @throws {RangeError} A code of `needs` is not the need of a draw of the layer, or a date is not `YYYY-MM-DD`. Or a
|
|
181
|
+
* @throws {RangeError} A code of `needs` is not the need of a draw of the layer, or a date is not `YYYY-MM-DD`. Or the horizon of a layer with a season is not more than 0.
|
|
154
182
|
*/
|
|
155
183
|
export declare function jointDays(layer: EnduranceLayer, caseCuts: CaseCuts, options: CaseOptions, needs: readonly string[]): JointDays;
|
|
156
184
|
/** The options of `bestEndurance`: the options of a case, and a horizon. */
|
|
@@ -189,11 +217,20 @@ export interface BestOptions extends CaseOptions {
|
|
|
189
217
|
* The programs use exact rationals, so the result has no error of the method. Only the change back to a number rounds.
|
|
190
218
|
* The fewest days of the first level are the joint days (`jointDays`) of the draws of that level.
|
|
191
219
|
*
|
|
220
|
+
* A layer with a converter with a season has the programs of a season (M2-grow-share):
|
|
221
|
+
* - The sowings take their inputs before the draws, as in `enduranceOf`. Each harvest is a lot from its day, and its rest spoils on its spoil day.
|
|
222
|
+
* - The days go in segments that end at each harvest day, at each spoil day and at the horizon (default `SEASON_HORIZON_DAYS`). A segment takes only
|
|
223
|
+
* the lots that are ready and not spoiled in all of it.
|
|
224
|
+
* - `days` is the first stop of each draw, with the same leximin share. The days to a stop are not linear, so each step tries the segments in order.
|
|
225
|
+
* - After the stops, a last program gives the most fed days to each level in order. `again` gives the spans in which a later harvest feeds a draw.
|
|
226
|
+
* In such a span, the runs share the device-days of the whole segment that the stops leave.
|
|
227
|
+
* - The result has the field `harvests`. It has no field `spoiled`: the share of a lot between the draws has no spoil of one draw.
|
|
228
|
+
*
|
|
192
229
|
* @param layer - The endurance layer
|
|
193
230
|
* @param caseCuts - The case
|
|
194
231
|
* @param options - The date, the stack or the parts that are also down, and the horizon
|
|
195
232
|
* @returns The endurance of each draw whose supply stops
|
|
196
|
-
* @throws {RangeError} A date is not `YYYY-MM-DD`, or the horizon is not more than 0.
|
|
233
|
+
* @throws {RangeError} A date is not `YYYY-MM-DD`, or the horizon is not more than 0.
|
|
197
234
|
*/
|
|
198
235
|
export declare function bestEndurance(layer: EnduranceLayer, caseCuts: CaseCuts, options: BestOptions): Endurance;
|
|
199
236
|
/**
|
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":";;;
|
|
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":";;;iBAWiB;;WAEN,IAAI;;WAEJ,QAAQ;;WAER;;;;;WAKA,QAAQ;;;;;;WAMR;;;qBAIE;;;;;wBAMG,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;;;;;;;;wBAyKxB,QAAQ,QAAQ,KAAK,wBAAwB,OAAO,SAAS;;iBAkG5D;WACN;WACA;WACA;WACA;;;iBAIM;;WAEN,OAAO;WACP,UAAU;;WAEV,eAAe;;WAEf;;;;;;wBAOK,aAAa,OAAO,gBA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C,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 {
|
|
2
|
+
import { A as addTo, C as Program, D as fewestRow, E as drawBlock, M as exact, O as reachOf, S as seasonPlan, T as deviceUse, _ as fewestOpen, a as hasEnduranceError, b as seasonBest, c as caseStopped, d as giftNeed, f as giftResource, g as storeAmounts, h as sowDays, i as curveFault, j as dense, k as valueAt, l as drawDemand, m as seasonSupply, n as ENDURANCE_CODES, o as SEASON_HORIZON_DAYS, p as hasSeason, r as checkEndurance, s as caseDraws, t as joinEndurance, u as enduranceOf, v as firstStop, w as caseParts, x as seasonJoint, y as fixStops } from "./join-Du2gsJJ6.js";
|
|
3
3
|
import { DEFAULT_MAX_SETS, STACK_SCHEMA, dateOfDay, dayNumber, 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";
|
|
@@ -26,20 +26,23 @@ import { pathSetReliability, stronglyConnectedComponents } from "@mark1russell7/
|
|
|
26
26
|
*
|
|
27
27
|
* The program uses exact rationals, so the result has no error of the method. Only the change back to a number rounds.
|
|
28
28
|
*
|
|
29
|
+
* With a converter with a season, `days` is the largest common first stop of the plan (M2-grow-share). The sowings, the lots and
|
|
30
|
+
* the segments are those of `bestEndurance`. The plan holds the horizon at most (default `SEASON_HORIZON_DAYS`), with `atHorizon`.
|
|
31
|
+
*
|
|
29
32
|
* @param layer - The endurance layer
|
|
30
33
|
* @param caseCuts - The case
|
|
31
34
|
* @param options - The date, and the stack or the parts that are also down
|
|
32
35
|
* @param needs - The codes of the needs of the draws of the set
|
|
33
36
|
* @returns The joint days, the takes of each draw, the binding resources and the runs of each converter
|
|
34
|
-
* @throws {RangeError} A code of `needs` is not the need of a draw of the layer, or a date is not `YYYY-MM-DD`. Or a
|
|
37
|
+
* @throws {RangeError} A code of `needs` is not the need of a draw of the layer, or a date is not `YYYY-MM-DD`. Or the horizon of a layer with a season is not more than 0.
|
|
35
38
|
*/
|
|
36
39
|
function jointDays(layer, caseCuts, options, needs) {
|
|
37
40
|
const known = new Set(layer.draws.map((draw) => draw.need));
|
|
38
41
|
const unknown = needs.filter((need) => !known.has(need));
|
|
39
42
|
if (unknown.length > 0) throw new RangeError(`The needs ${unknown.map((need) => `"${need}"`).join(", ")} are not the needs of draws of the layer.`);
|
|
40
43
|
const stoppedParts = caseStopped(caseCuts, options);
|
|
41
|
-
|
|
42
|
-
const stock = storeAmounts(layer, options.at, stoppedParts);
|
|
44
|
+
const supply = hasSeason(layer, stoppedParts) ? seasonSupply(layer, stoppedParts, options) : void 0;
|
|
45
|
+
const stock = supply?.stock ?? storeAmounts(layer, options.at, stoppedParts);
|
|
43
46
|
const wanted = new Set(needs);
|
|
44
47
|
const plan = caseDraws(layer, caseCuts, stoppedParts).filter((draw) => wanted.has(draw.need));
|
|
45
48
|
const planned = new Set(plan.map((draw) => draw.need));
|
|
@@ -59,6 +62,15 @@ function jointDays(layer, caseCuts, options, needs) {
|
|
|
59
62
|
};
|
|
60
63
|
if (plan.length === 0) return endless;
|
|
61
64
|
const parts = caseParts(layer, stoppedParts, stock, planned);
|
|
65
|
+
if (supply !== void 0) {
|
|
66
|
+
const devices = new Map([...deviceUse([...parts.cooks, ...parts.makers].map((converter) => [converter, 0])).limits].map(([key, limit]) => [key, limit.devices]));
|
|
67
|
+
const { atHorizon, ...joint } = seasonJoint(seasonPlan(supply, parts, caseCuts, plan, devices), new Set(layer.stores.map((store) => store.resource)));
|
|
68
|
+
return {
|
|
69
|
+
...base,
|
|
70
|
+
...joint,
|
|
71
|
+
...atHorizon ? { atHorizon: true } : {}
|
|
72
|
+
};
|
|
73
|
+
}
|
|
62
74
|
const program = new Program();
|
|
63
75
|
const days = program.next();
|
|
64
76
|
const blocks = plan.map((draw) => {
|
|
@@ -168,16 +180,25 @@ function horizonOf$1(horizon) {
|
|
|
168
180
|
* The programs use exact rationals, so the result has no error of the method. Only the change back to a number rounds.
|
|
169
181
|
* The fewest days of the first level are the joint days (`jointDays`) of the draws of that level.
|
|
170
182
|
*
|
|
183
|
+
* A layer with a converter with a season has the programs of a season (M2-grow-share):
|
|
184
|
+
* - The sowings take their inputs before the draws, as in `enduranceOf`. Each harvest is a lot from its day, and its rest spoils on its spoil day.
|
|
185
|
+
* - The days go in segments that end at each harvest day, at each spoil day and at the horizon (default `SEASON_HORIZON_DAYS`). A segment takes only
|
|
186
|
+
* the lots that are ready and not spoiled in all of it.
|
|
187
|
+
* - `days` is the first stop of each draw, with the same leximin share. The days to a stop are not linear, so each step tries the segments in order.
|
|
188
|
+
* - After the stops, a last program gives the most fed days to each level in order. `again` gives the spans in which a later harvest feeds a draw.
|
|
189
|
+
* In such a span, the runs share the device-days of the whole segment that the stops leave.
|
|
190
|
+
* - The result has the field `harvests`. It has no field `spoiled`: the share of a lot between the draws has no spoil of one draw.
|
|
191
|
+
*
|
|
171
192
|
* @param layer - The endurance layer
|
|
172
193
|
* @param caseCuts - The case
|
|
173
194
|
* @param options - The date, the stack or the parts that are also down, and the horizon
|
|
174
195
|
* @returns The endurance of each draw whose supply stops
|
|
175
|
-
* @throws {RangeError} A date is not `YYYY-MM-DD`, or the horizon is not more than 0.
|
|
196
|
+
* @throws {RangeError} A date is not `YYYY-MM-DD`, or the horizon is not more than 0.
|
|
176
197
|
*/
|
|
177
198
|
function bestEndurance(layer, caseCuts, options) {
|
|
178
199
|
const horizon = horizonOf$1(options.horizon);
|
|
179
200
|
const stoppedParts = caseStopped(caseCuts, options);
|
|
180
|
-
if (hasSeason(layer, stoppedParts))
|
|
201
|
+
if (hasSeason(layer, stoppedParts)) return bestSeason(layer, caseCuts, options, stoppedParts);
|
|
181
202
|
const stock = storeAmounts(layer, options.at, stoppedParts);
|
|
182
203
|
const draws = caseDraws(layer, caseCuts, stoppedParts);
|
|
183
204
|
const parts = caseParts(layer, stoppedParts, stock, new Set(draws.map((draw) => draw.need)));
|
|
@@ -278,6 +299,41 @@ function bestEndurance(layer, caseCuts, options) {
|
|
|
278
299
|
needs
|
|
279
300
|
};
|
|
280
301
|
}
|
|
302
|
+
/** This function gives the best endurance of a case with a season (M2-grow-share). */
|
|
303
|
+
function bestSeason(layer, caseCuts, options, stoppedParts) {
|
|
304
|
+
const supply = seasonSupply(layer, stoppedParts, options);
|
|
305
|
+
const draws = caseDraws(layer, caseCuts, stoppedParts);
|
|
306
|
+
const parts = caseParts(layer, stoppedParts, supply.stock, new Set(draws.map((draw) => draw.need)));
|
|
307
|
+
const devices = new Map([...deviceUse([...parts.cooks, ...parts.makers].map((converter) => [converter, 0])).limits].map(([key, limit]) => [key, limit.devices]));
|
|
308
|
+
const plan = seasonPlan(supply, parts, caseCuts, draws, devices);
|
|
309
|
+
const harvests = supply.harvests.length === 0 ? {} : { harvests: supply.harvests };
|
|
310
|
+
if (draws.length === 0) return {
|
|
311
|
+
case: caseCuts.case,
|
|
312
|
+
at: options.at,
|
|
313
|
+
needs: {},
|
|
314
|
+
...harvests
|
|
315
|
+
};
|
|
316
|
+
const levels = levelGroups(layer, draws);
|
|
317
|
+
const fixed = /* @__PURE__ */ new Map();
|
|
318
|
+
for (const level of levels) {
|
|
319
|
+
let open = level;
|
|
320
|
+
while (open.length > 0) {
|
|
321
|
+
const opened = new Set(open.map((draw) => draw.need));
|
|
322
|
+
const stop = firstStop(plan, fixed, open, (step) => [fewestOpen(step, opened)]);
|
|
323
|
+
let done = stop.atHorizon ? open : open.filter((draw) => sign(stop.dual[stop.step.floors.get(draw.need)] ?? ZERO) !== 0);
|
|
324
|
+
if (done.length === 0) done = open;
|
|
325
|
+
fixStops(plan, stop, done, fixed);
|
|
326
|
+
open = open.filter((draw) => !done.includes(draw));
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
const { needs } = seasonBest(plan, fixed, levels, new Set(layer.stores.map((store) => store.resource)));
|
|
330
|
+
return {
|
|
331
|
+
case: caseCuts.case,
|
|
332
|
+
at: options.at,
|
|
333
|
+
needs,
|
|
334
|
+
...harvests
|
|
335
|
+
};
|
|
336
|
+
}
|
|
281
337
|
/** This function gives the draws of each level, in the order of `levels`. The draws of a level that is not in `levels` come last, together. */
|
|
282
338
|
function levelGroups(layer, draws) {
|
|
283
339
|
const rank = (draw) => {
|
|
@@ -1386,6 +1442,6 @@ const SAMPLE_ENDURANCE = {
|
|
|
1386
1442
|
asOf: "2025-12-01"
|
|
1387
1443
|
}]
|
|
1388
1444
|
};
|
|
1389
|
-
export { ENDURANCE_CODES, ENDURANCE_SCHEMA, INDEPENDENT_MAX_WORK, INDEPENDENT_TOLERANCE, MINIMAL_STOP_CUTS, SAMPLE_ENDURANCE, SAMPLE_ENDURANCE_STACK, SEASON_HORIZON_DAYS, SHARES, YEAR_STARTS, bestEndurance, caseDraws, caseOutlook, caseShortfall, caseStopped, checkEndurance, curveFault, drawDemand, enduranceOf, eventStop, giftNeed, giftResource, hasEnduranceError, hasSeason, heldTail, independentStop, joinEndurance, jointDays, longestStop, minimalStops, sowDays, stopCurves, storeAmounts, survivalAt, survivalQuantile, tailDays, upperStop, yearChance, yearRate, yearShortfall };
|
|
1445
|
+
export { ENDURANCE_CODES, ENDURANCE_SCHEMA, INDEPENDENT_MAX_WORK, INDEPENDENT_TOLERANCE, MINIMAL_STOP_CUTS, SAMPLE_ENDURANCE, SAMPLE_ENDURANCE_STACK, SEASON_HORIZON_DAYS, SHARES, YEAR_STARTS, bestEndurance, caseDraws, caseOutlook, caseShortfall, caseStopped, checkEndurance, curveFault, drawDemand, enduranceOf, eventStop, giftNeed, giftResource, hasEnduranceError, hasSeason, heldTail, independentStop, joinEndurance, jointDays, longestStop, minimalStops, seasonSupply, sowDays, stopCurves, storeAmounts, survivalAt, survivalQuantile, tailDays, upperStop, yearChance, yearRate, yearShortfall };
|
|
1390
1446
|
|
|
1391
1447
|
//# sourceMappingURL=index.js.map
|