DefaultMultiEchelonCostFormulation

open class DefaultMultiEchelonCostFormulation @JvmOverloads constructor(network: MultiEchelonNetwork, val params: CostParams = CostParams(), name: String? = null, paramsResolver: (NetworkNodeIfc?) -> CostParams? = null) : ModelElement, CostFormulation(source)

Standard cost formulation for a MultiEchelonNetwork. Walks the network at construction time and instantiates one CostCalculator per source kind: per inventory, per backlog, per outbound edge (inbound and outbound), per load builder, plus one for the ES.

Pre-allocates a Response for every line × tier combination plus per-line, per-tier, and grand-total Responses; sums them in replicationEnded. KSL's tree walk visits the calculator children before this formulation's replicationEnded, guaranteeing the calculators' Responses are populated by the time the formulation's rollup runs.

Auto-attach. Construction also registers this formulation with network via MultiEchelonNetwork.attachCostFormulation, so it appears in the network's costFormulations snapshot without an explicit second call.

Transport-strategy support. All three TransportStrategy variants are supported:

  • SharedCarrier: per-edge counters do not exist, so flow-line Responses (Loading, Shipping, Unloading, ESLoading) report 0, matching the legacy framework's behaviour.

  • PerIHPTimeBased: each node owns its own ksl.modeling.supplychain.transport.TimeBasedDemandCarrier; the formulation builds one EdgeOutboundCostCalculator + EdgeInboundCostCalculator per edge plus one ESCostCalculator for the ES outbound.

  • NetworkTimeBased: a single shared ksl.modeling.supplychain.transport.TimeBasedNetworkDemandCarrier carries every edge; the formulation builds the network-typed variants (NetworkEdgeOutboundCostCalculator, NetworkEdgeInboundCostCalculator, NetworkESCostCalculator) which read per-edge counts keyed on (filler, sender).

Parameters

network

the network whose calculators this formulation manages. Used as the ModelElement parent so KSL's tree walk includes this formulation in the network's replicationEnded lifecycle (children-first ordering guarantees calculator Responses are populated before this formulation's rollup runs).

params

parameter bundle for the line-item calculators

name

optional ModelElement name

paramsResolver

optional per-node parameter override. When non-null, it is consulted for the CostParams each calculator should use, keyed by the calculator's owning node (the inventory's / backlog's / builder's holder, an outbound edge's supplier, an inbound edge's customer; null for the external supplier's own outbound). Returning the node's override or falling back to params is the resolver's responsibility. When null (the default), every calculator uses the single params bundle — the uniform-cost behaviour. Passed as a constructor parameter (not an overridable method) so it is available while the init block builds calculators, avoiding the open-call-from-constructor initialization-order trap.

See also

Inheritors

Constructors

Link copied to clipboard
constructor(network: MultiEchelonNetwork, params: CostParams = CostParams(), name: String? = null, paramsResolver: (NetworkNodeIfc?) -> CostParams? = null)

Properties

Link copied to clipboard

The calculators this formulation manages. Phase 2's skeleton formulation returns an empty collection; Phase 3 populates it with concrete calculator instances.

Link copied to clipboard
Link copied to clipboard
open override val totalCostResponse: ResponseCIfc

Grand-total rollup Response — the sum across every line and every tier this formulation produces.

Functions

Link copied to clipboard
protected open override fun beforeExperiment()

Coverage guard (audit finding G). buildCalculators runs once at construction, so any node, edge, inventory, or demand generator attached to the network after this formulation was built gets no calculator and contributes nothing to any rollup — silently. This runs once before the experiment (after simulate() is called but before the executive starts) and fails loud if the topology grew.

Link copied to clipboard
open override fun byLineResponse(line: CostLine): ResponseCIfc?

Per-line rollup Response — the sum of every calculator's lineResponses[line] for the most recent replication, or null if this formulation does not produce that line.

Link copied to clipboard
open override fun byTierAndLineResponse(tier: NodeTier, line: CostLine): ResponseCIfc?

Per-(tier, line) rollup Response — the sum of every calculator's lineResponses[line] whose CostCalculator.tier matches tier, or null if this formulation does not produce a rollup for this combination. Used by Phase-4 to re-point the legacy 16 cost responses on ksl.modeling.supplychain.network.MultiEchelonNetwork onto formulation-managed Responses.

Link copied to clipboard
open override fun byTierResponse(tier: NodeTier): ResponseCIfc?

Per-tier rollup Response — the sum of every calculator's lineResponses[*] whose CostCalculator.tier matches tier, or null if this formulation does not produce a per-tier rollup for tier.

Link copied to clipboard
protected open override fun replicationEnded()

Roll up the calculators' line Responses into the per-(tier, line), per-line, per-tier, and grand-total Responses.