Cut buffers. More...
#include <ogdf/lib/abacus/cutbuffer.h>
Public Member Functions | |
CutBuffer (Master *master, int size) | |
Creates a cut buffer with capacity size. | |
~CutBuffer () | |
The destructor. | |
int | insert (PoolSlot< BaseType, CoType > *slot, bool keepInPool) |
Adds a slot to the buffer. | |
int | insert (PoolSlot< BaseType, CoType > *slot, bool keepInPool, double rank) |
Adds a slot with rank to the buffer. | |
int | number () const |
Returns the number of buffered items. | |
void | remove (ArrayBuffer< int > &index) |
Removes the elements specified by index from the buffer. | |
int | size () const |
Returns the maximal number of items that can be buffered. | |
PoolSlot< BaseType, CoType > * | slot (int i) |
Returns a pointer to the i-th PoolSlot that is buffered. | |
int | space () const |
Returns the number of items which can still be inserted into the buffer. | |
Public Member Functions inherited from abacus::AbacusRoot | |
virtual | ~AbacusRoot () |
The destructor. | |
Private Member Functions | |
CutBuffer (const CutBuffer< BaseType, CoType > &rhs) | |
void | extract (int max, ArrayBuffer< PoolSlot< BaseType, CoType > * > &newSlots) |
Takes the first max items from the buffer and clears the buffer. | |
const CutBuffer< BaseType, CoType > & | operator= (const CutBuffer< BaseType, CoType > &rhs) |
void | sort (int threshold) |
Sorts the items according to their ranks. | |
Private Attributes | |
Array< bool > | keepInPool_ |
If keepInPool_[i] is true for a buffered constraint/variables, then it is not removed from its pool although it might be discarded in extract(). | |
Master * | master_ |
A pointer to the corresponding master of the optimization. | |
int | n_ |
The number of buffered items. | |
Array< PoolSlotRef< BaseType, CoType > * > | psRef_ |
References to the pool slots of the buffered constraints/variables. | |
Array< double > | rank_ |
This array stores optionally the rank of the buffered items. | |
bool | ranking_ |
This flag is true if a rank for each buffered item is available. | |
Friends | |
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 char * | onOff (bool value) |
Converts a boolean variable to the strings "on" and "off". | |
Cut buffers.
This template class implements a buffer for constraints and variables which are generated during the cutting plane or column generation phase. There are two reasons why constraints/variables are buffered instead of being added immediately. First, the set of active constraints/variables should not be falsified during the cut/variable generation. Second, optionally a rank can be assigned to each buffered item. Then not all, but only the best items according to this rank are actually added.
Definition at line 52 of file cutbuffer.h.
|
inline |
Creates a cut buffer with capacity size.
master | A pointer to the corresponding master of the optimization. |
size | The maximal number of constraints/variables which can be buffered. |
Definition at line 63 of file cutbuffer.h.
The destructor.
If there are still items buffered when this object is destructed then we have to unset the locks of the buffered items. This can happen if in the feasibility test constraints are generated but for some reason (e.g., due to tailing off) the optimization of the subproblem is terminated.
|
private |
|
private |
Takes the first max items from the buffer and clears the buffer.
Constraints or variables stored in slots which are not extracted are also removed from their pools if keepInPool has not been set to true at insertion time.
max | The maximal number of extracted items. |
newSlots | The extracted items are inserted into this buffer. |
int abacus::CutBuffer< BaseType, CoType >::insert | ( | PoolSlot< BaseType, CoType > * | slot, |
bool | keepInPool | ||
) |
Adds a slot to the buffer.
The member ranking_ has to be set to false, because since no rank is added together with this item a ranking of all items is impossible. Such that newly generated items cannot be removed immediately in a cleaning up process of the pool we set a lock which will be removed in the function extract().
slot | The inserted pool slot. |
keepInPool | If the flag keepInPool is true, then the item stored in the slot is not removed from the pool, even if it is discarded in extract(). Items regenerated from a pool should always have this flag set to true. |
int abacus::CutBuffer< BaseType, CoType >::insert | ( | PoolSlot< BaseType, CoType > * | slot, |
bool | keepInPool, | ||
double | rank | ||
) |
Adds a slot with rank to the buffer.
In addition to the previous version of the function insert() this version also adds a rank to the item such that all buffered items can be sorted with the function sort().
slot | The inserted pool slot. |
keepInPool | If the flag keepInPool is true, then the item stored in the slot is not removed from the pool, even if it is discarded in extract(). Items regenerated from a pool should always have this flag set to true. |
rank | A rank associated with the constraint/variable. |
|
inline |
Returns the number of buffered items.
Definition at line 86 of file cutbuffer.h.
|
private |
void abacus::CutBuffer< BaseType, CoType >::remove | ( | ArrayBuffer< int > & | index | ) |
Removes the elements specified by index from the buffer.
index | The numbers of the elements which should be removed. |
|
inline |
Returns the maximal number of items that can be buffered.
Definition at line 83 of file cutbuffer.h.
Returns a pointer to the i-th PoolSlot that is buffered.
Definition at line 133 of file cutbuffer.h.
|
private |
Sorts the items according to their ranks.
threshold | Only if more than threshold items are buffered, the sorting is performed. |
|
inline |
Returns the number of items which can still be inserted into the buffer.
Definition at line 89 of file cutbuffer.h.
Definition at line 54 of file cutbuffer.h.
|
private |
If keepInPool_[i] is true for a buffered constraint/variables, then it is not removed from its pool although it might be discarded in extract().
Definition at line 169 of file cutbuffer.h.
|
private |
A pointer to the corresponding master of the optimization.
Definition at line 158 of file cutbuffer.h.
The number of buffered items.
Definition at line 159 of file cutbuffer.h.
|
private |
References to the pool slots of the buffered constraints/variables.
Definition at line 162 of file cutbuffer.h.
|
private |
This array stores optionally the rank of the buffered items.
Definition at line 172 of file cutbuffer.h.
|
private |
This flag is true if a rank for each buffered item is available.
As soon as an item without rank is inserted it becomes false.
Definition at line 178 of file cutbuffer.h.