Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Loading...
Searching...
No Matches
abacus::Pool< BaseType, CoType > Class Template Referenceabstract

Base class for constraint/variabe pools. More...

#include <ogdf/lib/abacus/pool.h>

+ Inheritance diagram for abacus::Pool< BaseType, CoType >:

Public Types

enum  RANKING { NO_RANK , RANK , ABS_RANK }
 Determines how th rank of a constraint/variable is computed. More...
 

Public Member Functions

 Pool (Master *master)
 Initializes an empty pool.
 
virtual ~Pool ()
 
virtual PoolSlot< BaseType, CoType > * insert (BaseType *cv)=0
 Tries to insert a constraint/variable in the pool.
 
int number () const
 Returns the current number of items in the pool.
 
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.
 
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.
 
- Public Member Functions inherited from abacus::AbacusRoot
virtual ~AbacusRoot ()
 The destructor.
 

Protected Member Functions

virtual PoolSlot< BaseType, CoType > * getSlot ()=0
 Tries to find a free slot in the pool.
 
virtual void hardDeleteConVar (PoolSlot< BaseType, CoType > *slot)
 Removes a constraint/variable from the pool and adds the slot to the set of free slots.
 
virtual void putSlot (PoolSlot< BaseType, CoType > *slot)=0
 Makes an PoolSlot again available for later calls of getSlot().
 
virtual int softDeleteConVar (PoolSlot< BaseType, CoType > *slot)
 Removes the constraint/variable stored in slot from the pool if it can be deleted.
 

Protected Attributes

Mastermaster_
 A pointer to the corresponding master of the optimization.
 
int number_
 The current number of constraints in the pool.
 

Additional Inherited Members

- Static Public Member Functions inherited from abacus::AbacusRoot
static bool ascii2bool (const string &str)
 Converts the string str to a boolean value.
 
static bool endsWith (const string &str, const string &end)
 Returns true if str ends with end, false otherwise.
 
static double fracPart (double x)
 Returns the absolute value of the fractional part of x.
 
static const charonOff (bool value)
 Converts a boolean variable to the strings "on" and "off".
 

Detailed Description

template<class BaseType, class CoType>
class abacus::Pool< BaseType, CoType >

Base class for constraint/variabe pools.

Every constraint and variable has to to be stored in a pool. This class implements an abstract template class for a pool, which can be used to store objects of the class Variable or of the class Constraint. A constraint or variable is not directly stored in the pool, but in an PoolSlot. Hence, a pool is a collection of pool slots.

A pool has two template arguments: the BaseType and the CoType. Only two scenarios make sense in the current context. For a pool storing constraints the BaseType is Constraint and the CoType is Variable. For a pool storing variables the BaseType is Variable and the corresponding CoType is Constraint.

The class Pool is an abstract class from which concrete classes have to be derived, implementing the data structures for the storage of pool slots. We provide already in the class StandardPool a simple but convenient implementation of a pool. We refer to all constraints and variables via the class PoolSlotRef.

Definition at line 62 of file pool.h.

Member Enumeration Documentation

◆ RANKING

Determines how th rank of a constraint/variable is computed.

The enumeration RANKING indicates how the rank of a constraint/variable in a pool separation is determined. This enumeration is not used at the moment because we cannot use the enumeration as the type of a function parameter in a derived class.

Enumerator
NO_RANK 

No rank is computed.

RANK 

The violation computed by the function violated() of the classes Constraint or Variable is used as rank.

ABS_RANK 

The absolute value of the violation is taken as rank.

Definition at line 73 of file pool.h.

Constructor & Destructor Documentation

◆ Pool()

template<class BaseType , class CoType >
abacus::Pool< BaseType, CoType >::Pool ( Master master)
inline

Initializes an empty pool.

Parameters
masterA pointer to the corresponding master of the optimization.

Definition at line 87 of file pool.h.

◆ ~Pool()

template<class BaseType , class CoType >
virtual abacus::Pool< BaseType, CoType >::~Pool ( )
inlinevirtual

Definition at line 89 of file pool.h.

Member Function Documentation

◆ getSlot()

template<class BaseType , class CoType >
virtual PoolSlot< BaseType, CoType > * abacus::Pool< BaseType, CoType >::getSlot ( )
protectedpure virtual

Tries to find a free slot in the pool.

This function is protected since it should only be used by insert(). The data structure managing the free poolslots can be individually defined for each derived pool class.

Returns
A pointer to a free PoolSlot where a constraint/variable can be inserted. If no pool slot is available getSlot() returns 0.

