| Title: | Logistics Chain Simulation under Dynamic Challenges |
|---|---|
| Description: | A research implementation of a fixed five-leg logistics chain with time-varying item specifications, imperfect observations, finite transport resources, route-risk learning, and static or adaptive disruptions. Supports reproducible allocation-rule comparisons, optional item-condition and processing models, and paired disruptions-disabled experiments. Includes synthetic teaching scenarios and nonparametric analysis helpers. The model and its decision heuristics require application-specific validation. |
| Authors: | R. Heller [aut, cre] |
| Maintainer: | R. Heller <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.6.0 |
| Built: | 2026-11-04 22:05:54 UTC |
| Source: | https://github.com/CTTIR/shieldR |
Adjust one explicitly defined family using Benjamini-Hochberg FDR
adjust_fdr(log10_p)adjust_fdr(log10_p)
log10_p |
Vector of base-10 log p-values, each at most zero. Missing
values are preserved and excluded from the family size. |
Adjusted log10 p-values in input order. The caller supplies each prespecified family separately; no SHIELD hypothesis grid is embedded.
Percentile intervals for independent arms or explicitly paired batch
outcomes. The caller must establish pairing before passing paired vectors.
Prefer compare_intervention() when working with complete shield_run objects,
because it also verifies settings and replication identities.
bootstrap_statistic( x, y, statistic = c("cliffs_delta", "median_difference", "mean_difference"), paired = FALSE, B = 10000L, conf = 0.95, seed = 20260512L )bootstrap_statistic( x, y, statistic = c("cliffs_delta", "median_difference", "mean_difference"), paired = FALSE, B = 10000L, conf = 0.95, seed = 20260512L )
x, y
|
Nonempty finite numeric vectors. |
statistic |
One of cliffs_delta, median_difference or mean_difference. |
paired |
Logical. If TRUE, resample matching indices jointly. |
B |
Positive integer resample count, default 10,000. |
conf |
Confidence level strictly between zero and one. |
seed |
Bootstrap seed, default 20260512. |
Named vector with est, lwr and upr; orientation is x minus y. Caller RNG state is restored. Intervals quantify Monte Carlo uncertainty conditional on the model and do not propagate parameter uncertainty.
Uses deterministic expected competing risks on a fixed supplied service sample. Fits degradation and early/late residual coefficients. Numerical interval integration is explicit. Aggregate fitting is not item validation and does not identify unserviced pre-service trajectories.
calibrate_item_model(model, control, fragility, targets, intake = 0, step = 5)calibrate_item_model(model, control, fragility, targets, intake = 0, step = 5)
model |
Item model configuration; initial coefficient values positive. |
control |
Vector of damage-to-stabilization times, Inf for failures. |
fragility |
Positive vector of corresponding fragility weights. |
targets |
Named vector: loss_24, loss_30, degradation_24. |
intake |
Nonnegative damage-to-intake offset in minutes. |
step |
Integration interval in minutes. |
List with fitted model, expected outcomes and optimizer convergence.
Checks that the two runs have matching parameters, policy, disruption_model, replication identifiers and seeds, with disruptions enabled only in the first. Rows are aligned by replication identifier. The contrast is no disruptions minus disruptions, a total modelled intervention effect that includes downstream and administrative-horizon effects. It is not direct disruption loss.
compare_intervention( disruptions, no_disruptions, endpoint = "viable_stage2", B = 10000L, seed = 20260512L )compare_intervention( disruptions, no_disruptions, endpoint = "viable_stage2", B = 10000L, seed = 20260512L )
disruptions, no_disruptions
|
|
endpoint |
Arrival viability at Stages 1–3, or item |
B |
Positive integer paired bootstrap resamples; default 10,000. |
seed |
Bootstrap seed; default 20260512. |
One row with paired mean difference and percentile 95 percent interval on the proportion scale. Replication indices are resampled jointly.
Kruskal-Wallis comparison of multiple independent arms
compare_multiple(values, groups, family = "comparison")compare_multiple(values, groups, family = "comparison")
values |
Finite batch-level outcomes. |
groups |
Nonmissing group labels of the same length, at least three arms. |
family |
Explicit comparison-family label. |
One row containing H, degrees of freedom and raw and log10 p-values. This is an omnibus test. Pairwise contrasts and multiplicity gates must be specified by the study; no post-hoc test is selected automatically.
Applies a two-sided, tie-corrected Mann-Whitney U approximation, Cliff's
delta and percentile bootstrap intervals for delta and the median difference.
Positive effects favour x. This test compares distributions; it is not
specifically a test of medians. Observations must be independent batches.
Normality testing is not a prerequisite. Intervals describe Monte Carlo
sampling uncertainty conditional on the assumed model.
compare_policies( x, y, label_x = "x", label_y = "y", family = "comparison", B = 10000L, seed = 20260512L )compare_policies( x, y, label_x = "x", label_y = "y", family = "comparison", B = 10000L, seed = 20260512L )
x, y
|
Nonempty finite numeric vectors from independent arms. |
label_x, label_y
|
Arm labels. |
family |
Explicit comparison-family label; no automatic FDR grouping. |
B |
Positive integer bootstrap resamples; default 10,000. |
seed |
Bootstrap seed; default 20260512. |
One-row data frame containing U, raw and log10 p-values, sample sizes,
medians and quartiles, Cliff's delta and median difference with percentile
95 percent intervals. p_raw_log10 is authoritative for very small tails;
p_raw is floored at the smallest normal positive double when necessary.
Point intervals are flagged. Apply adjust_fdr() to an explicitly defined
family of comparisons. The caller's RNG state is restored.
Describe Cliff's delta using conventional magnitude thresholds
effect_magnitude(delta)effect_magnitude(delta)
delta |
Finite numeric Cliff's delta values in |
Character magnitude labels. These descriptive thresholds are not application-specific importance margins and do not establish practical benefit.
Both examples use equal abstract travel durations and zero exposure and
item-condition hazards. They do not contain the controlled study inputs.
constrained reduces vehicle availability and shortens the horizon to
illustrate congestion and administrative censoring.
example_scenario(kind = c("balanced", "constrained"), N = 6L)example_scenario(kind = c("balanced", "constrained"), N = 6L)
kind |
Either |
N |
Positive integer batch size. |
A shield_parameters() object.
set.seed(20260512) scenario <- example_scenario(N = 4L) result <- simulate_shield(scenario, n_rep = 2L) summarize_shield(result)set.seed(20260512) scenario <- example_scenario(N = 4L) result <- simulate_shield(scenario, n_rep = 2L) summarize_shield(result)
Mann-Whitney U with log-scale tail probabilities
mann_whitney_u(x, y)mann_whitney_u(x, y)
x, y
|
Finite independent batch-level observations. |
List U, p, p_log10, z, underflow. The log probability is authoritative
for very small tails. The linear value is floored if necessary. Uses the
same two-sided, tie- and continuity-corrected approximation as
compare_policies(). No preliminary normality test is performed.
Construct the reproducible seed schedule for a complete cell
replication_seeds(n_rep, seed = 20260512L)replication_seeds(n_rep, seed = 20260512L)
n_rep |
Positive integer total number of batch replications. |
seed |
Master/cell seed, default 20260512. |
Integer vector of length n_rep. Generate the complete schedule once; chunking must not change its declared length or resample the schedule.
A local scenario workbench with an editable five-leg graph, independent
policy comparisons and paired disruptions-disabled interventions. Teaching
presets have zero item-condition hazards and zero exposure. Every edited
scenario is validated by shield_parameters() before simulation.
shield_app(launch = TRUE, ...)shield_app(launch = TRUE, ...)
launch |
Logical. If |
... |
Passed to |
The primary endpoint is live arrival at Stage 2 by the administrative
horizon. Arrival-time summaries condition on observed arrivals. The coupled
policy is a heuristic, and neither the app nor its examples establish
application-specific validity. Simulations use simulate_shield();
comparisons use the documented package analysis functions, with 10,000
bootstrap resamples. The interactive workload is bounded; use scripts for
full study runs. Independent policy arms use distinct master seeds; paired
intervention arms use identical seeds and replication counts.
Requires the optional packages shiny, bslib, DT and ggplot2.
The app uses local system fonts and makes no external data requests.
Uploads and results remain in the running R process unless downloaded.
Use host = "127.0.0.1" (the Shiny default) for local-only access.
A shiny.appobj, invisibly when launched.
if (interactive()) { shield_app() }if (interactive()) { shield_app() }
Neutral defaults switch off item-condition and disruption hazards. They are synthetic settings rather than calibrated application parameters. The topology is fixed: Source, Collection, parallel Transfer nodes, parallel Stage 1 nodes, Stage 2 and Stage 3. Every leg has routes A, B and C. Time is in whole minutes. A live arrival at Stage 2 ends item-condition hazard. Stage 3 is terminal.
shield_parameters( graph, N = 20L, horizon = 60L, slot = 1L, departure_holds = 0:2, h = c(0, 0, 0), esc32 = 0, esc21 = 0, mix = NULL, reassess = 1L, misclass = 0, t_load = 1L, t_unload = 1L, disruption_risk = c(low = 0, high = 0), disruption_risk_level = c("low", "high"), p_cap = 1, q = 0, att_delay = 0L, lambda = 0, atk_window = 1L, beta = 1, beta_prior = c(1, 1), eps_time = 1e-04, disruptions_enabled = FALSE, hazard_band = 1 )shield_parameters( graph, N = 20L, horizon = 60L, slot = 1L, departure_holds = 0:2, h = c(0, 0, 0), esc32 = 0, esc21 = 0, mix = NULL, reassess = 1L, misclass = 0, t_load = 1L, t_unload = 1L, disruption_risk = c(low = 0, high = 0), disruption_risk_level = c("low", "high"), p_cap = 1, q = 0, att_delay = 0L, lambda = 0, atk_window = 1L, beta = 1, beta_prior = c(1, 1), eps_time = 1e-04, disruptions_enabled = FALSE, hazard_band = 1 )
graph |
Data frame with exactly the columns |
N |
Positive integer batch size. |
horizon |
Positive integer administrative horizon in minutes. |
slot |
Positive integer dispatch interval in minutes. |
departure_holds |
Increasing nonnegative whole-minute holds, starting
at zero; each must be a multiple of |
h |
Three finite nonnegative instantaneous loss rates for classes
1, 2 and 3, before multiplication by |
esc32, esc21
|
Nonnegative class escalation rates before scaling. |
mix |
Three integer class counts summing to |
reassess |
Positive integer observation interval in minutes. |
misclass |
Probability of an adjacent-class observation error. |
t_load, t_unload
|
Positive integer loading and unloading durations. |
disruption_risk |
Named vector of probabilities with names |
disruption_risk_level |
Selected named disruption_risk level. |
p_cap |
Maximum disruption probability, in (0, 1]. |
q |
Conditional disruption destructiveity probability and security-loss weight. |
att_delay |
Nonnegative integer nondestructive disruption delay in minutes. |
lambda |
Nonnegative finite response parameter. |
atk_window |
Positive integer nominal departure-history window. |
beta |
Nonnegative finite policy softmax parameter. |
beta_prior |
Two strictly positive Beta prior shapes. |
eps_time |
Positive route-time tie-break weight for P2. |
disruptions_enabled |
Logical; whether to simulate disruption outcomes. |
hazard_band |
Positive multiplier of loss and escalation rates. |
A shield_parameters list. Treat derived fields as read-only and
reconstruct through this function when changing a scenario.
Uses the stochastic item event engine with unlimited procedural capacity and no transport or disruption_risk. All items are eligible at intake. Reports outcomes on the intake clock, which differs from the chain's damage clock. This is a numerical calibration check, not external validation.
simulate_item_reference(model, N = 100L, intake = 0, seed = 20260512L)simulate_item_reference(model, N = 100L, intake = 0, seed = 20260512L)
model |
Item configuration. |
N |
Positive batch size. |
intake |
Damage-to-intake offset in minutes. |
seed |
Integer seed, default 20260512. |
Named vector of intake-clock loss and degradation loss risks.
This entry point supports external schedulers and durable checkpoints.
The seed is a replication seed, not a cell/master seed. Obtain a complete
schedule with replication_seeds() before splitting work into chunks.
The caller's RNG kind and state are restored, including on error.
simulate_replication( parameters, policy = c("P0", "P1", "P2", "P3"), disruption_model = c("static", "adaptive"), replication_seed = 20260512L )simulate_replication( parameters, policy = c("P0", "P1", "P2", "P3"), disruption_model = c("static", "adaptive"), replication_seed = 20260512L )
parameters |
A |
policy |
One of P0, P1, P2, P3. |
disruption_model |
Either static or adaptive. |
replication_seed |
One nonnegative integer seed. |
One-row data frame of batch outcomes, without study identifiers.
Each row represents one batch. All items enter at time zero. The engine advances in one-minute intervals and preserves the original event ordering. P0 uses initial true class and a fixed route; P1 uses noisy reassessment; P2 updates route beliefs; P3 couples reassessment, route, destination and departure holds. P3 knows the specified disruption_model response model and uses an entropy-regularized heuristic. It does not solve an equilibrium.
simulate_shield( parameters, policy = c("P0", "P1", "P2", "P3"), disruption_model = c("static", "adaptive"), n_rep = 10L, seed = 20260512L, disruptions_enabled = parameters$disruptions_enabled )simulate_shield( parameters, policy = c("P0", "P1", "P2", "P3"), disruption_model = c("static", "adaptive"), n_rep = 10L, seed = 20260512L, disruptions_enabled = parameters$disruptions_enabled )
parameters |
Object created by |
policy |
One of P0, P1, P2 or P3. |
disruption_model |
Either |
n_rep |
Positive integer replication count. The package default is deliberately small; choose study size using a Monte Carlo precision assessment. |
seed |
Integer seed; default 20260512. |
disruptions_enabled |
Optional logical override of the scenario setting. |
The master seed creates a per-replication seed schedule. Item, policy and disruption streams are separated using L'Ecuyer-CMRG. Item draws are indexed by item and minute. The caller's RNG kind and seed are restored. Equal seeds and equal replication counts support an disruptions-disabled pair. Use distinct seeds for independent policy arms.
A shield_run data frame with replication identifiers and seeds,
viability-to-arrival proportions at Stages 1–3, conditional arrival-time
medians, disruptions, dispatches, holds, route counts and resource utilization.
Scenario parameters, software version and RNG kind are stored as attributes.
For the legacy mode the primary endpoint is viable_stage2. The opt-in
with_item_model() extension adds overall viable_30d from damage,
viable_24h, cause-specific loss and servicing-access endpoints. Its risk
continues after arrival; it does not establish application-specific validity.
Viable nonarrivals at the transport horizon are
endpoint failures; missing arrival times remain NA.
Summarize batch outcomes
summarize_shield(x)summarize_shield(x)
x |
A |
Data frame of endpoint names, valid and missing replication counts, median, first quartile and third quartile. Arrival-time summaries are across defined batch medians, not pooled item times.
Separates item information use and P3 anticipation while keeping item deterioration, observation draws and decision architecture unchanged.
with_decision_controls(parameters, item = c("updated", "initial_observed"), anticipation = c("known_model", "reactive"))with_decision_controls(parameters, item = c("updated", "initial_observed"), anticipation = c("known_model", "reactive"))
parameters |
A |
item |
Use updated observations or retain the first observed class. |
anticipation |
Use the specified-response forecast or current risk estimates. |
All controlled policies start from the first noisy observation. The initial-observation arm retains this signal; updated arms use the latest scheduled observation. P3 reactive controls update risk estimates but do not forecast changes from committed future departures. Candidate actions, weights, queues and randomization remain identical. The anticipation switch is unused by P0, P1 and P2. Uncontrolled parameters retain legacy behavior. No servicing model or equilibrium solution is introduced, and existing reservations are not replanned after a new item observation. Use a separate experiment identifier and distinct seeds for independent policy arms.
A new parameter object with recorded decision_controls.
set.seed(20260512) p <- with_decision_controls(example_scenario(N = 2L), item = "initial_observed", anticipation = "reactive") simulate_shield(p, policy = "P3", n_rep = 1L)set.seed(20260512) p <- with_decision_controls(example_scenario(N = 2L), item = "initial_observed", anticipation = "reactive") simulate_shield(p, policy = "P3", n_rep = 1L)
The caller supplies coefficients and explicit processing and observation assumptions for abstract logistics items. The model tracks degradation and other loss processes, finite processing capacity, and noisy item specifications. The condition index is dimensionless and synthetic. Coefficients and thresholds require validation for each application; this is not a calibrated materials model.
with_item_model(parameters, model, planner = model)with_item_model(parameters, model, planner = model)
parameters |
A shield_parameters object. |
model |
Named list: degradation_scale, early_other, late_other, tau, residual, prep (min/mode/max), processing (min/mode/max), failure, capacity, fragility (three positive weights), sensitivity, specificity, persistence, missing, refresh, delivery, useful_updates, item_age. Rates are cumulative coefficients; tau and all times are minutes. |
planner |
Same schema, fixed across truth sensitivity conditions. |
A new parameter object with an opt-in item configuration.