Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

abacus::PoolSlot< BaseType, CoType > Class Template Reference

Stores constraints and variables. More...

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

Public Member Functions

 PoolSlot (Master *master, Pool< BaseType, CoType > *pool, BaseType *convar=0)
 Creates a pool slot and inserts convar. More...
 
 ~PoolSlot ()
 
BaseType * conVar () const
 Returns a pointer to the constraint/variable in the pool slot. More...
 

Private Member Functions

 PoolSlot (const PoolSlot< BaseType, CoType > &rhs)
 
void hardDelete ()
 Deletes the constraint/variable in the slot. More...
 
void insert (BaseType *convar)
 Inserts a constraint/variable in the slot and updates the version number. More...
 
Mastermaster ()
 Returns a pointer to the corresponding master of the optimization. More...
 
const Mastermaster () const
 Returns a const pointer to the corresponding master of the optimization. More...
 
const PoolSlot< BaseType, CoType > & operator= (const PoolSlot< BaseType, CoType > &rhs)
 
void removeConVarFromPool ()
 Removes the constraint contained in this slot from its pool. More...
 
int softDelete ()
 Tries to remove the item from the slot. More...
 
unsigned long version () const
 Return the version number of the constraint/variable in the slot. More...
 

Private Attributes

BaseType * conVar_
 A pointer to the constraint/variable. More...
 
Mastermaster_
 A pointer to the corresponding master of the optimization. More...
 
Pool< BaseType, CoType > * pool_
 A pointer to the corresponding pool. More...
 
unsigned long version_
 The version of the constraint in the slot. More...
 

Friends

class CutBuffer< BaseType, CoType >
 
class CutBuffer< Constraint, Variable >
 
class CutBuffer< Variable, Constraint >
 
class NonDuplPool< Constraint, Variable >
 
class NonDuplPool< Variable, Constraint >
 
class Pool< BaseType, CoType >
 
class Pool< Constraint, Variable >
 
class Pool< Variable, Constraint >
 
class PoolSlotRef< BaseType, CoType >
 
class PoolSlotRef< Constraint, Variable >
 
class PoolSlotRef< Variable, Constraint >
 
class StandardPool< BaseType, CoType >
 
class StandardPool< Constraint, Variable >
 
class StandardPool< Variable, Constraint >
 
class Sub
 

Detailed Description

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

Stores constraints and variables.

Constraints or variables are not directly stored in a pool, but in pool slots, which form again the basic building blocks of a pool. The reason is that in order to save memory it can be necessary that a constraint or variable in the pool has to be deleted although it is still contained in the active formulation of an inactive subproblem. Of course this deletion can be only done with constraints/variables which can be regenerated or which are not required for the correctness of the algorithm (e.g., for a cutting plane, but not for a variable or constraint of the problem formulation of a general mixed integer optimization problem).

Such that the deletion of a variable or constraint cannot cause a run-time error, we store it in a pool slot. Together with the pointer to the constraint/variable we store also its version number. The version number is initially zero and incremented each time when a new item is inserted in the pool slot. When we refer to a constraint/variable, e.g., from the sets of active constraints or variables, then we point to the slot and memorize the version number (class PoolSlotRef), when this reference has been set up. Later by comparing the version number of PoolSlotRef and the one of the corresponding PoolSlot we can check if still the constraint/variable is contained in the slot which is supposed to be there. Usually, if the expected constraint/variable is missing, it is ignored.

Warning
A PoolSlot must not be deleted before the termination of the optimization process, except that it can be guaranteed that there is no reference to this slot from any other place of the program.

Definition at line 39 of file active.h.

Constructor & Destructor Documentation

◆ PoolSlot() [1/2]

template<class BaseType , class CoType >
abacus::PoolSlot< BaseType, CoType >::PoolSlot ( Master master,
Pool< BaseType, CoType > *  pool,
BaseType *  convar = 0 
)

Creates a pool slot and inserts convar.

Sets the version number to 1, if a constraint has already been inserted in this slot, 0 otherwise.

Parameters
masterA pointer to the corresponding master of the optimization.
poolThe pool this slot belongs to.
convarThe constraint/variable inserted in this slot if not 0. The default value is 0.

◆ ~PoolSlot()

template<class BaseType , class CoType >
abacus::PoolSlot< BaseType, CoType >::~PoolSlot ( )

◆ PoolSlot() [2/2]

template<class BaseType , class CoType >
abacus::PoolSlot< BaseType, CoType >::PoolSlot ( const PoolSlot< BaseType, CoType > &  rhs)
private

Member Function Documentation

◆ conVar()

template<class BaseType , class CoType >
BaseType* abacus::PoolSlot< BaseType, CoType >::conVar ( ) const
inline

Returns a pointer to the constraint/variable in the pool slot.

Definition at line 115 of file poolslot.h.

◆ hardDelete()

template<class BaseType , class CoType >
void abacus::PoolSlot< BaseType, CoType >::hardDelete ( )
inlineprivate

Deletes the constraint/variable in the slot.

Warning
This function should be used very carefully.

Definition at line 147 of file poolslot.h.

◆ insert()

template<class BaseType , class CoType >
void abacus::PoolSlot< BaseType, CoType >::insert ( BaseType *  convar)
private

Inserts a constraint/variable in the slot and updates the version number.

If the slot still contains a constraint, the program stops.

