Common base class for constraints (Constraint) and variables (Variable). More...
#include <ogdf/lib/abacus/convar.h>
Public Member Functions  
ConVar (Master *master, const Sub *sub, bool dynamic, bool local)  
Creates an instance of type ConVar.  
virtual  ~ConVar () 
bool  active () const 
Checks if the constraint/variable is active in at least one active subproblem.  
virtual bool  dynamic () const 
Return true if the constraint/variable is dynamic.  
virtual bool  equal (const ConVar *cv) const 
Should compare if the constraint/variable is identical (in a mathematical sense) with the constraint/variable cv.  
bool  global () const 
Returns true if the constraint/variable is globally valid, false otherwise.  
virtual unsigned  hashKey () const 
Should provide a key for the constraint/variable that can be used to insert it into a hash table.  
bool  local () const 
Returns true if the constraint/variable is only locally valid, false otherwise.  
virtual const char *  name () const 
Should return the name of the constraint/variable.  
virtual void  print (std::ostream &out) const 
Writes the constraint/variable to the output stream out.  
virtual double  rank () const 
The function should return a rank associated with the constraint/variable.  
const Sub *  sub () const 
Returns a const pointer to the subproblem associated with the constraint/variable.  
void  sub (Sub *sub) 
Associates a new subproblem with the constraint/variable.  
Expand and Compress  
Constraints/Variables often have to be stored in a format different from the format used in the linear program. One reason is to save memory and the other reason is that if constraints and/or variable sets are dynamic, then we require a format to compute the coefficients of later activated variables/constraints. The disadvantage of such a constraint format is that the computation of a single constraint coefficient can be very time consuming. Often it cannot be done in constant time. Hence we provide a mechanism which converts a constraint/variable to a format enabling efficient computation of coefficients. The following functions provide this feature.  
bool  expanded () const 
Returns true if the expanded format of a constraint/variable is available, false otherwise.  
virtual void  expand () const 
Expands a constraint/variable.  
virtual void  compress () const 
Compresses a constraint/variable.  
virtual bool  deletable () const 
Returns true if the constraint/variable can be destructed.  
Public Member Functions inherited from abacus::AbacusRoot  
virtual  ~AbacusRoot () 
The destructor.  
Protected Attributes  
bool  dynamic_ 
If this member is true then the constraint/variable can be also removed from the active formulation after it is added the first time.  
bool  expanded_ 
true, if expanded version of constraint/variables available.  
bool  local_ 
true if the constraint/variable is only locally valid  
Master *  master_ 
A pointer to the corresponding master of the optimization.  
int  nActive_ 
The number of active subproblems of which the constraint/variable belongs to the set of active constraints/variables.  
int  nLocks_ 
The number of locks which have been set on the constraint/variable.  
int  nReferences_ 
The number of references to the pool slot the constraint is stored in.  
const Sub *  sub_ 
A pointer to the subproblem associated with the constraint/variable.  
Private Member Functions  
void  _compress () const 
Removes the expanded format of the constraint/variable.  
void  _expand () const 
Tries to generate the expanded format of the constraint/variable.  
void  activate () 
Must be called if the constraint/variable is added to the active formulation of an active subproblem.  
void  addReference () 
Indicates that there is a new reference to the pool slot storing this constraint/variable.  
void  deactivate () 
Counterpart of activate().  
int  nReferences () const 
Returns the number of references to the pool slot PoolSlotRef storing this constraint/variable.  
void  removeReference () 
Is the counterpart of the function addReference() and indicates the removal of a reference to this constraint.  
Locking  
If a constraint/variable has just been separated and added to the buffer of currently separated constraints/variables, then this item should not be removed before the buffer is emptied at the beginning of the next iteration. Hence, we provide a locking mechanism for constraints/variables by the following three functions.  
bool  locked () const 
Returns true if at least one lock is set on the constraint/variable, false otherwise.  
void  lock () 
Adds an additional lock to the constraint/variable.  
void  unlock () 
Removes one lock from the constraint/variable.  
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".  
Common base class for constraints (Constraint) and variables (Variable).
ConVar is the common base class for constraints and variables, which are implemented in the derived classes Constraint and Variable, respectively. It might seem a bit strange to implement a common base class for these two objects. Besides several technical reasons, there is linear programming duality which motivates this point of view. E.g., the separation problem for the primal problem is equivalent to the pricing problem for the dual problem.
ConVar is not the base class for constraints and variables as they are used in the interface to the linear programming solver. There are the classes Row and Column for this purpose. ConVar is the father of a class hierarchy for abstract constraints and variables which are used in the branchandbound algorithm.
Creates an instance of type ConVar.
master  A pointer to the corresponding master of the optimization. 
sub  A pointer the subproblem the constraint/variable is associated with. If the item is not associated with any subproblem, then this can also be the 0pointer. 
dynamic  If this paramument is true, then the constraint/variable can also be removed again from the set of active constraints/variables after it is added once. 
local  If local is true, then the constraint/variable is only locally valid. 

private 
Removes the expanded format of the constraint/variable.
This will be only possible if the virtual function compress() is redefined for the specific constraint/variable.

private 
Tries to generate the expanded format of the constraint/variable.
This will be only possible if the virtual function expand() is redefined for the specific constraint/variable.

inlineprivate 

inline 

inlineprivate 
Indicates that there is a new reference to the pool slot storing this constraint/variable.
The function is only called from members of the class PoolSlotRef.
Compresses a constraint/variable.
The default implementation does nothing. It should be redefined in derived classes. Attention: Data that is compacted/compressed needs to be marked as mutable, as this function is supposed to be applicable for const objects! Compressing/expanding is NOT expected to change the "outer" status of this class, and compression/expansion is done automatically on the fly on an asneeded basis.

inlineprivate 
Counterpart of activate().
Is also called within members of the class Sub to indicate that the constraint/variable does not belong any more to the active formulation of an active subproblem.
Should compare if the constraint/variable is identical (in a mathematical sense) with the constraint/variable cv.
Using RTTI or its emulation provided by the function name() it is sufficient to implement this functions for constraints/variables of the same type.
This function is required if the constraint/variable is stored in a pool of the class NonDuplPool.
The default implementation shows a warning and throws an exception. This function is not a pure virtual function because in the default version of ABACUS it is not required.
cv  The constraint/variable that should be compared with this object. 
Expands a constraint/variable.
The default implementation does nothing. It should be redefined in derived classes. Attention: Data that is compacted/compressed needs to be marked as mutable, as this function is supposed to be applicable for const objects! Compressing/expanding is NOT expected to change the "outer" status of this class, and compression/expansion is done automatically on the fly on an asneeded basis.

inline 

inline 
Should provide a key for the constraint/variable that can be used to insert it into a hash table.
As usual for hashing, it is not required that any two items have different keys.
This function is required if the constraint/variable is stored in a pool of the class NonDuplPool.
The default implementation just throws an exception. This function is not a pure virtual function because in the default version of ABACUS it is not required.
We do not use double as result type because typical problems in floating point arithmetic might give slightly different hash keys for two constraints that are equal from a mathematical point of view.
Reimplemented in ogdf::MinSteinerTreeDirectedCut< T >::DirectedCutConstraint.

inline 

inlineprivate 

inlineprivate 
Should return the name of the constraint/variable.
This function is required to emulate a simple run time type information (RTTI) that is still missing in g++. This function will be removed as soon as RTTI is supported sufficiently.
A user must take care that for each redefined version of this function in a derived class a unique name is returned. Otherwise fatal run time errors can occur. Therefore, we recommend to return always the name of the class.
This function is required if the constraint/variable is stored in a pool of the class NonDuplPool.
The default implementation shows a warning and throws an exception. This function is not a pure virtual function because in the default version of ABACUS it is not required.
Reimplemented in ogdf::MinSteinerTreeDirectedCut< T >::DirectedCutConstraint.

inlineprivate 
Returns the number of references to the pool slot PoolSlotRef storing this constraint/variable.
We require the bookkeeping of the references in order to determine if a constraint/variable can be deleted without causing any harm.
Writes the constraint/variable to the output stream out.
This function is used since the output operator cannot be declared virtual. The default implementation only writes "ConVar::print() is only a dummy."
. We do not declare this function pure virtual since it is not really required, mainly only for debugging. In this case a constraint/variable specific redefinition is strongly recommended.
Normally, the implementation out << *this
should be sufficient.
out  The output stream. 
Reimplemented in abacus::ColVar, abacus::NumCon, and abacus::RowCon.

inlineprivate 
Is the counterpart of the function addReference() and indicates the removal of a reference to this constraint.
It is only called from members of the class PoolSlotRef.

inlineprivate 

friend 

friend 

friend 

friend 

protected 

mutableprotected 

protected 

protected 

protected 
The number of active subproblems of which the constraint/variable belongs to the set of active constraints/variables.
This value is always 0 after construction and has to be set and reset during the subproblem optimization. This member is mainly used to accelerate pool separation and to control that the same variable is not multiply included into a set of active variables.

protected 

protected 