The deterministic consolidation policy (Definition 2)
Definitionowmr_consolidation_policyFix and define, as in (33),
Retailer plans at setup cost ; write and . If , let be the width of a canonical optimum at setup cost , and its setup-cost share. The consolidation policy follows four rules.
- Retailer policies. Retailer uses base stock at a minimizer of if (an immediate retailer). Otherwise it is a batch retailer and uses the best half window of if , and the full window otherwise.
- Requests and allocation. Retailer applies its policy to . Requests join one FIFO queue, and after the supplier order the warehouse allocates its unallocated stock to requests in queue order, the last one possibly in part.
- Dispatch. Allocations to immediate retailers are dispatched at once. A request of a batch retailer, of size , receives at creation an offset and ships its entire reserve in each period in which its cumulative allocation rises to or past , or past when , or reaches .
- Supplier orders. If , the warehouse uses , where is a canonical optimum attaining and ; if , base stock at a nonnegative minimizer of . It applies this policy to , with the selected targets.
Offsets (Appendix C.7). Ordinary requests are indexed in creation order. For request of a batch retailer , of size , created in period , the credited full-lifetime proxy (C.29) is
where is the number of interior thresholds, the stock allocated to request and retained at the warehouse in period , and the total ideal depletion. With its average over the fresh demand vectors of periods given the state at creation, and , the offset is the first rational in a fixed enumeration of with (Lemma C.7).
Initialization (Appendix C.8). Prescribed pipelines arrive without new orders, the remaining warehouse stock is sent to a fixed retailer, and no further action is taken until it is received and every retailer net inventory is at most . Then retailer receives an initial request of size (if positive), initial requests of batch retailers get fixed offsets, and the four rules run, so the first supplier order raises the supplier position to its shifted target.
Theorem 2 bounds the long-run average cost of this policy for arbitrary nonnegative setup costs.
Formalization Note The choices (canonical optima, best half windows, minimizers, the supplier pair, the fixed retailer, the fixed initial offsets in , and the enumeration) are parameters c : ConChoice n, constrained by IsConChoice N m c; and are compared in . Simultaneous requests are queued and indexed in increasing retailer index. With , the stock is sent in period (period if ), after its receipts, and the policy starts in the first later period, no earlier than the arrival of that shipment, in which every after the receipts. The averages are computed by simulating the ideal dynamics (supplier orders, requests, and allocations, which do not depend on offsets) over the next periods; the value used when no rational satisfies the inequality is a formal default that Lemma C.7 shows is never used. is a Lebesgue integral over in .
import Definitions.Def_owmr_queue_engine
/-!
# The deterministic consolidation policy `π_con^{(m)}` (Definition 2)
Source: M. Hu, "A 5/2 Guarantee for Echelon Stock (s,S) Policies in One-Warehouse
Multi-Retailer Systems", Section 6 (equation (33) and Definition 2), Appendix C.2
(policy and allocation), Appendix C.7 (deterministic offset selection, Lemma C.7 and the
credited full-lifetime proxy (C.29)), and Appendix C.8 (initialization).
The definition involves choices (canonical optima, minimizing half windows, minimizers, a fixed
retailer for the initialization, fixed offsets of the initial requests, and an enumeration of
the rationals in `(0,1)`). They are collected in `ConChoice`; `IsConChoice` states the properties
Definition 2 requires of them. Simultaneous requests join the queue, and are indexed, in
increasing retailer index (a fixed tie-breaking rule; retailer labels are arbitrary).
Initialization (Appendix C.8): no orders or dispatches until all prescribed pipelines have
arrived (the last can arrive in period `Tpipe - 1`, where `Tpipe = max(L₀, max_i L_i)`; with
truncated subtraction, `Tpipe - 1 = 0` if `Tpipe = 0`); in period `Tpipe - 1`, after its
receipts, the whole warehouse stock is sent to the fixed retailer `sendTo`; no further action
until that shipment has arrived and every retailer net inventory is at most its selected target
`Γ_i = S_i` (checked after the receipts of each period `t > Tpipe - 1`). In the first such period
the policy starts: retailer `i` gets an initial request of size `Γ_i - I_i`
(if positive), the initial requests of batch retailers get the fixed offsets, and the supplier
rule and the queue then run as in Definition 2 (its first order raises the supplier position to
the shifted target).
Offsets of ordinary requests of batch retailers (Appendix C.7): ordinary requests are indexed
`j = 1, 2, …` in creation order. For request `j` (retailer `i`, size `Q_j`, created in period
`τ_j`) and an offset `ϑ`, the credited full-lifetime proxy is
`𝒵_j(ϑ) = K_i (1 + N_j(ϑ)) + (h + p) ∑_{t=τ_j}^{τ_j+L₀} (R_{j,t}(ϑ) - X_t)⁺`, where `N_j(ϑ)` is
the number of interior thresholds (`2` if `ϑ < 1/3`, else `1`), `R_{j,t}(ϑ)` the stock allocated
to request `j` and retained at the warehouse in period `t`, and `X_t` the total ideal depletion
`∑_i (Γ_i - P̂_{i,t})`. It depends on the ideal state at creation and on the fresh demand vectors
of periods `τ_j, …, τ_j + L₀ - 1`. With `z_j(ϑ)` its conditional expectation given the state at
creation and `z̄_j = ∫_0^1 z_j(ϑ) dϑ`, the offset is the first rational `ϑ` in the enumeration with
`z_j(ϑ) < z̄_j + 2^{-j}`.
-/
open MeasureTheory
open scoped ENNReal NNReal
noncomputable section
namespace OWMR
variable {n : ℕ}
/-- `γ̄_m = 13/3 + 32/(57m)` from (33). -/
def conGammaBar (m : ℝ) : ℝ := 13 / 3 + 32 / (57 * m)
/-- `g_m = γ̄_m / 2` from (33). -/
def conG (m : ℝ) : ℝ := conGammaBar m / 2
/-- `ζ_m = g_m / (g_m - 1)` from (33). -/
def conZeta (m : ℝ) : ℝ := conG m / (conG m - 1)
/-- `B_m = 2 (g_m - 1)` from (33). -/
def conB (m : ℝ) : ℝ := 2 * (conG m - 1)
/-- `u_m = 3 ζ_m (1 + 1/m) / (4 (4 + ζ_m/m))` from (33). -/
def conU (m : ℝ) : ℝ := 3 * conZeta m * (1 + 1 / m) / (4 * (4 + conZeta m / m))
/-- The choices made in Definition 2: retailer `(s_i, S_i)` (base stock when `s_i = S_i`) and
batch flags, the supplier `(s₀, S₀)`, the fixed retailer that receives the initial warehouse
stock, the fixed offsets of initial requests, and the enumeration of `ℚ ∩ (0,1)`. -/
structure ConChoice (n : ℕ) where
s : Fin n → ℝ
S : Fin n → ℝ
batch : Fin n → Bool
s0 : ℝ
S0 : ℝ
sendTo : Fin n
initOffset : Fin n → ℝ
enum : ℕ ≃ {q : ℚ // 0 < q ∧ q < 1}
/-- The requirements of Definition 2 (with `k_i = ζ_m K_i`, `G_i = J_i(k_i)`,
`Λ_i = min_x F_i(x)`):
* (i) if `Λ_i + K_i ≤ B_m G_i`, retailer `i` is a non-batch (immediate) retailer using base stock
at a minimizer of `F_i`; otherwise it is a batch retailer and, for a canonical optimum
`(ŝ_i, Ŝ_i)` at setup cost `k_i` with width `ŵ_i` and setup share
`u_i = k_i / (G_i M_i(ŵ_i))`, it uses a minimizing half window of `[ŝ_i, Ŝ_i]` if `u_i ≤ u_m`
and `(ŝ_i, Ŝ_i)` otherwise;
* (iv) if `K₀ > 0`, the supplier uses `(ŝ₀ + a₀, Ŝ₀ + a₀)` for a canonical optimum `(ŝ₀, Ŝ₀)`
attaining `J₀(g_m K₀)`, with `a₀ = (-ŝ₀)⁺`; if `K₀ = 0`, base stock at a nonnegative minimizer
of `f_{L₀}`;
* the fixed offsets of initial requests lie in `(0,1)`. -/
def IsConChoice (N : Network n) (m : ℝ) (c : ConChoice n) : Prop :=
(∀ i,
(ENNReal.ofReal ((⨅ y, N.F i y) + N.K i)
≤ ENNReal.ofReal (conB m) * N.J i (conZeta m * N.K i) →
c.batch i = false ∧ c.s i = c.S i ∧ ∀ y, N.F i (c.S i) ≤ N.F i y) ∧
(ENNReal.ofReal (conB m) * N.J i (conZeta m * N.K i)
< ENNReal.ofReal ((⨅ y, N.F i y) + N.K i) →
c.batch i = true ∧ ∃ sh Sh : ℝ,
IsCanonicalOptimum (N.marginal i) (N.F i) (conZeta m * N.K i) sh Sh ∧
(ENNReal.ofReal (conZeta m * N.K i)
/ (N.J i (conZeta m * N.K i) * renewalM (N.marginal i) (Sh - sh))
≤ ENNReal.ofReal (conU m) →
IsBestHalfWindow (N.marginal i) (N.F i) sh Sh (c.s i) (c.S i)) ∧
(ENNReal.ofReal (conU m)
< ENNReal.ofReal (conZeta m * N.K i)
/ (N.J i (conZeta m * N.K i) * renewalM (N.marginal i) (Sh - sh)) →
c.s i = sh ∧ c.S i = Sh))) ∧
(0 < N.K0 → ∃ sh Sh : ℝ, IsCanonicalOptimum N.aggregate N.fL0 (conG m * N.K0) sh Sh ∧
c.s0 = sh + max (-sh) 0 ∧ c.S0 = Sh + max (-sh) 0) ∧
(N.K0 = 0 → c.s0 = c.S0 ∧ 0 ≤ c.S0 ∧ ∀ y, N.fL0 c.S0 ≤ N.fL0 y) ∧
(∀ i, 0 < c.initOffset i ∧ c.initOffset i < 1)
/-- The queue parameters of `π_con`: centers `Γ_i = S_i` in the supplier position. -/
def ConChoice.params (c : ConChoice n) : EngParams n where
s := c.s
S := c.S
center := c.S
batch := c.batch
s0 := c.s0
S0 := c.S0
/-! ## Deterministic offset selection (Appendix C.7) -/
/-- Ideal forward simulation from a state `σ` at creation in period `t0` (after the requests and
the supplier order of `t0`), with demand vectors `ds k` in periods `t0 + k`: the state after the
requests and supplier order of period `t0 + k`. Every allocation ships at once here, which does
not change the ideal quantities (positions including outstanding requests, supplier position,
allocations). -/
def idealA (N : Network n) (P : EngParams n) (σ : EngState n) (t0 : ℕ) (ds : ℕ → DemandVec n) :
ℕ → EngState n
| 0 => σ
| k + 1 =>
(phaseA N.L0 N.L { P with batch := fun _ => false } (fun _ _ _ _ _ => 0) (t0 + k + 1)
(receive (applyDemand (phaseB N.L { P with batch := fun _ => false } (t0 + k)
(idealA N P σ t0 ds k)).1 (ds k)) (t0 + k + 1))).1
/-- Cumulative allocation of the request created by retailer `i` in period `t0`, of size `Q`,
after the allocation of period `t0 + k` along the ideal simulation (it is `Q` once the request
has left the queue). -/
def idealAlloc (N : Network n) (P : EngParams n) (σ : EngState n) (t0 : ℕ) (i : Fin n) (Q : ℝ)
(ds : ℕ → DemandVec n) (k : ℕ) : ℝ :=
match ((phaseB N.L { P with batch := fun _ => false } (t0 + k)
(idealA N P σ t0 ds k)).1.queue.find? (fun r => r.born = t0 ∧ r.ret = i)) with
| some r => r.alloc
| none => Q
/-- Total ideal depletion `X_{t0+k} = ∑_i (Γ_i - P̂_{i,t0+k})` after the requests of period
`t0 + k`. -/
def idealDepletion (N : Network n) (P : EngParams n) (σ : EngState n) (t0 : ℕ)
(ds : ℕ → DemandVec n) (k : ℕ) : ℝ :=
∑ i, (P.S i - phat N.L (idealA N P σ t0 ds k) (t0 + k) i)
/-- Quantity of a batch request (size `Q`, offset `ϑ`) shipped by the end of period `t0 + k`,
along the allocation path `A k` (cumulative allocation after the allocation of period `t0 + k`;
the allocation before creation is `0`). -/
def shippedPath (Q θ : ℝ) (A : ℕ → ℝ) : ℕ → ℝ
| 0 => if crossesThreshold Q θ 0 (A 0) then A 0 else 0
| k + 1 => if crossesThreshold Q θ (A k) (A (k + 1)) then A (k + 1) else shippedPath Q θ A k
/-- The credited full-lifetime proxy (C.29) of request `j` (retailer `i`, size `Q`, created in
period `t0` with state `σ`) for offset `ϑ`, given the demand vectors `ds` of periods
`t0, …, t0 + L₀ - 1`. -/
def proxy (N : Network n) (P : EngParams n) (σ : EngState n) (t0 : ℕ) (i : Fin n) (Q θ : ℝ)
(ds : ℕ → DemandVec n) : ℝ :=
N.K i * (1 + if θ < 1 / 3 then 2 else 1)
+ (N.h + N.p) * ∑ k ∈ Finset.range (N.L0 + 1),
max (idealAlloc N P σ t0 i Q ds k - shippedPath Q θ (idealAlloc N P σ t0 i Q ds) k
- idealDepletion N P σ t0 ds k) 0
/-- `z_j(ϑ)`: the proxy averaged over the fresh demand vectors of periods
`t0, …, t0 + L₀ - 1`. -/
def proxyMean (N : Network n) (P : EngParams n) (σ : EngState n) (t0 : ℕ) (i : Fin n)
(Q θ : ℝ) : ℝ≥0∞ :=
∫⁻ ds, ENNReal.ofReal (proxy N P σ t0 i Q θ (padHist N.L0 ds))
∂(Measure.pi fun _ : Fin N.L0 => N.μ)
open Classical in
/-- The deterministic offset rule of Lemma C.7: the first rational `ϑ ∈ (0,1)` in the enumeration
with `z_j(ϑ) < z̄_j + 2^{-j}`, where `z̄_j = ∫_0^1 z_j(ϑ) dϑ`. (Lemma C.7 shows such a `ϑ` exists;
the value `1/2` is only a formal default.) -/
def conRule (N : Network n) (c : ConChoice n) : OffsetRule n := fun σ t0 j i Q =>
let z : ℝ → ℝ≥0∞ := fun θ => proxyMean N c.params σ t0 i Q θ
let zbar : ℝ≥0∞ := ∫⁻ θ in Set.Ioo (0 : ℝ) 1, z θ
if h : ∃ k : ℕ, z ((c.enum k : ℚ) : ℝ) < zbar + (2 : ℝ≥0∞)⁻¹ ^ j then
((c.enum (Nat.find h) : ℚ) : ℝ)
else 1 / 2
/-! ## The policy -/
/-- One period of `π_con` (including the initialization): returns the state before demand, the
supplier order, and the dispatches. -/
def conStep (N : Network n) (c : ConChoice n) (t : ℕ) (st0 : EngState n) :
EngState n × ℝ × (Fin n → ℝ) :=
let st := receive st0 t
if st.running then runStep N.L0 N.L c.params (conRule N c) t st
else if t = N.Tpipe - 1 then
(sendOut N.L t (Pi.single c.sendTo st.Wbar) { st with Wbar := 0 }, 0,
Pi.single c.sendTo st.Wbar)
else if N.Tpipe - 1 < t ∧ N.Tpipe - 1 + N.L c.sendTo ≤ t ∧ ∀ i, st.I i ≤ c.S i then
runStep N.L0 N.L c.params (conRule N c) t
(startWith st t (fun i => c.S i - st.I i) c.initOffset)
else (st, 0, 0)
/-- The state of `π_con` at the start of period `t` along the demand sequence `d`. -/
def conRun (N : Network n) (x : InitState n) (c : ConChoice n) (d : ℕ → DemandVec n) :
ℕ → EngState n
| 0 => initEngState N x
| t + 1 => applyDemand (conStep N c t (conRun N x c d t)).1 (d t)
/-- The deterministic consolidation policy `π_con^{(m)}` of Definition 2 (the dependence on `m`
is through the choices `c`, constrained by `IsConChoice N m c`), from the initial state `x`. -/
def conPolicy (N : Network n) (x : InitState n) (c : ConChoice n) : DetPolicy n where
order t d := (conStep N c t (conRun N x c d t)).2.1
dispatch t d := (conStep N c t (conRun N x c d t)).2.2
end OWMR
Read-back
What the Lean code literally says, in plain math · claude-opus-5-5
This file defines several things for an arbitrary (indices , with allowed) and a network :
- five real functions of a real number ;
- a record type of choices , and a predicate on ;
- a forward simulation of an imported state machine, and three quantities read off from it;
- a proxy cost and its average;
- an offset rule;
- a one-period transition and the state sequence it generates;
- a deterministic policy built from , an initial datum and a choice .
The policy is defined for every choice . Neither the predicate nor enters it.
Conventions
- . A real number that is compared or combined with a value in is first replaced by .
- In the order is total, , , and with and . Hence for , , and for finite .
- Real division by gives .
- The real infimum over of a function that is unbounded below gives .
- A real-valued integral gives when its integrand is not integrable. Integrals with values in are lower Lebesgue integrals.
- Subtraction of natural numbers is truncated at .
- is the -fold product of a probability measure . is the unit mass on the single empty tuple, on which every sum is .
- For a tuple , is the sequence equal to for and to for .
Imported objects, unfolded
Network data
consists of:
- , and for each ;
- a probability measure on ;
- reals ;
- real vectors and .
Nothing in this file assumes any sign condition on these numbers. The following objects are derived from .
- is the law of under , and is the law of under . Both are probability measures on .
- , where the inner maximum is when . Also , which is the truncated subtraction used in the code.
- For , the functions and are given below. The sum runs over in the first line and over in the second.
When this gives .
Single-location functionals
Let be a probability measure on , let , and let .
(code name slValue). This is the infimum of the quantity displayed below, taken over:
- all probability spaces , and
- all maps that are nonnegative, measurable in for each , and nonanticipative, meaning whenever for all .
In the display, . Write .
(code name ssAvgCost), for reals . Given a sequence , set . Let if and otherwise, and let . Then:
(code name IsCanonicalOptimum) means all of the following:
- ;
- ;
- ;
- ;
- for all .
Because is finite, this forces .
(code name IsBestHalfWindow) means all of the following:
- ;
- ;
- for all reals with and . Both sides use fixed cost .
(code name renewalM):
Its term is . So for , and for .
Engine
Requests, states, parameters and rules.
- A request has an index , reals , , and , and a birth time .
- A state has:
- a flag , which is true or false;
- a real ;
- a vector ;
- real sequences and , for and (fields
supPipeandretPipe); - a finite ordered list of requests, called the queue;
- a counter .
- Engine parameters are , with , flags , and .
- An offset rule is any function of a state, two naturals , an index and a real .
Receipt and subtraction.
- adds to and adds to for each . The pipeline entries stay in place.
- , for , subtracts from .
- Neither operation changes anything else.
The quantity (code name phat):
The code writes the last sum as an unallocated part plus an allocated-but-unshipped part.
Phase A at time , with parameters and rule , applied to :
- The following are computed from :
- if , and otherwise;
- , the list of indices with , in increasing order;
- , as displayed below;
- if , and otherwise. No sign restriction is applied.
- The intermediate state is with three changes:
- is added to if , or to if ;
- for each in order, a request is appended to with , , , and ;
- is increased by the length of .
- The output is together with the number , with one change to . The request appended at position of , with index , gets offset if is true, and offset if is false.
Crossing predicate. holds if and only if at least one of these holds:
- ;
- and ;
- and .
Phase B at time , with parameters , applied to :
- Go through in order, with a running amount that starts at . For each request :
- let ;
- the shipped amount is if is false or holds, and otherwise;
- then increases by , increases by , and decreases by .
- Let .
- The new state has equal to the final . Its queue is the updated requests with , in the same order.
- Then, for each , is added to if , and to if . This last operation is the code's
sendOut. - Phase B also returns .
When is false, after the update.
Other engine operations.
- runs phase A at , then phase B at on the state phase A returns. It returns the state after phase B, the from phase A, and the from phase B.
- sets to true. For each with , in increasing order, it appends to a request with , , , and . It does not change .
- An initial datum consists of a real , a vector , and real sequences and . No validity condition is assumed. The state has:
- false;
- and ;
- for , and otherwise;
- for , and otherwise;
- an empty queue, and .
- Only startWith changes the flag . recv, dem, phases A and B, and sendOut leave it unchanged.
- A deterministic policy is a pair of maps and .
Declarations
Numeric parameters (conGammaBar, conG, conZeta, conB, conU)
For every real :
It follows that and for every , including under the convention below.
Values at :
- ;
- ;
- ;
- ;
- .
For no denominator vanishes, and , , and .
Real division by gives , so the degenerate cases are:
- : , and all equal . This gives , , , and .
- : here , so , and .
- exactly when , that is, or . At these values .
is used only through . The functions are used only in the choice predicate.
Choice record (ConChoice n)
A choice consists of:
- real vectors and ;
- flags , each true or false (field
batch); - reals and ;
- an index (field
sendTo); - a real vector (field
initOffset); - a bijection (field
enum), stored together with its inverse.
The record imposes no constraint between its fields. Because must lie in , no choice exists when . So for the predicate, the offset rule, the step, the run and the policy have no instances, and neither do the declarations that take an index .
Engine parameters of a choice (ConChoice.params)
with . All entries are copied from , and the center vector used in phase A's is the vector .
Choice predicate (IsConChoice N m c)
For a network , a real and a choice , the predicate is the conjunction of conditions (1) to (4).
Condition (1). For every , define in :
- First case, : is false, , and for all .
- Second case, : is true, and there exist reals such that holds and, with as displayed below:
- if , then holds;
- if , then and .
How the cases split:
- is totally ordered, so exactly one of the two cases applies to each . For the chosen witnesses , exactly one of the two sub-cases applies. Only one witness pair has to work.
- is always finite.
- If and , then and the first case applies.
- If , then (even when ), and the second case applies exactly when .
Values of inside the second case. Here gives and . Hence:
- if ;
- if ;
- if and ;
- otherwise is an ordinary ratio of positive reals.
The infimum in is the real infimum of over , which is if is unbounded below. Also at any where its integrand is not integrable.
Condition (2). If , there exist reals such that holds, , and . That is, both are shifted up by .
Condition (3). If , then , , and for all .
Condition (4). for every .
What is left unconstrained: if , nothing constrains and . Nothing constrains or .
The predicate fails whenever a required object does not exist:
- in the first case of (1), if has no global minimizer on ;
- in the second case of (1), if no canonical-optimum pair meets the applicable sub-case. For instance, there may be no canonical optimum at all, or, when , no best half window;
- in (2), if no canonical optimum exists;
- in (3), if has no nonnegative global minimizer on .
Ideal forward simulation (idealA N P σ t₀ ds)
The inputs are parameters , a state , a time , and a sequence in . Let be with every flag set to false, and use the offset rule that is identically . Then:
Here and are the states returned by phase A and phase B at time , with parameters and the lead times of .
- Each step does the following in order: phase B of period , subtract , receive at , and phase A of period .
- The first operation applied to is phase B of period .
- Because all flags are false, new requests get offset and the rule is never evaluated. Phase B ships every request's entire allocated-but-unshipped amount.
- The values are those of .
- depends only on .
Allocation read-off (idealAlloc N P σ t₀ i Q ds k)
Take and . Apply phase B at time , with parameters , to . In the resulting queue every request has , and only requests with remain. In that queue, take the first request , in queue order, with and .
- If such an exists, .
- Otherwise .
The fallback is used whenever no such request remains. For example, none was in , or its allocation has reached its size. Requests created inside the simulation are born at , so only requests already in can be found.
Depletion read-off (idealDepletion N P σ t₀ ds k)
- This is a sum over all indices, with taken from .
- It is evaluated on , before the phase B of period . For it is evaluated on itself.
- It does not depend on , or .
- It is when .
Shipped-quantity recursion (shippedPath Q θ α)
For reals and a real sequence :
Equivalently, for the largest at which the crossing predicate holds, comparing against , or against when . If there is no such , then .
Proxy (proxy N P σ t₀ i Q θ ds)
The ingredients are:
- , the allocation read-off for ;
- , the shipped-quantity recursion of ;
- , the depletion read-off for .
The first term is if , and otherwise. Here and are the scalars of . The sum has terms (only when ), and it uses only .
Proxy average (proxyMean N P σ t₀ i Q θ)
- This is a lower Lebesgue integral over independent draws from . The draws serve as , and the zero padding after them is never read.
- Negative values of count as .
- For , is evaluated with .
Offset rule (conRule N c)
Given a choice , the rule maps to a real number as follows. Let be the proxy average with parameters and these . Let be its lower Lebesgue integral over the open interval, with respect to Lebesgue measure:
The comparison, made in , is:
- If some satisfies it, the rule returns the real number for the least such . This is the first rational in the stored enumeration that satisfies the inequality, and it lies in .
- Otherwise the rule returns .
The fallback fires exactly when for every . In particular it fires whenever for all such . If , the inequality reads .
The rule uses only through and . It does not involve , or .
In the step below, the rule is evaluated only inside phase A, and only for indices with true. Its arguments there are:
- the intermediate state of that phase A, which already contains the period's and all of the period's new requests with offset ;
- equal to the current time;
- equal to the counter before that phase A, plus the position of in (counted from ), plus ;
- the index ;
- .
Per-period step (conStep N c t ξ)
For a time and a state , let . The step returns a triple: a state, an order quantity in , and a dispatch vector in . The first of these branches that applies is used:
- Running. If is true, the step returns , with parameters and the offset rule above.
- Send-out period. Otherwise, if :
- The state is with set to , after which the amount is sent to index . It is added to if , and to otherwise.
- The order quantity is .
- The dispatch vector has in coordinate and elsewhere.
- The flag stays false. Note that means when .
- Start-up. Otherwise, if , , and for every :
- The step returns , with parameters and the rule above, applied to .
- So the flag becomes true. For each with , whatever is, a request is appended before that period's phases A and B. It has size , allocation and shipped amount , offset and birth time .
- The two time conditions together say .
- Idle. Otherwise the step returns .
No sign restriction is applied to the returned order or dispatch quantities.
Run (conRun N x c d)
For an initial datum and a sequence in :
depends only on .
Starting from , which has flag false and an empty queue, the flag stays false and the queue stays empty until branch 3 fires. The branches occur in this order:
- branch 4 for ;
- branch 2 exactly once, at ;
- branch 4 again for , until the first that meets branch 3's conditions;
- branch 3 at that period;
- branch 1 at every later period.
If branch 3's conditions are never met, every period after has order and dispatch .
Policy (conPolicy N x c)
This is the deterministic policy with
where is the run above. By branch, these outputs are:
- branches 1 and 3: phase A's and phase B's vector ;
- branch 2: order , and dispatch in coordinate ;
- branch 4: both .
At time , both outputs depend on only through .
The policy is defined for every choice , whether or not the choice predicate holds, and it does not involve . It uses (through ), together with , and .