|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectfern.simulation.Simulator
public abstract class Simulator
Base class for stochastic simulators. Extending classes just have to implement
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).
Nested Class Summary | |
---|---|
static class |
Simulator.FireType
Defines different types of a firing for reactions. |
Constructor Summary | |
---|---|
Simulator(Network net)
Creates a new simulator for the given network. |
Method Summary | |
---|---|
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 |
boolean |
isInterpolateTheta()
Gets whether the amount values are returned interpolated for theta events. |
abstract void |
performStep(SimulationController control)
Performs one simulation step. |
void |
registerNewTheta(Observer obs,
double theta)
Is called by Observer.setTheta(double) . |
abstract void |
reinitialize()
Reset propensities when a event has been executed. |
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 |
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 . |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Simulator(Network net)
net
- the network to simulateMethod Detail |
---|
public void start(double time)
DefaultController
and calls start(SimulationController)
.
time
- simulation timepublic void start(SimulationController control)
SimulationController
.
control
- the SimulationController
public void initialize()
AmountManager
start
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 index
AmountManager.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 add
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 reaction
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |