Demand Load Builder
Holds incoming demands in a queue and packages them into SupplyChainModel.DemandLoads. Automatic load formation is driven by loadFormingOption; the ALWAYS default forms a single-demand load per arriving demand.
Custom strategies hook in via loadFormingRule (replaces the built-in option) and loadFormedListener (fires after each automatically formed load).
Optional per-item on-hand tracking: when itemTypes is non-empty, the builder creates one TWResponse per item type and tracks the time-weighted average number of units of that item sitting in the demand queue. Read each via unitsOnHandResponse; consumed by the network cost model to compute shipmentBuildingHoldingCost. When itemTypes is empty (the default), no per-item TWResponses are created and the cost line stays at 0 — opt-in.
RULE-mode caveat: a custom DemandLoadFormingRuleIfc that removes demands from demandQueue directly (rather than via formLoadByCount / formLoadByWeight / formLoadByCube / formLoadAlways) will not decrement the per-item TWResponses, leaving them stale. RULE-mode users who care about shipmentBuildingHoldingCost accounting must use the built-in form helpers or maintain their own stats. Documented limitation, not a guard.
Parameters
model that owns the created SupplyChainModel.DemandLoads
parent model element; defaults to supplyChainModel
optional model-element name
item types this builder may carry; required for per-item on-hand TWResponse tracking. Pre-create them at construction time because KSL forbids adding stats elements once the simulation is running.
See sc.transportlayer.DemandLoadBuilder
Constructors
Types
Properties
Read-only view of the waiting-demand queue.
Optional fire-on-form callback.
String view of loadFormingOption for the controls machinery (string controls carry String values; the property itself remains the type-safe enum). Setting a valid option name applies the corresponding LoadFormingOption; values outside the allowed set are rejected by the control machinery with a ControlUpdateException. Assigning loadFormingRule still flips the option to RULE, exactly as before — this adapter adds a control surface, not new behavior.
Optional user-supplied rule. Setting a non-null rule switches loadFormingOption to LoadFormingOption.RULE; setting null reverts to LoadFormingOption.NONE (Java parity).
Read-only view of the formed-load queue.
Read-only view of the loads-formed Counter.
Maximum cube threshold for LoadFormingOption.CUBE; must be >= the minimum when used (validated pairwise at replication start).
Maximum weight threshold for LoadFormingOption.WEIGHT; must be >= the minimum when used (validated pairwise at replication start).
Minimum cube threshold for LoadFormingOption.CUBE; must be > 0 when used (validated pairwise at replication start).
Minimum weight threshold for LoadFormingOption.WEIGHT; must be > 0 when used (validated pairwise at replication start).
Read-only view of total cube waiting in the demand queue.
Read-only view of total weight waiting in the demand queue.
Item types this builder is tracking on-hand units for.
Functions
This method should be overridden by subclasses that need actions performed prior to each replication. It is called prior to each replication and can be used to initialize the model element. It is called before initialize() is called.
Form a load using the current loadFormingOption.
Form a load using the supplied option.
Form a load from the first numDemands entries in the demand queue, when at least that many are present.
Form a load by accumulating demands whose total cube stays within [minCube, maxCube].
Form a load by accumulating demands whose total weight stays within [minWeight, maxWeight].
Accept demand into the waiting queue and try to form a load (unless loadFormingOption is LoadFormingOption.NONE).
Update the cube limits used by LoadFormingOption.CUBE.
Discipline applied to demandQueue at the start of each replication.
Discipline applied to loadQueue at the start of each replication.
Update the weight limits used by LoadFormingOption.WEIGHT.
Capture a BuilderCostObservables snapshot from this builder. Loops over DemandLoadBuilder.trackedItemTypes and reads each item's TW-average units-on-hand; returns an empty per-item map when the builder was constructed without an itemTypes list.