it.unibo.alchemist.boundary.Loader.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of alchemist-loading Show documentation
Show all versions of alchemist-loading Show documentation
Alchemist Machinery to load from files
/*
* Copyright (C) 2010-2023, Danilo Pianini and contributors
* listed, for each module, in the respective subproject's build.gradle.kts file.
*
* This file is part of Alchemist, and is distributed under the terms of the
* GNU General Public License, with a linking exception,
* as described in the file LICENSE in the Alchemist distribution's top directory.
*/
package it.unibo.alchemist.boundary
import it.unibo.alchemist.core.Simulation
import it.unibo.alchemist.model.Position
import java.io.Serializable
/**
* An entity which is able to produce an Alchemist [Simulation], resolving user defined variable values.
*/
interface Loader : Serializable {
/**
* Allows to access the currently defined constants, namely variables defined in the simulation file whose value is
* constant and does not depend on the value of any free variable (directly or indirectly).
*
* @return a [Map] between variable names and their computed value
*/
val constants: Map
/**
* @return remote dependencies files
*/
val remoteDependencies: List
/**
* Returns the launcher to be used in to manage the simulation lifecycle.
*
* @return launcher
*/
val launcher: Launcher
/**
* Allows to access the currently defined dependent variable (those variables whose value can be determined given a
* valid set of values for the free variables).
*
* @return a [Map] between variable names and their actual
* representation
*/
val dependentVariables: Map>
/**
* @return a [Map] between variable names and their actual
* representation
*/
val variables: Map>
/**
* @param concentration type
* @param position type
* @return an [Simulation] with all the variables set at their
* default values
*/
fun > getDefault(): Simulation {
return getWith(emptyMap())
}
/**
* @param values a map specifying name-value bindings for the variables in this
* scenario
* @param concentration type
* @param position type
* @return an [Simulation] with all the variables set at the
* specified values. If the value is unspecified, the default is
* used instead
*/
fun > getWith(values: Map): Simulation
/**
* Launches the simulations as configured by this loader.
* A custom [launcher] can be provided.
* Blocking, returns when all simulations are completed.
* @param launcher the launcher to be used
*/
fun launch(launcher: Launcher = this.launcher): Unit = launcher.launch(this)
}