AgentPerformance

Per-agent statistics observer for a PermanentAgent. Modeled on ksl.modeling.entity.TaskProcessingSystem.TaskProcessorPerformance: a ModelElement that subscribes to a specific mailbox via MailboxObserver (and optionally a statechart via StatechartObserver) and publishes standard KSL Response/TWResponse instances.

Mailbox metrics (always published):

  • NumMessagesReceived — total messages delivered to the mailbox during a replication.

  • NumMessagesConsumed — total messages consumed from the mailbox during a replication.

  • NumInMailbox — time-weighted size of the pending queue.

With allPerformance = true, additionally:

  • NumPendingAtEndOfReplication — final pending size at end-of-replication.

Statechart metrics (published when the agent had a statechart configured at the time collectPerformance was called):

  • TimeInState_<name> — time-weighted fraction of replication time spent in each declared state.

  • NumTimesEntered_<name> — number of entries into each state per replication.

  • NumTransitions — total state transitions per replication.

Per-state responses are pre-allocated at construction from statechart.stateNames so no new ModelElements are created during simulate(). Consequently, the statechart must be configured on the agent before collectPerformance is called for statechart stats to be tracked.

Must be constructed before simulate() runs — it's a ModelElement and registers in the model's element map. Typically created via PermanentAgent.collectPerformance.

Properties

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

Per-state count of entries per replication.

Link copied to clipboard

Total transitions per replication (null if no statechart).

Link copied to clipboard

Per-state time-weighted occupancy (1.0 while in state, else 0.0).

Link copied to clipboard

True if statechart stats are being collected. False if the agent had no statechart at the time of construction.

Functions

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
protected open override fun warmUp()

This method should be overridden by subclasses that need actions performed at the warm-up event during each replication. It is called once during each replication if the model element reacts to warm-up actions.