Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Loading...
Searching...
No Matches
abacus::PoolSlot< BaseType, CoType > Class Template Reference

Stores constraints and variables. More...

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

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

Public Member Functions

 PoolSlot (Master *master, Pool< BaseType, CoType > *pool, BaseType *convar=0)
 Creates a pool slot and inserts convar.
 
 ~PoolSlot ()
 
BaseTypeconVar () const
 Returns a pointer to the constraint/variable in the pool slot.
 
- Public Member Functions inherited from abacus::AbacusRoot
virtual ~AbacusRoot ()
 The destructor.
 

Private Member Functions

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

Private Attributes

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

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
 

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::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 77 of file poolslot.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()

◆ 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=()

◆ 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 Symbol Documentation

◆ CutBuffer< BaseType, CoType >

Definition at line 1 of file poolslot.h.

◆ CutBuffer< Constraint, Variable >

Definition at line 84 of file poolslot.h.

◆ CutBuffer< Variable, Constraint >

Definition at line 84 of file poolslot.h.

◆ NonDuplPool< Constraint, Variable >

Definition at line 84 of file poolslot.h.

◆ NonDuplPool< Variable, Constraint >

Definition at line 84 of file poolslot.h.

◆ Pool< BaseType, CoType >

Definition at line 1 of file poolslot.h.

◆ Pool< Constraint, Variable >

Definition at line 84 of file poolslot.h.

◆ Pool< Variable, Constraint >

Definition at line 84 of file poolslot.h.

◆ PoolSlotRef< BaseType, CoType >

Definition at line 1 of file poolslot.h.

◆ PoolSlotRef< Constraint, Variable >

Definition at line 84 of file poolslot.h.

◆ PoolSlotRef< Variable, Constraint >

Definition at line 84 of file poolslot.h.

◆ StandardPool< BaseType, CoType >

Definition at line 1 of file poolslot.h.

◆ StandardPool< Constraint, Variable >

Definition at line 84 of file poolslot.h.

◆ StandardPool< Variable, Constraint >

Definition at line 84 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_

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: