COPASI API  4.16.103
CBitPatternMethod.h
Go to the documentation of this file.
2 // \$Source: /Volumes/Home/Users/shoops/cvs/copasi_dev/copasi/elementaryFluxModes/CBitPatternMethod.h,v \$
3 // \$Revision: 1.2 \$
4 // \$Name: \$
5 // \$Author: shoops \$
6 // \$Date: 2011/03/07 19:27:36 \$
8
9 // Copyright (C) 2011 - 2010 by Pedro Mendes, Virginia Tech Intellectual
10 // Properties, Inc., University of Heidelberg, and The University
11 // of Manchester.
13
14 // Copyright (C) 2008 by Pedro Mendes, Virginia Tech Intellectual
15 // Properties, Inc., EML Research, gGmbH, University of Heidelberg,
16 // and The University of Manchester.
18
19 #ifndef COPASI_CBitPatternMethod
20 #define COPASI_CBitPatternMethod
21
22 #include <vector>
23 #include <stack>
24
28
29 class CStepMatrix;
30 class CStepMatrixColumn;
31 class CReaction;
32 class CZeroSet;
33
35 {
37
38 public:
39  /**
40  * A static method that calculates the kernel of a full column rank matrix.
41  * Note, the input matrix is used as work area and will be modified during the calculation.
42  * @param const CMatrix< C_INT64 > & matrix
43  * @param CMatrix< C_INT64 > & kernel
44  * @param CVector< size_t > & rowPivot
45  * @return bool success
46  */
47  static bool CalculateKernel(CMatrix< C_INT64 > & matrix,
48  CMatrix< C_INT64 > & kernel,
49  CVector< size_t > & rowPivot);
50
51  /**
52  * Calculate the greatest common divisor (GCD) of 2 positive integers. On return
53  * m and n contain the GCD
54  * @param C_INT64 & m
55  * @param C_INT64 & n
56  */
57  static inline void GCD(C_INT64 & m, C_INT64 & n)
58  {
59  assert(m > 0 && n > 0);
60
61  while (m != n)
62  {
63  if (m > n)
64  {
65  m %= n;
66
67  if (m == 0)
68  {
69  m = n;
70  }
71  }
72  else
73  {
74  n %= m;
75
76  if (n == 0)
77  {
78  n = m;
79  }
80  }
81  }
82  }
83
84 protected:
85  /**
86  * Default constructor
87  * @param const CCopasiContainer * pParent (Default: NULL)
88  */
89  CBitPatternMethod(const CCopasiContainer * pParent = NULL);
90
91  /**
92  * Constructor to be called by derived methods
93  * @param const CCopasiMethod::SubType subType
94  * @param const CCopasiContainer * pParent (Default: NULL)
95  */
97  const CCopasiContainer * pParent = NULL);
98
99 public:
100  /**
101  * Copy Constructor
102  * @param const CBitPatternMethod & src
103  */
105  const CCopasiContainer * pParent = NULL);
106
107  /**
108  * Destructor
109  */
111
112  /**
113  * Execute the optimization algorithm calling simulation routine
114  * when needed. It is noted that this procedure can give feedback
115  * of its progress by the callback function set with SetCallback.
116  * @ return success;
117  */
118  virtual bool calculate();
119
120  /**
121  * Initialize arrays and pointer.
122  * @return bool success
123  */
124  virtual bool initialize();
125
126 private:
127  /**
128  * Initialize the needed CCopasiObjects.
129  */
130  void initObjects();
131
132  /**
133  * Construct the kernel matrix
134  * @param CMatrix< C_FLOAT64> & kernel
135  */
136  void buildKernelMatrix(CMatrix< C_INT64 > & kernel);
137
138  void buildFluxModeMatrix(CStepMatrix * fluxModeMatrix,
139  std::stack< CStepMatrixColumn * > kernelStack);
140
141  /**
142  * Create all possible linear combinations of the bit pattern nodes pPositive
143  * and pNegative and all their child nodes.
144  * @param const CBitPatternTreeNode * pPositive
145  * @param const CBitPatternTreeNode * pNegative
146  */
147  void combine(const CStepMatrixColumn * pPositive,
148  const CStepMatrixColumn * pNegative,
149  const std::vector< CStepMatrixColumn * > NullColumns);
150
151  /**
152  * Remove the invalid columns from the step matrix
153  * @param const std::vector< CStepMatrix::iterator > & nullColumns
154  */
155  void findRemoveInvalidColumns(const std::vector< CStepMatrixColumn * > & nullColumns);
156
157  /**
158  * Postprocess the step matrix to construct the flux modes.
159  */
160  void buildFluxModes();
161
162  /**
163  * Add the flux mode to the list only if the reversed does not exist
164  * @param const CFluxMode & mode
165  */
166  void addMode(const CFluxMode & mode);
167
168  void getAllUnsetBitIndexes(const CStepMatrixColumn * pColumn,
169  CVector<size_t> & indexes) const;
170
171  /**
172  * Get the index of the unset bits of the flux mode.
173  */
174  void getUnsetBitIndexes(const CStepMatrixColumn * pColumn,
175  CVector< size_t > & indexes) const;
176
177  /**
178  * Performs rank test on given intersection.
179  */
181
182  // Attributes
183 protected:
184  /**
185  * A pointer to the model which is analyzed.
186  */
188
189  /**
190  * The current step used for process report.
191  */
193
194  /**
195  * The max step used for process report.
196  */
198
199  /**
200  * Handle to the process report item "Current Step"
201  */
203
204  /**
205  * The current combination used for process report.
206  */
208
209  /**
210  * The max combination used for process report.
211  */
213
214  /**
215  * Handle to the process report item "Combination"
216  */
218
219  /**
220  * A vector to recording the expansion of the stoichiometry matrix.
221  */
222  std::vector< std::pair< size_t, bool > > mReactionForward;
223
224  /**
225  * A vector recording the pivots for the QR factorization
226  */
228
229  /**
230  * The transpose of the expanded stoichiometry matrix.
231  */
233
234  /**
235  * A pointer to the step matrix for creating the flux modes
236  */
238
239  /**
240  * A list of invalid columns currently in the step matrix
241  */
242  std::vector< CStepMatrixColumn * > mNewColumns;
243
244  /**
245  * The minimum set size use to determine whether a linear combination is allowed.
246  */
248
249  /**
250  * The currently process step
251  */
252  size_t mStep;
253
254  /**
255  * Boolean value indicating whether combination should continue.
256  */
258 };
259
260 #endif // COPASI_CBitPatternTreeMethod
void buildKernelMatrix(CMatrix< C_INT64 > &kernel)
void combine(const CStepMatrixColumn *pPositive, const CStepMatrixColumn *pNegative, const std::vector< CStepMatrixColumn * > NullColumns)
static void GCD(C_INT64 &m, C_INT64 &n)
static CEFMMethod * createMethod(CCopasiMethod::SubType subType=CCopasiMethod::EFMAlgorithm)
Definition: CEFMMethod.cpp:47
void buildFluxModeMatrix(CStepMatrix *fluxModeMatrix, std::stack< CStepMatrixColumn * > kernelStack)
#define C_INT64
Definition: copasi.h:88
unsigned C_INT32 mProgressCounterMax
#define C_INT32
Definition: copasi.h:90
void findRemoveInvalidColumns(const std::vector< CStepMatrixColumn * > &nullColumns)
virtual bool calculate()
unsigned C_INT32 mProgressCounter2Max
void getAllUnsetBitIndexes(const CStepMatrixColumn *pColumn, CVector< size_t > &indexes) const