StationNetwork

A StationNetwork is a container that models a queueing network as a graph of receivers (stations) connected by senders/routers. It owns the network-level responses that essentially every queueing model re-derives by hand — the number in the system, the total time in the system, and the number completed — and it provides a name registry, named boundary ports (ingress/egress), and a lifecycle event stream so that the network is an open, observable system.

Stations are created through the helper functions (source, singleQStation, activityStation, sink) so that each station is parented to the network, named consistently, and registered for lookup and validation. The helpers are intentionally plain functions; a type-safe builder DSL is layered on top of them separately.

Expose StationNetworkCIfc to clients that only need to observe the network.

Parameters

parent

the model element serving as this network's parent

name

the name of the network

Constructors

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

Properties

Link copied to clipboard
open override val classNames: Set<String>

The registered QObject class names within the network.

Link copied to clipboard
open override val holdingsAtRunEnd: ResponseCIfc

Diagnostic: the number of entities still holding allocations at the end of each replication. Non-zero typically reflects work-in-process at the end of a terminating run (normal); a steadily growing value across replications suggests a leak (an entity that seized but never released — surfaced more precisely by the exit-time validation in sinks/transfers/joins/separates).

Link copied to clipboard
open override val nodeNames: Set<String>

The registered node names within this network.

Link copied to clipboard
open override val numCompleted: CounterCIfc

The number of QObject instances that have left the network.

Link copied to clipboard
open override val numInSystem: TWResponseCIfc

The number of QObject instances currently within the network.

Link copied to clipboard
open override val systemTime: ResponseCIfc

The total time that a QObject instance spends from creation to leaving the network.

Functions

Link copied to clipboard
fun activityStation(name: String, activityTime: RVariableIfc = ConstantRV.ZERO, nextReceiver: QObjectReceiverIfc = NotImplementedReceiver): ActivityStation

Creates an ActivityStation (pure delay, no resource contention) parented to the network and registered under name.

Link copied to clipboard

The allocations qObject currently holds, in seize order (possibly empty).

Link copied to clipboard
open override fun arcs(): List<NetworkArc>

The directed connections between registered nodes (best-effort static graph).

Link copied to clipboard
open override fun attachNetworkObserver(observer: NetworkObserver)

Attaches an observer for the network's lifecycle events.

Link copied to clipboard
fun batchStation(name: String, batchSize: Int, nextReceiver: QObjectReceiverIfc = NotImplementedReceiver): BatchStation

Creates a BatchStation that forms batches of batchSize instances, parented to the network and registered under name.

Link copied to clipboard
fun blockingStation(name: String, bufferCapacity: Int, activityTime: RVariableIfc, nextReceiver: QObjectReceiverIfc = NotImplementedReceiver): BlockingStation

Creates a BlockingStation (finite buffer, block-after-service), parented to the network and registered under name.

Link copied to clipboard
open override fun classNumCompleted(className: String): CounterCIfc?

The per-class number completed, or null if className is not registered.

Link copied to clipboard
open override fun classSystemTime(className: String): ResponseCIfc?

The per-class total time in the system, or null if className is not registered.

Link copied to clipboard
open override fun detachNetworkObserver(observer: NetworkObserver)

Detaches a previously attached observer.

Link copied to clipboard
fun forkStation(name: String, join: JoinStation, childCount: ChildCountIfc, childFactory: ChildFactoryIfc? = null, childReceiver: QObjectReceiverIfc = NotImplementedReceiver, nextReceiver: QObjectReceiverIfc = NotImplementedReceiver): ForkStation

Creates a ForkStation (the send side of a fork-join pair) tied to a paired join, parented to the network and registered under name.

Link copied to clipboard
fun gateStation(name: String, nextReceiver: QObjectReceiverIfc = NotImplementedReceiver, initiallyOpen: Boolean = true): GateStation

Creates a GateStation (holds instances while closed), parented to the network and registered under name.

Link copied to clipboard
fun ingress(name: String, firstReceiver: QObjectReceiverIfc = NotImplementedReceiver): IngressStation

Creates an IngressStation (a non-generating entry port for transferred or externally created instances), parented to the network and registered under name.

Link copied to clipboard
protected open override fun initialize()

This method should be overridden by subclasses that need actions performed to initialize prior to a replication. It is called once before each replication occurs if the model element wants initialization. It is called after beforeReplication() is called

Link copied to clipboard
fun joinStation(name: String, nextReceiver: QObjectReceiverIfc = NotImplementedReceiver): JoinStation

Creates a JoinStation (the receive side of a fork-join pair), parented to the network and registered under name. Route to a specific input with the "name#0" (parent) or "name#1" (child) target syntax.

Link copied to clipboard
fun matchStation(name: String, numInputs: Int, keyExtractor: (ModelElement.QObject) -> Any? = null, nextReceiver: QObjectReceiverIfc = NotImplementedReceiver): MatchStation

Creates a MatchStation (assembles one instance from each input, optionally by a matching key). Wired through its MatchStation.input endpoints, so it is network-parented but not a single routing node.

Link copied to clipboard
fun nhppSource(name: String, rateFunction: PiecewiseRateFunction, firstReceiver: QObjectReceiverIfc = NotImplementedReceiver, streamNum: Int = 0, maxArrivals: Long = Long.MAX_VALUE, marking: (ModelElement.QObject) -> Unit? = null): NHPPSource

Creates an NHPPSource (non-homogeneous Poisson arrival source driven by a piecewise rate function), parented to the network and registered under name.

