Engine

open class Engine<T, P : Position<out P>>(environment: Environment<T, P>, scheduler: Scheduler<T>) : Simulation<T, P>

Represents a simulation engine that manages execution and scheduling. Provides multiple factory methods to simplify the creation process.

Parameters

T

the concentration type

P

the position type, extending Position

Inheritors

Constructors

Link copied to clipboard
constructor(environment: Environment<T, P>, scheduler: Scheduler<T>)
constructor(environment: Environment<T, P>)

Constructs a simulation with a default scheduler.

Properties

Link copied to clipboard
open override val environment: Environment<T, P>
Link copied to clipboard
open override val error: Optional<Throwable>
Link copied to clipboard
open override val outputMonitors: List<OutputMonitor<T, P>>
Link copied to clipboard
open override val status: Status
Link copied to clipboard
open override val step: Long
Link copied to clipboard
open override val time: Time

Functions

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

Adds an output monitor to track simulation events.

Link copied to clipboard
open override fun getEnvironment(): Environment<T, P>
Link copied to clipboard
open override fun getError(): Optional<Throwable>
Link copied to clipboard
open override fun getOutputMonitors(): List<OutputMonitor<T, P>>
Link copied to clipboard
open override fun getStatus(): Status
Link copied to clipboard
open override fun getStep(): Long
Link copied to clipboard
open override fun getTime(): Time
Link copied to clipboard
open override fun goToStep(step: Long): CompletableFuture<Unit>

Moves the simulation forward until the given step is reached.

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

Moves the simulation forward until the given time is reached.

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

Registers a newly added neighbor.

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

Registers a removed neighbor.

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

Handles the addition of a new node.

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

Handles node movement.

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

Handles the removal of a node.

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

Pauses the simulation.

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

Resumes the simulation.

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

Registers a newly added reaction.

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

Registers a removed reaction.

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

Runs the simulation.

Link copied to clipboard

Runs an existing Simulation in the current thread.

Link copied to clipboard
open override fun schedule(runnable: ERROR CLASS: Symbol not found for CheckedRunnable)

Schedules a task for execution.

abstract fun schedule(r: org/jooq/lambda/fi/lang/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<Unit>

Terminates the simulation.

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

Waits for the simulation to reach a given status.