Parameters
convarThe constraint/variable that is inserted.

◆ master() [1/2]

template<class BaseType , class CoType >
Master* abacus::PoolSlot< BaseType, CoType >::master ( )
inlineprivate

Returns a pointer to the corresponding master of the optimization.

Definition at line 161 of file poolslot.h.

◆ master() [2/2]

template<class BaseType , class CoType >
const Master* abacus::PoolSlot< BaseType, CoType >::master ( ) const
inlineprivate

Returns a const pointer to the corresponding master of the optimization.

Definition at line 164 of file poolslot.h.

◆ operator=()

template<class BaseType , class CoType >
const PoolSlot<BaseType, CoType>& abacus::PoolSlot< BaseType, CoType >::operator= ( const PoolSlot< BaseType, CoType > &  rhs)
private

◆ removeConVarFromPool()

template<class BaseType , class CoType >
void abacus::PoolSlot< BaseType, CoType >::removeConVarFromPool ( )
inlineprivate

Removes the constraint contained in this slot from its pool.

Definition at line 153 of file poolslot.h.

◆ softDelete()

template<class BaseType , class CoType >
int abacus::PoolSlot< BaseType, CoType >::softDelete ( )
inlineprivate

Tries to remove the item from the slot.

This is possible if the function ConVar::deletable() returns true.

Returns
0 if the constraint/variable in the slot could be deleted, 1 otherwise.

Definition at line 134 of file poolslot.h.

◆ version()

template<class BaseType , class CoType >
unsigned long abacus::PoolSlot< BaseType, CoType >::version ( ) const
inlineprivate

Return the version number of the constraint/variable in the slot.

Definition at line 158 of file poolslot.h.

Friends And Related Function Documentation

◆ CutBuffer< BaseType, CoType >

template<class BaseType , class CoType >
friend class CutBuffer< BaseType, CoType >
friend

Definition at line 82 of file poolslot.h.

◆ CutBuffer< Constraint, Variable >

template<class BaseType , class CoType >
friend class CutBuffer< Constraint, Variable >
friend

Definition at line 93 of file poolslot.h.

◆ CutBuffer< Variable, Constraint >

template<class BaseType , class CoType >
friend class CutBuffer< Variable, Constraint >
friend

Definition at line 94 of file poolslot.h.

◆ NonDuplPool< Constraint, Variable >

template<class BaseType , class CoType >
friend class NonDuplPool< Constraint, Variable >
friend

Definition at line 91 of file poolslot.h.

◆ NonDuplPool< Variable, Constraint >

template<class BaseType , class CoType >
friend class NonDuplPool< Variable, Constraint >
friend

Definition at line 92 of file poolslot.h.

◆ Pool< BaseType, CoType >

template<class BaseType , class CoType >
friend class Pool< BaseType, CoType >
friend

Definition at line 80 of file poolslot.h.

◆ Pool< Constraint, Variable >

template<class BaseType , class CoType >
friend class Pool< Constraint, Variable >
friend

Definition at line 87 of file poolslot.h.

◆ Pool< Variable, Constraint >

template<class BaseType , class CoType >
friend class Pool< Variable, Constraint >
friend

Definition at line 88 of file poolslot.h.

◆ PoolSlotRef< BaseType, CoType >

template<class BaseType , class CoType >
friend class PoolSlotRef< BaseType, CoType >
friend

Definition at line 79 of file poolslot.h.

◆ PoolSlotRef< Constraint, Variable >

template<class BaseType , class CoType >
friend class PoolSlotRef< Constraint, Variable >
friend

Definition at line 85 of file poolslot.h.

◆ PoolSlotRef< Variable, Constraint >

template<class BaseType , class CoType >
friend class PoolSlotRef< Variable, Constraint >
friend

Definition at line 86 of file poolslot.h.

◆ StandardPool< BaseType, CoType >

template<class BaseType , class CoType >
friend class StandardPool< BaseType, CoType >
friend

Definition at line 81 of file poolslot.h.

◆ StandardPool< Constraint, Variable >

template<class BaseType , class CoType >
friend class StandardPool< Constraint, Variable >
friend

Definition at line 89 of file poolslot.h.

◆ StandardPool< Variable, Constraint >

template<class BaseType , class CoType >
friend class StandardPool< Variable, Constraint >
friend

Definition at line 90 of file poolslot.h.

◆ Sub

template<class BaseType , class CoType >
friend class Sub
friend

Definition at line 84 of file poolslot.h.

Member Data Documentation

◆ conVar_

template<class BaseType , class CoType >
BaseType* abacus::PoolSlot< BaseType, CoType >::conVar_
private

A pointer to the constraint/variable.

Definition at line 167 of file poolslot.h.

◆ master_

template<class BaseType , class CoType >
Master* abacus::PoolSlot< BaseType, CoType >::master_
private

A pointer to the corresponding master of the optimization.

Definition at line 166 of file poolslot.h.

◆ pool_

template<class BaseType , class CoType >
Pool<BaseType, CoType>* abacus::PoolSlot< BaseType, CoType >::pool_
private

A pointer to the corresponding pool.

Definition at line 169 of file poolslot.h.

◆ version_

template<class BaseType , class CoType >
unsigned long abacus::PoolSlot< BaseType, CoType >::version_
private

The version of the constraint in the slot.

Definition at line 168 of file poolslot.h.


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