@mark1russell7/stack-endurance 0.8.7 → 0.8.9
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/add-on.js +1 -1
- package/build/index.d.ts.map +1 -1
- package/build/index.js +4 -155
- package/build/index.js.map +1 -1
- package/build/{join-DdVFmRh6.js → join-BJJdchyI.js} +180 -99
- package/build/join-BJJdchyI.js.map +1 -0
- package/package.json +2 -2
- package/build/join-DdVFmRh6.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"join-DdVFmRh6.js","names":["curveFault"],"sources":["../src/converter.ts","../src/fit.ts","../src/rows.ts","../src/share.ts","../src/endurance.ts","../src/check.ts","../src/join.ts"],"sourcesContent":["import type { Converter } from \"./layer.ts\";\n\n// The internal rules of a converter that the endurance query and the joint days share. The root entry does not give them.\n\n/** This function gives the amount of each resource that one run of a converter takes. Two lines of one resource add. */\nexport function inputsOf(converter: Converter): Map<string, number> {\n const out = new Map<string, number>();\n for (const input of converter.takes) if (input.amount > 0) out.set(input.resource, (out.get(input.resource) ?? 0) + input.amount);\n return out;\n}\n\n/** This function tells if a converter can run in a case. Its device works, it takes a resource, and it gives an amount more than 0. */\nexport function canRun(converter: Converter, stoppedParts: ReadonlySet<string>): boolean {\n return converter.gives.amount > 0 && inputsOf(converter).size > 0 && (converter.device === undefined || !stoppedParts.has(converter.device));\n}\n\n/**\n * This function gives the key of the device-days that a converter uses. The converters of one device share one key.\n * A converter with no device has a key of its own.\n */\nexport function deviceKey(converter: Converter): string {\n return converter.device === undefined ? `converter:${converter.id}` : `device:${converter.device}`;\n}\n","/** The relative tolerance of a take and of a fit. */\nexport const TOLERANCE = 1e-13;\n\n/** One try of a fit: the amount that the stores could not give, out of the amount wanted, and the value of the try. */\nexport interface Try<T> {\n readonly short: number;\n readonly need: number;\n readonly value: T;\n}\n\n/** The result of a fit: the largest amount with no shortfall, and the value of its try. The value is `undefined` when only 0 fits. */\nexport interface Fit<T> {\n readonly x: number;\n readonly value: T | undefined;\n}\n\n/**\n * The count of the tries of `largestFit`, for the tests of the cost. It is not in the public API, and it does not change a result.\n * It is the one side effect of `largestFit` and of the queries that use it.\n */\nexport const fitTries = { count: 0 };\n\n/**\n * This function gives the largest `x` in `[0, most]` at which `attempt` has no shortfall, to the relative tolerance `TOLERANCE`.\n *\n * - A try fits when its shortfall is not more than `TOLERANCE` times its need.\n * - The shortfall must not decrease when `x` increases. A take of a chain of converters gives a shortfall that is linear in parts.\n * - The first try is `most`. After it, each step tries the zero of the line through the last two tries that do not fit.\n * With one try that does not fit, the step tries `x` times the part of the need that the stores gave.\n * - When a step does not halve the interval, the next step is a bisection. Thus a fit takes at most approximately twice the steps of a bisection.\n * - A step on the lower end tries a point just above it, so a correct estimate ends the fit in one more try.\n * - An estimate that fits with a shortfall above 0 is in the band of the tolerance above the zero, so the fit ends there.\n * A bisection step or a probe at the lower end can fit with a shortfall of rounding below the zero. The fit does not end there.\n *\n * @param most - The upper limit of `x`\n * @param attempt - The try at an amount. It must not change its input\n * @returns The largest amount that fits, and the value of its try\n */\nexport function largestFit<T>(most: number, attempt: (x: number) => Try<T>): Fit<T> {\n const fits = (tried: Try<T>): boolean => tried.short <= TOLERANCE * tried.need;\n fitTries.count += 1;\n const first = attempt(most);\n if (fits(first)) return { x: most, value: first.value };\n let low = 0;\n let best: T | undefined;\n let high = most;\n let highShort = first.short;\n let highNeed = first.need;\n let before: { readonly x: number; readonly short: number } | undefined;\n let bisect = false;\n for (let step = 0; step < 400 && high - low > 4 * TOLERANCE * high; step += 1) {\n const width = high - low;\n let x: number;\n if (bisect) x = (low + high) / 2;\n else if (before !== undefined && before.short > highShort) x = high - (highShort * (before.x - high)) / (before.short - highShort);\n else x = high * (1 - highShort / highNeed);\n // Only a secant or ratio estimate through tries that do not fit lands at or above the zero of a convex shortfall.\n const estimate = !bisect && x < high;\n if (!(x < high)) x = (low + high) / 2;\n const floor = low + 2 * TOLERANCE * high;\n const clamped = !(x > floor);\n if (clamped) x = floor;\n fitTries.count += 1;\n const tried = attempt(x);\n if (fits(tried)) {\n low = x;\n best = tried.value;\n // An estimate that fits with a shortfall is in the band of the tolerance above the zero, so the fit ends.\n if (tried.short > 0 && estimate && !clamped) break;\n } else {\n before = { x: high, short: highShort };\n high = x;\n highShort = tried.short;\n highNeed = tried.need;\n }\n bisect = !bisect && high - low > width / 2;\n }\n return { x: low, value: best };\n}\n","import { add, fromFloat, type Rational, ZERO } from \"@mark1russell7/rational\";\n\n// The internal rows of the linear programs of the queries. The root entry does not give them.\n\n/** A sparse row: the coefficient of each variable, by its index. */\nexport type Row = Map<number, Rational>;\n\n/** This function adds `value` to the coefficient of the variable `index` in `row`. It changes `row`. */\nexport function addTo(row: Row, index: number, value: Rational): void {\n row.set(index, add(row.get(index) ?? ZERO, value));\n}\n\n/** This function gives the dense form of a row: one coefficient for each of `count` variables. */\nexport function dense(row: Row, count: number): Rational[] {\n const out = new Array<Rational>(count).fill(ZERO);\n for (const [index, value] of row) out[index] = value;\n return out;\n}\n\n/** This function gives the exact rational of a finite double, with no rounding. A double is a dyadic rational. */\nexport function exact(value: number): Rational {\n return fromFloat(value);\n}\n","import { type Constraint, type Objective, solveLexicographic } from \"@mark1russell7/linear\";\nimport { add, div, mul, neg, ONE, type Rational, sign, toNumber, ZERO } from \"@mark1russell7/rational\";\nimport { deviceKey, inputsOf } from \"./converter.ts\";\nimport type { Converter, DirectUse } from \"./layer.ts\";\nimport { addTo, dense, exact, type Row } from \"./rows.ts\";\n\n// The best share of one draw: a linear program over the totals of its days, with exact rationals (@mark1russell7/linear).\n// The endurance query uses it for a draw whose converters share the days of a device. The root entry does not give it.\n\n/** The input of the best share of one draw. */\nexport interface ShareInput {\n /** The stock of each resource that the draw can take, by the code of the resource. */\n readonly stock: ReadonlyMap<string, number>;\n /** The device-days of each day that the draw can use, by the key of the device (`deviceKey`). */\n readonly room: ReadonlyMap<string, number>;\n /** The direct uses that give the need of the draw. */\n readonly direct: readonly DirectUse[];\n /** The converters that give the need of the draw. */\n readonly converters: readonly Converter[];\n /** The converters that make each resource, by the code of the resource. */\n readonly makers: ReadonlyMap<string, readonly Converter[]>;\n /** The amount of the need for each day. It is more than 0. */\n readonly demand: number;\n}\n\n/** The best share of one draw: its days, the take of each stock and the device-days of each device. */\nexport interface Share {\n /** The largest count of days at which the draw gets its demand. */\n readonly days: number;\n /** The amount of each resource that the draw takes from the stock. A resource with no take is not in the map. */\n readonly taken: ReadonlyMap<string, number>;\n /** The device-days that the runs use in `days`, by the key of the device. A device with no use is not in the map. */\n readonly used: ReadonlyMap<string, number>;\n}\n\n/** This function gives the makers that a draw can use: the makers of its inputs, through each chain. */\nfunction reachedMakers(input: ShareInput): Converter[] {\n const out = new Set<Converter>();\n const seen = new Set<string>();\n const queue = [...input.direct.map((use) => use.resource), ...input.converters.flatMap((converter) => [...inputsOf(converter).keys()])];\n for (let resource = queue.shift(); resource !== undefined; resource = queue.shift()) {\n if (seen.has(resource)) continue;\n seen.add(resource);\n for (const maker of input.makers.get(resource) ?? []) {\n out.add(maker);\n queue.push(...inputsOf(maker).keys());\n }\n }\n return [...out];\n}\n\n/**\n * This function gives the best share of the stocks and of the device-days for one draw.\n * It gives `undefined` when the program has no optimum.\n *\n * - The variables are the days `T`, the take of each direct use, the runs of each converter and maker, and the take of each stock.\n * - The gifts of the direct uses and of the converters are not less than `T` times the demand.\n * - The takes of each resource are not more than the take of its stock plus the gifts of its makers. The take of a stock is not more than the stock.\n * - The runs of the converters of one device use `room` times `T` device-days or less. One run uses `1 / perDay` of a device-day. A limit of 0 stops the converter.\n * - The first objective takes the largest `T`. The second takes the smallest sum of the takes of the stocks, each over its stock. The third takes the fewest device-days.\n *\n * The gifts at `T` days are a concave function of `T`, and they are 0 at 0. Thus each count of days up to the largest `T` also fits.\n *\n * @param input - The stocks, the device-days of each day, the ways of the draw and its demand\n * @returns The days, the takes of the stocks and the device-days of each device\n */\nexport function bestShare(input: ShareInput): Share | undefined {\n const makers = reachedMakers(input);\n const resources = new Set<string>([...input.direct.map((use) => use.resource), ...[...input.converters, ...makers].flatMap((converter) => [...inputsOf(converter).keys()])]);\n for (const maker of makers) if (\"resource\" in maker.gives && maker.gives.resource !== undefined) resources.add(maker.gives.resource);\n const stocked = [...resources].filter((resource) => (input.stock.get(resource) ?? 0) > 0).sort();\n\n let count = 0;\n const next = (): number => count++;\n const days = next();\n const useCol = input.direct.map(next);\n const runs = new Map<Converter, number>([...input.converters, ...makers].map((converter) => [converter, next()] as const));\n const shareCol = new Map(stocked.map((resource) => [resource, next()] as const));\n\n const rows: { readonly row: Row; readonly relation: Constraint[\"relation\"]; readonly rhs: Rational }[] = [];\n // The need: the gifts are not less than the demand times the days.\n const need: Row = new Map([[days, neg(exact(input.demand))]]);\n input.direct.forEach((use, k) => addTo(need, useCol[k] as number, exact(use.amount)));\n for (const converter of input.converters) addTo(need, runs.get(converter) as number, exact(converter.gives.amount));\n rows.push({ row: need, relation: \">=\", rhs: ZERO });\n // The balance of each resource: its takes are not more than the take of its stock plus the gifts of its makers.\n const balance = new Map<string, Row>([...resources].map((resource) => [resource, new Map()]));\n const consume = (resource: string, index: number, amount: Rational): void => addTo(balance.get(resource) as Row, index, amount);\n input.direct.forEach((use, k) => consume(use.resource, useCol[k] as number, ONE));\n for (const [converter, index] of runs) {\n for (const [resource, each] of inputsOf(converter)) consume(resource, index, exact(each));\n if (\"resource\" in converter.gives && converter.gives.resource !== undefined) consume(converter.gives.resource, index, neg(exact(converter.gives.amount)));\n }\n for (const [resource, index] of shareCol) consume(resource, index, neg(ONE));\n for (const row of balance.values()) if (row.size > 0) rows.push({ row, relation: \"<=\", rhs: ZERO });\n // The take of each stock is not more than the stock.\n for (const [resource, index] of shareCol) rows.push({ row: new Map([[index, ONE]]), relation: \"<=\", rhs: exact(input.stock.get(resource) ?? 0) });\n // The limit of each device: the runs use `room` times `T` device-days or less. The converters of one device share one limit.\n const limits = new Map<string, Row>();\n for (const [converter, index] of runs) {\n if (converter.perDay === undefined) continue;\n if (!(converter.perDay > 0)) {\n rows.push({ row: new Map([[index, ONE]]), relation: \"<=\", rhs: ZERO });\n continue;\n }\n const key = deviceKey(converter);\n const limit = limits.get(key) ?? new Map([[days, neg(exact(input.room.get(key) ?? 0))]]);\n limits.set(key, limit);\n addTo(limit, index, div(ONE, exact(converter.perDay)));\n }\n for (const row of limits.values()) rows.push({ row, relation: \"<=\", rhs: ZERO });\n\n const most: Row = new Map([[days, ONE]]);\n const least: Row = new Map();\n for (const [resource, index] of shareCol) addTo(least, index, div(ONE, exact(input.stock.get(resource) ?? 1)));\n const fewest: Row = new Map();\n for (const [converter, index] of runs) addTo(fewest, index, converter.perDay !== undefined && converter.perDay > 0 ? div(ONE, exact(converter.perDay)) : ONE);\n const objectives: Objective[] = [\n { sense: \"max\", coefficients: dense(most, count) },\n { sense: \"min\", coefficients: dense(least, count) },\n { sense: \"min\", coefficients: dense(fewest, count) },\n ];\n const constraints: Constraint[] = rows.map(({ row, relation, rhs }) => ({ coefficients: dense(row, count), relation, rhs }));\n const solved = solveLexicographic(constraints, objectives);\n // The point 0 is feasible, and the later objectives are not less than 0. Thus only an unbounded first stage has no optimum.\n if (solved.status !== \"optimal\") return undefined;\n\n const at = (index: number): Rational => solved.x[index] ?? ZERO;\n const taken = new Map<string, number>();\n for (const [resource, index] of shareCol) if (sign(at(index)) > 0) taken.set(resource, toNumber(at(index)));\n const used = new Map<string, number>();\n for (const [key, row] of limits) {\n let sum: Rational = ZERO;\n for (const [index, value] of row) if (index !== days) sum = add(sum, mul(value, at(index)));\n if (sign(sum) > 0) used.set(key, toNumber(sum));\n }\n return { days: toNumber(at(days)), taken, used };\n}\n","import { dayNumber, stopped, type Stack } from \"@mark1russell7/system-stack\";\nimport { canRun, deviceKey, inputsOf } from \"./converter.ts\";\nimport { largestFit, type Try } from \"./fit.ts\";\nimport type { CaseCuts, Converter, DirectUse, Draw, Endurance, EnduranceLayer, IsoDate } from \"./layer.ts\";\nimport { bestShare } from \"./share.ts\";\n\n// The endurance query: the days that each draw holds when a case stops its supply.\n\n/** The options of the queries of a case. */\nexport interface CaseOptions {\n /** The date of the query. A store whose due date is on this date or before it gives nothing. */\n readonly at: IsoDate;\n /** The base stack. With it, a cut also stops each part that cannot work without a cut part (`stopped` of the core). */\n readonly stack?: Stack | undefined;\n /** The `id` of more parts that are down, with the cuts of the case. */\n readonly down?: readonly string[] | undefined;\n}\n\n/**\n * This function gives the `id` of each part that does not work in a case: the cut parts and the parts of `down`.\n * With a stack, it also gives each part that stops.\n */\nexport function caseStopped(caseCuts: CaseCuts, options: Pick<CaseOptions, \"stack\" | \"down\">): Set<string> {\n const down = [...caseCuts.cuts.map((cut) => cut.part), ...(options.down ?? [])];\n const out = new Set(down);\n if (options.stack !== undefined) for (const id of stopped(options.stack, down)) out.add(id);\n return out;\n}\n\n/** This function gives the day number of a date, or throws a `RangeError` for a date that is not `YYYY-MM-DD`. */\nfunction dayOf(date: IsoDate): number {\n const day = dayNumber(date);\n if (day === undefined) throw new RangeError(`The date \"${date}\" is not a date YYYY-MM-DD.`);\n return day;\n}\n\n/**\n * This function gives the amount of each resource in the stores at a date, by the code of the resource.\n *\n * - A store gives nothing on its due date and after it.\n * - A store gives nothing when its part is in `stoppedParts`.\n */\nexport function storeAmounts(layer: EnduranceLayer, at: IsoDate, stoppedParts: ReadonlySet<string> = new Set()): Map<string, number> {\n const today = dayOf(at);\n const out = new Map<string, number>();\n for (const store of layer.stores) {\n if (store.due !== undefined && today >= dayOf(store.due)) continue;\n if (store.part !== undefined && stoppedParts.has(store.part)) continue;\n out.set(store.resource, (out.get(store.resource) ?? 0) + store.amount);\n }\n return out;\n}\n\n/** This function gives the amount of a need for each day in a case: the rate of the draw times the factor of the case. */\nexport function drawDemand(draw: Draw, caseCuts: CaseCuts): number {\n return draw.perDay * (caseCuts.factors?.[draw.need] ?? 1);\n}\n\n/**\n * This function gives the draws that take from the stores in a case: each draw whose supply stops, with a demand more than 0.\n * The sequence is by the level (the order of `levels`), then by the code of the need.\n */\nexport function caseDraws(layer: EnduranceLayer, caseCuts: CaseCuts, stoppedParts: ReadonlySet<string>): Draw[] {\n const rank = (level: string): number => {\n const index = layer.levels.indexOf(level);\n return index < 0 ? layer.levels.length : index;\n };\n return layer.draws\n .filter((draw) => stoppedParts.has(draw.supply) && drawDemand(draw, caseCuts) > 0)\n .sort((a, b) => rank(a.level) - rank(b.level) || (a.need < b.need ? -1 : a.need > b.need ? 1 : 0));\n}\n\n/** This function gives the need that a converter gives, or `undefined` when it gives a resource. */\nexport function giftNeed(converter: Converter): string | undefined {\n return \"need\" in converter.gives ? converter.gives.need : undefined;\n}\n\n/** This function gives the resource that a converter gives, or `undefined` when it gives a need. */\nexport function giftResource(converter: Converter): string | undefined {\n return \"resource\" in converter.gives ? converter.gives.resource : undefined;\n}\n\n/** The converters of a case that make each resource, in the order of the layer, by the code of the resource. */\ntype Makers = ReadonlyMap<string, readonly Converter[]>;\n\nfunction makersOf(layer: EnduranceLayer, stoppedParts: ReadonlySet<string>): Makers {\n const out = new Map<string, Converter[]>();\n for (const converter of layer.converters ?? []) {\n const resource = giftResource(converter);\n if (resource === undefined || !canRun(converter, stoppedParts)) continue;\n out.set(resource, [...(out.get(resource) ?? []), converter]);\n }\n return out;\n}\n\n/** The ways to get one need in a case: its direct uses, then the converters that give it, in the order of the layer. `makers` make the resources. */\ninterface Ways {\n readonly direct: readonly DirectUse[];\n readonly converters: readonly Converter[];\n readonly makers: Makers;\n}\n\nfunction waysOf(layer: EnduranceLayer, need: string, stoppedParts: ReadonlySet<string>, makers: Makers): Ways {\n return {\n direct: (layer.direct ?? []).filter((use) => use.need === need && use.amount > 0),\n converters: (layer.converters ?? []).filter((converter) => giftNeed(converter) === need && canRun(converter, stoppedParts)),\n makers,\n };\n}\n\n// A chain: the resources on the path of a take. A maker does not take a resource of its own path, so a cycle of the layer stops there.\nconst NO_PATH: ReadonlySet<string> = new Set();\n\n// The device-days that are left to the converters with a limit `perDay` are in the map of the resources, under a key that\n// no code of a resource has. Thus each copy of the map in a try copies them too. The converters of one device share one\n// key (`deviceKey`), and a converter with no device has a key of its own. One run of a converter uses `1 / perDay` of a device-day.\nconst RUNS = \"\\u0000runs:\";\n\nfunction runsKey(converter: Converter): string {\n return RUNS + deviceKey(converter);\n}\n\n/** This function gives the device-days that a converter has left in `left`, or undefined with no limit. */\nfunction daysLeft(left: ReadonlyMap<string, number>, converter: Converter): number | undefined {\n return converter.perDay === undefined ? undefined : left.get(runsKey(converter));\n}\n\n/** This function gives the map with no runs left of the converters: a map of the resources only. */\nfunction resourcesOnly(left: ReadonlyMap<string, number>): Map<string, number> {\n return new Map([...left].filter(([key]) => !key.startsWith(RUNS)));\n}\n\n/**\n * This function gives the most of a resource that `left` gives: its stock, and the runs of each maker.\n * It is an upper limit. When two inputs come from one resource, the true amount can be less.\n */\nfunction mostResource(left: ReadonlyMap<string, number>, makers: Makers, resource: string, path: ReadonlySet<string>): number {\n let total = left.get(resource) ?? 0;\n if (path.has(resource)) return total;\n const next = new Set(path).add(resource);\n for (const maker of makers.get(resource) ?? []) total += mostRuns(left, makers, maker, next) * maker.gives.amount;\n return total;\n}\n\n/** This function gives the most runs of a converter that `left` gives. It is an upper limit, as for `mostResource`. */\nfunction mostRuns(left: ReadonlyMap<string, number>, makers: Makers, converter: Converter, path: ReadonlySet<string>): number {\n const limit = daysLeft(left, converter);\n let runs = limit === undefined ? Infinity : limit * (converter.perDay ?? 0);\n for (const [resource, each] of inputsOf(converter)) runs = Math.min(runs, mostResource(left, makers, resource, path) / each);\n return Number.isFinite(runs) ? runs : 0;\n}\n\n/**\n * This function takes an amount of a resource from `left`: the stock first, then the makers in the order of the layer.\n * It changes `left`, and it gives the amount that it could not take.\n */\nfunction takeResource(left: Map<string, number>, makers: Makers, resource: string, amount: number, path: ReadonlySet<string>): number {\n const has = left.get(resource) ?? 0;\n const got = Math.min(amount, has);\n left.set(resource, has - got);\n let rest = amount - got;\n if (rest <= 0 || path.has(resource)) return Math.max(0, rest);\n const next = new Set(path).add(resource);\n for (const maker of makers.get(resource) ?? []) {\n if (rest <= 0) break;\n rest -= run(left, makers, maker, rest / maker.gives.amount, next) * maker.gives.amount;\n }\n return Math.max(0, rest);\n}\n\n/**\n * This function runs a converter up to `wanted` times with the resources of `left`, and it gives the count of runs.\n * It changes `left`. When two inputs come from one resource, `largestFit` finds the runs that the resources give.\n */\nfunction run(left: Map<string, number>, makers: Makers, converter: Converter, wanted: number, path: ReadonlySet<string>): number {\n const inputs = inputsOf(converter);\n const most = Math.min(wanted, mostRuns(left, makers, converter, path));\n if (!(most > 0)) return 0;\n const attempt = (runs: number): Try<Map<string, number>> => {\n const copy = new Map(left);\n let need = 0;\n let short = 0;\n // The converter takes its device-days before its inputs. Thus a maker on the same device gets only the rest.\n const limit = daysLeft(copy, converter);\n if (limit !== undefined && converter.perDay !== undefined && converter.perDay > 0) {\n const wanted = runs / converter.perDay;\n const got = Math.min(wanted, limit);\n copy.set(runsKey(converter), limit - got);\n need += runs;\n short += (wanted - got) * converter.perDay;\n }\n for (const [resource, each] of inputs) {\n need += runs * each;\n short += takeResource(copy, makers, resource, runs * each, path);\n }\n return { short, need, value: copy };\n };\n const { x: runs, value: best } = largestFit(most, attempt);\n if (best === undefined) return 0;\n for (const [resource, amount] of best) left.set(resource, amount);\n return runs;\n}\n\n/**\n * This function takes an amount of a need from the resources in `left`: the direct uses first, then the converters.\n * A direct use or a converter takes each resource from its stock first, then from its makers.\n * It changes `left`, and it gives the amount that it could not take.\n */\nfunction take(left: Map<string, number>, ways: Ways, amount: number): number {\n let rest = amount;\n for (const use of ways.direct) {\n if (rest <= 0) break;\n const wanted = rest / use.amount;\n rest -= (wanted - takeResource(left, ways.makers, use.resource, wanted, NO_PATH)) * use.amount;\n }\n for (const converter of ways.converters) {\n if (rest <= 0) break;\n rest -= run(left, ways.makers, converter, rest / converter.gives.amount, NO_PATH) * converter.gives.amount;\n }\n return Math.max(0, rest);\n}\n\n/** This function gives each resource that a need can use: the inputs of its ways, and the inputs of their makers, through each chain. */\nfunction inputClosure(ways: Ways): Set<string> {\n const out = new Set<string>();\n const queue = [...ways.direct.map((use) => use.resource), ...ways.converters.flatMap((converter) => [...inputsOf(converter).keys()])];\n for (let resource = queue.shift(); resource !== undefined; resource = queue.shift()) {\n if (out.has(resource)) continue;\n out.add(resource);\n for (const maker of ways.makers.get(resource) ?? []) queue.push(...inputsOf(maker).keys());\n }\n return out;\n}\n\n/** The relative tolerance of a used-up resource. */\nconst USED_UP = 1e-9;\n\n/**\n * This function gives the days that each draw holds when a case stops its supply, and the resources that are used up then.\n *\n * - A draw takes from the stores only when the case stops its supply part. Each other draw holds without end, and the result leaves it out.\n * - The demand of a draw for each day is its rate times the factor of the case.\n * - The draws take the resources in the order of their level, then of their codes. A draw takes from its direct uses first, then from its converters.\n * - The days of a draw are the largest `T` at which the stores give `T` days of its demand, after each higher draw.\n * - Each higher draw keeps back its own days times its demand. Thus the takes of all the draws are not more than the stores at any time.\n * - The take order is a rule, not the best share: the direct uses in the order of the list, then the converters. The days are the days of this order.\n * A draw with a shared device is different. Refer to the last item.\n * - A converter whose device stops gives nothing. A store whose part stops gives nothing.\n * - A converter can give a resource. A take of a resource uses the stock first, then the converters that make it, through each chain.\n * - A converter with a limit `perDay` runs `perDay` times `devices` times `T` times or less in `T` days. The converters of one device share it.\n * - The higher draws use the runs of a limit first.\n * - A higher draw keeps back its runs of each day for all the days of a lower draw, also when its own days are fewer. This is the safe side.\n * - Two limited converters of one device can make the shortfall of the take order decrease when the days increase.\n * Thus a draw whose ways reach two converters of one device, each with a limit `perDay` more than 0, does not use the take order.\n * A linear program with exact rationals gives its days: the largest `T` with the best share of its stocks and of the device-days.\n * At this `T`, the draw takes the smallest sum of its takes of the stocks, each over its stock, then the fewest device-days.\n *\n * 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.\n *\n * @param layer - The endurance layer\n * @param caseCuts - The case\n * @param options - The date, and the stack or the parts that are also down\n * @returns The endurance of each draw whose supply stops\n */\nexport function enduranceOf(layer: EnduranceLayer, caseCuts: CaseCuts, options: CaseOptions): Endurance {\n const stoppedParts = caseStopped(caseCuts, options);\n const start = storeAmounts(layer, options.at, stoppedParts);\n const makers = makersOf(layer, stoppedParts);\n const stocked = new Set(layer.stores.map((store) => store.resource));\n const limited = (layer.converters ?? []).filter((converter) => converter.perDay !== undefined && canRun(converter, stoppedParts));\n // The count of devices of each key (`deviceKey`). The gate refuses two counts for one device.\n const devices = new Map(limited.map((converter) => [deviceKey(converter), converter.devices ?? 1]));\n // The device-days of each day that the higher draws use, by the key of the device. A higher draw keeps back its\n // device-days of each day for all the days of a lower draw, also after its own days end. This is the safe side.\n const used = new Map<string, number>();\n // The stocks that the higher draws leave after their own days.\n let before = new Map(start);\n const needs: Record<string, { days: number; binding: string[]; takes: Record<string, number>; capped?: string[] }> = {};\n for (const draw of caseDraws(layer, caseCuts, stoppedParts)) {\n const ways = waysOf(layer, draw.need, stoppedParts, makers);\n const demand = drawDemand(draw, caseCuts);\n // The device-days of each day that the higher draws leave to this draw, by the key of the device.\n const room = new Map([...devices].map(([key, count]) => [key, Math.max(0, count - (used.get(key) ?? 0))] as const));\n const closure = inputClosure(ways);\n // The converters that the draw can use: the converters that give its need, and the makers of its inputs through each chain.\n const reach = new Set([...ways.converters, ...[...closure].flatMap((resource) => makers.get(resource) ?? [])]);\n // With two limited converters of one device, the shortfall of the take order can decrease when the days increase.\n // For such a draw, a linear program gives the best share of the device-days and of the stocks.\n const share = sharesDevice(reach) ? bestShare({ stock: before, room, direct: ways.direct, converters: ways.converters, makers, demand }) : undefined;\n let low: number;\n let left: Map<string, number>;\n if (share !== undefined) {\n low = share.days;\n left = new Map(before);\n for (const [resource, amount] of share.taken) left.set(resource, Math.max(0, (left.get(resource) ?? 0) - amount));\n for (const [key, free] of room) left.set(RUNS + key, Math.max(0, free * low - (share.used.get(key) ?? 0)));\n } else {\n const after = (days: number): { left: Map<string, number>; short: number } => {\n const tried = new Map(before);\n for (const [key, free] of room) tried.set(RUNS + key, free * days);\n return { left: tried, short: take(tried, ways, days * demand) };\n };\n // The upper limit: the days that the draw holds when it takes all the stores itself. `largestFit` finds the days below it.\n const fit = largestFit(capacity(start, ways) / demand, (days) => {\n const tried = after(days);\n return { short: tried.short, need: days * demand, value: tried.left };\n });\n low = fit.x;\n left = fit.value ?? after(low).left;\n }\n // The binding resources are of the stores only: a used-up limit of runs is in `capped`, not here.\n const stores = resourcesOnly(left);\n const binding = [...closure]\n .filter((resource) => !makers.has(resource) || stocked.has(resource))\n .filter((resource) => mostResource(stores, makers, resource, NO_PATH) <= USED_UP * Math.max(1, start.get(resource) ?? 0))\n .sort();\n const takes: Record<string, number> = {};\n for (const [resource, amount] of before) {\n const taken = amount - (left.get(resource) ?? 0);\n if (taken > 0) takes[resource] = taken;\n }\n // A limit stops the draw when its limit gives the converter no runs left, and its inputs give more runs.\n // The runs left are the device-days left times `perDay`. Thus a limit of 0 stops the draw, also with its device-days left.\n const runsLeft = (converter: Converter): number => (daysLeft(left, converter) ?? 0) * (converter.perDay ?? 0);\n const runsGiven = (converter: Converter): number => (devices.get(deviceKey(converter)) ?? 1) * (converter.perDay ?? 0) * low;\n const capped = limited\n .filter((converter) => reach.has(converter))\n .filter((converter) => runsLeft(converter) <= USED_UP * Math.max(1, runsGiven(converter)))\n .filter((converter) => mostRuns(stores, makers, converter, NO_PATH) > USED_UP)\n .map((converter) => converter.id)\n .sort();\n needs[draw.need] = capped.length === 0 ? { days: low, binding, takes } : { days: low, binding, takes, capped };\n // The device-days of each day of this draw count against each lower draw, for all of its days.\n if (low > 0) for (const [key, free] of room) used.set(key, (used.get(key) ?? 0) + (free * low - (left.get(RUNS + key) ?? 0)) / low);\n before = stores;\n }\n return { case: caseCuts.case, at: options.at, needs };\n}\n\n/** This function tells if two converters of `reach` with a limit `perDay` more than 0 share one device. */\nfunction sharesDevice(reach: ReadonlySet<Converter>): boolean {\n const seen = new Set<string>();\n for (const converter of reach) {\n if (converter.perDay === undefined || !(converter.perDay > 0)) continue;\n const key = deviceKey(converter);\n if (seen.has(key)) return true;\n seen.add(key);\n }\n return false;\n}\n\n/**\n * This function gives an upper limit of a need that the stores give with no other draw, through each chain.\n * A converter that takes nothing gives nothing: the gate refuses it.\n */\nfunction capacity(start: ReadonlyMap<string, number>, ways: Ways): number {\n let total = 0;\n for (const use of ways.direct) total += mostResource(start, ways.makers, use.resource, NO_PATH) * use.amount;\n for (const converter of ways.converters) total += mostRuns(start, ways.makers, converter, NO_PATH) * converter.gives.amount;\n return total;\n}\n","import { stronglyConnectedComponents } from \"@mark1russell7/collections/graph\";\nimport { CUT_BOUNDS, curveFault, dayNumber, isCutBound, type Fault, type Stack } from \"@mark1russell7/system-stack\";\nimport { giftNeed, giftResource } from \"./endurance.ts\";\nimport type { Converter, EnduranceLayer } from \"./layer.ts\";\n\n// The gate of an endurance layer: the meaning of a layer with a correct form, for its base stack.\n\n/**\n * 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.\n *\n * - `endurance-twice`: two or more records of one list have one key. A key is a level, a resource, a store, a need, a converter or a case.\n * The key of a prior is its case and its place. A converter takes each resource on one line, and a case cuts each part one time.\n * - `endurance-level-unknown`: the level of a draw is not a level of the layer.\n * - `endurance-resource-unknown`: a store, a use or a converter names a resource that the layer does not have.\n * - `endurance-part-unknown`: a supply, a device, the part of a store or a cut is not a part of the base stack.\n * - `endurance-range`: an amount, a rate, a count or a factor is not a finite number of 0 or more. Or a reach is not from 0 to 1.\n * - `endurance-date`: a date is not a date `YYYY-MM-DD`.\n * - `endurance-converter-empty`: a converter takes nothing, or it gives an amount of 0.\n * - `endurance-curve`: a survival curve does not start at `[0, 1]`, or it does not end at a chance of 0.\n * Or its days do not increase, or its chance increases.\n * - `endurance-bound`: the bound of a cut is not a value of `CUT_BOUNDS` of the core. Since 0.8.4.\n * - `endurance-prior-case`: a prior names a case that the layer does not have.\n * - `endurance-cycle`: converters make a resource from itself, through one converter or a chain. One fault names each cycle.\n * - `endurance-devices`: two converters of one device give two different counts of devices.\n * - `endurance-device-mix` (warning): a device has a converter with a limit `perDay` and a converter with no limit. The\n * converter with no limit uses no device-days, so its runs do not reduce the runs of the limited converter.\n * - `endurance-no-way` (warning): a draw has no direct use and no converter, so it holds 0 days when its supply stops.\n * - `endurance-cut-no-curve` (warning): a cut has no curve of its duration. The draws whose stop it can be part of are no read in the shortfall.\n */\nexport const ENDURANCE_CODES: readonly [\n \"endurance-twice\",\n \"endurance-level-unknown\",\n \"endurance-resource-unknown\",\n \"endurance-part-unknown\",\n \"endurance-range\",\n \"endurance-date\",\n \"endurance-converter-empty\",\n \"endurance-curve\",\n \"endurance-bound\",\n \"endurance-prior-case\",\n \"endurance-cycle\",\n \"endurance-devices\",\n \"endurance-device-mix\",\n \"endurance-no-way\",\n \"endurance-cut-no-curve\",\n] = [\n \"endurance-twice\",\n \"endurance-level-unknown\",\n \"endurance-resource-unknown\",\n \"endurance-part-unknown\",\n \"endurance-range\",\n \"endurance-date\",\n \"endurance-converter-empty\",\n \"endurance-curve\",\n \"endurance-bound\",\n \"endurance-prior-case\",\n \"endurance-cycle\",\n \"endurance-devices\",\n \"endurance-device-mix\",\n \"endurance-no-way\",\n \"endurance-cut-no-curve\",\n];\n\n/** A code of `ENDURANCE_CODES`. */\nexport type EnduranceCode = (typeof ENDURANCE_CODES)[number];\n\n/** A fault of the gate of an endurance layer. */\nexport interface EnduranceFault extends Fault {\n readonly code: EnduranceCode;\n}\n\nexport { curveFault } from \"@mark1russell7/system-stack\";\n\n/**\n * This function gives each fault of an endurance layer. With a base stack, it also examines the `id` of each part. A list with no error tells that the gate passes.\n *\n * The faults are in the order of the layer. The function is pure.\n *\n * @param layer - The endurance layer\n * @param stack - The base stack, with the layer. With no stack, the gate does not examine the parts.\n * @returns The faults\n */\nexport function checkEndurance(layer: EnduranceLayer, stack?: Stack): EnduranceFault[] {\n const faults: EnduranceFault[] = [];\n const add = (level: EnduranceFault[\"level\"], code: EnduranceCode, at: string, message: string): void => {\n faults.push({ level, code, at, message });\n };\n const once = (what: string, keys: readonly string[]): void => {\n const seen = new Set<string>();\n for (const key of keys) {\n if (seen.has(key)) add(\"error\", \"endurance-twice\", key, `Two or more ${what} have the key \"${key}\".`);\n seen.add(key);\n }\n };\n const range = (at: string, what: string, value: number): void => {\n if (!(Number.isFinite(value) && value >= 0)) add(\"error\", \"endurance-range\", at, `The ${what} of \"${at}\" is ${String(value)}. It must be a finite number of 0 or more.`);\n };\n const date = (at: string, value: string): void => {\n if (dayNumber(value) === undefined) add(\"error\", \"endurance-date\", at, `The date \"${value}\" of \"${at}\" is not a date YYYY-MM-DD.`);\n };\n const parts = stack === undefined ? undefined : new Set(stack.parts.map((part) => part.id));\n const part = (at: string, what: string, id: string | undefined): void => {\n if (parts !== undefined && id !== undefined && !parts.has(id)) add(\"error\", \"endurance-part-unknown\", at, `The ${what} \"${id}\" of \"${at}\" is not a part of the stack.`);\n };\n const resources = new Set(layer.resources.map((resource) => resource.code));\n const resource = (at: string, code: string): void => {\n if (!resources.has(code)) add(\"error\", \"endurance-resource-unknown\", at, `The resource \"${code}\" of \"${at}\" is not a resource of the layer.`);\n };\n const direct = layer.direct ?? [];\n const converters = layer.converters ?? [];\n const cases = layer.cases ?? [];\n const priors = layer.priors ?? [];\n\n once(\"levels\", layer.levels);\n once(\"resources\", layer.resources.map((item) => item.code));\n once(\"stores\", layer.stores.map((store) => store.id));\n once(\"draws\", layer.draws.map((draw) => draw.need));\n once(\"converters\", converters.map((converter) => converter.id));\n once(\"cases\", cases.map((item) => item.case));\n once(\"priors\", priors.map((prior) => `${prior.case}@${prior.place}`));\n\n for (const store of layer.stores) {\n resource(store.id, store.resource);\n range(store.id, \"amount\", store.amount);\n if (store.due !== undefined) date(store.id, store.due);\n part(store.id, \"part\", store.part);\n }\n const levels = new Set(layer.levels);\n for (const draw of layer.draws) {\n if (!levels.has(draw.level)) add(\"error\", \"endurance-level-unknown\", draw.need, `The level \"${draw.level}\" of the draw \"${draw.need}\" is not a level of the layer.`);\n range(draw.need, \"rate\", draw.perDay);\n if (draw.users !== undefined) range(draw.need, \"count of users\", draw.users);\n part(draw.need, \"supply\", draw.supply);\n const ways = direct.some((use) => use.need === draw.need) || converters.some((converter) => giftNeed(converter) === draw.need);\n if (!ways) add(\"warning\", \"endurance-no-way\", draw.need, `The draw \"${draw.need}\" has no direct use and no converter. It holds 0 days when its supply stops.`);\n }\n for (const use of direct) {\n const at = `${use.resource}>${use.need}`;\n resource(at, use.resource);\n range(at, \"amount\", use.amount);\n }\n for (const converter of converters) {\n once(`resources of the converter \"${converter.id}\"`, converter.takes.map((input) => input.resource));\n for (const input of converter.takes) {\n resource(converter.id, input.resource);\n range(converter.id, \"amount\", input.amount);\n }\n range(converter.id, \"amount\", converter.gives.amount);\n const made = giftResource(converter);\n if (made !== undefined) resource(converter.id, made);\n if (!converter.takes.some((input) => input.amount > 0) || converter.gives.amount === 0) add(\"error\", \"endurance-converter-empty\", converter.id, `The converter \"${converter.id}\" takes nothing, or it gives nothing.`);\n part(converter.id, \"device\", converter.device);\n if (converter.perDay !== undefined) range(converter.id, \"rate perDay\", converter.perDay);\n if (converter.devices !== undefined && !(Number.isSafeInteger(converter.devices) && converter.devices >= 1))\n add(\"error\", \"endurance-range\", converter.id, `The count of devices of \"${converter.id}\" is ${String(converter.devices)}. It must be a whole number of 1 or more.`);\n }\n const counts = new Map<string, number>();\n for (const converter of converters) {\n if (converter.device === undefined) continue;\n const count = converter.devices ?? 1;\n const seen = counts.get(converter.device);\n if (seen !== undefined && seen !== count)\n add(\"error\", \"endurance-devices\", converter.id, `The converter \"${converter.id}\" gives the count ${String(count)} for the device \"${converter.device}\". An other converter gives the count ${String(seen)}.`);\n if (seen === undefined) counts.set(converter.device, count);\n }\n // One fault names each device with a limited converter and a converter with no limit, at the first converter with no limit.\n const mixed = new Set<string>();\n for (const converter of converters) {\n const device = converter.device;\n if (device === undefined || converter.perDay !== undefined || mixed.has(device)) continue;\n const limited = converters.find((other) => other.device === device && other.perDay !== undefined);\n if (limited === undefined) continue;\n mixed.add(device);\n add(\"warning\", \"endurance-device-mix\", converter.id, `The device \"${device}\" has the limited converter \"${limited.id}\" and the converter \"${converter.id}\" with no limit. \"${converter.id}\" uses no device-days.`);\n }\n const caseCodes = new Set(cases.map((item) => item.case));\n for (const item of cases) {\n once(`cuts of the case \"${item.case}\"`, item.cuts.map((cut) => cut.part));\n for (const cut of item.cuts) {\n const at = `${item.case}/${cut.part}`;\n part(at, \"cut\", cut.part);\n if (cut.bound !== undefined && !isCutBound(cut.bound))\n add(\"error\", \"endurance-bound\", at, `The bound of the cut \"${at}\" is ${JSON.stringify(cut.bound)}. It must be one of ${CUT_BOUNDS.join(\", \")}.`);\n if (cut.duration === undefined) {\n add(\"warning\", \"endurance-cut-no-curve\", at, `The cut \"${at}\" has no curve of its duration, so the draws that it can stop are no read.`);\n continue;\n }\n const fault = curveFault(cut.duration);\n if (fault !== undefined) add(\"error\", \"endurance-curve\", at, `The duration of the cut \"${at}\": ${fault}`);\n }\n for (const [need, factor] of Object.entries(item.factors ?? {})) range(`${item.case}/${need}`, \"factor\", factor);\n if (item.leadSeconds !== undefined) range(item.case, \"lead time\", item.leadSeconds);\n }\n for (const cycle of resourceCycles(converters)) {\n const [first = \"\"] = cycle;\n const names = cycle.map((code) => `\"${code}\"`).join(\", \");\n const message = cycle.length === 1 ? `A converter makes the resource ${names} from itself.` : `Converters make the resources ${names} from each other.`;\n add(\"error\", \"endurance-cycle\", first, `${message} A chain of converters cannot end.`);\n }\n for (const prior of priors) {\n const at = `${prior.case}@${prior.place}`;\n if (!caseCodes.has(prior.case)) add(\"error\", \"endurance-prior-case\", at, `The prior \"${at}\" names the case \"${prior.case}\", which the layer does not have.`);\n range(at, \"count of events in one year\", prior.perYear);\n if (!(prior.reach >= 0 && prior.reach <= 1)) add(\"error\", \"endurance-range\", at, `The reach of \"${at}\" is ${String(prior.reach)}. It must be from 0 to 1.`);\n date(at, prior.asOf);\n }\n return faults;\n}\n\n/** This function gives each cycle of resources: a resource is made from a resource that a converter makes from it. Each cycle is a list of codes. */\nfunction resourceCycles(converters: readonly Converter[]): string[][] {\n const from = new Map<string, Set<string>>();\n for (const converter of converters) {\n const made = giftResource(converter);\n if (made === undefined) continue;\n const inputs = from.get(made) ?? new Set<string>();\n for (const input of converter.takes) if (input.amount > 0) inputs.add(input.resource);\n from.set(made, inputs);\n }\n const successors = (code: string): Iterable<string> => from.get(code) ?? [];\n return stronglyConnectedComponents(from.keys(), successors).filter((component) => {\n const [only = \"\"] = component;\n return component.length > 1 || (from.get(only)?.has(only) ?? false);\n });\n}\n\n/** This function tells if a list of faults has an error. */\nexport function hasEnduranceError(faults: readonly EnduranceFault[]): boolean {\n return faults.some((fault) => fault.level === \"error\");\n}\n","import { canonicalJson } from \"@mark1russell7/rigor-generators\";\nimport { joinRecords, joinSetting, type LayerParse, type LayerPiece } from \"@mark1russell7/system-stack\";\nimport { ENDURANCE_SCHEMA, type EnduranceLayer } from \"./layer.ts\";\n\n// The join of the endurance layers of the fragments of a stack, for example one file of stores for each owner.\n\n/**\n * This function joins the endurance layers of the fragments of a stack into one layer.\n *\n * - The levels are one setting: each fragment that has levels gives the same list, else the join has a fault.\n * - The records of each list are in the order of the fragments.\n * - Two resources with one code in two fragments join into one resource when their records are equal. A different field is a fault.\n * Its message gives the canonical JSON of the record of each fragment.\n * - A code that one fragment has two times stays in the joined layer. The gate `checkEndurance` finds it.\n * - One key of each other list in two or more fragments is a fault, also when the records are equal.\n * - The key of a direct use is its resource and its need.\n *\n * The function is pure, and it changes no layer. The gate `checkEndurance` examines the joined layer afterward.\n *\n * @param pieces - The layers, with the name of the fragment of each one, in the order of the fragments.\n * @returns The joined layer, or the faults of the join.\n */\nexport function joinEndurance(pieces: readonly LayerPiece<EnduranceLayer>[]): LayerParse<EnduranceLayer> {\n const levels = joinSetting(pieces, (layer) => (layer.levels.length > 0 ? layer.levels.join(\"\\n\") : undefined), \"levels\");\n // Two fragments can declare one resource, for example `water.stored` in `L`. Canonical JSON (RFC 8785) compares the records,\n // so the order of the keys has no effect. The message of a fault gives the canonical JSON of the record of each fragment.\n const resources = joinRecords(pieces, (layer) => layer.resources, (item) => item.code, \"resource\", {\n equal: (first, other) => canonicalJson(first) === canonicalJson(other),\n text: canonicalJson,\n });\n const stores = joinRecords(pieces, (layer) => layer.stores, (item) => item.id, \"store\");\n const draws = joinRecords(pieces, (layer) => layer.draws, (item) => item.need, \"draw\");\n const direct = joinRecords(pieces, (layer) => layer.direct, (item) => `${item.resource}>${item.need}`, \"direct use\");\n const converters = joinRecords(pieces, (layer) => layer.converters, (item) => item.id, \"converter\");\n const cases = joinRecords(pieces, (layer) => layer.cases, (item) => item.case, \"case\");\n const priors = joinRecords(pieces, (layer) => layer.priors, (item) => `${item.case}@${item.place}`, \"prior\");\n const errors = [levels, resources, stores, draws, direct, converters, cases, priors].flatMap((join) => join.errors);\n if (errors.length > 0) return { ok: false, errors };\n const has = (key: \"direct\" | \"converters\" | \"cases\" | \"priors\"): boolean => pieces.some((piece) => piece.layer[key] !== undefined);\n return {\n ok: true,\n layer: {\n schema: ENDURANCE_SCHEMA,\n levels: levels.value === undefined ? [] : levels.value.split(\"\\n\"),\n resources: resources.items,\n stores: stores.items,\n draws: draws.items,\n ...(has(\"direct\") ? { direct: direct.items } : {}),\n ...(has(\"converters\") ? { converters: converters.items } : {}),\n ...(has(\"cases\") ? { cases: cases.items } : {}),\n ...(has(\"priors\") ? { priors: priors.items } : {}),\n },\n };\n}\n"],"mappings":";;;;;;;;AAKA,SAAgB,SAAS,WAA2C;CAClE,MAAM,sBAAM,IAAI,IAAoB;CACpC,KAAK,MAAM,SAAS,UAAU,OAAO,IAAI,MAAM,SAAS,GAAG,IAAI,IAAI,MAAM,WAAW,IAAI,IAAI,MAAM,QAAQ,KAAK,KAAK,MAAM,MAAM;CAChI,OAAO;AACT;;AAGA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