Inventory

open class Inventory @JvmOverloads constructor(parent: ModelElement, itemType: ItemType, policy: InventoryPolicyAbstract, initialOnHand: Int = 0, mayPartiallyFill: Boolean = true, name: String? = null) : DemandFillerAbstract, InventoryIfc, DemandSenderIfc, InventoryStatisticsIfc(source)

A stocking point for a single ItemType. Holds inventory, fills customer demands, requests replenishment from a supplier, and optionally backlogs demands it cannot fill immediately.

Construct with an InventoryPolicyAbstract that controls when replenishment is requested. A BackLogPolicyAbstract is attached separately by constructing one with this inventory as its parent — the backlog policy's init block establishes the bidirectional link via setBackLogPolicy.

Parameters

parent

the parent model element (must be reachable to a SupplyChainModel so replenishment demands can be created)

itemType

the single ItemType this inventory carries

policy

the replenishment policy

initialOnHand

initial stock at the start of each replication

mayPartiallyFill

whether the inventory may partially fill an incoming demand

name

optional model-element name

See sc.inventorylayer.Inventory

Constructors

Link copied to clipboard
constructor(parent: ModelElement, itemType: ItemType, policy: InventoryPolicyAbstract, initialOnHand: Int = 0, mayPartiallyFill: Boolean = true, name: String? = null)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

Whether incoming customer demands may be backlogged here.

Link copied to clipboard
open override val amountOnHand: Int

Units currently on hand.

Link copied to clipboard
open override val amountOnOrder: Int

Units currently on order (in replenishment).

Link copied to clipboard
Link copied to clipboard
open override val backLogInfo: BackLogInfoIfc

The inventory's backlog info.

Link copied to clipboard

Currently attached backlog policy, or null.

Link copied to clipboard
Link copied to clipboard
open override var demandFiller: DemandFillerIfc?

Direct filler override; if set, used instead of demandFillerFinder.

Link copied to clipboard

Finder used to locate a filler for each generated demand.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open override val inventoryPosition: Int

amountOnHand + amountOnOrder − backlog, the usual inventory-position metric used by reorder policies.

Link copied to clipboard
Link copied to clipboard
open override val itemTypes: Collection<ItemType>

All item types this filler is willing to fill.

Link copied to clipboard

Counter of lost-sale events (per-replication, post-warmup). Fires when a stockout demand is rejected (either because the demand is non-backloggable, or because this inventory is not configured to allow backlogging). Subset of stockoutCounter — a stockout that gets backlogged is not a lost sale.

Link copied to clipboard
Link copied to clipboard

Read-only response views for external observers and aggregates.

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

Current count of replenishment orders observed this replication.

Link copied to clipboard

Whether replenishment demands this inventory sends may be backlogged.

Link copied to clipboard

Whether replenishment demands this inventory sends may be partially filled.

Link copied to clipboard

Policy-level reaction invoked when a replenishment this inventory sent is rejected by its filler. Defaults to an InventoryReplenishmentRejectionListener whose dispatch methods throw (fail-loud). Replace it before simulating with a subclass that handles rejection gracefully — to retry, route to an alternate supplier, or record-and-continue.

Link copied to clipboard

Counter of stockout events (per-replication, post-warmup). A stockout fires every time a customer demand arrives and finds amountOnHand < remainingDemand, regardless of whether the demand is then backlogged or rejected. Drives the stockout-cost line in the cost model.

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

Total units ordered upstream across all replenishment requests in the replication (post-warmup). Incremented by qty at each requestReplenishment(qty) call. Drives variable-quantity ordering-cost formulations.

Link copied to clipboard

Total units short across all stockout events in the replication (post-warmup). Incremented by remainingDemand − amountOnHand at each stockout. Drives the unit-shortage-cost line.

Functions

Link copied to clipboard
open override fun canFillItemType(type: ItemType): Boolean

True if this filler can fill demands of type.

open override fun canFillItemType(demand: SupplyChainModel.Demand): Boolean

True if this filler can fill demands of demand's item type.

Link copied to clipboard

The status demand would receive if filled now. Only valid at the current simulation time.

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

Fill a previously received demand. Must be called at the same simulation time as the receipt — no time may elapse between receive and fillDemand.

Link copied to clipboard
protected open override fun initialize()

Resets availability to initialAvailability before each replication. The Java original had a typo (intialize) so it never actually overrode the framework hook; this port fixes the override.

Link copied to clipboard
open override fun mightRequest(type: ItemType): Boolean

True if this sender may produce demands of type.

Link copied to clipboard

Returns a DemandMessageIfc describing what would happen if demand were sent now, or null if negotiation is not supported.

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

Receive demand and place it in SupplyChainModel.received, or reject by transitioning to SupplyChainModel.rejected. The filler may set the demand's SupplyChainModel.Demand.status to indicate the rejection reason but is not required to.

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

Capture an InventoryCostObservables snapshot of this inventory's current within-replication state. Intended to be called from a cost calculator's ModelElementObserver.replicationEnded(this) callback, when KSL guarantees the within-replication statistics are stable for the post-warmup window.

Link copied to clipboard
open override fun toString(): String

Includes the model name, the id, the model element name, the parent name, and parent id

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

True if demand would be rejected if filled now.