alchemist-interfaces / it.unibo.alchemist.core.interfaces / Simulation

Simulation

interface Simulation<T : Any!, P : Position<out P>!> : Runnable

This interface forces simulations to be independent threads, and make them controllable from an external console.

Functions

addOutputMonitor

Adds an OutputMonitor to this simulation.

abstract fun addOutputMonitor(op: OutputMonitor<T, P>!): Unit

getEnvironment

Allows to access the current environment.

abstract fun getEnvironment(): Environment<T, P>!

getError

abstract fun getError(): Optional<Throwable!>!

getFinalStep

abstract fun getFinalStep(): Long

getFinalTime

Allows to at which time this simulation will end.

abstract fun getFinalTime(): Time!

getStatus

Allows to access the current status.

abstract fun getStatus(): Status!

getStep

Allows to access the current simulation step.

abstract fun getStep(): Long

getTime

Allows to know which is the current simulation time.

abstract fun getTime(): Time!

goToStep

Executes a certain number of steps, then pauses it.

abstract fun goToStep(steps: Long): Unit

goToTime

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

abstract fun goToTime(t: Time!): Unit

neighborAdded

This method must get called in case a 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 by such change.

abstract fun neighborAdded(node: Node<T>!, n: Node<T>!): Unit

neighborRemoved

This method must get called in case a 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 by such change.

abstract fun neighborRemoved(node: Node<T>!, n: Node<T>!): Unit

nodeAdded

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.

abstract fun nodeAdded(node: Node<T>!): Unit

nodeMoved

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.

abstract fun nodeMoved(node: Node<T>!): Unit

nodeRemoved

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.

abstract fun nodeRemoved(node: Node<T>!, oldNeighborhood: Neighborhood<T>!): Unit

pause

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

abstract fun pause(): Unit

play

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

abstract fun play(): Unit

removeOutputMonitor

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

abstract fun removeOutputMonitor(op: OutputMonitor<T, P>!): Unit

schedule

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.

abstract fun schedule(r: CheckedRunnable!): Unit

terminate

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

abstract fun terminate(): Unit

waitFor

Suspends the caller until the simulation reaches the selected Status.

abstract fun waitFor(s: Status!, timeout: Long, timeunit: TimeUnit!): Status!