SimulationContext

interface SimulationContext<T, P : Position<P>>

Top-level DSL scope for defining a simulation scenario.

A SimulationContext is responsible for collecting all scenario components that are needed to build a runnable simulation, including:

  • the Environment and its configuration (deployments, layers, global programs, network model, terminators);

  • exporters and output monitors;

  • the Launcher used to run the simulation;

  • scenario variables, exposed as delegated read-only properties.

Implementations typically distinguish between two random generators:

  • a scenario generator, used while constructing the scenario (e.g., during deployments or initialization);

  • a simulation generator, used for components that require randomness tied to simulation execution.

Type Parameters

T

the concentration type used by the simulation.

P

the position type used by the environment.

Functions

Link copied to clipboard
context(incarnation: Incarnation<T, P>)
open fun concentrationOf(concentration: Any?): T

Creates a concentration value using the current Incarnation.

Link copied to clipboard
abstract fun <E : Environment<T, P>> environment(environment: E, environmentConfiguration: context(E) EnvironmentContext<T, P>.() -> Unit)

Sets the simulation environment and configures it through environmentConfiguration.

Link copied to clipboard

Convenience overload that installs a default Continuous2DEnvironment and configures it via block.

Link copied to clipboard
abstract fun exportWith(exporter: Exporter<T, P>, block: ExporterContext<T, P>.() -> Unit)

Registers an Exporter and configures which it.unibo.alchemist.boundary.Extractor instances it should use.

Link copied to clipboard
abstract fun launcher(launcher: Launcher)

Sets the Launcher used to run the simulation.

Link copied to clipboard
abstract fun monitor(monitor: OutputMonitor<T, P>)

Registers an OutputMonitor to observe the simulation execution.

Link copied to clipboard
abstract fun scenarioRandomGenerator(randomGenerator: RandomGenerator)

Sets the random generator used during scenario construction.

Link copied to clipboard
open fun scenarioSeed(seed: Long)

Sets the scenario random generator to a MersenneTwister initialized with seed.

Link copied to clipboard
abstract fun simulationRandomGenerator(randomGenerator: RandomGenerator)

Sets the random generator used for simulation-related components.

Link copied to clipboard
open fun simulationSeed(seed: Long)

Sets the simulation random generator to a MersenneTwister initialized with seed.

Link copied to clipboard
abstract fun <V : Serializable> variable(variable: Variable<out V>): VariableDelegateFactory<V>

Declares a scenario Variable and returns a read-only property delegate that provides its value.