Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

pool.h
Go to the documentation of this file.
1 
29 #pragma once
30 
31 #include <ogdf/lib/abacus/pool.h>
33 #include <ogdf/lib/abacus/master.h>
34 
35 #pragma GCC visibility push(default)
36 namespace abacus {
37 
38 
39 template <class BaseType, class CoType> class Active;
40 
41 
43 
62 template<class BaseType, class CoType>
63 class Pool : public AbacusRoot {
64 public:
65 
67 
74  enum RANKING {
82  };
83 
85 
88  Pool(Master *master) : master_(master), number_(0) { }
89 
90  virtual ~Pool() { }
91 
99  virtual PoolSlot<BaseType, CoType> *insert(BaseType *cv) = 0;
100 
107  if (softDeleteConVar(slot)) {
108  Logger::ifout() << "removeConVar(): removing constraint from slot failed\n";
110  }
111  }
112 
114  int number() const { return number_; }
115 
117 
136  virtual int separate(
137  double *z,
138  Active<CoType, BaseType> *active,
139  Sub *sub,
140  CutBuffer<BaseType, CoType> *cutBuffer,
141  double minAbsViolation = 0.001,
142  int ranking = 0) = 0;
143 
144 protected:
145 
147 
156  if (slot->softDelete() == 0) {
157  putSlot(slot);
158  --number_;
159  return 0;
160  }
161  return 1;
162  }
163 
165 
170  --number_;
171  slot->hardDelete();
172  putSlot(slot);
173  }
174 
176 
184  virtual PoolSlot<BaseType, CoType> *getSlot() = 0;
185 
187 
192  virtual void putSlot(PoolSlot<BaseType, CoType> *slot) = 0;
193 
195  int number_;
196 };
197 
198 }
199 #pragma GCC visibility pop
abacus::Active< CoType, BaseType >
abacus::Pool::putSlot
virtual void putSlot(PoolSlot< BaseType, CoType > *slot)=0
Makes an PoolSlot again available for later calls of getSlot().
abacus::Pool::RANK
@ RANK
The violation computed by the function violated() of the classes Constraint or Variable is used as ra...
Definition: pool.h:79
abacus::Pool::insert
virtual PoolSlot< BaseType, CoType > * insert(BaseType *cv)=0
Tries to insert a constraint/variable in the pool.
abacus::Pool< CoType, BaseType >::RANKING
RANKING
Determines how th rank of a constraint/variable is computed.
Definition: pool.h:74
abacus::CutBuffer
Cut buffers.
Definition: convar.h:46
abacus::Pool::number
int number() const
Returns the current number of items in the pool.
Definition: pool.h:114
abacus
Definition: ILPClusterPlanarity.h:50
abacus::Pool::softDeleteConVar
virtual int softDeleteConVar(PoolSlot< BaseType, CoType > *slot)
Removes the constraint/variable stored in slot from the pool if it can be deleted.
Definition: pool.h:155
abacus::PoolSlot::hardDelete
void hardDelete()
Deletes the constraint/variable in the slot.
Definition: poolslot.h:148
abacus::Pool::master_
Master * master_
A pointer to the corresponding master of the optimization.
Definition: pool.h:194
abacus::Pool
Base class for constraint/variabe pools.
Definition: pool.h:63
ogdf::AlgorithmFailureException
Exception thrown when an algorithm realizes an internal bug that prevents it from continuing.
Definition: exceptions.h:247
abacus::AbacusRoot
Base class of all other classes of ABACUS.
Definition: abacusroot.h:69
pool.h
abacus::Pool::removeConVar
void removeConVar(PoolSlot< BaseType, CoType > *slot)
Removes the constraint/variable stored in a pool slot and adds the slot to the list of free slots.
Definition: pool.h:106
abacus::Pool::ABS_RANK
@ ABS_RANK
The absolute value of the violation is taken as rank.
Definition: pool.h:81
abacus::PoolSlot::softDelete
int softDelete()
Tries to remove the item from the slot.
Definition: poolslot.h:135
abacus::Pool::~Pool
virtual ~Pool()
Definition: pool.h:90
ogdf::AlgorithmFailureCode::Active
@ Active
abacus::Pool::Pool
Pool(Master *master)
Initializes an empty pool.
Definition: pool.h:88
abacus::Pool::getSlot
virtual PoolSlot< BaseType, CoType > * getSlot()=0
Tries to find a free slot in the pool.
abacus::Pool::separate
virtual int separate(double *z, Active< CoType, BaseType > *active, Sub *sub, CutBuffer< BaseType, CoType > *cutBuffer, double minAbsViolation=0.001, int ranking=0)=0
Checks if a pair of a vector and an active constraint/variable set violates any item in the pool.
OGDF_THROW_PARAM
#define OGDF_THROW_PARAM(CLASS, PARAM)
Replacement for throw.
Definition: exceptions.h:71
ogdf::AlgorithmFailureCode::Pool
@ Pool
ogdf::Logger::ifout
static std::ostream & ifout()
stream for forced output (global; used by internal libraries, e.g. Abacus)
Definition: Logger.h:218
master.h
the master of the optimization.
abacus::Sub
The subproblem.
Definition: sub.h:69
poolslot.h
poolslot.
abacus::PoolSlot
Stores constraints and variables.
Definition: active.h:40
abacus::Pool::NO_RANK
@ NO_RANK
No rank is computed.
Definition: pool.h:76
abacus::Pool::number_
int number_
The current number of constraints in the pool.
Definition: pool.h:195
abacus::Master
The master of the optimization.
Definition: master.h:70
abacus::Pool::hardDeleteConVar
virtual void hardDeleteConVar(PoolSlot< BaseType, CoType > *slot)
Removes a constraint/variable from the pool and adds the slot to the set of free slots.
Definition: pool.h:169