COPASI API  4.16.103
CNewtonMethod.h
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  * CNewtonMethod class.
17  * This class implements the enhanced Newton method which attempts to find the
18  * the steady state.
19  *
20  * Created for COPASI by Stefan Hoops 2002
21  */
22 
23 #ifndef COPASI_CNewtonMethod
24 #define COPASI_CNewtonMethod
25 
26 #include "utilities/CMatrix.h"
27 #include "utilities/CVector.h"
28 #include "model/CState.h"
29 
30 class CTrajectoryTask;
31 
33 {
34  friend CSteadyStateMethod *
36 
37  // Attributes
38 private:
40  {
41  found = 0,
48  };
49 
50  //these member variables contain configuration information, mostly they
51  //are initialized from the CCopasiParameters
52  bool mUseNewton;
61 
62  size_t mDimension;
69 
71 
73 
74  // Operations
75 private:
76  /**
77  * Default constructor.
78  * @param const CCopasiContainer * pParent (default: NULL)
79  */
80  CNewtonMethod(const CCopasiContainer * pParent = NULL);
81 
82 public:
83  /**
84  * Copy constructor.
85  * @param "const CNewtonMethod &" src
86  * @param const CCopasiContainer * pParent (default: NULL)
87  */
88  CNewtonMethod(const CNewtonMethod & src,
89  const CCopasiContainer * pParent = NULL);
90 
91  /**
92  * Destructor.
93  */
95 
96  /**
97  * This methods must be called to elevate subgroups to
98  * derived objects. The default implementation does nothing.
99  * @return bool success
100  */
101  virtual bool elevateChildren();
102 
103  /**
104  * Load a list of parameters
105  * @param "CReadConfig &" configBuffer
106  * @param "CReadConfig::Mode" mode Default(CReadConfig::SEARCH)
107  */
108  virtual void load(CReadConfig & configBuffer,
110 
111  /**
112  * This instructs the method to calculate a the steady state
113  * starting with the initialState given.
114  * The steady state is returned in the object pointed to by steadyState.
115  * @param CState & steadyState
116  * @param const CState & initialState
117  * @return CSteadyStateMethod::ReturnCode returnCode
118  */
120 
121  bool isSteadyState(C_FLOAT64 value);
122 
123  /**
124  * This is the function that is supposed to be near zero if a steady
125  * state is detected.
126  * @param const CVector< C_FLOAT64 > & particleFluxes
127  */
128  C_FLOAT64 targetFunction(const CVector< C_FLOAT64 > & particleFluxes);
129 
130  /**
131  * Check if the method is suitable for this problem
132  * @return bool suitability of the method
133  */
134  virtual bool isValidProblem(const CCopasiProblem * pProblem);
135 
136  /**
137  * Initialize the method must be called before process
138  * @param const CSteadyStateProblem * pProblem
139  * @return bool success
140  */
141  virtual bool initialize(const CSteadyStateProblem * pProblem);
142 
143 private:
144  /**
145  * Initialize the method parameter
146  */
147  void initializeParameter();
148 
149  /**
150  * This instructs the method to calculate a the steady state
151  * starting with the initialState given.
152  * The steady state is returned in the object pointed to by steadyState.
153  * @param CState * steadyState
154  * @param const CState * initialState
155  * @return CNewtonMethod::NewtonReturnCode newtonReturnCode
156  */
158 
159  /**
160  * Do one newton step and subsequent damping. The value of the targetfunction
161  * before the step is provided by the calling method in currentValue, the value after the step
162  * is returned in currentValue.
163  * The step starts from the state in mpX (pointing to the independent variables of mpSteadyState).
164  * After the method returns mpX contains either the old state or the state after the step
165  * (if the step was succesful). mdxdt can be expected to be up to date.
166  * Possible return values are: dampingLimitExceeded, singularJacobian, stepSuccesful
167  */
169 
171 
172  void calculateDerivativesX();
173 
174  bool containsNaN() const;
175 
176  void cleanup();
177 
178  /**
179  * Solve JacobiabX * X = B
180  * @param CVector< C_FLOAT64 > & X
181  * @param const CVector< C_FLOAT64 > & B
182  * @return C_FLOAT64 error
183  */
185 };
186 #endif // COPASI_CNewtonMethod
CVector< C_FLOAT64 > mH
Definition: CNewtonMethod.h:65
#define C_INT
Definition: copasi.h:115
C_FLOAT64 mMaxDurationBackward
Definition: CNewtonMethod.h:60
virtual bool elevateChildren()
void initializeParameter()
Definition: CState.h:305
CState mStartState
Definition: CNewtonMethod.h:72
CVector< C_FLOAT64 > mdxdt
Definition: CNewtonMethod.h:67
C_FLOAT64 targetFunction(const CVector< C_FLOAT64 > &particleFluxes)
#define C_INT32
Definition: copasi.h:90
bool mUseBackIntegration
Definition: CNewtonMethod.h:54
bool isSteadyState(C_FLOAT64 value)
CVector< C_FLOAT64 > mXold
Definition: CNewtonMethod.h:66
virtual CSteadyStateMethod::ReturnCode processInternal()
CNewtonMethod::NewtonResultCode processNewton()
CVector< C_FLOAT64 > mAtol
Definition: CNewtonMethod.h:64
virtual bool isValidProblem(const CCopasiProblem *pProblem)
CTrajectoryTask * mpTrajectory
Definition: CNewtonMethod.h:70
static CSteadyStateMethod * createMethod(CCopasiMethod::SubType subType=CCopasiMethod::Newton)
C_FLOAT64 * mpX
Definition: CNewtonMethod.h:63
unsigned C_INT32 mIterationLimit
Definition: CNewtonMethod.h:58
virtual void load(CReadConfig &configBuffer, CReadConfig::Mode mode=CReadConfig::SEARCH)
CNewtonMethod(const CCopasiContainer *pParent=NULL)
void calculateDerivativesX()
#define C_FLOAT64
Definition: copasi.h:92
CNewtonMethod::NewtonResultCode doNewtonStep(C_FLOAT64 &currentValue)
virtual bool initialize(const CSteadyStateProblem *pProblem)
C_FLOAT64 solveJacobianXeqB(CVector< C_FLOAT64 > &X, const CVector< C_FLOAT64 > &B) const
size_t mDimension
Definition: CNewtonMethod.h:62
bool mUseIntegration
Definition: CNewtonMethod.h:53
CNewtonMethod::NewtonResultCode doIntegration(bool forward)
bool containsNaN() const
C_FLOAT64 mMaxDurationForward
Definition: CNewtonMethod.h:59
bool mAcceptNegative
Definition: CNewtonMethod.h:55