public abstract class Simulator extends Object
performStep
which gets invoked as long as the simulation is lasting. They also may
override initialize
but should in that case call super.initialize()
to
avoid unwished effects.
Simulators also should handle the special time theta
: is is a moment in time when
thetaEvent
is supposed to be invoked (e.g. to measure species populations at this
moment). Consider this, if you want to implement a simulator.
The fireReaction
are supposed to be invoked when a simulator causes a reaction to
fire.
If an extending class sticks to these conventions, it can take full benefit of the observer
system: One or more Observer
can be registered at a simulator and observe certain aspects
of the simulation (see the Observer
s javadoc for more information).
Modifier and Type | Class and Description |
---|---|
static class |
Simulator.FireType
Defines different types of a firing for reactions.
|
Constructor and Description |
---|
Simulator(Network net)
Creates a new simulator for the given network.
|
Modifier and Type | Method and Description |
---|---|
Observer |
addObserver(Observer observer)
Adds an observer to the list of observers.
|
double |
getAmount(int species)
Gets the amount of the given species.
|
abstract String |
getName()
Gets the name of the algorithm.
|
Network |
getNet()
Gets the simulation network.
|
double |
getNextThetaEvent()
Theta defines a moment, where the simulator has to invoke
theta of a observer. |
double |
getPropensity(int reaction)
Gets the current propensity for the given reaction.
|
PropensityCalculator |
getPropensityCalculator()
Gets the
PropensityCalculator . |
double |
getTime()
Gets the actual simulation time.
|
double |
getVolume()
Gets the volume of the reaction network.
|
void |
initialize()
Initializes the algorithm:
set t=0reset the
AmountManager recalculate the propensities
Gets called at the very beginning of start |
void |
initializePropensities()
Initializes the propensities.
|
boolean |
isInterpolateTheta()
Gets whether the amount values are returned interpolated for theta events.
|
abstract void |
performStep(SimulationController control)
Performs one simulation step.
|
void |
postRun()
Finalizes a simulation, i.e. call it, when this simulation will not be continued.
|
void |
preRun()
Initializes this simulator for the first run (or a further run starting from time 0).
|
void |
registerNewTheta(Observer obs,
double theta)
Is called by
Observer.setTheta(double) . |
abstract void |
reinitialize()
Reset propensities when a event has been executed.
|
void |
run(SimulationController control)
Runs a simulation, after it's initialized by calling
preRun() (allows to continue a
simulation). |
void |
setAmount(int species,
long amount)
Sets the amount of the given species.
|
void |
setInterpolateTheta(boolean interpolateTheta)
Sets whether the amount values are returned interpolated for theta events.
|
void |
setStochasticSeed(long seed)
Sets the seed for a particular model.
|
void |
setVolume(double volume)
Sets the volume of the reaction network.
|
void |
start(double time)
Starts the simulation up to a given time.
|
void |
start(SimulationController control)
Start the simulation with the given
SimulationController . |
public Simulator(Network net)
net
- the network to simulatepublic void start(double time)
DefaultController
and calls
start(SimulationController)
.time
- simulation timepublic void start(SimulationController control)
SimulationController
. Basically calls preRun()
,run(SimulationController)
and postRun()
.control
- the SimulationController
public void preRun()
public void run(SimulationController control)
preRun()
(allows to continue a
simulation).control
- public void postRun()
public void initialize()
AmountManager
start
public void initializePropensities()
public abstract void reinitialize()
public abstract void performStep(SimulationController control)
setAmount(int, long)
and setVolume(double)
if they need correct values!control
- the simulators controllerpublic abstract String getName()
public double getTime()
public void registerNewTheta(Observer obs, double theta)
Observer.setTheta(double)
.obs
- the observer which is registeringtheta
- the theta to registerpublic double getNextThetaEvent()
theta
of a observer. It
is used e.g. to determine the amounts of species at one moments. Extending class just have to
call thetaEvent()
which basically calls the observer.public double getAmount(int species)
species
- species indexAmountManager.getAmount(int)
public void setAmount(int species, long amount)
species
- species indexamount
- amount of speciesAmountManager.setAmount(int, long)
public PropensityCalculator getPropensityCalculator()
PropensityCalculator
.PropensityCalculator
public Network getNet()
public Observer addObserver(Observer observer)
observer
- the observer to addpublic void setStochasticSeed(long seed)
seed
- public double getVolume()
public void setVolume(double volume)
volume
- the volumepublic boolean isInterpolateTheta()
public void setInterpolateTheta(boolean interpolateTheta)
public double getPropensity(int reaction)
reaction
- index of the reactionCopyright © 2007–2021. All rights reserved.