fun nhppSource(name: String, durations: DoubleArray, rates: DoubleArray, firstReceiver: QObjectReceiverIfc = NotImplementedReceiver, streamNum: Int = 0, maxArrivals: Long = Long.MAX_VALUE, marking: (ModelElement.QObject) -> Unit? = null): NHPPSource

Convenience overload that creates an NHPPSource from parallel durations and rates arrays (piecewise-constant rate function), parented to the network and registered under name.

Link copied to clipboard

Returns the registered node with the given name or null if not present.

Link copied to clipboard
fun nWayStation(name: String, numQueues: Int, activityTime: RVariableIfc, capacity: Int = 1, selectionRule: NWayQueueSelectionRuleIfc = PriorityQueueSelection(), nextReceiver: QObjectReceiverIfc = NotImplementedReceiver): NWayStation

Creates an NWayStation (several input queues sharing one server group), parented to the network and registered under name. Wire upstream nodes to the station's NWayStation.input endpoints.

Link copied to clipboard
fun StationNetwork.processStation(name: String, nextReceiver: QObjectReceiverIfc = NotImplementedReceiver, activity: suspend KSLProcessBuilder.(ModelElement.QObject) -> Unit): ProcessStation

Creates a ProcessStation in this network whose activity is the supplied process activity, registered under name. Wire upstream nodes to it like any receiver.

Link copied to clipboard

Registers a node (receiver) under a name that is unique within the network. The creation helpers call this automatically; supply a custom receiver or router here to make it part of the network's graph and validation.

Link copied to clipboard
fun registerClass(qObjectClass: QObjectClass)

Registers a QObject class for per-class statistics. The creation helpers call this automatically when a class is supplied to a source. Registering the same class (same name and type id) more than once is a no-op; registering a conflicting class is an error.

Link copied to clipboard
fun registerRoute(route: Route)

Registers a Route so its step-to-step connections are included in the network graph and so its non-terminal steps are exempt from the dangling check (their onward routing is carried dynamically on each instance). The route also becomes lookup-able by name via route. The creation/registration helpers register class routes automatically.

Link copied to clipboard
fun releaseStation(name: String, resource: SResource, nextReceiver: QObjectReceiverIfc = NotImplementedReceiver): ReleaseStation

Creates a ReleaseStation that releases this entity's oldest outstanding allocation on resource, parented to the network and registered under name.

Link copied to clipboard
protected open override fun replicationEnded()

This method should be overridden by subclasses that need actions performed when the replication ends and prior to the calling of afterReplication(). It is called when each replication ends and can be used to collect data from the model element, etc.

Link copied to clipboard
fun resource(name: String, capacity: Int = 1): SResource

Creates a free-standing SResource of capacity units parented to the network. The resource is not a routing node; pass it to seizeStation / releaseStation for Arena-style atomic seize/release.

Link copied to clipboard
fun resourcePool(name: String, capacity: Int = 1): SResourcePool

Creates a shared SResourcePool of capacity units parented to the network. The pool is not a routing node; pass it to resourcePoolStations that share it.

Link copied to clipboard
fun resourcePoolStation(name: String, pool: SResourcePool, activityTime: RVariableIfc = ConstantRV.ZERO, nextReceiver: QObjectReceiverIfc = NotImplementedReceiver): ResourcePoolStation

Creates a ResourcePoolStation that seizes from a shared pool, parented to the network and registered under name.

Link copied to clipboard
open override fun route(name: String): Route?

Looks up a registered Route by its Route.routeName or null if not registered.

Link copied to clipboard
fun seizeStation(name: String, resource: SResource, amount: Int = 1, nextReceiver: QObjectReceiverIfc = NotImplementedReceiver): SeizeStation

Creates a SeizeStation that acquires amount units of resource (or queues the entity if not available), parented to the network and registered under name.

Link copied to clipboard
fun separateStation(name: String, nextReceiver: QObjectReceiverIfc = NotImplementedReceiver): SeparateStation

Creates a SeparateStation that recovers batch members, parented to the network and registered under name.

Link copied to clipboard
fun singleQStation(name: String, activityTime: RVariableIfc = ConstantRV.ZERO, capacity: Int = 1, nextReceiver: QObjectReceiverIfc = NotImplementedReceiver): SingleQStation

Creates a SingleQStation (single queue, simple resource) parented to the network and registered under name.

Link copied to clipboard
fun sink(name: String): SinkStation

Creates a SinkStation (egress that disposes of received instances) parented to the network and registered under name.

Link copied to clipboard
fun source(name: String, interArrivalRV: RVariableIfc, firstReceiver: QObjectReceiverIfc = NotImplementedReceiver, timeUntilFirstRV: RVariableIfc = interArrivalRV, maxArrivals: Long = Long.MAX_VALUE, qObjectClass: QObjectClass? = null, marking: (ModelElement.QObject) -> Unit? = null): SourceStation

Creates a SourceStation that generates arriving QObject instances and injects them into the network. The created station is registered under name and returned for further wiring.

Link copied to clipboard
fun transferStation(name: String, target: QObjectReceiverIfc, transferDelay: GetValueIfc? = null, transform: (ModelElement.QObject) -> Unit? = null): TransferStation

Creates a TransferStation that hands instances off to target (typically another network's ingress), parented to this network and registered under name.

Link copied to clipboard

Throws if qObject has any outstanding allocations. Called at exit points (sinks, transfers, join child-absorbs, separate batch-wrappers) — the entity must release everything it holds before leaving the network or being destroyed. The error names qObject and the resources it still holds.