Open
Graph Drawing
Framework

 v. 2020.02 (Catalpa)
 

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 namespace abacus {
36 
37 
38 template <class BaseType, class CoType> class Active;
39 
40 
42 
61 template<class BaseType, class CoType>
62 class Pool : public AbacusRoot {
63 public:
64 
66 
73  enum RANKING {
81  };
82 
84 
87  Pool(Master *master) : master_(master), number_(0) { }
88 
89  virtual ~Pool() { }
90 
98  virtual PoolSlot<BaseType, CoType> *insert(BaseType *cv) = 0;
99 
106  if (softDeleteConVar(slot)) {
107  Logger::ifout() << "removeConVar(): removing constraint from slot failed\n";
109  }
110  }
111 
113  int number() const { return number_; }
114 
116 
135  virtual int separate(
136  double *z,
137  Active<CoType, BaseType> *active,
138  Sub *sub,
139  CutBuffer<BaseType, CoType> *cutBuffer,
140  double minAbsViolation = 0.001,
141  int ranking = 0) = 0;
142 
143 protected:
144 
146 
155  if (slot->softDelete() == 0) {
156  putSlot(slot);
157  --number_;
158  return 0;
159  }
160  return 1;
161  }
162 
164 
169  --number_;
170  slot->hardDelete();
171  putSlot(slot);
172  }
173 
175 
183  virtual PoolSlot<BaseType, CoType> *getSlot() = 0;
184 
186 
191  virtual void putSlot(PoolSlot<BaseType, CoType> *slot) = 0;
192 
194  int number_;
195 };
196 
197 }
Base class of all other classes of ABACUS.
Definition: abacusroot.h:68
The master of the optimization.
Definition: master.h:69
The absolute value of the violation is taken as rank.
Definition: pool.h:80
virtual ~Pool()
Definition: pool.h:89
virtual PoolSlot< BaseType, CoType > * getSlot()=0
Tries to find a free slot in the pool.
The subproblem.
Definition: sub.h:68
int number_
The current number of constraints in the pool.
Definition: pool.h:194
virtual PoolSlot< BaseType, CoType > * insert(BaseType *cv)=0
Tries to insert a constraint/variable in the pool.
the master of the optimization.
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...
RANKING
Determines how th rank of a constraint/variable is computed.
Definition: pool.h:73
int number() const
Returns the current number of items in the pool.
Definition: pool.h:113
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:154
int softDelete()
Tries to remove the item from the slot.
Definition: poolslot.h:134
Cut buffers.
Definition: convar.h:45
static std::ostream & ifout()
stream for forced output (global; used by internal libraries, e.g. Abacus)
Definition: Logger.h:194
Master * master_
A pointer to the corresponding master of the optimization.
Definition: pool.h:193
#define OGDF_THROW_PARAM(CLASS, PARAM)
Replacement for throw.
Definition: exceptions.h:55
Exception thrown when an algorithm realizes an internal bug that prevents it from continuing...
Definition: exceptions.h:253
Pool(Master *master)
Initializes an empty pool.
Definition: pool.h:87
Base class for constraint/variabe pools.
Definition: pool.h:62
poolslot.
Stores constraints and variables.
Definition: active.h:39
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:105
virtual void putSlot(PoolSlot< BaseType, CoType > *slot)=0
Makes an PoolSlot again available for later calls of getSlot().
No rank is computed.
Definition: pool.h:75
The violation computed by the function violated() of the classes Constraint or Variable is used as ra...
Definition: pool.h:78
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:168
void hardDelete()
Deletes the constraint/variable in the slot.
Definition: poolslot.h:147