COPASI API  4.16.103
Public Member Functions | Private Member Functions | Private Attributes | List of all members
CBitPatternTreeNode Class Reference

#include <CBitPatternTreeNode.h>

Collaboration diagram for CBitPatternTreeNode:
Collaboration graph
[legend]

Public Member Functions

 CBitPatternTreeNode (const CBitPatternTreeNode &src)
 
 CBitPatternTreeNode (const size_t &index, const std::vector< CStepMatrixColumn * > &patterns)
 
size_t getChildrenCount () const
 
const CBitPatternTreeNodegetSetChild () const
 
const CStepMatrixColumngetStepMatrixColumn () const
 
const CBitPatternTreeNodegetUnsetChild () const
 
const CZeroSetgetZeroSet () const
 
bool hasSuperset (const CZeroSet &set) const
 
virtual ~CBitPatternTreeNode (void)
 

Private Member Functions

 CBitPatternTreeNode ()
 
size_t nextAvailableIndex () const
 
void splitPatterns (const std::vector< CStepMatrixColumn * > &patterns)
 

Private Attributes

bool mIgnoreCheck
 
size_t mIndex
 
CBitPatternTreeNodempSetChild
 
CStepMatrixColumnmpStepMatrixColumn
 
CBitPatternTreeNodempUnsetChild
 
CZeroSetmpZeroSet
 

Detailed Description

Definition at line 24 of file CBitPatternTreeNode.h.

Constructor & Destructor Documentation

CBitPatternTreeNode::CBitPatternTreeNode ( void  )
private

Definition at line 19 of file CBitPatternTreeNode.cpp.

Referenced by splitPatterns().

19  :
20  mIndex(0),
21  mpZeroSet(NULL),
22  mIgnoreCheck(false),
23  mpUnsetChild(NULL),
24  mpSetChild(NULL),
25  mpStepMatrixColumn(NULL)
26 {}
CBitPatternTreeNode * mpUnsetChild
CStepMatrixColumn * mpStepMatrixColumn
CBitPatternTreeNode * mpSetChild
CBitPatternTreeNode::CBitPatternTreeNode ( const CBitPatternTreeNode src)
CBitPatternTreeNode::CBitPatternTreeNode ( const size_t &  index,
const std::vector< CStepMatrixColumn * > &  patterns 
)

Definition at line 28 of file CBitPatternTreeNode.cpp.

References CStepMatrixColumn::getZeroSet(), mpStepMatrixColumn, mpZeroSet, and splitPatterns().

29  :
30  mIndex(index),
31  mpZeroSet(NULL),
32  mIgnoreCheck(false),
33  mpUnsetChild(NULL),
34  mpSetChild(NULL),
35  mpStepMatrixColumn(NULL)
36 {
37  // Note: patterns may contain NULL pointers
38  switch (patterns.size())
39  {
40  case 0:
41  assert(false);
42  break;
43 
44  case 1:
45  {
46  std::vector< CStepMatrixColumn * >::const_iterator it = patterns.begin();
47 
48  // This should never happen.
49  assert(*it != NULL);
50 
51  mpZeroSet = new CZeroSet((*it)->getZeroSet());
52  mpStepMatrixColumn = *it;
53  }
54  break;
55 
56  default:
57  {
58  std::vector< CStepMatrixColumn * >::const_iterator it = patterns.begin();
59  std::vector< CStepMatrixColumn * >::const_iterator end = patterns.end();
60 
61  // This should never happen.
62 
63  for (; it != end; ++it)
64  {
65  if (*it != NULL)
66  {
67  break;
68  }
69  }
70 
71  // This should never happen.
72  assert(*it != NULL);
73 
74  CStepMatrixColumn * pFirstColumn = *it;
75 
76  mpZeroSet = new CZeroSet(pFirstColumn->getZeroSet());
77  size_t Count = 1;
78 
79  for (++it; it != end; ++it)
80  {
81  if (*it != NULL)
82  {
83  *mpZeroSet |= (*it)->getZeroSet();
84  Count++;
85  }
86  }
87 
88  if (Count != 1)
89  {
90  splitPatterns(patterns);
91  }
92  else
93  {
94  mpStepMatrixColumn = pFirstColumn;
95  }
96  }
97  break;
98  }
99 }
const CZeroSet & getZeroSet() const
CBitPatternTreeNode * mpUnsetChild
CStepMatrixColumn * mpStepMatrixColumn
CBitPatternTreeNode * mpSetChild
void splitPatterns(const std::vector< CStepMatrixColumn * > &patterns)
CBitPatternTreeNode::~CBitPatternTreeNode ( void  )
virtual

Definition at line 101 of file CBitPatternTreeNode.cpp.

References mpSetChild, mpUnsetChild, mpZeroSet, and pdelete.

102 {
106 }
#define pdelete(p)
Definition: copasi.h:215
CBitPatternTreeNode * mpUnsetChild
CBitPatternTreeNode * mpSetChild

Member Function Documentation

size_t CBitPatternTreeNode::getChildrenCount ( ) const

Definition at line 170 of file CBitPatternTreeNode.cpp.

References getChildrenCount(), mpSetChild, mpStepMatrixColumn, and mpUnsetChild.

Referenced by getChildrenCount(), and CBitPatternTree::size().

171 {
172  if (mpStepMatrixColumn != NULL)
173  {
174  return 1;
175  }
176 
177  size_t Count = 0;
178 
179  if (mpUnsetChild != NULL)
180  {
181  Count = mpUnsetChild->getChildrenCount();
182  }
183 
184  if (mpSetChild != NULL)
185  {
186  Count += mpSetChild->getChildrenCount();
187  }
188 
189  return Count;
190 }
CBitPatternTreeNode * mpUnsetChild
CStepMatrixColumn * mpStepMatrixColumn
CBitPatternTreeNode * mpSetChild
size_t getChildrenCount() const
const CBitPatternTreeNode* CBitPatternTreeNode::getSetChild ( ) const
inline

