Class Engine<T>
java.lang.Object
it.unibo.alchemist.core.implementations.Engine<T>
- Type Parameters:
T- ignored
- All Implemented Interfaces:
it.unibo.alchemist.core.interfaces.Simulation<T>,Runnable
public final class Engine<T>
extends Object
implements it.unibo.alchemist.core.interfaces.Simulation<T>
This class implements a simulation. It offers a wide number of static
factories to ease the creation process.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classThis class provides a flexible Builder to create a new Command whose aim is to change the status of an Engine. -
Constructor Summary
ConstructorsConstructorDescriptionBuilds a simulation for a given environment.Engine(it.unibo.alchemist.model.interfaces.Environment<T> e, long maxSteps, it.unibo.alchemist.model.interfaces.Time t) Builds a simulation for a given environment.Engine(it.unibo.alchemist.model.interfaces.Environment<T> e, it.unibo.alchemist.model.interfaces.Time t) Builds a simulation for a given environment. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddCommand(it.unibo.alchemist.core.interfaces.Command<T> comm) voidaddOutputMonitor(it.unibo.alchemist.boundary.interfaces.OutputMonitor<T> op) static <T> voidaddOutputMonitor(it.unibo.alchemist.model.interfaces.Environment<T> env, it.unibo.alchemist.boundary.interfaces.OutputMonitor<T> monitor) Statically searches for the simulation running some environment and adds an OutputMonitor to it.static <T> Engine<T>buildSimulation(it.unibo.alchemist.model.interfaces.Environment<T> env) static <T> Engine<T>buildSimulation(it.unibo.alchemist.model.interfaces.Environment<T> env, long steps) static <T> Engine<T>buildSimulation(it.unibo.alchemist.model.interfaces.Environment<T> env, long steps, it.unibo.alchemist.model.interfaces.Time t) static <T> Engine<T>buildSimulation(it.unibo.alchemist.model.interfaces.Environment<T> env, it.unibo.alchemist.model.interfaces.Time t) static <T> Engine<T>fromEnvironment(it.unibo.alchemist.model.interfaces.Environment<T> env) Given an environment, returns the corresponding simulation.it.unibo.alchemist.core.interfaces.DependencyGraph<T>it.unibo.alchemist.model.interfaces.Environment<T>getError()longit.unibo.alchemist.model.interfaces.Timeit.unibo.alchemist.core.interfaces.ReactionManager<T>it.unibo.alchemist.core.interfaces.StatuslonggetStep()it.unibo.alchemist.model.interfaces.TimegetTime()static <T> voidneighborAdded(it.unibo.alchemist.model.interfaces.Environment<T> env, it.unibo.alchemist.model.interfaces.Node<T> node, it.unibo.alchemist.model.interfaces.Node<T> n) static <T> voidneighborRemoved(it.unibo.alchemist.model.interfaces.Environment<T> env, it.unibo.alchemist.model.interfaces.Node<T> node, it.unibo.alchemist.model.interfaces.Node<T> n) static <T> voidnodeAdded(it.unibo.alchemist.model.interfaces.Environment<T> env, it.unibo.alchemist.model.interfaces.Node<T> node) This method provides a facility for adding all the reactions of a node to the current simulation, creating also the dependencies.static <T> voidnodeMoved(it.unibo.alchemist.model.interfaces.Environment<T> env, it.unibo.alchemist.model.interfaces.Node<T> node) static <T> voidnodeRemoved(it.unibo.alchemist.model.interfaces.Environment<T> env, it.unibo.alchemist.model.interfaces.Node<T> node, it.unibo.alchemist.model.interfaces.Neighborhood<T> oldNeighborhood) This method provides a facility for removing all the reactions of a node from the current simulation, along with their dependencies.voidremoveOutputMonitor(it.unibo.alchemist.boundary.interfaces.OutputMonitor<T> op) static <T> voidremoveReaction(it.unibo.alchemist.model.interfaces.Environment<T> env, it.unibo.alchemist.model.interfaces.Reaction<T> r) voidrun()toString()it.unibo.alchemist.core.interfaces.Status
-
Constructor Details
-
Engine
public Engine(it.unibo.alchemist.model.interfaces.Environment<T> e, it.unibo.alchemist.model.interfaces.Time t) Builds a simulation for a given environment. By default, it uses a DependencyGraph and an IndexedPriorityQueue internally. If you want to use your own implementations of DependencyGraph and ReactionManager interfaces, don't use this constructor.- Parameters:
e- the environment at the initial timet- the maximum time to reach
-
Engine
Builds a simulation for a given environment. By default, it uses a DependencyGraph and an IndexedPriorityQueue internally. If you want to use your own implementations of DependencyGraph and ReactionManager interfaces, don't use this constructor.- Parameters:
e- the environment at the initial timemaxSteps- the maximum number of steps to take
-
Engine
public Engine(it.unibo.alchemist.model.interfaces.Environment<T> e, long maxSteps, it.unibo.alchemist.model.interfaces.Time t) Builds a simulation for a given environment. By default, it uses a DependencyGraph and an IndexedPriorityQueue internally. If you want to use your own implementations of DependencyGraph and ReactionManager interfaces, don't use this constructor.- Parameters:
e- the environment at the initial timemaxSteps- the maximum number of steps to taket- the maximum time to reach
-
-
Method Details
-
addOutputMonitor
public static <T> void addOutputMonitor(it.unibo.alchemist.model.interfaces.Environment<T> env, it.unibo.alchemist.boundary.interfaces.OutputMonitor<T> monitor) Statically searches for the simulation running some environment and adds an OutputMonitor to it.- Type Parameters:
T- The format of the concentrations- Parameters:
env- The current environmentmonitor- The monitor to add
-
buildSimulation
- Type Parameters:
T- The format of the concentrations- Parameters:
env- The environment to be simulated- Returns:
- A simulation ready to be run, the environment structures get updated coherently
-
buildSimulation
public static <T> Engine<T> buildSimulation(it.unibo.alchemist.model.interfaces.Environment<T> env, it.unibo.alchemist.model.interfaces.Time t) - Type Parameters:
T- The format of the concentrations- Parameters:
env- The environment to be simulatedt- The final simulation time to reach- Returns:
- A simulation ready to be run, the environment structures get updated coherently
-
buildSimulation
public static <T> Engine<T> buildSimulation(it.unibo.alchemist.model.interfaces.Environment<T> env, long steps) - Type Parameters:
T- The format of the concentrations- Parameters:
env- The environment to be simulatedsteps- The number of steps to run- Returns:
- A simulation ready to be run, the environment structures get updated coherently
-
buildSimulation
public static <T> Engine<T> buildSimulation(it.unibo.alchemist.model.interfaces.Environment<T> env, long steps, it.unibo.alchemist.model.interfaces.Time t) - Type Parameters:
T- The format of the concentrations- Parameters:
env- The environment to be simulatedsteps- The number of steps to runt- The final simulation time to reach- Returns:
- A simulation ready to be run, the environment structures get updated coherently
-
fromEnvironment
Given an environment, returns the corresponding simulation.- Type Parameters:
T- concentrations- Parameters:
env- the environment- Returns:
- the simulation
-
neighborAdded
public static <T> void neighborAdded(it.unibo.alchemist.model.interfaces.Environment<T> env, it.unibo.alchemist.model.interfaces.Node<T> node, it.unibo.alchemist.model.interfaces.Node<T> n) - Type Parameters:
T- Type for concentrations- Parameters:
env- the environmentnode- first noden- second node
-
neighborRemoved
public static <T> void neighborRemoved(it.unibo.alchemist.model.interfaces.Environment<T> env, it.unibo.alchemist.model.interfaces.Node<T> node, it.unibo.alchemist.model.interfaces.Node<T> n) - Type Parameters:
T- Type for concentrations- Parameters:
env- the environmentnode- first noden- second node
-
nodeMoved
public static <T> void nodeMoved(it.unibo.alchemist.model.interfaces.Environment<T> env, it.unibo.alchemist.model.interfaces.Node<T> node) - Type Parameters:
T- Type for concentrations- Parameters:
env- the environmentnode- the node
-
nodeAdded
public static <T> void nodeAdded(it.unibo.alchemist.model.interfaces.Environment<T> env, it.unibo.alchemist.model.interfaces.Node<T> node) This method provides a facility for adding all the reactions of a node to the current simulation, creating also the dependencies. This method must be called only when it is possible for the environment to successfully compute the neighborhood for the new node.- Type Parameters:
T- Type for concentrations- Parameters:
env- the environmentnode- the freshly added node
-
nodeRemoved
public static <T> void nodeRemoved(it.unibo.alchemist.model.interfaces.Environment<T> env, it.unibo.alchemist.model.interfaces.Node<T> node, it.unibo.alchemist.model.interfaces.Neighborhood<T> oldNeighborhood) This method provides a facility for removing all the reactions of a node from the current simulation, along with their dependencies. This method must be called when it is still possible for the environment to successfully compute the neighborhood for the removed node.- Type Parameters:
T- Type for concentrations- Parameters:
env- the environmentnode- the freshly removed nodeoldNeighborhood- the neighborhood of the node as it was before it was removed (used to calculate reverse dependencies)
-
removeReaction
public static <T> void removeReaction(it.unibo.alchemist.model.interfaces.Environment<T> env, it.unibo.alchemist.model.interfaces.Reaction<T> r) - Type Parameters:
T- Type for concentrations- Parameters:
env- the environmentr- the removed reaction
-
addOutputMonitor
- Specified by:
addOutputMonitorin interfaceit.unibo.alchemist.core.interfaces.Simulation<T>
-
removeOutputMonitor
- Specified by:
removeOutputMonitorin interfaceit.unibo.alchemist.core.interfaces.Simulation<T>
-
getDependencyGraph
- Returns:
- the dependency graph
-
getEnvironment
- Specified by:
getEnvironmentin interfaceit.unibo.alchemist.core.interfaces.Simulation<T>
-
getFinalStep
public long getFinalStep()- Specified by:
getFinalStepin interfaceit.unibo.alchemist.core.interfaces.Simulation<T>
-
getFinalTime
public it.unibo.alchemist.model.interfaces.Time getFinalTime()- Specified by:
getFinalTimein interfaceit.unibo.alchemist.core.interfaces.Simulation<T>
-
getReactionManager
- Returns:
- The IPQ
-
getStatus
public it.unibo.alchemist.core.interfaces.Status getStatus()- Specified by:
getStatusin interfaceit.unibo.alchemist.core.interfaces.Simulation<T>
-
getStep
public long getStep()- Specified by:
getStepin interfaceit.unibo.alchemist.core.interfaces.Simulation<T>
-
getTime
public it.unibo.alchemist.model.interfaces.Time getTime()- Specified by:
getTimein interfaceit.unibo.alchemist.core.interfaces.Simulation<T>
-
addCommand
- Specified by:
addCommandin interfaceit.unibo.alchemist.core.interfaces.Simulation<T>
-
waitFor
public it.unibo.alchemist.core.interfaces.Status waitFor(it.unibo.alchemist.core.interfaces.Status s, long timeout, TimeUnit tu) - Specified by:
waitForin interfaceit.unibo.alchemist.core.interfaces.Simulation<T>
-
run
public void run() -
toString
-
getError
- Returns:
- the error or null if there is none
-