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
34#pragma GCC visibility push(default)
35namespace abacus {
36
37class Master;
38class SparVec;
39
40template<class BaseType, class CoType> class PoolSlot;
41template<class BaseType, class CoType> class PoolSlotRef;
42
43template<class BaseType,class CoType>
44class Active;
45
46template<class BaseType,class CoType>
47std::ostream&operator<< (std::ostream &out, const Active<BaseType, CoType> &rhs);
48
49
51
62template <class BaseType, class CoType>
63class Active : public AbacusRoot {
64public:
65
67
71 Active(Master *master, int max)
72 : master_(master), n_(0), active_(max), redundantAge_(0,max-1, 0)
73 { }
74
76
81 Active(Master *master, Active *a, int max);
82
84
88
90
92
104 friend std::ostream &operator<< <> (std::ostream &out, const Active<BaseType, CoType> &rhs);
105
107 int number() const { return n_; }
108
109
111 int max() const { return active_.size(); }
112
113
115
120 BaseType* operator[](int i) {
121#ifdef OGDF_DEBUG
122 if (i > n_) {
123 Logger::ifout() << "Active::operator[] : no active item in slot " << i << ".\n";
125 }
126#endif
127 return (active_[i]) ? active_[i]->conVar() : nullptr;
128 }
129
131
136 const BaseType* operator[](int i) const {
137#ifdef OGDF_DEBUG
138 if (i > n_) {
139 Logger::ifout() << "Active::operator[] : no active item in slot " << i << ".\n";
141 }
142#endif
143 return (active_[i]) ? active_[i]->conVar() : 0;
144 }
145
147
151 return active_[i];
152 }
153
155
159 return active_[i];
160 }
161
163
167
169
173
175
179
181
184 void realloc(int newSize);
185
187 int redundantAge(int i) const {
188 return redundantAge_[i];
189 }
190
192
196 redundantAge_[i]++;
197 }
198
200
203 void resetRedundantAge(int i) {
204 redundantAge_[i] = 0;
205 }
206
207private:
209
210 int n_;
213
216
218};
219
220}
221
223#pragma GCC visibility pop
Base class of all other classes of ABACUS.
Definition abacusroot.h:69
Implements the sets of active constraints and variables which are associated with each subproblem.
Definition active.h:63
void resetRedundantAge(int i)
Sets the number of iterations item i is redundant to 0.
Definition active.h:203
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:208
int n_
The number of active items.
Definition active.h:210
int number() const
Returns the current number of active items.
Definition active.h:107
Array< int > redundantAge_
The number of iterations a constraint is already redundant.
Definition active.h:212
int max() const
Returns the maximum number of storable active items (without reallocation).
Definition active.h:111
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:187
const PoolSlotRef< BaseType, CoType > * poolSlotRef(int i) const
Returns the i-th entry in the Array active.
Definition active.h:158
void incrementRedundantAge(int i)
Increments the number ofiterations the item i is already redundant by 1.
Definition active.h:195
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:211
const BaseType * operator[](int i) const
Access to the i-th active item.
Definition active.h:136
BaseType * operator[](int i)
Access to the i-th active item.
Definition active.h:120
Active(Master *master, int max)
Creates an empty set of active items.
Definition active.h:71
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:150
The master of the optimization.
Definition master.h:70
Stores constraints and variables.
Definition poolslot.h:78
Stores a pointer to a pool slot with version number.
Definition poolslotref.h:55
Exception thrown when an algorithm realizes an internal bug that prevents it from continuing.
Definition exceptions.h:247
An array that keeps track of the number of inserted elements; also usable as an efficient stack.
Definition ArrayBuffer.h:64
The parameterized class Array implements dynamic arrays of type E.
Definition Array.h:219
static std::ostream & ifout()
stream for forced output (global; used by internal libraries, e.g. Abacus)
Definition Logger.h:218
#define OGDF_NEW_DELETE
Makes the class use OGDF's memory allocator.
Definition memory.h:85
#define OGDF_THROW_PARAM(CLASS, PARAM)
Replacement for throw.
Definition exceptions.h:58
std::ostream & operator<<(std::ostream &out, const Active< BaseType, CoType > &rhs)