Definition at line 73 of file CBitPatternTreeNode.h.

References mpSetChild.

Referenced by CBitPatternTreeMethod::combine().

74  {
75  return mpSetChild;
76  }
CBitPatternTreeNode * mpSetChild
const CStepMatrixColumn * CBitPatternTreeNode::getStepMatrixColumn ( ) const

Definition at line 108 of file CBitPatternTreeNode.cpp.

References mpStepMatrixColumn.

Referenced by CBitPatternTreeMethod::combine().

109 {
110  return mpStepMatrixColumn;
111 }
CStepMatrixColumn * mpStepMatrixColumn
const CBitPatternTreeNode* CBitPatternTreeNode::getUnsetChild ( ) const
inline

Definition at line 68 of file CBitPatternTreeNode.h.

References mpUnsetChild.

Referenced by CBitPatternTreeMethod::combine().

69  {
70  return mpUnsetChild;
71  }
CBitPatternTreeNode * mpUnsetChild
const CZeroSet& CBitPatternTreeNode::getZeroSet ( ) const
inline

Definition at line 63 of file CBitPatternTreeNode.h.

References mpZeroSet.

Referenced by CBitPatternTreeMethod::combine(), and splitPatterns().

64  {
65  return *mpZeroSet;
66  }
bool CBitPatternTreeNode::hasSuperset ( const CZeroSet set) const
inline

Definition at line 40 of file CBitPatternTreeNode.h.

References hasSuperset(), mIgnoreCheck, mpSetChild, mpStepMatrixColumn, mpUnsetChild, and mpZeroSet.

Referenced by hasSuperset(), and CBitPatternTree::isExtremeRay().

41  {
42  if (mIgnoreCheck || *mpZeroSet >= set)
43  {
44  if (mpStepMatrixColumn != NULL)
45  {
46  return true;
47  }
48 
49  if (mpUnsetChild->hasSuperset(set))
50  {
51  return true;
52  }
53 
54  if (mpSetChild->hasSuperset(set))
55  {
56  return true;
57  }
58  }
59 
60  return false;
61  }
CBitPatternTreeNode * mpUnsetChild
CStepMatrixColumn * mpStepMatrixColumn
bool hasSuperset(const CZeroSet &set) const
CBitPatternTreeNode * mpSetChild
size_t CBitPatternTreeNode::nextAvailableIndex ( ) const
private

Definition at line 165 of file CBitPatternTreeNode.cpp.

References mIndex.

Referenced by splitPatterns().

166 {
167  return mIndex + 1;
168 }
void CBitPatternTreeNode::splitPatterns ( const std::vector< CStepMatrixColumn * > &  patterns)
private

Definition at line 113 of file CBitPatternTreeNode.cpp.

References CBitPatternTreeNode(), getZeroSet(), mIgnoreCheck, mIndex, mpSetChild, mpUnsetChild, mpZeroSet, and nextAvailableIndex().

Referenced by CBitPatternTreeNode().

114 {
115  size_t Index = mIndex;
117 
118  std::vector< CStepMatrixColumn * > SetPatterns;
119  std::vector< CStepMatrixColumn * > UnsetPatterns;
120 
121  while (UnsetPatterns.empty() || SetPatterns.empty())
122  {
123  SetPatterns.clear();
124  UnsetPatterns.clear();
125 
126  mIndex = Index;
127  Bit = mIndex;
128 
129  std::vector< CStepMatrixColumn * >::const_iterator it = patterns.begin();
130  std::vector< CStepMatrixColumn * >::const_iterator end = patterns.end();
131 
132  for (; it != end; ++it)
133  {
134  if (*it != NULL)
135  {
136  if ((*it)->getZeroSet().isSet(Bit))
137  {
138  SetPatterns.push_back((*it));
139  }
140  else
141  {
142  UnsetPatterns.push_back((*it));
143  }
144  }
145  }
146 
147  Index = nextAvailableIndex();
148  }
149 
150  mpUnsetChild = new CBitPatternTreeNode(Index, UnsetPatterns);
151 
152  if (mpUnsetChild->getZeroSet() == *mpZeroSet)
153  {
154  mpUnsetChild->mIgnoreCheck = true;
155  }
156 
157  mpSetChild = new CBitPatternTreeNode(Index, SetPatterns);
158 
159  if (mpSetChild->getZeroSet() == *mpZeroSet)
160  {
161  mpSetChild->mIgnoreCheck = true;
162  }
163 }
CBitPatternTreeNode * mpUnsetChild
size_t nextAvailableIndex() const
const CZeroSet & getZeroSet() const
CBitPatternTreeNode * mpSetChild

Member Data Documentation

bool CBitPatternTreeNode::mIgnoreCheck
private

Definition at line 91 of file CBitPatternTreeNode.h.

Referenced by hasSuperset(), and splitPatterns().

size_t CBitPatternTreeNode::mIndex
private

Definition at line 87 of file CBitPatternTreeNode.h.

Referenced by nextAvailableIndex(), and splitPatterns().

CBitPatternTreeNode* CBitPatternTreeNode::mpSetChild
private
CStepMatrixColumn* CBitPatternTreeNode::mpStepMatrixColumn
private
CBitPatternTreeNode* CBitPatternTreeNode::mpUnsetChild
private
CZeroSet* CBitPatternTreeNode::mpZeroSet
private

The documentation for this class was generated from the following files: