org.systemsbiology.chem
Class Simulator

java.lang.Object
  extended byorg.systemsbiology.chem.Simulator
Direct Known Subclasses:
SimulatorDeterministicBase, SimulatorOdeToJavaBase, SimulatorStochasticBase

public abstract class Simulator
extends Object

Base class extended by all classes implementing ISimulator. This class contains a lot of methods and fields of common use to all simulator classes. From the standpoint of object-oriented correctness, this really should be done by composition rather than inheritance. For performance, accessor methods are avoided in favor of direct field access by subclasses.

Author:
sramsey

Field Summary
protected static long DEFAULT_MIN_NUM_MILLISECONDS_FOR_UPDATE
           
protected  DelayedReactionSolver[] mDelayedReactionSolvers
           
protected  Object[] mDynamicSymbolAdjustmentVectors
           
protected  String[] mDynamicSymbolNames
           
protected  Species[] mDynamicSymbols
           
protected  double[] mDynamicSymbolValues
           
protected  double[] mInitialDynamicSymbolValues
           
protected  boolean mInitialized
           
protected  boolean mIsStochasticSimulator
           
protected  long mMinNumMillisecondsForUpdate
           
protected  String mModelName
           
protected  Value[] mNonDynamicSymbolExpressionValues
           
protected  Value[] mNonDynamicSymbolValues
           
protected  double[] mReactionProbabilities
           
protected  Value[] mReactionRates
           
protected  Reaction[] mReactions
           
protected  DelayedReactionSolver[] mReactionsDelayedReactionAssociations
           
protected  HashMap[] mReactionsLocalParamSymbolsMaps
           
protected  Object[] mReactionsProductsDynamic
           
protected  Object[] mReactionsProductsSpecies
           
protected  Object[] mReactionsProductsStoichiometries
           
protected  Object[] mReactionsReactantsDynamic
           
protected  Object[] mReactionsReactantsSpecies
           
protected  Object[] mReactionsReactantsStoichiometries
           
protected  Symbol[] mReactionSymbols
           
protected  SimulationController mSimulationController
           
protected  SimulationProgressReporter mSimulationProgressReporter
           
protected  SymbolEvaluatorChem mSymbolEvaluator
           
protected  HashMap mSymbolMap
           
protected  boolean mUseExpressionValueCaching
           
protected static int NULL_REACTION
           
 
Constructor Summary
Simulator()
           
 
Method Summary
protected  int addRequestedSymbolValues(double pCurTime, int pLastTimeIndex, Symbol[] pRequestedSymbols, double[] pTimeValues, Object[] pRetSymbolValues)
           
 boolean canComputeFluctuations()
           
 void checkSimulationParameters(double pStartTime, double pEndTime, SimulatorParameters pSimulatorParameters, int pNumResultsTimePoints)
           
protected  void checkSimulationParametersForDeterministicSimulator(SimulatorParameters pSimulatorParameters, int pNumResultsTimePoints)
           
protected abstract  void checkSimulationParametersImpl(SimulatorParameters pSimulatorParameters, int pNumResultsTimePoints)
           
protected  void clearExpressionValueCaches()
           
protected  void clearSimulatorState()
           
protected  void computeDerivative(double[] pTempDynamicSymbolValues, double[] pDynamicSymbolDerivatives)
           
protected  Expression computeRatePartialDerivativeExpression(int pReactionCtr, Expression pRateExpression, SymbolValue pSymbolValue, SymbolEvaluatorChem pSymbolEvaluator)
           
protected  void computeReactionProbabilities()
           
protected  Symbol[] createRequestedSymbolArray(HashMap pSymbolMap, String[] pRequestedSymbols)
           
protected  SimulationResults createSimulationResults(double pStartTime, double pEndTime, SimulatorParameters pSimulatorParameters, String[] pResultsSymbolNames, double[] pResultsTimeValues, Object[] pResultsSymbolValues, double[] pResultsFinalSymbolFluctuations)
           
protected static double[] createTimesArray(double pStartTime, double pEndTime, int pNumTimePoints)
           
abstract  String getAlias()
           
