Permanent Agent
A setup-time agent that is a ModelElement. Use when you need KSL lifecycle hooks (initialize, warmUp, afterReplication) on the agent itself, or want to own per-agent Response/TWResponse statistics. Modeled on ksl.modeling.entity.TaskProcessingSystem.TaskProcessor: a ModelElement wrapper that holds its own POJO mailbox and statechart and drives their lifecycle through its own hooks.
Must be constructed before simulate() since ModelElements cannot be added to the model while it is running.
Properties
The current simulation time. Provided here so action handlers can log or compute durations without having to reach for the owner's outer model element.
Default mailbox for receiving AgentMessage traffic. Routes through the enclosing AgentModel's shared message bus.
Optional performance observer attached to this agent's mailbox. Created by collectPerformance; null otherwise.
Optional statechart governing this agent's reactive behavior. Default null for AgentLike implementations that don't provide a statechart abstraction. The concrete agent types (AgentModel.Agent, AgentModel.PermanentAgent, AgentResource) each override this with their own backing field.
Functions
This method should be overridden by subclasses that need actions performed after each replication. It is called after replicationEnded() has been called.
Build a statechart without installing it. See Agent.buildStatechart. For a PermanentAgent, alternatives are typically selected via a control parameter between runs to compare designs without reconstructing the model.
Opt this agent in to mailbox-traffic statistics. Must be called before simulate() runs since the returned AgentPerformance is a ModelElement. Idempotent — a second call returns the existing observer.
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
Gracefully stop this agent's statechart, if any. Idempotent.
Select the active statechart. Allowed only when the current chart (if any) is not started — for a PermanentAgent that means between replications / simulate() calls (the chart is stopped at afterReplication). The selected chart is started by initialize at the next replication. See Agent.useStatechart.