DemandLoadBuilder

open class DemandLoadBuilder @JvmOverloads constructor(val supplyChainModel: SupplyChainModel, parent: ModelElement = supplyChainModel, name: String? = null, itemTypes: Collection<ItemType> = emptyList()) : ModelElement(source)

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

supplyChainModel

model that owns the created SupplyChainModel.DemandLoads

parent

parent model element; defaults to supplyChainModel

name

optional model-element name

itemTypes

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

Link copied to clipboard
constructor(supplyChainModel: SupplyChainModel, parent: ModelElement = supplyChainModel, name: String? = null, itemTypes: Collection<ItemType> = emptyList())

Types

Link copied to clipboard

Strategy used when a new demand arrives and the builder is asked to (possibly) form a load.

Properties

Link copied to clipboard
Link copied to clipboard

Read-only view of the waiting-demand queue.

Link copied to clipboard

Optional fire-on-form callback.

Link copied to clipboard

Optional user-supplied rule. Setting a non-null rule switches loadFormingOption to LoadFormingOption.RULE; setting null reverts to LoadFormingOption.NONE (Java parity).

Link copied to clipboard

Read-only view of the formed-load queue.

Link copied to clipboard

Read-only view of the loads-formed Counter.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Read-only view of total cube waiting in the demand queue.

Link copied to clipboard

Read-only view of total weight waiting in the demand queue.

Link copied to clipboard

Item types this builder is tracking on-hand units for.

Functions

Link copied to clipboard

Form a load using the current loadFormingOption.

Form a load using the supplied option.

Link copied to clipboard
fun formLoadByCount(numDemands: Int): Boolean

Form a load from the first numDemands entries in the demand queue, when at least that many are present.

Link copied to clipboard
fun formLoadByCube(minCube: Double, maxCube: Double): Boolean

Form a load by accumulating demands whose total cube stays within [minCube, maxCube].

Link copied to clipboard
fun formLoadByWeight(minWeight: Double, maxWeight: Double): Boolean

Form a load by accumulating demands whose total weight stays within [minWeight, maxWeight].

Link copied to clipboard

Accept demand into the waiting queue and try to form a load (unless loadFormingOption is LoadFormingOption.NONE).

Link copied to clipboard
fun setCubeFormingLimits(minCube: Double, maxCube: Double)

Update the cube limits used by LoadFormingOption.CUBE.

Link copied to clipboard

Discipline applied to demandQueue at the start of each replication.

Link copied to clipboard

Discipline applied to loadQueue at the start of each replication.

Link copied to clipboard
fun setWeightFormingLimits(minWeight: Double, maxWeight: Double)

Update the weight limits used by LoadFormingOption.WEIGHT.

Link copied to clipboard

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.

Link copied to clipboard

Time-weighted on-hand units of item sitting in the demand queue, or null if this builder was not constructed with per-item tracking for item.