Implemented in abacus::StandardPool< BaseType, CoType >, abacus::StandardPool< abacus::Constraint, abacus::Variable >, and abacus::StandardPool< abacus::Variable, abacus::Constraint >.

◆ hardDeleteConVar()

template<class BaseType , class CoType >
virtual void abacus::Pool< BaseType, CoType >::hardDeleteConVar ( PoolSlot< BaseType, CoType > *  slot)
inlineprotectedvirtual

Removes a constraint/variable from the pool and adds the slot to the set of free slots.

Parameters
slotA pointer to the pool slot from wich the constraint/variable should be deleted.

Reimplemented in abacus::NonDuplPool< BaseType, CoType >.

Definition at line 168 of file pool.h.

◆ insert()

template<class BaseType , class CoType >
virtual PoolSlot< BaseType, CoType > * abacus::Pool< BaseType, CoType >::insert ( BaseType cv)
pure virtual

Tries to insert a constraint/variable in the pool.

Returns
A pointer to the pool slot where the item has been inserted, or 0 if the insertion failed.
Parameters
cvThe constraint/variable being inserted.

Implemented in abacus::NonDuplPool< BaseType, CoType >, and abacus::StandardPool< BaseType, CoType >.

◆ number()

template<class BaseType , class CoType >
int abacus::Pool< BaseType, CoType >::number ( ) const
inline

Returns the current number of items in the pool.

Definition at line 113 of file pool.h.

◆ putSlot()

template<class BaseType , class CoType >
virtual void abacus::Pool< BaseType, CoType >::putSlot ( PoolSlot< BaseType, CoType > *  slot)
protectedpure virtual

Makes an PoolSlot again available for later calls of getSlot().

If somebody else refers to this constraint the function should abort with an error message.

Parameters
slotThe slot made available for further use.

Implemented in abacus::StandardPool< BaseType, CoType >.

◆ removeConVar()

template<class BaseType , class CoType >
void abacus::Pool< BaseType, CoType >::removeConVar ( PoolSlot< BaseType, CoType > *  slot)
inline

Removes the constraint/variable stored in a pool slot and adds the slot to the list of free slots.

Parameters
slotThe pool slot from which the constraint/variable is removed.

Definition at line 105 of file pool.h.

◆ separate()

template<class BaseType , class CoType >
virtual int abacus::Pool< BaseType, CoType >::separate ( double z,
Active< CoType, BaseType > *  active,
Sub sub,
CutBuffer< BaseType, CoType > *  cutBuffer,
double  minAbsViolation = 0.001,
int  ranking = 0 
)
pure virtual

Checks if a pair of a vector and an active constraint/variable set violates any item in the pool.

If the pool is a constraint pool, then the vector is an LP-solution and the active set is the set of active variables. Otherwise, if the pool is a variable pool, then the vector contains the dual variables and the active set is the set of associated active constraints.

Parameters
zThe vector for which violation is checked.
activeThe constraint/variable set associated with z.
subThe subproblem for which validity of the violated item is required.
cutBufferThe violated constraints/variables are added to this buffer.
minAbsViolationA violated constraint/variable is only added to the cutBuffer if the absolute value of its violation is at least minAbsViolation. The default value is 0.001.
rankingIf 1, the violation is associated with a rank of item in the buffer, if 2 the absolute violation is used, if 0 no rank is associated with the item.
Returns
The number of violated items.

Implemented in abacus::StandardPool< BaseType, CoType >.

◆ softDeleteConVar()

template<class BaseType , class CoType >
virtual int abacus::Pool< BaseType, CoType >::softDeleteConVar ( PoolSlot< BaseType, CoType > *  slot)
inlineprotectedvirtual

Removes the constraint/variable stored in slot from the pool if it can be deleted.

If the constraint/variable can be removed, the slot is added to the set of free slots.

Parameters
slotA pointer to the pool slot from wich the constraint/variable should be deleted.
Returns
0 if the constraint/variable could be deleted.
1 otherwise.

Reimplemented in abacus::NonDuplPool< BaseType, CoType >.

Definition at line 154 of file pool.h.

Member Data Documentation

◆ master_

template<class BaseType , class CoType >
Master* abacus::Pool< BaseType, CoType >::master_
protected

A pointer to the corresponding master of the optimization.

Definition at line 193 of file pool.h.

◆ number_

template<class BaseType , class CoType >
int abacus::Pool< BaseType, CoType >::number_
protected

The current number of constraints in the pool.

Definition at line 194 of file pool.h.


The documentation for this class was generated from the following file: