BatchEngine

class BatchEngine<T, P : Position<out P>> : Engine<T, P>

This class implements a simulation. It offers a wide number of static factories to ease the creation process.

Parameters

[Position] type

Constructors

Link copied to clipboard
constructor(environment: Environment<T, P>, scheduler: BatchedScheduler<T>, outputReplayStrategy: String = "aggregate")
constructor(environment: Environment<T, P>, scheduler: String, batchSizeOrEpsilon: Number, outputReplayStrategy: String = "aggregate")

Properties

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

Functions

Link copied to clipboard
open override fun addOutputMonitor(op: OutputMonitor<T, P>)

Adds an OutputMonitor to this simulation.

Link copied to clipboard

Allows to access a list of all the OutputMonitor currently attached to this simulation.

Link copied to clipboard
open override fun getStep(): Long

Allows to access the current simulation step.

Link copied to clipboard
open override fun getTime(): Time

Allows to know which is the current simulation time.

Link copied to clipboard
open override fun goToStep(step: Long): CompletableFuture<Void>

Executes a certain number of steps, then pauses it.

Link copied to clipboard
open override fun goToTime(t: Time): CompletableFuture<Void>

Executes the simulation until the target time is reached, then pauses it.

Link copied to clipboard
open override fun neighborAdded(node: Node<T>, n: Node<T>)

This method must get called in case a communication link connecting two nodes gets created during the simulation. This method provides dependency and scheduling times re-computation for all the reactions interested in such change.

Link copied to clipboard
open override fun neighborRemoved(node: Node<T>, n: Node<T>)

This method must get called in case a communication link connecting two nodes gets broken during the simulation. This method provides dependency and scheduling times re-computation for all the reactions interested in such change.

Link copied to clipboard
open override fun nodeAdded(node: Node<T>)

This method must get called in case a node is added to the environment during the simulation and after its neighborhood has been computed (or can be consistently computed by the simulated environment). This method provides dependency computation and is responsible of correctly scheduling the Node's new reactions.

Link copied to clipboard
open override fun nodeMoved(node: Node<T>)

This method must get called in case a node is moved in the environment during the simulation and after its neighborhood has been computed (or can be consistently computed by the simulated environment). This method provides dependency computation and is responsible of correctly scheduling the Node's reactions.

Link copied to clipboard
open override fun nodeRemoved(node: Node<T>, oldNeighborhood: Neighborhood<T>)

This method must get called in case a node is removed from the environment during the simulation and after its neighborhood has been computed (or can be consistently computed by the simulated environment). This method provides dependency computation and is responsible of correctly removing the Node's reactions from the scheduler.

Link copied to clipboard
open override fun pause(): CompletableFuture<Void>

Sends a pause command to the simulation. There is no guarantee on when this command will be actually processed.

Link copied to clipboard
open override fun play(): CompletableFuture<Void>

Sends a play command to the simulation. There is no guarantee on when this command will be actually processed.

Link copied to clipboard
open override fun reactionAdded(reactionToAdd: Actionable<T>)

Adds a reaction during the simulation to the scheduler and start to execute it. The reaction addition is not propagated in the Node entity. To do that call also the method addReaction.

Link copied to clipboard
open override fun reactionRemoved(reactionToRemove: Actionable<T>)

Removes a reaction during the simulation from the scheduler and stop to execute it. The reaction removal is not propagated in the Node entity. To do that call also the method removeReaction.

Link copied to clipboard
open override fun removeOutputMonitor(op: OutputMonitor<T, P>)

Removes an OutputMonitor to this simulation. If the OutputMonitor was not among those already added, this method does nothing.

Link copied to clipboard
open override fun run()
Link copied to clipboard

Runs an existing Simulation in the current thread.

Link copied to clipboard
open override fun schedule(runnable: CheckedRunnable)

Schedules a runnable to be executed by the Simulation thread, useful for synchronization purposes (e.g. make sure that the environment is not being changed while the requested operation is being executed). An exception thrown by the passed runnable will make the simulation terminate.

Link copied to clipboard
fun <T, P : Position<P>, Vector<P>> Simulation<T, P>.startSimulation(onceInitialized: (EuclideanEnvironment<T, P>) -> Unit = { }, atEachStep: (EuclideanEnvironment<T, P>, Actionable<T>?, Time, Long) -> Unit = { _, _, _, _ -> }, whenFinished: (EuclideanEnvironment<T, P>, Time, Long) -> Unit = { _, _, _ -> }, steps: Long = 10000): EuclideanEnvironment<T, P>

Run the simulation this environment owns.

Link copied to clipboard
open override fun terminate(): CompletableFuture<Void>

Sends a terminate command to the simulation. There is no guarantee on when this command will be actually processed.

Link copied to clipboard
Link copied to clipboard
open override fun toString(): String
Link copied to clipboard
open override fun waitFor(next: Status, timeout: Long, tu: TimeUnit): Status

Suspends the caller until the simulation reaches the selected Status or the timeout ends. Please note that waiting for a status does not mean that every OutputMonitor will already be notified of the update.