Open
Graph Drawing
Framework

 v. snapshot-2017-02-16
 

active.h
Go to the documentation of this file.
1 
29 #pragma once
30 
32 
33 
34 namespace abacus {
35 
36 class Master;
37 class SparVec;
38 
39 template<class BaseType, class CoType> class PoolSlot;
40 template<class BaseType, class CoType> class PoolSlotRef;
41 
42 template<class BaseType,class CoType>
43 class Active;
44 
45 template<class BaseType,class CoType>
46 ostream&operator<< (ostream &out, const Active<BaseType, CoType> &rhs);
47 
48 
50 
61 template <class BaseType, class CoType>
62 class Active : public AbacusRoot {
63 public:
64 
66 
70  Active(Master *master, int max)
71  : master_(master), n_(0), active_(max), redundantAge_(0,max-1, 0)
72  { }
73 
75 
80  Active(Master *master, Active *a, int max);
81 
83 
86  Active(const Active<BaseType, CoType> &rhs);
87 
88  ~Active();
89 
91 
103  friend ostream &operator<< <> (ostream &out, const Active<BaseType, CoType> &rhs);
104 
106  int number() const { return n_; }
107 
108 
110  int max() const { return active_.size(); }
111 
112 
114 
119  BaseType* operator[](int i) {
120 #ifdef OGDF_DEBUG
121  if (i > n_) {
122  Logger::ifout() << "Active::operator[] : no active item in slot " << i << ".\n";
124  }
125 #endif
126  return (active_[i]) ? active_[i]->conVar() : nullptr;
127  }
128 
130 
135  const BaseType* operator[](int i) const {
136 #ifdef OGDF_DEBUG
137  if (i > n_) {
138  Logger::ifout() << "Active::operator[] : no active item in slot " << i << ".\n";
140  }
141 #endif
142  return (active_[i]) ? active_[i]->conVar() : 0;
143  }
144 
146 
150  return active_[i];
151  }
152 
154 
158  return active_[i];
159  }
160 
162 
166 
168 
172 
174 
177  void remove(ArrayBuffer<int> &del);
178 
180 
183  void realloc(int newSize);
184 
186  int redundantAge(int i) const {
187  return redundantAge_[i];
188  }
189 
191 
194  void incrementRedundantAge(int i) {
195  redundantAge_[i]++;
196  }
197 
199 
202  void resetRedundantAge(int i) {
203  redundantAge_[i] = 0;
204  }
205 
206 private:
208 
209  int n_;
212 
214  &operator=(const Active<BaseType, CoType> & rhs);
215 
217 };
218 
219 
220 } //namespace abacus
221 
Array< int > redundantAge_
The number of iterations a constraint is already redundant.
Definition: active.h:211
The parameterized class Array implements dynamic arrays of type E.
Definition: Array.h:56
Base class of all other classes of ABACUS.
Definition: abacusroot.h:64
The master of the optimization.
Definition: master.h:69
Implements the sets of active constraints and variables which are associated with each subproblem...
Definition: active.h:43
An array that keeps track of the number of inserted elements; also usable as an efficient stack...
Definition: Array.h:44
void resetRedundantAge(int i)
Sets the number of iterations item i is redundant to 0.
Definition: active.h:202
void incrementRedundantAge(int i)
Increments the number ofiterations the item i is already redundant by 1.
Definition: active.h:194
BaseType * operator[](int i)
Access to the i-th active item.
Definition: active.h:119
Master * master_
A pointer to corresponding master of the optimization.
Definition: active.h:207
void insert(PoolSlot< BaseType, CoType > *ps)
Adds a constraint/variable to the active items set.
static std::ostream & ifout()
stream for forced output (global; used by internal libraries, e.g. Abacus)
Definition: Logger.h:194
const BaseType * operator[](int i) const
Access to the i-th active item.
Definition: active.h:135
#define OGDF_THROW_PARAM(CLASS, PARAM)
Replacement for throw.
Definition: exceptions.h:51
Exception thrown when an algorithm realizes an internal bug that prevents it from continuing...
Definition: exceptions.h:308
Array< PoolSlotRef< BaseType, CoType > * > active_
The array storing references to the pool slots of the active items.
Definition: active.h:210
int number() const
Returns the current number of active items.
Definition: active.h:106
int n_
The number of active items.
Definition: active.h:209
PoolSlotRef< BaseType, CoType > * poolSlotRef(int i)
Returns the i-th entry in the Array active.
Definition: active.h:149
#define OGDF_NEW_DELETE
Makes the class use OGDF&#39;s memory allocator.
Definition: memory.h:84
Stores a pointer to a pool slot with version number.
Definition: active.h:40
Stores constraints and variables.
Definition: active.h:39
const Active< BaseType, CoType > & operator=(const Active< BaseType, CoType > &rhs)
int redundantAge(int i) const
Returns the number of iterations a constraint/variable is already redundant.
Definition: active.h:186
Active(Master *master, int max)
Creates an empty set of active items.
Definition: active.h:70
int max() const
Returns the maximum number of storable active items (without reallocation).
Definition: active.h:110
void realloc(int newSize)
Changes the maximum number of active items which can be stored.
const PoolSlotRef< BaseType, CoType > * poolSlotRef(int i) const
Returns the i-th entry in the Array active.
Definition: active.h:157