copasi API
0.1
|
#include <CHybridMethodLSODA.h>
Classes | |
struct | Data |
Public Member Functions | |
CHybridMethodLSODA (const CHybridMethodLSODA &src, const CCopasiContainer *pParent=NULL) | |
~CHybridMethodLSODA () | |
virtual bool | elevateChildren () |
virtual Status | step (const double &deltaT) |
virtual void | start (const CState *initialState) |
virtual bool | isValidProblem (const CCopasiProblem *pProblem) |
Static Public Member Functions | |
static CHybridMethodLSODA * | createHybridMethodLSODA () |
Protected Types | |
enum | metabStatus { LOW = 0, HIGH } |
Protected Member Functions | |
CHybridMethodLSODA (const CCopasiContainer *pParent=NULL) | |
void | initMethod (C_FLOAT64 time) |
void | cleanup () |
virtual C_FLOAT64 | doSingleStep (C_FLOAT64 currentTime, C_FLOAT64 endTime)=0 |
void | integrateDeterministicPart (C_FLOAT64 ds) |
void | calculateDerivative (std::vector< C_FLOAT64 > &deriv) |
void | getState (std::vector< C_FLOAT64 > &target) |
void | setState (std::vector< C_FLOAT64 > &source) |
C_FLOAT64 | getDefaultAtol (const CModel *pModel) const |
void | evalF (const C_FLOAT64 *t, const C_FLOAT64 *y, C_FLOAT64 *ydot) |
void | getStochTimeAndIndex (C_FLOAT64 &ds, C_INT32 &rIndex) |
void | fireReaction (C_INT32 rIndex) |
void | updatePriorityQueue (C_INT32 rIndex, C_FLOAT64 time) |
C_FLOAT64 | generateReactionTime (C_INT32 rIndex) |
void | calculateAmu (C_INT32 rIndex) |
void | updateTauMu (C_INT32 rIndex, C_FLOAT64 time) |
void | setupBalances () |
void | setupDependencyGraph () |
void | setupMetab2React () |
void | setupMetab2ReactPlusModifier () |
void | setupMetab2ReactComplete () |
void | setupPartition () |
void | setupPriorityQueue (C_FLOAT64 startTime=0.0) |
void | partitionSystem () |
void | insertDeterministicReaction (C_INT32 rIndex) |
void | removeDeterministicReaction (C_INT32 rIndex) |
std::set< std::string > * | getDependsOn (C_INT32 rIndex) |
std::set< std::string > * | getAffects (C_INT32 rIndex) |
std::set< C_INT32 > * | getParticipatesIn (C_INT32 rIndex) |
void | outputData (std::ostream &os, C_INT32 mode) |
void | outputDebug (std::ostream &os, C_INT32 level) |
Static Protected Member Functions | |
static void | EvalF (const C_INT *n, const C_FLOAT64 *t, const C_FLOAT64 *y, C_FLOAT64 *ydot) |
static C_INT32 | checkModel (CModel *model) |
static bool | modelHasAssignments (const CModel *pModel) |
Protected Attributes | |
CVersion | mVersion |
CModel * | mpModel |
unsigned C_INT32 | mNumVariableMetabs |
unsigned C_INT32 | mFirstMetabIndex |
unsigned C_INT32 | mMaxSteps |
bool | mMaxStepsReached |
bool | mUseRandomSeed |
unsigned C_INT32 | mRandomSeed |
C_INT32 | mMaxBalance |
C_INT32 | mMaxIntBeforeStep |
bool | mDoCorrection |
const CCopasiVectorNS < CReaction > * | mpReactions |
CCopasiVector< CMetab > * | mpMetabolites |
CMatrix< C_FLOAT64 > | mStoi |
std::vector< C_FLOAT64 > | temp |
std::vector< C_FLOAT64 > | currentState |
std::vector < CHybridLSODAStochFlag > | mReactionFlags |
CHybridLSODAStochFlag * | mFirstReactionFlag |
std::vector< metabStatus > | mMetabFlags |
std::vector< std::vector < CHybridLSODABalance > > | mLocalBalances |
std::vector< std::vector < CHybridLSODABalance > > | mLocalSubstrates |
C_FLOAT64 | mLowerStochLimit |
C_FLOAT64 | mUpperStochLimit |
unsigned C_INT32 | mPartitioningInterval |
unsigned C_INT32 | mStepsAfterPartitionSystem |
C_FLOAT64 | mStepsize |
std::vector< std::set< C_INT32 > > | mMetab2React |
std::vector< C_FLOAT64 > | mAmu |
std::vector< C_FLOAT64 > | mAmuOld |
std::set< C_INT32 > | mUpdateSet |
CRandom * | mpRandomGenerator |
CDependencyGraph | mDG |
CIndexedPriorityQueue | mPQ |
bool | mRestartLSODA |
CState * | mpState |
Data | mData |
C_FLOAT64 * | mY |
CVector< C_FLOAT64 > | mYdot |
C_FLOAT64 | mTime |
C_FLOAT64 | mEndt |
C_INT | mLsodaStatus |
bool | mReducedModel |
C_FLOAT64 | mRtol |
bool | mDefaultAtol |
C_FLOAT64 | mAtol |
std::ostringstream | mErrorMsg |
CLSODA | mLSODA |
C_INT | mState |
CVector< C_FLOAT64 > | mDWork |
CVector< C_INT > | mIWork |
C_INT | mJType |
std::ofstream | mOutputFile |
std::string | mOutputFileName |
C_INT32 | mOutputCounter |
bool | mHasAssignments |
Friends | |
CTrajectoryMethod * | CTrajectoryMethod::createTrajectoryMethod (CCopasiMethod::SubType subType, CTrajectoryProblem *pProblem) |
enum CHybridMethodLSODA::metabStatus [protected] |
CHybridMethodLSODA::CHybridMethodLSODA | ( | const CHybridMethodLSODA & | src, |
const CCopasiContainer * | pParent = NULL |
||
) |
Copy constructor
const | CHybridMethodLSODA & src |
const | CCopasiContainer * pParent (default: NULL) |
CHybridMethodLSODA::~CHybridMethodLSODA | ( | ) |
Destructor.
CHybridMethodLSODA::CHybridMethodLSODA | ( | const CCopasiContainer * | pParent = NULL | ) | [protected] |
Default constructor.
const | CCopasiContainer * pParent (default: NULL) |
This class implements an hybrid algorithm for the simulation of a biochemical system over time.
File name: CHybridMethodLSODA.cpp Author: Juergen Pahle Email: juergen.pahle@eml-r.villa-bosch.de
Last change: 09, May 2006
(C) European Media Lab 2003. Default constructor.
void CHybridMethodLSODA::calculateAmu | ( | C_INT32 | rIndex | ) | [protected] |
Calculates an amu value for a given reaction.
rIndex | A C_INT32 specifying the reaction to be updated |
void CHybridMethodLSODA::calculateDerivative | ( | std::vector< C_FLOAT64 > & | deriv | ) | [protected] |
Calculates the derivative of the system and writes it into the vector deriv. Length of deriv must be mNumVariableMetabs. CAUTION: Only deterministic reactions are taken into account. That is, this is only the derivative of the deterministic part of the system.
deriv | A vector reference of length mNumVariableMetabs, into which the derivative is written |
C_INT32 CHybridMethodLSODA::checkModel | ( | CModel * | model | ) | [static, protected] |
Test the model if it is proper to perform stochastic simulations on. Several properties are tested (e.g. integer stoichometry, all reactions take place in one compartment only, irreversibility...).
model | The model to be checked |
Test the model if it is proper to perform stochastic simulations on. Several properties are tested (e.g. integer stoichometry, all reactions take place in one compartment only, irreversibility...).
void CHybridMethodLSODA::cleanup | ( | ) | [protected] |
Cleans up memory, etc.
CHybridMethodLSODA * CHybridMethodLSODA::createHybridMethodLSODA | ( | ) | [static] |
Creates a HybridMethod adequate for the problem. (only CHybridNextReactionLSODAMethod so far)
Creates a HybridMethodLSODA adequate for the problem.
virtual C_FLOAT64 CHybridMethodLSODA::doSingleStep | ( | C_FLOAT64 | currentTime, |
C_FLOAT64 | endTime | ||
) | [protected, pure virtual] |
Simulates the system over the next interval of time. The current time and the end time of the current step() are given as arguments.
currentTime | A C_FLOAT64 specifying the current time |
endTime | A C_FLOAT64 specifying the end time of the step() |
Implemented in CHybridNextReactionLSODAMethod.
bool CHybridMethodLSODA::elevateChildren | ( | ) | [virtual] |
This methods must be called to elevate subgroups to derived objects. The default implementation does nothing.
Reimplemented from CCopasiParameterGroup.
void CHybridMethodLSODA::EvalF | ( | const C_INT * | n, |
const C_FLOAT64 * | t, | ||
const C_FLOAT64 * | y, | ||
C_FLOAT64 * | ydot | ||
) | [static, protected] |
void CHybridMethodLSODA::evalF | ( | const C_FLOAT64 * | t, |
const C_FLOAT64 * | y, | ||
C_FLOAT64 * | ydot | ||
) | [protected] |
This evaluates the derivatives for the complete model
void CHybridMethodLSODA::fireReaction | ( | C_INT32 | rIndex | ) | [protected] |
Executes the specified reaction in the system once.
rIndex | A C_INT32 specifying the index of the reaction, which will be fired. |
Executes the specified reaction in the system once.
rIndex | A C_INT32 specifying the index of the reaction, which will be fired. |
time | The current time |
C_FLOAT64 CHybridMethodLSODA::generateReactionTime | ( | C_INT32 | rIndex | ) | [protected] |
Generates a putative reaction time for the given reaction.
rIndex | A C_INT32 specifying the index of the reaction |
std::set< std::string > * CHybridMethodLSODA::getAffects | ( | C_INT32 | rIndex | ) | [protected] |
Gets the set of metabolites which change number when a given reaction is executed.
rIndex | The index of the reaction being executed. |
C_FLOAT64 CHybridMethodLSODA::getDefaultAtol | ( | const CModel * | pModel | ) | const [protected] |
Calculate the default absolute tolerance
const | CModel * pModel |
std::set< std::string > * CHybridMethodLSODA::getDependsOn | ( | C_INT32 | rIndex | ) | [protected] |
Gets the set of metabolites on which a given reaction depends.
rIndex | The index of the reaction being executed. |
std::set< C_INT32 > * CHybridMethodLSODA::getParticipatesIn | ( | C_INT32 | rIndex | ) | [protected] |
Gets the set of metabolites, which participate in the given reaction either as substrate, product or modifier.
rIndex | The index of the reaction being executed. |
void CHybridMethodLSODA::getState | ( | std::vector< C_FLOAT64 > & | target | ) | [protected] |
Gathers the state of the system into the array target. Later on CState should be used for this. Length of the array target must be mNumVariableMetabs.
target | A vector reference of length mNumVariableMetabs, into which the state of the system is written |
void CHybridMethodLSODA::getStochTimeAndIndex | ( | C_FLOAT64 & | ds, |
C_INT32 & | rIndex | ||
) | [protected] |
Find the reaction index and the reaction time of the stochastic (!) reaction with the lowest reaction time.
ds | A reference to a C_FLOAT64. The putative reaction time for the first stochastic reaction is written into this variable. |
rIndex | A reference to a C_INT32. The index of the first stochastic reaction is written into this variable. |
void CHybridMethodLSODA::initMethod | ( | C_FLOAT64 | start_time | ) | [protected] |
Initializes the solver.
time | the current time |
Initializes the solver and sets the model to be used.
model | A reference to an instance of a CModel |
void CHybridMethodLSODA::insertDeterministicReaction | ( | C_INT32 | rIndex | ) | [protected] |
Inserts a new deterministic reaction into the linked list in the vector mReactionFlags.
rIndex | A C_INT32 giving the index of the reaction to be inserted into the list of deterministic reactions. |
Inserts a new deterministic reaction into the linked list in the array mReactionFlags.
rIndex | A C_INT32 giving the index of the reaction to be inserted into the list of deterministic reactions. |
void CHybridMethodLSODA::integrateDeterministicPart | ( | C_FLOAT64 | deltaT | ) | [protected] |
Integrates the deterministic reactions of the system over the specified time interval.
ds | A C_FLOAT64 specifying the stepsize. |
bool CHybridMethodLSODA::isValidProblem | ( | const CCopasiProblem * | pProblem | ) | [virtual] |
Check if the method is suitable for this problem
Reimplemented from CTrajectoryMethod.
bool CHybridMethodLSODA::modelHasAssignments | ( | const CModel * | pModel | ) | [static, protected] |
tests if the model contains a global value with an assignment rule that is used in calculations
void CHybridMethodLSODA::outputData | ( | std::ostream & | os, |
C_INT32 | mode | ||
) | [protected] |
Prints out data on standard output.
Prints out data on standard output. Deprecated.
void CHybridMethodLSODA::outputDebug | ( | std::ostream & | os, |
C_INT32 | level | ||
) | [protected] |
Prints out various data on standard output for debugging purposes.
void CHybridMethodLSODA::partitionSystem | ( | ) | [protected] |
Updates the partitioning of the system depending on the particle numbers present.
void CHybridMethodLSODA::removeDeterministicReaction | ( | C_INT32 | rIndex | ) | [protected] |
Removes a deterministic reaction from the linked list in the vector mReactionFlags.
rIndex | A C_INT32 giving the index of the reaction to be removed from the list of deterministic reactions. |
Removes a deterministic reaction from the linked list in the array mReactionFlags.
rIndex | A C_INT32 giving the index of the reaction to be removed from the list of deterministic reactions. |
void CHybridMethodLSODA::setState | ( | std::vector< C_FLOAT64 > & | source | ) | [protected] |
Writes the state specified in the array source into the model. Length of the vector source must be mNumVariableMetabs. (Number of non-fixed metabolites in the model).
source | A vector reference with length mNumVariableMetabs, holding the state of the system to be set in the model |
void CHybridMethodLSODA::setupBalances | ( | ) | [protected] |
Sets up an internal representation of the balances for each reaction. This is done in order to be able to deal with fixed metabolites and to avoid a time consuming search for the indices of metabolites in the model.
void CHybridMethodLSODA::setupDependencyGraph | ( | ) | [protected] |
Sets up the dependency graph
Sets up the dependency graph.
void CHybridMethodLSODA::setupMetab2React | ( | ) | [protected] |
Creates for each metabolite a set of reaction indices. If the metabolite participates in a reaction as substrate or product this reaction is added to the corresponding set.
Creates for each metabolite a set of reaction indices. If the metabolite participates in a reaction as substrate or product (that means: balance != 0) this reaction is added to the corresponding set.
void CHybridMethodLSODA::setupMetab2ReactComplete | ( | ) | [protected] |
Creates for each metabolite a set of reaction indices. Each reaction is dependent on each metabolite resulting in a complete switch.
void CHybridMethodLSODA::setupMetab2ReactPlusModifier | ( | ) | [protected] |
Creates for each metabolite a set of reaction indices. If the metabolite participates in a reaction as substrate, product or modifier this reaction is added to the corresponding set.
void CHybridMethodLSODA::setupPartition | ( | ) | [protected] |
Creates an initial partitioning of the system. Deterministic and stochastic reactions are determined. The array mStochReactions is initialized.
Creates an initial partitioning of the system. Deterministic and stochastic reactions are determined. The vector mReactionFlags and the vector mMetabFlags are initialized.
void CHybridMethodLSODA::setupPriorityQueue | ( | C_FLOAT64 | startTime = 0.0 | ) | [protected] |
Sets up the priority queue.
startTime | The time at which the simulation starts. |
void CHybridMethodLSODA::start | ( | const CState * | initialState | ) | [virtual] |
This instructs the method to prepare for integration starting with the initialState given.
const CState * | initialState |
Reimplemented from CTrajectoryMethod.
CTrajectoryMethod::Status CHybridMethodLSODA::step | ( | const double & | deltaT | ) | [virtual] |
This instructs the method to calculate a time step of deltaT starting with the current state, i.e., the result of the previous step. The new state (after deltaT) is expected in the current state. The return value is the actual timestep taken.
const double & | deltaT |
Reimplemented from CTrajectoryMethod.
void CHybridMethodLSODA::updatePriorityQueue | ( | C_INT32 | rIndex, |
C_FLOAT64 | time | ||
) | [protected] |
Updates the priority queue.
rIndex | A C_INT32 giving the index of the fired reaction |
time | A C_FLOAT64 holding the time taken by this reaction |
Updates the priority queue.
rIndex | A C_INT32 giving the index of the fired reaction (-1, if no stochastic reaction has fired) |
time | A C_FLOAT64 holding the current time |
void CHybridMethodLSODA::updateTauMu | ( | C_INT32 | rIndex, |
C_FLOAT64 | time | ||
) | [protected] |
Updates the putative reaction time of a stochastic reaction in the priority queue. The corresponding amu and amu_old must be set prior to the call of this method.
rIndex | A C_INT32 specifying the index of the reaction |
time | A C_FLOAT64 specifying the current time |
Updates the putative reaction time of a stochastic reaction in the priority queue. The corresponding amu and amu_old must be set prior to the call of this method.
rIndex | A C_INT32 specifying the index of the reaction |
CTrajectoryMethod* CTrajectoryMethod::createTrajectoryMethod | ( | CCopasiMethod::SubType | subType, |
CTrajectoryProblem * | pProblem | ||
) | [friend] |
std::vector<C_FLOAT64> CHybridMethodLSODA::currentState [protected] |
std::vector<C_FLOAT64> CHybridMethodLSODA::mAmu [protected] |
The propensities of the stochastic reactions.
std::vector<C_FLOAT64> CHybridMethodLSODA::mAmuOld [protected] |
C_FLOAT64 CHybridMethodLSODA::mAtol [protected] |
Absolute tolerance.
Data CHybridMethodLSODA::mData [protected] |
mData.dim is the dimension of the ODE system. mData.pMethod contains CLsodaMethod * this to be used in the static method EvalF
bool CHybridMethodLSODA::mDefaultAtol [protected] |
CDependencyGraph CHybridMethodLSODA::mDG [protected] |
The graph of reactions and their dependent reactions. When a reaction is executed, the propensities for each of its dependents must be updated.
bool CHybridMethodLSODA::mDoCorrection [protected] |
indicates if the correction N^2 -> N*(N-1) should be performed
CVector< C_FLOAT64 > CHybridMethodLSODA::mDWork [protected] |
C_FLOAT64 CHybridMethodLSODA::mEndt [protected] |
Requested end time.
std::ostringstream CHybridMethodLSODA::mErrorMsg [protected] |
unsigned C_INT32 CHybridMethodLSODA::mFirstMetabIndex [protected] |
index of the first metab in CState
bool CHybridMethodLSODA::mHasAssignments [protected] |
Indicates whether the model has global quantities with assignment rules. If it has, we will use a less efficient way to update the model state to handle this.
CVector< C_INT > CHybridMethodLSODA::mIWork [protected] |
C_INT CHybridMethodLSODA::mJType [protected] |
std::vector<std::vector <CHybridLSODABalance> > CHybridMethodLSODA::mLocalBalances [protected] |
Internal representation of the balances of each reaction. The index of each metabolite in the reaction is provided.
std::vector<std::vector <CHybridLSODABalance> > CHybridMethodLSODA::mLocalSubstrates [protected] |
Internal representation of the substrates of each reaction. The index of each substrate-metabolite is provided.
C_FLOAT64 CHybridMethodLSODA::mLowerStochLimit [protected] |
Limit for particle numbers. If a particle number is < StochLimit the corresponding reactions must be simulated stochastically.
CLSODA CHybridMethodLSODA::mLSODA [protected] |
C_INT CHybridMethodLSODA::mLsodaStatus [protected] |
LSODA state.
C_INT32 CHybridMethodLSODA::mMaxBalance [protected] |
maximal increase of a particle number in one step.
C_INT32 CHybridMethodLSODA::mMaxIntBeforeStep [protected] |
This is set to maxint - mMaxSteps*mMaxBalance
unsigned C_INT32 CHybridMethodLSODA::mMaxSteps [protected] |
Max number of doSingleStep() per step()
bool CHybridMethodLSODA::mMaxStepsReached [protected] |
std::vector<std::set <C_INT32> > CHybridMethodLSODA::mMetab2React [protected] |
Vector of relations between metabolites to reactions.
std::vector<metabStatus> CHybridMethodLSODA::mMetabFlags [protected] |
Vector holding information on the status of metabolites. They can have low or high particle numbers.
unsigned C_INT32 CHybridMethodLSODA::mNumVariableMetabs [protected] |
Dimension of the system. Total number of metabolites.
C_INT32 CHybridMethodLSODA::mOutputCounter [protected] |
Output counter.
std::ofstream CHybridMethodLSODA::mOutputFile [protected] |
File output stream to write data.
std::string CHybridMethodLSODA::mOutputFileName [protected] |
Output filename.
unsigned C_INT32 CHybridMethodLSODA::mPartitioningInterval [protected] |
The system gets repartitioned after this number of elementary steps.
CCopasiVector<CMetab>* CHybridMethodLSODA::mpMetabolites [protected] |
A pointer to the metabolites of the model.
CModel* CHybridMethodLSODA::mpModel [protected] |
Pointer to the model
CIndexedPriorityQueue CHybridMethodLSODA::mPQ [protected] |
The set of putative stochastic (!) reactions and associated times at which each reaction occurs. This is represented as a priority queue, sorted by the reaction time. This heap changes dynamically as stochastic reactions become deterministic (delete this reaction from the queue) or vice versa (insert a new reaction into the queue).
CRandom* CHybridMethodLSODA::mpRandomGenerator [protected] |
The random number generator.
const CCopasiVectorNS<CReaction>* CHybridMethodLSODA::mpReactions [protected] |
A pointer to the reactions of the model.
CState* CHybridMethodLSODA::mpState [protected] |
A pointer to the current state in complete model view.
unsigned C_INT32 CHybridMethodLSODA::mRandomSeed [protected] |
The random seed to use.
std::vector<CHybridLSODAStochFlag> CHybridMethodLSODA::mReactionFlags [protected] |
Vector to hold information about how many metabolites of a reaction have low particle numbers. If no metabolite of one reaction has low particle numbers this reaction will be simulated det.
bool CHybridMethodLSODA::mReducedModel [protected] |
bool CHybridMethodLSODA::mRestartLSODA [protected] |
this flag indicates whether the next LSODA call needs to reinitialize the integrater (if the partitioning has changed or a stochastic reaction was fired)
C_FLOAT64 CHybridMethodLSODA::mRtol [protected] |
Relative tolerance.
C_INT CHybridMethodLSODA::mState [protected] |
unsigned C_INT32 CHybridMethodLSODA::mStepsAfterPartitionSystem [protected] |
Number of elementary steps after the last partitioning.
C_FLOAT64 CHybridMethodLSODA::mStepsize [protected] |
Partitioning stepsize
CMatrix<C_FLOAT64> CHybridMethodLSODA::mStoi [protected] |
The stoichometry matrix of the model.
C_FLOAT64 CHybridMethodLSODA::mTime [protected] |
Current time.
std::set<C_INT32> CHybridMethodLSODA::mUpdateSet [protected] |
Set of the reactions, which must be updated.
C_FLOAT64 CHybridMethodLSODA::mUpperStochLimit [protected] |
bool CHybridMethodLSODA::mUseRandomSeed [protected] |
Specifies if the mRandomSeed should be used. otherwise a randomly chosen seed is used.
CVersion CHybridMethodLSODA::mVersion [protected] |
Version number of this class
C_FLOAT64* CHybridMethodLSODA::mY [protected] |
Pointer to the array with left hand side values.
CVector< C_FLOAT64 > CHybridMethodLSODA::mYdot [protected] |
Vector containig the derivatives after calling eval
std::vector<C_FLOAT64> CHybridMethodLSODA::temp [protected] |
Vectors to hold the system state and intermediate results