Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Loading...
Searching...
No Matches
active.h
Go to the documentation of this file.
1
29#pragma once
30
32
33
34namespace abacus {
35
36class Master;
37class SparVec;
38
39template<class BaseType, class CoType> class PoolSlot;
40template<class BaseType, class CoType> class PoolSlotRef;
41
42template<class BaseType,class CoType>
43class Active;
44
45template<class BaseType,class CoType>
46std::ostream&operator<< (std::ostream &out, const Active<BaseType, CoType> &rhs);
47
48
50
61template <class BaseType, class CoType>
62class Active : public AbacusRoot {
63public:
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
87
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
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
178
180
183 void realloc(int newSize);
184
186 int redundantAge(int i) const {
187 return redundantAge_[i];
188 }
189
191
195 redundantAge_[i]++;
196 }
197
199
202 void resetRedundantAge(int i) {
203 redundantAge_[i] = 0;
204 }
205
206private:
208
209 int n_;
212
215
217};
218
219}
220
Base class of all other classes of ABACUS.
Definition abacusroot.h:68
Implements the sets of active constraints and variables which are associated with each subproblem.
Definition active.h:62
void resetRedundantAge(int i)
Sets the number of iterations item i is redundant to 0.
Definition active.h:202
void insert(PoolSlot< BaseType, CoType > *ps)
Adds a constraint/variable to the active items set.
Master * master_
A pointer to corresponding master of the optimization.
Definition active.h:207
int n_
The number of active items.
Definition active.h:209
int number() const
Returns the current number of active items.
Definition active.h:106
Array< int > redundantAge_
The number of iterations a constraint is already redundant.
Definition active.h:211
int max() const
Returns the maximum number of storable active items (without reallocation).
Definition active.h:110
const Active< BaseType, CoType > & operator=(const Active< BaseType, CoType > &rhs)
Active(Master *master, Active *a, int max)
Creates a set of active items, initialized to at most max items from a.
int redundantAge(int i) const
Returns the number of iterations a constraint/variable is already redundant.
Definition active.h:186
const PoolSlotRef< BaseType, CoType > * poolSlotRef(int i) const
Returns the i-th entry in the Array active.
Definition active.h:157
void incrementRedundantAge(int i)
Increments the number ofiterations the item i is already redundant by 1.
Definition active.h:194
void remove(ArrayBuffer< int > &del)
Removes items from the list of active items.
Active(const Active< BaseType, CoType > &rhs)
Copy constructor.
void realloc(int newSize)
Changes the maximum number of active items which can be stored.
Array< PoolSlotRef< BaseType, CoType > * > active_
The array storing references to the pool slots of the active items.
Definition active.h:210
const BaseType * operator[](int i) const
Access to the i-th active item.
Definition active.h:135
BaseType * operator[](int i)
Access to the i-th active item.
Definition active.h:119
Active(Master *master, int max)
Creates an empty set of active items.
Definition active.h:70
void insert(ArrayBuffer< PoolSlot< BaseType, CoType > * > &ps)
Adds constraints/variables to the active items set.
PoolSlotRef< BaseType, CoType > * poolSlotRef(int i)
Returns the i-th entry in the Array active.
Definition active.h:149
The master of the optimization.
Definition master.h:69
Stores constraints and variables.
Definition poolslot.h:77
Stores a pointer to a pool slot with version number.
Definition poolslotref.h:54
Exception thrown when an algorithm realizes an internal bug that prevents it from continuing.
Definition exceptions.h:241
An array that keeps track of the number of inserted elements; also usable as an efficient stack.
Definition ArrayBuffer.h:56
The parameterized class Array implements dynamic arrays of type E.
Definition Array.h:214
static std::ostream & ifout()
stream for forced output (global; used by internal libraries, e.g. Abacus)
Definition Logger.h:192
#define OGDF_NEW_DELETE
Makes the class use OGDF's memory allocator.
Definition memory.h:84
#define OGDF_THROW_PARAM(CLASS, PARAM)
Replacement for throw.
Definition exceptions.h:54
static MultilevelBuilder * getDoubleFactoredZeroAdjustedMerger()
std::ostream & operator<<(std::ostream &out, const Active< BaseType, CoType > &rhs)