protected static double getDelayedReactionEstimatedAverageFutureRate(SymbolEvaluatorChem pSymbolEvaluator, DelayedReactionSolver[] pDelayedReactionSolvers)
           
protected  double getMinDelayedReactionDelay()
           
static Expression[] getReactionRateExpressions(Reaction[] pReactions)
           
protected  boolean hasDelayedReactionSolvers()
           
protected  void initializeDynamicSymbolAdjustmentVectors()
           
protected  void initializeSimulator(Model pModel)
           
 boolean isInitialized()
           
abstract  boolean isStochasticSimulator()
           
protected  void prepareForSimulation(double pStartTime)
           
protected  void resizeDelayedReactionSolvers(int pNumHistoryBins)
           
 void setController(SimulationController pSimulationController)
           
protected  void setInitialized(boolean pInitialized)
           
protected  void setMinNumMillisecondsForUpdate(long pMinNumMillisecondsForUpdate)
           
 void setProgressReporter(SimulationProgressReporter pSimulationProgressReporter)
           
 void setStatusUpdateIntervalSeconds(double pUpdateIntervalSeconds)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_MIN_NUM_MILLISECONDS_FOR_UPDATE

protected static final long DEFAULT_MIN_NUM_MILLISECONDS_FOR_UPDATE
See Also:
Constant Field Values

NULL_REACTION

protected static final int NULL_REACTION
See Also:
Constant Field Values

mModelName

protected String mModelName

mNonDynamicSymbolValues

protected Value[] mNonDynamicSymbolValues

mNonDynamicSymbolExpressionValues

protected Value[] mNonDynamicSymbolExpressionValues

mUseExpressionValueCaching

protected boolean mUseExpressionValueCaching

mSymbolEvaluator

protected SymbolEvaluatorChem mSymbolEvaluator

mSymbolMap

protected HashMap mSymbolMap

mSimulationController

protected SimulationController mSimulationController

mDelayedReactionSolvers

protected DelayedReactionSolver[] mDelayedReactionSolvers

mInitialized

protected boolean mInitialized

mMinNumMillisecondsForUpdate

protected long mMinNumMillisecondsForUpdate

mSimulationProgressReporter

protected SimulationProgressReporter mSimulationProgressReporter

mIsStochasticSimulator

protected boolean mIsStochasticSimulator

mDynamicSymbols

protected Species[] mDynamicSymbols

mInitialDynamicSymbolValues

protected double[] mInitialDynamicSymbolValues

mDynamicSymbolNames

protected String[] mDynamicSymbolNames

mDynamicSymbolValues

protected double[] mDynamicSymbolValues

mReactions

protected Reaction[] mReactions

mDynamicSymbolAdjustmentVectors

protected Object[] mDynamicSymbolAdjustmentVectors

mReactionProbabilities

protected double[] mReactionProbabilities

mReactionsReactantsSpecies

protected Object[] mReactionsReactantsSpecies

mReactionsReactantsStoichiometries

protected Object[] mReactionsReactantsStoichiometries

mReactionsReactantsDynamic

protected Object[] mReactionsReactantsDynamic

mReactionsProductsSpecies

protected Object[] mReactionsProductsSpecies

mReactionsProductsStoichiometries

protected Object[] mReactionsProductsStoichiometries

mReactionsProductsDynamic

protected Object[] mReactionsProductsDynamic

mReactionsLocalParamSymbolsMaps

protected HashMap[] mReactionsLocalParamSymbolsMaps

mReactionRates

protected Value[] mReactionRates

mReactionsDelayedReactionAssociations

protected DelayedReactionSolver[] mReactionsDelayedReactionAssociations

mReactionSymbols

protected Symbol[] mReactionSymbols
Constructor Detail

Simulator

public Simulator()
Method Detail

hasDelayedReactionSolvers

protected boolean hasDelayedReactionSolvers()

isInitialized

public final boolean isInitialized()

canComputeFluctuations

public boolean canComputeFluctuations()

resizeDelayedReactionSolvers

protected final void resizeDelayedReactionSolvers(int pNumHistoryBins)

prepareForSimulation

protected final void prepareForSimulation(double pStartTime)

isStochasticSimulator

