@mark1russell7/stack-endurance 0.8.20 → 0.8.21
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 +10 -1
- package/build/add-on.d.ts +1 -1
- package/build/add-on.js +1 -1
- package/build/index.d.ts +5 -2
- package/build/index.d.ts.map +1 -1
- package/build/index.js +3 -3
- package/build/index.js.map +1 -1
- package/build/{join-BB1qLU4e.js → join-CM_zwI78.js} +115 -16
- package/build/join-CM_zwI78.js.map +1 -0
- package/build/{layer-CsVKqL3L.d.ts → layer-DuGjz7Cl.d.ts} +17 -1
- package/build/layer-DuGjz7Cl.d.ts.map +1 -0
- package/build/layer-a3Fr70Uh.js.map +1 -1
- package/build/schema.d.ts +1 -1
- package/build/schema.d.ts.map +1 -1
- package/build/schema.js +2 -1
- package/build/schema.js.map +1 -1
- package/package.json +1 -1
- package/build/join-BB1qLU4e.js.map +0 -1
- package/build/layer-CsVKqL3L.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -59,13 +59,22 @@ A converter can have a `season`. It has a window of sow days in each year (`from
|
|
|
59
59
|
|
|
60
60
|
A converter with a limit `perDay` more than 0 can take nothing. It is a source, for example a solar panel. A converter can also have `monthly`: 12 shares from 0 to 1, January first. In a day of month `m`, the converter has `devices` times `monthly[m]` device-days. Thus a panel with `perDay` 1500 and a share of 0.2 in January gives 300 runs in a day of January. Since 0.8.20 (M2-solar).
|
|
61
61
|
|
|
62
|
-
- The energy of a day that no draw takes is lost
|
|
62
|
+
- The energy of a day that no draw takes is lost, unless a store of its resource has a `capacity`. Then the store takes a charge (the next section).
|
|
63
63
|
- A take uses a source first, before the stores and the other converters. The runs of a source in a day are lost when no draw uses them.
|
|
64
64
|
- A layer with a source or with shares goes in segments to the horizon, as a layer with a season. A segment also ends at the start of each month. A source can feed a draw with no end, thus the horizon is the upper limit of its days.
|
|
65
65
|
- After a stop, a draw can hold again from the start of a month with more device-days. `again` gives these spans.
|
|
66
66
|
- A higher draw keeps the largest part of the device-days that it uses in a month, for each month of a lower draw. This is the safe side.
|
|
67
67
|
- The converters of one device have the same shares. A converter with shares has a limit `perDay` and no season. The gate refuses the other cases (`endurance-monthly`).
|
|
68
68
|
|
|
69
|
+
### A battery: a store with a capacity
|
|
70
|
+
|
|
71
|
+
A store can have a `capacity`: the most amount that it holds. A source that gives the resource of the store charges it with the runs that no draw takes on their day. Example: a battery of 6000 Wh takes the energy of a sunny day, and gives it back on a dark day. Since 0.8.21 (M2-solar-charge).
|
|
72
|
+
|
|
73
|
+
- `bestEndurance` and `jointDays` give the charge in each segment of the days. In a segment, the takes are not more than the level at the start of the segment. Also the level at the start plus the charge is not more than the capacity. Thus each order of the takes and the charges in the segment is a plan. This is the safe side.
|
|
74
|
+
- The sweep of `enduranceOf` takes one draw at a time, and it gives no charge. There a store with a capacity is a store with no charge. The follow-up M2-solar-charge-sweep adds the charge to the sweep.
|
|
75
|
+
- Only a source charges a store. A maker with inputs gives no charge, because its inputs keep to the day of the take.
|
|
76
|
+
- The stores of one resource all have a capacity, or none has one. A store with a capacity has no due date, and its capacity is not less than its amount. The gate refuses the other cases (`endurance-capacity`).
|
|
77
|
+
|
|
69
78
|
## The rule of shortfall
|
|
70
79
|
|
|
71
80
|
- For one draw in one case, the shortfall is `E[max(0, D - T)] * users`. `T` is the endurance of the draw. `D` is the duration of the stop of its supply.
|
package/build/add-on.d.ts
CHANGED
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-CM_zwI78.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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as Season, a as DirectUse, c as ENDURANCE_SCHEMA, d as Gift, f as Harvest, g as Resource, h as Prior, i as CutBound, l as Endurance, m as MonthDay, n as Converter, o as Draw, p as IsoDate, r as Cut, s as DrawEndurance, t as CaseCuts, u as EnduranceLayer, v as Store, y as Survival } from "./layer-
|
|
1
|
+
import { _ as Season, a as DirectUse, c as ENDURANCE_SCHEMA, d as Gift, f as Harvest, g as Resource, h as Prior, i as CutBound, l as Endurance, m as MonthDay, n as Converter, o as Draw, p as IsoDate, r as Cut, s as DrawEndurance, t as CaseCuts, u as EnduranceLayer, v as Store, y as Survival } from "./layer-DuGjz7Cl.js";
|
|
2
2
|
import { CutBound as CutBound$1, Fault, LayerParse, LayerPiece, PathOptions, Stack, curveFault, survivalAt } from "@mark1russell7/system-stack";
|
|
3
3
|
/**
|
|
4
4
|
* This function tells if a converter is a source (M2-solar): it takes nothing, and it has a limit `perDay` more than 0.
|
|
@@ -657,8 +657,11 @@ export declare function caseOutlook(layer: EnduranceLayer, caseCuts: CaseCuts, o
|
|
|
657
657
|
* `perDay` or `devices`. Since 0.8.16 (M2-grow).
|
|
658
658
|
* - `endurance-monthly`: the shares `monthly` of a converter are not 12 numbers from 0 to 1. Or the converter has
|
|
659
659
|
* `monthly` and no `perDay`, or a season. Or two converters of one device have different shares. Since 0.8.20 (M2-solar).
|
|
660
|
+
* - `endurance-capacity`: the capacity of a store is not a finite number more than 0, or it is less than the amount.
|
|
661
|
+
* Or a store with a capacity has a due date. Or a resource has a store with a capacity and a store with no capacity.
|
|
662
|
+
* Since 0.8.21 (M2-solar-charge).
|
|
660
663
|
*/
|
|
661
|
-
export declare const ENDURANCE_CODES: readonly ["endurance-twice", "endurance-level-unknown", "endurance-resource-unknown", "endurance-part-unknown", "endurance-range", "endurance-date", "endurance-converter-empty", "endurance-curve", "endurance-bound", "endurance-prior-case", "endurance-cycle", "endurance-devices", "endurance-device-mix", "endurance-no-way", "endurance-cut-no-curve", "endurance-season", "endurance-monthly"];
|
|
664
|
+
export declare const ENDURANCE_CODES: readonly ["endurance-twice", "endurance-level-unknown", "endurance-resource-unknown", "endurance-part-unknown", "endurance-range", "endurance-date", "endurance-converter-empty", "endurance-curve", "endurance-bound", "endurance-prior-case", "endurance-cycle", "endurance-devices", "endurance-device-mix", "endurance-no-way", "endurance-cut-no-curve", "endurance-season", "endurance-monthly", "endurance-capacity"];
|
|
662
665
|
/** A code of `ENDURANCE_CODES`. */
|
|
663
666
|
export type EnduranceCode = (typeof ENDURANCE_CODES)[number];
|
|
664
667
|
/** A fault of the gate of an endurance layer. */
|
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":["CutBound"],"sources":["../src/converter.ts","../src/endurance.ts","../src/joint.ts","../src/best.ts","../src/shortfall.ts","../src/check.ts","../src/join.ts","../src/sample.ts"],"mappings":";;;;;;wBAegB,SAAS,WAAW;;iBCJnB;;WAEN,IAAI;;WAEJ,QAAQ;;WAER;;;;;;WAMA,QAAQ;;;;;;WAMR;;;qBAIE;;;;;wBAMG,YAAY,UAAU,UAAU,SAAS,KAAK,iCAAiC;;wBAiB/E,QAAQ,OAAO,SAAS;;;;;wBASxB,WAAW,OAAO,SAAS;;wBAc3B,cAAc,YAAY,SAAS,aAAa;;wBAOhD,QAAQ,QAAQ,wCAAwC,aAAa;;;;;;;wBAarE,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;;;;;;;;wBAmMxB,QAAQ,QAAQ,KAAK,wBAAwB,OAAO,SAAS;;iBAkG5D;WACN;WACA;WACA;WACA;;;iBAIM;;WAEN,OAAO;WACP,UAAU;;WAEV,eAAe;;WAEf;;WAEA,OAAO;;;;;;wBAOF,aAAa,OAAO,gBAAgB,cAAc,qBAAqB,SAAS,cAAc;;;;;;wBAkB9F,UAA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KN,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;;;;;;;WAOR;;;qBAIE;;YAGD,gBAAgB,KAAK;;;;;;;iBAQhB;;WAEN;WACA,KAAK;WACL,MAAM;;WAEN;;;iBAIM;WACN;;WAEA;;WAEA,yBAAyB,aAAa;;WAEtC,WAAW;;WAEX,WAAW;;WAEX,kBAAkB;;;iBAIZ;WACN,OAAO;WACP,WAAW;;;iBAIL,sBAAsB;WAC5B;;WAEA,gBAAgB;;WAEhB,QAAQ;;;;;;;;;;;;;;;;;;;wBAoBH,cAAc,OAAO,gBAAgB,eAAe,SAAS,uBAAuB;;YA0ExF,iBAAiB;;iBAGZ;;WAEN;;WAEA;;WAEA;;;iBAIM;WACN,OAAO;WACP,WAAW;;;;;;;iBAQL;WACN,SAAS;WACT,QAAQ;;;iBAIF;WACN;WACA;WACA;WACA;;WAEA;;WAEA;;;;;;WAMA,OAAO;;WAEP,WAAW;;WAEX,OAAOA;;WAEP;;;;;WAKA,OAAO;;;iBAID;WACN;WACA;WACA;WACA,OAAO;;WAEP;;WAEA,gBAAgB;;WAEhB;;WAEA;;WAEA,OAAOA;;;;;;;;;;;;;;;;wBAiBF,YAAY,OAAO,gBAAgB,UAAU,UAAU,SAAS,iBAAiB
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":["CutBound"],"sources":["../src/converter.ts","../src/endurance.ts","../src/joint.ts","../src/best.ts","../src/shortfall.ts","../src/check.ts","../src/join.ts","../src/sample.ts"],"mappings":";;;;;;wBAegB,SAAS,WAAW;;iBCJnB;;WAEN,IAAI;;WAEJ,QAAQ;;WAER;;;;;;WAMA,QAAQ;;;;;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AuB;;YA0ExF,iBAAiB;;iBAGZ;;WAEN;;WAEA;;WAEA;;;iBAIM;WACN,OAAO;WACP,WAAW;;;;;;;iBAQL;WACN,SAAS;WACT,QAAQ;;;iBAIF;WACN;WACA;WACA;WACA;;WAEA;;WAEA;;;;;;WAMA,OAAO;;WAEP,WAAW;;WAEX,OAAOA;;WAEP;;;;;WAKA,OAAO;;;iBAID;WACN;WACA;WACA;WACA,OAAO;;WAEP;;WAEA,gBAAgB;;WAEhB;;WAEA;;WAEA,OAAOA;;;;;;;;;;;;;;;;wBAiBF,YAAY,OAAO,gBAAgB,UAAU,UAAU,SAAS,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBCnzBpF;;YAyCD,wBAAwB;;iBAGnB,uBAAuB;WAC7B,MAAM;;;;;;;;;;;wBAcD,eAAe,OAAO,gBAAgB,QAAQ,QAAQ;;wBAwNtD,kBAAkB,iBAAiB;;;;;;;;;;;;;;;;;wBCnSnC,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 { A as
|
|
2
|
+
import { A as deviceUse, C as fixStops, D as storeCapacities, E as seasonPlan, F as addTo, I as dense, L as exact, M as fewestRow, N as reachOf, O as Program, P as valueAt, R as isSource, S as firstStop, T as seasonJoint, _ as seasonSupply, a as hasEnduranceError, b as storeAmounts, c as caseStopped, d as giftNeed, f as giftResource, g as monthlyShares, h as monthOf, i as curveFault, j as drawBlock, k as caseParts, l as drawDemand, m as monthEdges, 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 shareOf, w as seasonBest, x as fewestOpen, y as sowDays } from "./join-CM_zwI78.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";
|
|
@@ -64,7 +64,7 @@ function jointDays(layer, caseCuts, options, needs) {
|
|
|
64
64
|
const parts = caseParts(layer, stoppedParts, stock, planned);
|
|
65
65
|
if (supply !== void 0) {
|
|
66
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)));
|
|
67
|
+
const { atHorizon, ...joint } = seasonJoint(seasonPlan(supply, parts, caseCuts, plan, devices, storeCapacities(layer, stoppedParts)), new Set(layer.stores.map((store) => store.resource)));
|
|
68
68
|
return {
|
|
69
69
|
...base,
|
|
70
70
|
...joint,
|
|
@@ -305,7 +305,7 @@ function bestSeason(layer, caseCuts, options, stoppedParts) {
|
|
|
305
305
|
const draws = caseDraws(layer, caseCuts, stoppedParts);
|
|
306
306
|
const parts = caseParts(layer, stoppedParts, supply.stock, new Set(draws.map((draw) => draw.need)));
|
|
307
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);
|
|
308
|
+
const plan = seasonPlan(supply, parts, caseCuts, draws, devices, storeCapacities(layer, stoppedParts));
|
|
309
309
|
const harvests = supply.harvests.length === 0 ? {} : { harvests: supply.harvests };
|
|
310
310
|
if (draws.length === 0) return {
|
|
311
311
|
case: caseCuts.case,
|