COPASI API  4.16.103
CTrajectoryMethod.cpp
Go to the documentation of this file.
1 // Copyright (C) 2010 - 2013 by Pedro Mendes, Virginia Tech Intellectual
2 // Properties, Inc., University of Heidelberg, and The University
3 // of Manchester.
4 // All rights reserved.
5 
6 // Copyright (C) 2008 - 2009 by Pedro Mendes, Virginia Tech Intellectual
7 // Properties, Inc., EML Research, gGmbH, University of Heidelberg,
8 // and The University of Manchester.
9 // All rights reserved.
10 
11 // Copyright (C) 2002 - 2007 by Pedro Mendes, Virginia Tech Intellectual
12 // Properties, Inc. and EML Research, gGmbH.
13 // All rights reserved.
14 
15 /**
16  * CTrajectoryMethod class.
17  * This class describes the interface to all integration methods.
18  * The various method like LSODA or Gillespie have to be derived from
19  * this class.
20  *
21  * Created for COPASI by Stefan Hoops 2002
22  */
23 
24 #include "copasi.h"
25 
26 #include "CTrajectoryMethod.h"
27 #include "CLsodaMethod.h"
28 #include "CStochDirectMethod.h"
30 #include "CTrajAdaptiveSA.h"
31 #include "CHybridMethod.h"
32 #include "CHybridMethodLSODA.h"
33 #include "CTauLeapMethod.h"
34 #include "CHybridMethodODE45.h"
36 #include "CTrajectoryProblem.h"
37 #include "model/CState.h"
38 #include "model/CCompartment.h"
39 
42 {
43  CTrajectoryMethod * pMethod = NULL;
44 
45  switch (subType)
46  {
47  case unset:
48  case deterministic:
49  pMethod = new CLsodaMethod();
50  break;
51 
52  case stochastic:
53  pMethod = new CStochNextReactionMethod();
54  break;
55 
56  case directMethod:
57  pMethod = new CStochDirectMethod();
58  break;
59 
60  case tauLeap:
61  pMethod = new CTauLeapMethod();
62  break;
63 
64  case adaptiveSA:
65  pMethod = new CTrajAdaptiveSA();
66  break;
67 
68  case hybrid:
70  break;
71 
72  case hybridLSODA:
74  break;
75 
76 #ifdef COPASI_DEBUG
77 
78  case hybridODE45:
79  pMethod = new CHybridMethodODE45();
80  break;
81 #endif // COPASI_DEBUG
82 
83  case DsaLsodar:
84  pMethod = new CTrajectoryMethodDsaLsodar();
85  break;
86 
87  default:
88  fatalError();
89  break;
90  }
91 
92  return pMethod;
93 }
94 
95 /**
96  * Default constructor.
97  */
99  const CCopasiContainer * pParent) :
100  CCopasiMethod(CCopasiTask::timeCourse, subType, pParent),
101  mpCurrentState(NULL),
102  mpProblem(NULL),
103  mRoots(0)
105 
106 /**
107  * Copy constructor.
108  * @param "const CTrajectoryMethod &" src
109  */
111  const CCopasiContainer * pParent):
112  CCopasiMethod(src, pParent),
113  mpCurrentState(src.mpCurrentState),
114  mpProblem(src.mpProblem),
115  mRoots(src.mRoots)
117 
118 /**
119  * Destructor.
120  */
123 
125 {
126  mpCurrentState = currentState;
127 }
128 
129 /**
130  * Set a pointer to the problem.
131  * This method is used by CTrajectory
132  * @param "CTrajectoryProblem *" problem
133  */
135 {mpProblem = problem;}
136 
137 // virtual
139 {}
140 
141 /**
142  * This instructs the method to calculate a a time step of deltaT
143  * starting with the current state, i.e., the result of the previous
144  * step.
145  * The new state (after deltaT) is expected in the current state.
146  * The return value is the actual timestep taken.
147  * @param "const double &" deltaT
148  */
150 {return FAILURE;}
151 
152 /**
153  * This instructs the method to calculate a a time step of deltaT
154  * starting with the initialState given.
155  * The new state (after deltaT) is expected in the current state.
156  * The return value is the actual timestep taken.
157  * @param "double &" deltaT
158  * @param "const CState *" initialState
159  * @return "const double &" actualDeltaT
160  */
161 void CTrajectoryMethod::start(const CState * C_UNUSED(initialState))
162 {return;}
163 
164 //virtual
166 {
167  if (!CCopasiMethod::isValidProblem(pProblem)) return false;
168 
169  const CTrajectoryProblem * pTP = dynamic_cast<const CTrajectoryProblem *>(pProblem);
170 
171  if (!pTP)
172  {
173  //not a TrajectoryProblem
175  return false;
176  }
177 
178  return true;
179 }
180 
182 {
183  return mRoots;
184 }
void setProblem(CTrajectoryProblem *problem)
virtual void stateChanged()
#define fatalError()
Definition: CState.h:305
CTrajectoryProblem * mpProblem
void setCurrentState(CState *currentState)
#define C_UNUSED(p)
Definition: copasi.h:220
virtual bool isValidProblem(const CCopasiProblem *pProblem)
virtual bool isValidProblem(const CCopasiProblem *pProblem)
static CHybridMethodLSODA * createHybridMethodLSODA()
const CVector< C_INT > & getRoots() const
CVector< C_INT > mRoots
#define MCTrajectoryMethod
#define DESTRUCTOR_TRACE
Definition: copasi.h:206
virtual void start(const CState *initialState)
static CTrajectoryMethod * createMethod(CCopasiMethod::SubType subType=CCopasiMethod::deterministic)
static CHybridMethod * createHybridMethod()
virtual Status step(const double &deltaT)
#define CONSTRUCTOR_TRACE
Definition: copasi.h:202