TimeBasedDemandCarrier

open class TimeBasedDemandCarrier @JvmOverloads constructor(parent: ModelElement, name: String? = null) : DemandCarrierAbstract(source)

Demand carrier that delays each shipment by a per-DemandSenderIfc random transport time. Senders without a configured time are either rejected with NoCarrierOptionException or, if immediateTransportFlag is true, shipped and delivered immediately (zero simulated time).

Statistics: numInTransitResponse (time-weighted by SupplyChainModel.Demand.amountFilled) and transitTimeResponse (per-shipment transit time) are updated for every shipment.

Parameters

parent

the parent model element

name

optional model-element name

See sc.transportlayer.TimeBasedDemandCarrier

Inheritors

Constructors

Link copied to clipboard
constructor(parent: ModelElement, name: String? = null)

Properties

Link copied to clipboard

When true, demands whose sender has no configured transport time are shipped and delivered immediately (zero simulated time) instead of throwing NoCarrierOptionException. Default false.

Link copied to clipboard

Read-only view of the amount-in-transit response.

Link copied to clipboard

Read-only view of the per-shipment transit-time response.

Functions

Link copied to clipboard
open override fun canShip(demand: SupplyChainModel.Demand): Boolean

Side-effect-free probe: returns true iff demand would route successfully under the carrier's current configuration. A false result indicates transportDemand would either throw or silently drop the demand. Useful as a self-guard inside carrier implementations and as a configuration test from external code.

Link copied to clipboard

True if a transport time has been configured for sender.

Link copied to clipboard

Per-destination demand-shipment counter, or null if no transport time has been registered for sender. Counts individual demands shipped to sender via this carrier in the current replication.

Link copied to clipboard

Per-destination demand-shipment count, or 0 if sender is unregistered.

Link copied to clipboard
protected fun recordShipmentArrival(amountInTransit: Double, transitTime: Double)

Record that a shipment carrying amountInTransit units has arrived after transitTime in transit: decrements the in-transit response and observes the transit time. Pairs with recordShipmentDeparture.

Link copied to clipboard
protected fun recordShipmentDeparture(amountInTransit: Double)

Record that a shipment carrying amountInTransit units has departed: increments this carrier's in-transit response. A hook for subclasses (e.g. TimeBasedLoadCarrier) that dispatch through their own path but should still feed the inherited numInTransitResponse / transitTimeResponse. Pair every call with a later recordShipmentArrival of the same amount.

Link copied to clipboard

Create the per-destination shipment / weight / cube counters for sender if they do not yet exist. KSL forbids new ModelElements after the executive starts, so this is a construction-time operation. Call it for any destination that may receive a shipment under immediateTransportFlag without a configured transport time — otherwise the per-destination counters never get created and the increments in transportDemand silently no-op (audit finding D). setTransportTime already calls this.

Link copied to clipboard
fun setTransportTime(sender: DemandSenderIfc, distribution: RVariableIfc)

Register (or replace) the transport-time distribution used for sender. The supplied distribution is wrapped in a new RandomVariable (per porting plan §4.1) the first time the sender is added; subsequent calls swap the underlying source.

Link copied to clipboard

Per-destination cumulative cube of all shipments sent to sender in the current replication (post-warmup), or null if sender is unregistered.

Link copied to clipboard

Per-destination cumulative weight of all shipments sent to sender in the current replication (post-warmup), or null if sender is unregistered. In this base class, the shipment unit is a single demand, so the accumulator sums demand.weight across every transportDemand(demand) call. Subclasses (TimeBasedLoadCarrier) override to attribute load-level weight instead.

Link copied to clipboard
open override fun transportDemand(demand: SupplyChainModel.Demand)

Transport demand from its origin to its destination.

Link copied to clipboard

Lookup hook for subclasses that need to schedule shipments on the same per-sender distributions (e.g. TimeBasedLoadCarrier dispatching load shipments).