Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

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 std::ostream&operator<< (std::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 std::ostream &operator<< <> (std::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 
ogdf::ArrayBuffer
An array that keeps track of the number of inserted elements; also usable as an efficient stack.
Definition: Array.h:46
abacus::Active
Implements the sets of active constraints and variables which are associated with each subproblem.
Definition: active.h:43
abacus::PoolSlotRef
Stores a pointer to a pool slot with version number.
Definition: active.h:40
active.inc
abacus::Active::max
int max() const
Returns the maximum number of storable active items (without reallocation).
Definition: active.h:110
abacus::Active::realloc
void realloc(int newSize)
Changes the maximum number of active items which can be stored.
abacus::Active::poolSlotRef
const PoolSlotRef< BaseType, CoType > * poolSlotRef(int i) const
Returns the i-th entry in the Array active.
Definition: active.h:157
abacus::operator<<
std::ostream & operator<<(std::ostream &out, const Active< BaseType, CoType > &rhs)
abacusroot.h
abacus::Active::incrementRedundantAge
void incrementRedundantAge(int i)
Increments the number ofiterations the item i is already redundant by 1.
Definition: active.h:194
abacus
Definition: abacusroot.h:48
abacus::Active::master_
Master * master_
A pointer to corresponding master of the optimization.
Definition: active.h:207
OGDF_NEW_DELETE
#define OGDF_NEW_DELETE
Makes the class use OGDF's memory allocator.
Definition: memory.h:84
abacus::Active::operator[]
const BaseType * operator[](int i) const
Access to the i-th active item.
Definition: active.h:135
ogdf::AlgorithmFailureException
Exception thrown when an algorithm realizes an internal bug that prevents it from continuing.
Definition: exceptions.h:243
abacus::Active::number
int number() const
Returns the current number of active items.
Definition: active.h:106
abacus::AbacusRoot
Base class of all other classes of ABACUS.
Definition: abacusroot.h:68
ogdf::Array
The parameterized class Array implements dynamic arrays of type E.
Definition: Array.h:214
abacus::Active::operator[]
BaseType * operator[](int i)
Access to the i-th active item.
Definition: active.h:119
abacus::Active::resetRedundantAge
void resetRedundantAge(int i)
Sets the number of iterations item i is redundant to 0.
Definition: active.h:202
abacus::Active::insert
void insert(PoolSlot< BaseType, CoType > *ps)
Adds a constraint/variable to the active items set.
ogdf::AlgorithmFailureCode::Active
@ Active
abacus::Active::remove
void remove(ArrayBuffer< int > &del)
Removes items from the list of active items.
abacus::Active::operator=
const Active< BaseType, CoType > & operator=(const Active< BaseType, CoType > &rhs)
OGDF_THROW_PARAM
#define OGDF_THROW_PARAM(CLASS, PARAM)
Replacement for throw.
Definition: exceptions.h:67
abacus::Active::~Active
~Active()
abacus::Active::Active
Active(Master *master, int max)
Creates an empty set of active items.
Definition: active.h:70
ogdf::Logger::ifout
static std::ostream & ifout()
stream for forced output (global; used by internal libraries, e.g. Abacus)
Definition: Logger.h:216
ogdf::AlgorithmFailureCode::SparVec
@ SparVec
abacus::PoolSlot
Stores constraints and variables.
Definition: active.h:39
abacus::Active::active_
Array< PoolSlotRef< BaseType, CoType > * > active_
The array storing references to the pool slots of the active items.
Definition: active.h:210
abacus::Active::n_
int n_
The number of active items.
Definition: active.h:209
abacus::Active::redundantAge_
Array< int > redundantAge_
The number of iterations a constraint is already redundant.
Definition: active.h:211
abacus::Active::poolSlotRef
PoolSlotRef< BaseType, CoType > * poolSlotRef(int i)
Returns the i-th entry in the Array active.
Definition: active.h:149
abacus::Active::redundantAge
int redundantAge(int i) const
Returns the number of iterations a constraint/variable is already redundant.
Definition: active.h:186
abacus::Master
The master of the optimization.
Definition: master.h:69