AbstractEngine

abstract class AbstractEngine<T, P : Position<out P>>(val environment: Environment<T, P>) : Simulation<T, P> (source)

Abstract base class for simulation engines, providing common functionality for status management, time tracking, command scheduling, and output monitoring.

Type Parameters

T

the concentration type

P

the position type

Inheritors

Constructors

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

Properties

Link copied to clipboard
override val environment: Environment<T, P>

the simulation environment

Link copied to clipboard
override var error: Option<Throwable>

The error that made the simulation fail, if any.

Link copied to clipboard

The registered output monitors, as a read-only view.

Link copied to clipboard

The current simulation status.

Link copied to clipboard
override val step: Long

The current step (thread-safe).

Link copied to clipboard
override val time: Time

The current simulation time (thread-safe).

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 goToStep(steps: Long): CompletableFuture<Unit>

Moves the simulation forward until the given step is reached.

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

Moves the simulation forward until the given time is reached.

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
abstract fun reactionAdded(reactionToAdd: Reaction<T>)
Link copied to clipboard
abstract fun reactionInvalidated(reactionToUpdate: Reaction<T>)
Link copied to clipboard
abstract fun reactionRemoved(reactionToRemove: Reaction<T>)
Link copied to clipboard
open override fun removeOutputMonitor(monitor: OutputMonitor<T, P>)
Link copied to clipboard
open override fun run()

Internal method to run the simulation loop. Implementations must provide initialize, doStep, and hooks for run cycle.

Link copied to clipboard
open override fun schedule(action: () -> Unit)

Schedules a task for execution.

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

Terminates the simulation.

Link copied to clipboard
open override fun toString(): String
Link copied to clipboard
open override fun waitFor(state: SimulationState, timeout: Long, timeunit: TimeUnit): SimulationState

Waits for the simulation to reach a given status.