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