Coordinator

class Coordinator(scheduler: Scheduler, singleThread: Boolean, startingTime: Long)(using x$4: ExecutionContext) extends Manager with HashMapPublisher

Provides coordination for discrete event simulation of multiple asynchronous simulations.

Default implementation of Manager.

It can run in a single thread or multi-threaded depending on the singleThread constructor parameter. In the multi-threaded setting, task completions are reported to the simulations asynchronously through a new thread (Future) each time. This allows simulations to run things concurrently, with the added overhead of thread spawning.

Value Params
scheduler

The Scheduler responsible for task allocation at any given time.

singleThread

Flag to run everything in a single thread or else use Futures.

startingTime

The starting timestamp of the entire simulation.

trait Publisher
trait Manager
class Object
trait Matchable
class Any

Document{}

Add a new TaskResource to our map of available resources.

Add a new TaskResource to our map of available resources.

Value Params
r

The TaskResource to be added.

def addResources(r: Seq[TaskResource]): Unit

Add multiple TaskResources in one go.

Add multiple TaskResources in one go.

Value Params
r

The sequence of TaskResources to be added.

def addSimulation(t: Long, simulation: SimulationRef): Unit

Add a new simulation to be run.

Add a new simulation to be run.

Publishes a ESimAdd.

Value Params
simulation

The Simulation to run.

t

The timestamp when the simulation needs to start. Must be greater or equal to the current time.

def addSimulationNow(simulation: SimulationRef): Unit

Add a new simulation to be run in the current virtual time.

Add a new simulation to be run in the current virtual time.

Publishes a ESimAdd for each simulation.

Value Params
simulation

The Simulation to run.

def addSimulations(sims: Seq[(Long, SimulationRef)]): Unit

Adds multiple simulations at the same time.

Adds multiple simulations at the same time.

This is equivalent to mapping addSimulation over the given sequence, but more efficient.

Value Params
sims

A sequence of pairs, each consisting of a starting timestamp and a Simulation. Timestamps must be greater or equal to the current time.

def addSimulationsNow(sims: Seq[SimulationRef]): Unit

Add multiple simulations to be run in the current virtual time.

Add multiple simulations to be run in the current virtual time.

Value Params
sims

A sequence of Simulations.

def getTime(): Long

Returns the current virtual time.

Returns the current virtual time.

Returns

The current virtual time.

val id: String

A unique id/name for logging purposes.

A unique id/name for logging purposes.

override
def isFinalEvent(e: Event): Boolean

Checks if a given Event in the output stream is the final one.

Checks if a given Event in the output stream is the final one.

Causes the stream to shutdown after EDone is published.

Value Params
e

The Event to check.

Returns

true if it is a EDone, otherwise false.

Definition Classes
def limit(t: Long): Unit

Sets a time limit in virtual time for the simulation to end.

Sets a time limit in virtual time for the simulation to end.

Value Params
t

The virtual timestamp to end the simulation.

Note

Once a time limit is placed it cannot be removed. Multiple time limits can be set so that the earliest one will be triggered.

val resourceMap: Map[String, TaskResource]

Map of the available TaskResources

Map of the available TaskResources

override
def simResponse(response: SimResponse): Unit

Handles a SimResponse from a simulation.

Handles a SimResponse from a simulation.

Definition Classes
def start(): Future[Any]

Starts the entire simulation scenario.

Starts the entire simulation scenario.

Publishes a EStart.

def stop(): Unit

Aborts all simulations and stops immediately.

Aborts all simulations and stops immediately.

override
def waitFor(simulation: String): Unit

Adds a simulation to the waiting list.

Adds a simulation to the waiting list.

The manager needs to wait for that simulation to send a SimResponse.

Definition Classes

Value members

Concrete methods

def addArrival(t: Long, limit: Int, rate: Distribution, simulationGenerator: SimulationRefGenerator): Unit

Adds a new arrival process to the coordinator.

