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 #pragma GCC visibility push(default)
35 namespace abacus {
36 
37 class Master;
38 class SparVec;
39 
40 template<class BaseType, class CoType> class PoolSlot;
41 template<class BaseType, class CoType> class PoolSlotRef;
42 
43 template<class BaseType,class CoType>
44 class Active;
45 
46 template<class BaseType,class CoType>
47 std::ostream&operator<< (std::ostream &out, const Active<BaseType, CoType> &rhs);
48 
49 
51 
62 template <class BaseType, class CoType>
63 class Active : public AbacusRoot {
64 public:
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 
87  Active(const Active<BaseType, CoType> &rhs);
88 
89  ~Active();
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 
178  void remove(ArrayBuffer<int> &del);
179 
181 
184  void realloc(int newSize);
185 
187  int redundantAge(int i) const {
188  return redundantAge_[i];
189  }
190 
192 
195  void incrementRedundantAge(int i) {
196  redundantAge_[i]++;
197  }
198 
200 
203  void resetRedundantAge(int i) {
204  redundantAge_[i] = 0;
205  }
206 
207 private:
209 
210  int n_;
213 
215  &operator=(const Active<BaseType, CoType> & rhs);
216 
218 };
219 
220 }
221 
223 #pragma GCC visibility pop
ogdf::ArrayBuffer
An array that keeps track of the number of inserted elements; also usable as an efficient stack.
Definition: Array.h:53
abacus::Active
Implements the sets of active constraints and variables which are associated with each subproblem.
Definition: active.h:44
abacus::PoolSlotRef
Stores a pointer to a pool slot with version number.
Definition: active.h:41
active.inc
abacus::Active::max
int max() const
Returns the maximum number of storable active items (without reallocation).
Definition: active.h:111
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:158
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:195
abacus
Definition: ILPClusterPlanarity.h:50
abacus::Active::master_
Master * master_
A pointer to corresponding master of the optimization.
Definition: active.h:208
OGDF_NEW_DELETE
#define OGDF_NEW_DELETE
Makes the class use OGDF's memory allocator.
Definition: memory.h:85
abacus::Active::operator[]
const BaseType * operator[](int i) const
Access to the i-th active item.
Definition: active.h:136
ogdf::AlgorithmFailureException
Exception thrown when an algorithm realizes an internal bug that prevents it from continuing.
Definition: exceptions.h:247
abacus::Active::number
int number() const
Returns the current number of active items.
Definition: active.h:107
abacus::AbacusRoot
Base class of all other classes of ABACUS.
Definition: abacusroot.h:69
ogdf::Array
The parameterized class Array implements dynamic arrays of type E.
Definition: Array.h:219
abacus::Active::operator[]
BaseType * operator[](int i)
Access to the i-th active item.
Definition: active.h:120
abacus::Active::resetRedundantAge
void resetRedundantAge(int i)
Sets the number of iterations item i is redundant to 0.
Definition: active.h:203
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:71
abacus::Active::~Active
~Active()
abacus::Active::Active
Active(Master *master, int max)
Creates an empty set of active items.
Definition: active.h:71
ogdf::Logger::ifout
static std::ostream & ifout()
stream for forced output (global; used by internal libraries, e.g. Abacus)
Definition: Logger.h:218
ogdf::AlgorithmFailureCode::SparVec
@ SparVec
abacus::PoolSlot
Stores constraints and variables.
Definition: active.h:40
abacus::Active::active_
Array< PoolSlotRef< BaseType, CoType > * > active_
The array storing references to the pool slots of the active items.
Definition: active.h:211
abacus::Active::n_
int n_
The number of active items.
Definition: active.h:210
abacus::Active::redundantAge_
Array< int > redundantAge_
The number of iterations a constraint is already redundant.
Definition: active.h:212
abacus::Active::poolSlotRef
PoolSlotRef< BaseType, CoType > * poolSlotRef(int i)
Returns the i-th entry in the Array active.
Definition: active.h:150
abacus::Active::redundantAge
int redundantAge(int i) const
Returns the number of iterations a constraint/variable is already redundant.
Definition: active.h:187
abacus::Master
The master of the optimization.
Definition: master.h:70