public abstract boolean isStochasticSimulator()

initializeSimulator

protected final void initializeSimulator(Model pModel)
                                  throws DataNotFoundException
Throws:
DataNotFoundException

setInitialized

protected void setInitialized(boolean pInitialized)

clearSimulatorState

protected void clearSimulatorState()

initializeDynamicSymbolAdjustmentVectors

protected final void initializeDynamicSymbolAdjustmentVectors()

getAlias

public abstract String getAlias()

createSimulationResults

protected final SimulationResults createSimulationResults(double pStartTime,
                                                          double pEndTime,
                                                          SimulatorParameters pSimulatorParameters,
                                                          String[] pResultsSymbolNames,
                                                          double[] pResultsTimeValues,
                                                          Object[] pResultsSymbolValues,
                                                          double[] pResultsFinalSymbolFluctuations)

addRequestedSymbolValues

protected final int addRequestedSymbolValues(double pCurTime,
                                             int pLastTimeIndex,
                                             Symbol[] pRequestedSymbols,
                                             double[] pTimeValues,
                                             Object[] pRetSymbolValues)
                                      throws DataNotFoundException
Throws:
DataNotFoundException

createTimesArray

protected static final double[] createTimesArray(double pStartTime,
                                                 double pEndTime,
                                                 int pNumTimePoints)

createRequestedSymbolArray

protected final Symbol[] createRequestedSymbolArray(HashMap pSymbolMap,
                                                    String[] pRequestedSymbols)
                                             throws DataNotFoundException
Throws:
DataNotFoundException

checkSimulationParameters

public final void checkSimulationParameters(double pStartTime,
                                            double pEndTime,
                                            SimulatorParameters pSimulatorParameters,
                                            int pNumResultsTimePoints)
                                     throws IllegalArgumentException,
                                            IllegalStateException
Throws:
IllegalArgumentException
IllegalStateException

checkSimulationParametersImpl

protected abstract void checkSimulationParametersImpl(SimulatorParameters pSimulatorParameters,
                                                      int pNumResultsTimePoints)

computeReactionProbabilities

protected final void computeReactionProbabilities()
                                           throws DataNotFoundException
Throws:
DataNotFoundException

getDelayedReactionEstimatedAverageFutureRate

protected static final double getDelayedReactionEstimatedAverageFutureRate(SymbolEvaluatorChem pSymbolEvaluator,
                                                                           DelayedReactionSolver[] pDelayedReactionSolvers)
                                                                    throws DataNotFoundException
Throws:
DataNotFoundException

clearExpressionValueCaches

protected final void clearExpressionValueCaches()

computeDerivative

protected final void computeDerivative(double[] pTempDynamicSymbolValues,
                                       double[] pDynamicSymbolDerivatives)
                                throws DataNotFoundException
Throws:
DataNotFoundException

setProgressReporter

public final void setProgressReporter(SimulationProgressReporter pSimulationProgressReporter)

setController

public final void setController(SimulationController pSimulationController)

setStatusUpdateIntervalSeconds

public final void setStatusUpdateIntervalSeconds(double pUpdateIntervalSeconds)
                                          throws IllegalArgumentException
Throws:
IllegalArgumentException

setMinNumMillisecondsForUpdate

protected final void setMinNumMillisecondsForUpdate(long pMinNumMillisecondsForUpdate)

getMinDelayedReactionDelay

protected final double getMinDelayedReactionDelay()

computeRatePartialDerivativeExpression

protected Expression computeRatePartialDerivativeExpression(int pReactionCtr,
                                                            Expression pRateExpression,
                                                            SymbolValue pSymbolValue,
                                                            SymbolEvaluatorChem pSymbolEvaluator)
                                                     throws DataNotFoundException
Throws:
DataNotFoundException

getReactionRateExpressions

public static Expression[] getReactionRateExpressions(Reaction[] pReactions)
                                               throws DataNotFoundException
Throws:
DataNotFoundException

checkSimulationParametersForDeterministicSimulator

protected void checkSimulationParametersForDeterministicSimulator(SimulatorParameters pSimulatorParameters,
                                                                  int pNumResultsTimePoints)