Adds a new arrival process to the coordinator.

Value Params
limit

The number of simulation instances to spawn.

rate

The arrival rate of the simulation instances.

simulationGenerator

The generator used to create new instances.

t

The virtual timestamp when the arrival process will begin.

def addArrivalNext(limit: Int, rate: Distribution, simulationGenerator: SimulationRefGenerator): Unit

Adds a new arrival process to the coordinator at the next arrival time.

Adds a new arrival process to the coordinator at the next arrival time.

Value Params
limit

The number of simulation instances to spawn.

rate

The arrival rate of the simulation instances.

simulationGenerator

The generator used to create new instances.

def addArrivalNow(limit: Int, rate: Distribution, simulationGenerator: SimulationRefGenerator): Unit

Adds a new arrival process to the coordinator at the current virtual time.

Adds a new arrival process to the coordinator at the current virtual time.

Value Params
limit

The number of simulation instances to spawn.

rate

The arrival rate of the simulation instances.

simulationGenerator

The generator used to create new instances.

def addInfiniteArrival(t: Long, rate: Distribution, simulationGenerator: SimulationRefGenerator): Unit

Adds a new infinite arrival process to the coordinator.

Adds a new infinite arrival process to the coordinator.

Value Params
rate

The arrival rate of the simulation instances.

simulationGenerator

The generator used to create new instances.

t

The virtual timestamp when the arrival process will begin.

Note

This will generate new simulations infinitely. The Coordinator will not terminate unless you add a TimeLimit event via limit.

def addInfiniteArrivalNext(rate: Distribution, simulationGenerator: SimulationRefGenerator): Unit

Adds a new infinite arrival process to the coordinator at the next arrival time.

Adds a new infinite arrival process to the coordinator at the next arrival time.

Value Params
rate

The arrival rate of the simulation instances.

simulationGenerator

The generator used to create new instances.

Note

This will generate new simulations infinitely. The Coordinator will not terminate unless you add a TimeLimit event via limit.

def addInfiniteArrivalNow(rate: Distribution, simulationGenerator: SimulationRefGenerator): Unit

Adds a new infinite arrival process to the coordinator at the current virtual time.

Adds a new infinite arrival process to the coordinator at the current virtual time.

Value Params
rate

The arrival rate of the simulation instances.

simulationGenerator

The generator used to create new instances.

Note

This will generate new simulations infinitely. The Coordinator will not terminate unless you add a TimeLimit event via limit.

Inherited methods

override
def doPublish(evt: Event): Unit

Publishes an event into the stream.

Publishes an event into the stream.

Sends the event to all subscribers in the HashMap.

Definition Classes
Inherited from
HashMapPublisher
def publish(evt: Event): Unit

Wrapper method for doPublish that also stops the stream upon final events.

Wrapper method for doPublish that also stops the stream upon final events.

Inherited from
Publisher
override
def stopStream(): Unit

Performs any cleaning up required when the stream is finished.

Performs any cleaning up required when the stream is finished.

Notifies all subscribers that the stream is done and clears the HashMap to prevent any further events being delivered.

Definition Classes
Inherited from
HashMapPublisher
override
def subscribe(subscriber: EventHandler): Unit

Subscribes an EventHandler to the stream so they can receive events.

Subscribes an EventHandler to the stream so they can receive events.

Adds the subscriber to the HashMap and calls its onInit method.

Definition Classes
Inherited from
HashMapPublisher
override
def unsubscribe(subscriber: EventHandler): Unit

Unsubscribes an EventHandler to the stream so they can stop receiving events.

Unsubscribes an EventHandler to the stream so they can stop receiving events.

Removes the subscriber from the HashMap.

Definition Classes
Inherited from
HashMapPublisher

Inherited fields

val subscribers: HashMap[UUID, EventHandler]

The HashMap of subscribers that receive events.

The HashMap of subscribers that receive events.

Inherited from
HashMapPublisher