OpenGM  2.3.x
Discrete Graphical Model Library
Classes | Public Types | Public Member Functions | Public Attributes | Protected Types | Protected Member Functions | Protected Attributes | List of all members
opengm::LPInferenceBase< LP_INFERENCE_TYPE > Class Template Reference

Base class for Linear Programming based inference. More...

#include <lp_inference_base.hxx>

+ Inheritance diagram for opengm::LPInferenceBase< LP_INFERENCE_TYPE >:
+ Collaboration diagram for opengm::LPInferenceBase< LP_INFERENCE_TYPE >:

Classes

struct  AddAllViolatedLinearConstraintsFunctor
 Functor used to access the method challenge() of the underlying linear constraint function of a graphical model factor and to add all violated constraints to the LP/MIP model. More...
 
struct  AddAllViolatedLinearConstraintsRelaxedFunctor
 Functor used to access the method challengeRelaxed() of the underlying linear constraint function of a graphical model factor and to add all violated constraints to the LP/MIP model. More...
 
struct  ConstraintStorage
 Storage class for linear constraints representing the local polytope constraints. They are generated and stored for later use if LPInferenceBase::Parameter::LoosePolytope is selected as relaxation method. More...
 
struct  GetIndicatorVariablesOrderBeginFunctor
 Functor used to access the method indicatorVariablesOrderBegin() of the underlying linear constraint function of a graphical model factor. More...
 
struct  GetIndicatorVariablesOrderEndFunctor
 Functor used to access the method indicatorVariablesOrderEnd() of the underlying linear constraint function of a graphical model factor. More...
 
struct  GetLinearConstraintsBeginFunctor
 Functor used to access the method linearConstraintsBegin() of the underlying linear constraint function of a graphical model factor. More...
 
struct  GetLinearConstraintsEndFunctor
 Functor used to access the method linearConstraintsEnd() of the underlying linear constraint function of a graphical model factor. More...
 
struct  Parameter
 Parameter class for opengm::LPInferenceBase. More...
 

Public Types

typedef LP_INFERENCE_TYPE LPInferenceType
 Typedef of the child class which inherits from opengm::LPInferenceBase. More...
 
typedef LPInferenceTraits< LPInferenceTypeLPInferenceTraitsType
 Typedef of the opengm::LPInferenceTraits class with appropriate template parameter. More...
 
typedef LPInferenceBase< LPInferenceTypeLPInferenceBaseType
 Typedef of the opengm::LPInferenceBase class with appropriate template parameter. More...
 
typedef LPInferenceTraitsType::AccumulationType AccumulationType
 Typedef of the Accumulation type. More...
 
typedef LPInferenceTraitsType::GraphicalModelType GraphicalModelType
 Typedef of the graphical model type. More...
 
typedef visitors::VerboseVisitor< LPInferenceBaseTypeVerboseVisitorType
 Typedef of the opengm::visitors::VerboseVisitor class with appropriate template parameter. More...
 
typedef visitors::EmptyVisitor< LPInferenceBaseTypeEmptyVisitorType
 Typedef of the opengm::visitors::EmptyVisitor class with appropriate template parameter. More...
 
typedef visitors::TimingVisitor< LPInferenceBaseTypeTimingVisitorType
 Typedef of the opengm::visitors::TimingVisitor class with appropriate template parameter. More...
 
typedef LinearConstraint< ValueType, IndexType, LabelTypeLinearConstraintType
 Typedef of the opengm::LinearConstraint class with appropriate template parameter. Used to represent linear constraints. More...
 
typedef std::vector< LinearConstraintTypeLinearConstraintsContainerType
 Typedef of the container type used to store a set of linear constraints. More...
 
typedef LinearConstraintsContainerType::const_iterator LinearConstraintsIteratorType
 Typedef of the iterator type used to iterate over a set of linear constraints. More...
 
typedef LinearConstraintType::IndicatorVariableType IndicatorVariableType
 Typedef of the indicator variable type used within linear constraints. More...
 
typedef LinearConstraintType::IndicatorVariablesContainerType IndicatorVariablesContainerType
 Typedef of the container type used to store a set of indicator variables. More...
 
typedef LinearConstraintType::IndicatorVariablesIteratorType IndicatorVariablesIteratorType
 Typedef of the iterator type used to iterate over a set of indicator variables. More...
 
typedef LinearConstraintType::VariableLabelPairsIteratorType VariableLabelPairsIteratorType
 Typedef of the iterator type used to iterate over a set of varible label pairs used within an indicator variable. More...
 
typedef LPFunctionTransfer< ValueType, IndexType, LabelTypeLPFunctionTransferType
 Typedef of the opengm::LPFunctionTransfer class with appropriate template parameter. More...
 
typedef LPInferenceTraitsType::SolverType SolverType
 Typedef of the solver type used to solve the LP or MIP which is generated from the graphical model. More...
 
typedef LPInferenceTraitsType::SolverIndexType SolverIndexType
 Typedef of the index type used by the LP/MIP solver. More...
 
typedef LPInferenceTraitsType::SolverValueType SolverValueType
 Typedef of the value type used by the LP/MIP solver. More...
 
typedef LPInferenceTraitsType::SolverSolutionIteratorType SolverSolutionIteratorType
 Typedef of the iterator type used to iterate over the computed solution from the LP/MIP solver. More...
 
typedef LPInferenceTraitsType::SolverTimingType SolverTimingType
 Typedef of the type used by the LP/MIP solver to measure timings. More...
 
typedef LPInferenceTraitsType::SolverParameterType SolverParameterType
 Typedef of the parameter class used by the LP/MIP solver. More...
 
typedef SubsequenceIterator< typename std::vector< LabelType >::const_iterator, typename std::vector< size_t >::const_iterator > IntegerSolutionSubsequenceIterator
 Typedef of the iterator type used to iterate over a subset of the computed solution. This iterator type is used to challenge the linear constraint functions present in the model. Only used when the problem is solved as a MIP. More...
 
typedef SubsequenceIterator< SolverSolutionIteratorType, typename std::vector< size_t >::const_iterator > RelaxedSolutionSubsequenceIterator
 Typedef of the iterator type used to iterate over a subset of the computed solution. This iterator type is used to challenge the linear constraint functions present in the model. Only used when the problem is solved as a LP. More...
 
- Public Types inherited from opengm::Inference< LPInferenceTraits< LP_INFERENCE_TYPE >::GraphicalModelType, LPInferenceTraits< LP_INFERENCE_TYPE >::AccumulationType >
typedef LPInferenceTraits< LP_INFERENCE_TYPE >::GraphicalModelType GraphicalModelType
 
typedef LPInferenceTraits< LP_INFERENCE_TYPE >::AccumulationType AccumulationType
 
typedef GraphicalModelType::LabelType LabelType
 
typedef GraphicalModelType::IndexType IndexType
 
typedef GraphicalModelType::ValueType ValueType
 
typedef GraphicalModelType::OperatorType OperatorType
 
typedef GraphicalModelType::FactorType FactorType
 
typedef GraphicalModelType::IndependentFactorType IndependentFactorType
 
typedef GraphicalModelType::FunctionIdentifier FunctionIdentifier
 

Public Member Functions

virtual const GraphicalModelTypegraphicalModel () const
 Get graphical model. More...
 
virtual InferenceTermination infer ()
 Run inference with empty visitor. More...
 
template<class VISITOR_TYPE >
InferenceTermination infer (VISITOR_TYPE &visitor)
 Run inference with provided visitor. More...
 
virtual ValueType bound () const
 Get the current bound. More...
 
virtual ValueType value () const
 Get the current value. More...
 
virtual InferenceTermination arg (std::vector< LabelType > &x, const size_t N=1) const
 Get the current argument. More...
 
- Public Member Functions inherited from opengm::Inference< LPInferenceTraits< LP_INFERENCE_TYPE >::GraphicalModelType, LPInferenceTraits< LP_INFERENCE_TYPE >::AccumulationType >
virtual ~Inference ()
 
virtual std::string name () const =0
 
virtual void setStartingPoint (typename std::vector< LabelType >::const_iterator)
 set initial labeling More...
 
virtual InferenceTermination args (std::vector< std::vector< LabelType > > &) const
 
virtual InferenceTermination marginal (const size_t, IndependentFactorType &) const
 output a solution for a marginal for a specific variable More...
 
virtual InferenceTermination factorMarginal (const size_t, IndependentFactorType &) const
 output a solution for a marginal for all variables connected to a factor More...
 
InferenceTermination constrainedOptimum (std::vector< IndexType > &, std::vector< LabelType > &, std::vector< LabelType > &) const
 
InferenceTermination modeFromMarginal (std::vector< LabelType > &) const
 
InferenceTermination modeFromFactorMarginal (std::vector< LabelType > &) const
 

Public Attributes

 OPENGM_GM_TYPE_TYPEDEFS
 

Protected Types

typedef std::list< ConstraintStorageInactiveConstraintsListType
 Typedef of the container type used to sore a set of LPInferenceBase::ConstraintStorage objects. More...
 
typedef InactiveConstraintsListType::iterator InactiveConstraintsListIteratorType
 Typedef of the iterator type used to iterate over a set of LPInferenceBase::ConstraintStorage objects. More...
 
typedef std::pair< IndexType, const LinearConstraintType * > FactorIndexConstraintPointerPairType
 Typedef of the pair type used to store a pointer to a linear constraint in combination with the linear constraint factor index it belongs to. More...
 
typedef std::pair< InactiveConstraintsListIteratorType, FactorIndexConstraintPointerPairTypeInactiveConstraintFactorConstraintPairType
 Typedef of the pair type used to store a pointer to an inactive constraint of the local polytope constraints and a LPInferenceBase::FactorIndexConstraintPointerPairType. More...
 
typedef std::multimap< double, InactiveConstraintFactorConstraintPairTypeSortedViolatedConstraintsListType
 Typedef of the map type used to store a set of violated constraints sorted by their weights. Is only used when LPInferenceBase::Parameter::Weighted is selected as challenge heuristic. More...
 
typedef meta::GetLinearConstraintFunctionTypeList< typename GraphicalModelType::FunctionTypeList >::type LinearConstraintFunctionTypeList
 Typelist of all linear constraint function types which are present in the graphical model type. More...
 

Protected Member Functions

 LPInferenceBase (const GraphicalModelType &gm, const Parameter &parameter=Parameter())
 LPInferenceBase constructor. More...
 
virtual ~LPInferenceBase ()
 LPInferenceBase destructor. More...
 
void sortFactors ()
 Sorts the factors of the graphical model into the lists unaryFactors_, higherOrderFactors_, linearConstraintFactors_ and transferableFactors_. More...
 
void countLPVariables ()
 Count the number of lp variables required to build a lp model for inference of the graphical model. More...
 
void fillLinearConstraintLPVariablesSubsequenceIndices ()
 Fill the variable LPInferenceBase::linearConstraintLPVariablesSubsequenceIndices_ with the appropriate indices of the subset of the solution variables which are relevant for each linear constraint. More...
 
void setAccumulation ()
 Set the accumulation for the lp solver. More...
 
void addLPVariables ()
 Add the number of lp variables computed by LPInferenceBase::countLPVariables to the lp model. More...
 
void createObjectiveFunction ()
 Create the objective function for the lp model. More...
 
void addLocalPolytopeConstraints ()
 Add all constraints to the lp model which are required by the local polytope relaxation. More...
 
void addLoosePolytopeConstraints ()
 Add all constraints to the lp model which are required by the loose polytope relaxation. More...
 
void addTightPolytopeConstraints ()
 Add all constraints to the lp model which are required by the tight polytope relaxation. More...
 
SolverIndexType nodeLPVariableIndex (const IndexType nodeID, const LabelType label) const
 Get the lp variable which corresponds to the variable label pair of the graphical model. More...
 
SolverIndexType factorLPVariableIndex (const IndexType factorID, const size_t labelingIndex) const
 Get the lp variable which corresponds to the labeling of the factor. More...
 
template<class LABELING_ITERATOR_TYPE >
SolverIndexType factorLPVariableIndex (const IndexType factorID, LABELING_ITERATOR_TYPE labelingBegin, const LABELING_ITERATOR_TYPE labelingEnd) const
 Get the lp variable which corresponds to the labeling of the factor. More...
 
template<class HIGHER_ORDER_FACTORS_MAP_TYPE , class INDICATOR_VARIABLES_MAP_TYPE >
bool getLPVariableIndexFromIndicatorVariable (const HIGHER_ORDER_FACTORS_MAP_TYPE &higherOrderFactorVariablesLookupTable, const INDICATOR_VARIABLES_MAP_TYPE &indicatorVariablesLookupTable, const IndicatorVariableType &indicatorVariable, const IndexType linearConstraintFactorIndex, SolverIndexType &lpVariableIndex) const
 Get the index of the lp variable associated with an indicator variable. More...
 
void addLocalPolytopeVariableConstraint (const IndexType variableID, const bool addToModel)
 Add a new variable constraint to the lp model. More...
 
void addLocalPolytopeFactorConstraint (const IndexType factor, const IndexType variable, const LabelType label, const bool addToModel)
 Add a new factor constraint to the lp model. More...
 
void addIndicatorVariableConstraints (const IndexType factor, const IndicatorVariableType &indicatorVariable, const SolverIndexType indicatorVariableLPVariable, const bool addToModel)
 Add constraints for an indicator variable to the lp model. More...
 
void addLinearConstraint (const IndexType linearConstraintFactor, const LinearConstraintType &constraint)
 Add a new linear constraint from a linear constraint function to the lp model. More...
 
template<class VISITOR_TYPE >
InferenceTermination infer_impl_selectRelaxation (VISITOR_TYPE &visitor)
 Helper function for LPInferenceBase::infer_impl to select the relaxation template parameter. More...
 
template<class VISITOR_TYPE , typename Parameter::Relaxation RELAXATION>
InferenceTermination infer_impl_selectHeuristic (VISITOR_TYPE &visitor)
 Helper function for LPInferenceBase::infer_impl to select the challenge heuristic template parameter. More...
 
template<class VISITOR_TYPE , typename Parameter::Relaxation RELAXATION, typename Parameter::ChallengeHeuristic HEURISTIC>
InferenceTermination infer_impl_selectIterations (VISITOR_TYPE &visitor)
 Helper function for LPInferenceBase::infer_impl to select the use infinite iterations template parameter. More...
 
template<class VISITOR_TYPE , typename Parameter::Relaxation RELAXATION, typename Parameter::ChallengeHeuristic HEURISTIC, bool USE_INFINITE_ITERATIONS>
InferenceTermination infer_impl_selectViolatedConstraints (VISITOR_TYPE &visitor)
 Helper function for LPInferenceBase::infer_impl to select the add all violated constraints template parameter. More...
 
template<class VISITOR_TYPE , typename Parameter::Relaxation RELAXATION, typename Parameter::ChallengeHeuristic HEURISTIC, bool USE_INFINITE_ITERATIONS, bool ADD_ALL_VIOLATED_CONSTRAINTS>
InferenceTermination infer_impl_selectLPType (VISITOR_TYPE &visitor)
 Helper function for LPInferenceBase::infer_impl to select the use integer constraints template parameter. More...
 
template<class VISITOR_TYPE , typename Parameter::Relaxation RELAXATION, typename Parameter::ChallengeHeuristic HEURISTIC, bool USE_INFINITE_ITERATIONS, bool ADD_ALL_VIOLATED_CONSTRAINTS, bool USE_INTEGER_CONSTRAINTS>
InferenceTermination infer_impl (VISITOR_TYPE &visitor)
 The implementation of the inference method. More...
 
template<typename Parameter::Relaxation RELAXATION, typename Parameter::ChallengeHeuristic HEURISTIC, bool ADD_ALL_VIOLATED_CONSTRAINTS>
bool tightenPolytope ()
 Search for linear constraints which are violated by the current integer solution and add them to the MIP model. More...
 
template<typename Parameter::Relaxation RELAXATION, typename Parameter::ChallengeHeuristic HEURISTIC, bool ADD_ALL_VIOLATED_CONSTRAINTS>
bool tightenPolytopeRelaxed ()
 Search for linear constraints which are violated by the current relaxed solution and add them to the LP model. More...
 
void checkInactiveConstraint (const ConstraintStorage &constraint, double &weight) const
 Check if a given linear constraint from the local polytope constraints is violated. More...
 
void addInactiveConstraint (const ConstraintStorage &constraint)
 Add a linear constraint from the local polytope constraint to the LP/MIP model. More...
 

Protected Attributes

const GraphicalModelTypegm_
 Reference to the graphical model. More...
 
const Parameter parameter_
 Parameter which stores the settings for the inference. More...
 
ValueType constValue_
 Constant value offset. More...
 
std::vector< IndexTypeunaryFactors_
 List of all unary factors. More...
 
std::vector< IndexTypehigherOrderFactors_
 List of all higher order factors. More...
 
std::vector< IndexTypelinearConstraintFactors_
 List of all linear constraint factors. More...
 
std::vector< IndexTypetransferableFactors_
 List of all transferable factors. More...
 
bool inferenceStarted_
 Tell if inference was already started. More...
 
SolverIndexType numLPVariables_
 The total number of lp variables except slack variables. More...
 
SolverIndexType numNodesLPVariables_
 The number of lp variables for the nodes of the graphical model. More...
 
SolverIndexType numFactorsLPVariables_
 The number of lp variables for the factors of the graphical model. More...
 
SolverIndexType numLinearConstraintsLPVariables_
 The number of lp variables for the linear constraint factors of the graphical model. More...
 
SolverIndexType numTransferedFactorsLPVariables
 The number of lp variables for the transferable factors of the graphical model. More...
 
SolverIndexType numSlackVariables_
 The number of slack variables for the transferable factors of the graphical model. More...
 
std::vector< SolverIndexTypenodesLPVariablesOffset_
 The offsets for the indices of the lp variables for each node of the graphical model. More...
 
std::vector< SolverIndexTypefactorsLPVariablesOffset_
 The offsets for the indices of the lp variables for each factor of the graphical model. More...
 
std::vector< std::map< const IndicatorVariableType, SolverIndexType > > linearConstraintsLPVariablesIndicesLookupTable_
 Lookup table for the lp variable indices of each linear constraint. More...
 
std::vector< std::map< const IndicatorVariableType, SolverIndexType > > transferedFactorsLPVariablesIndicesLookupTable_
 Lookup table for the lp variable indices of each transferable factor. More...
 
std::vector< std::vector< size_t > > linearConstraintLPVariablesSubsequenceIndices_
 The indices of the subset of the solution variables which are relevant for each linear constraint. More...
 
IndexType addLocalPolytopeFactorConstraintCachePreviousFactorID_
 Cache for the function LPInferenceBase::addLocalPolytopeFactorConstraint. It is used to store the factor id used for the last call of this function. If the previous factor id and the factor id of the current call to LPInferenceBase::addLocalPolytopeFactorConstraint are the same, the variable LPInferenceBase::addLocalPolytopeFactorConstraintCacheFactorLPVariableIDs_ does not have to be updated. More...
 
marray::Marray< SolverIndexTypeaddLocalPolytopeFactorConstraintCacheFactorLPVariableIDs_
 Lookup table for the factor lp variable ids required by the LPInferenceBase::addLocalPolytopeFactorConstraint function. This lookup table is cached as it may not be necessary to create a new lookup table at each function call. This is only required if the factor id of the previous function call and the factor id of the current function call differ. The factor id of the previous function call is stored in the variable LPInferenceBase::addLocalPolytopeFactorConstraintCachePreviousFactorID_. More...
 
InactiveConstraintsListType inactiveConstraints_
 Storage for all linear constraints representing the local polytope constraints. They are generated and stored for later use if LPInferenceBase::Parameter::LoosePolytope is selected as relaxation method. The constraints are removed from this list when they are added to the LP/MIP model. More...
 

Detailed Description

template<class LP_INFERENCE_TYPE>
class opengm::LPInferenceBase< LP_INFERENCE_TYPE >

Base class for Linear Programming based inference.

This base class provides optimization by Linear Programming (LP) or Mixed Integer Programming (MIP) it can be used with different LP and MIP solvers (e.g. IBM ILOG CPLEX). Only a small interface class has to be written for each desired LP and MIP solver. It uses the curiously recurring template pattern (CRTP) to provide static polymorphism.

Template Parameters
LP_INFERENCE_TYPEThe lp inference class.
Note
  1. A template specialization of class opengm::LPInferenceTraits has to be defined for each class which inherits from opengm::LPInferenceBase.
  2. The child class which inherits from opengm::LPInferenceBase has to provide the same interface as it is defined by opengm::LPSolverInterface.

Definition at line 29 of file lp_inference_base.hxx.

Member Typedef Documentation

template<class LP_INFERENCE_TYPE>
opengm::LPInferenceBase< LP_INFERENCE_TYPE >::AccumulationType

Typedef of the Accumulation type.

Definition at line 35 of file lp_inference_base.hxx.

template<class LP_INFERENCE_TYPE>
opengm::LPInferenceBase< LP_INFERENCE_TYPE >::EmptyVisitorType

Typedef of the opengm::visitors::EmptyVisitor class with appropriate template parameter.

Definition at line 40 of file lp_inference_base.hxx.

template<class LP_INFERENCE_TYPE>
opengm::LPInferenceBase< LP_INFERENCE_TYPE >::FactorIndexConstraintPointerPairType
protected

Typedef of the pair type used to store a pointer to a linear constraint in combination with the linear constraint factor index it belongs to.

Definition at line 108 of file lp_inference_base.hxx.

template<class LP_INFERENCE_TYPE>
opengm::LPInferenceBase< LP_INFERENCE_TYPE >::GraphicalModelType

Typedef of the graphical model type.

Definition at line 36 of file lp_inference_base.hxx.

template<class LP_INFERENCE_TYPE>
opengm::LPInferenceBase< LP_INFERENCE_TYPE >::InactiveConstraintFactorConstraintPairType
protected

Typedef of the pair type used to store a pointer to an inactive constraint of the local polytope constraints and a LPInferenceBase::FactorIndexConstraintPointerPairType.

Definition at line 109 of file lp_inference_base.hxx.

template<class LP_INFERENCE_TYPE>
opengm::LPInferenceBase< LP_INFERENCE_TYPE >::InactiveConstraintsListIteratorType
protected

Typedef of the iterator type used to iterate over a set of LPInferenceBase::ConstraintStorage objects.

Definition at line 107 of file lp_inference_base.hxx.

template<class LP_INFERENCE_TYPE>
opengm::LPInferenceBase< LP_INFERENCE_TYPE >::InactiveConstraintsListType
protected

Typedef of the container type used to sore a set of LPInferenceBase::ConstraintStorage objects.

Definition at line 106 of file lp_inference_base.hxx.

template<class LP_INFERENCE_TYPE>
opengm::LPInferenceBase< LP_INFERENCE_TYPE >::IndicatorVariablesContainerType

Typedef of the container type used to store a set of indicator variables.

Definition at line 47 of file lp_inference_base.hxx.

template<class LP_INFERENCE_TYPE>
opengm::LPInferenceBase< LP_INFERENCE_TYPE >::IndicatorVariablesIteratorType

Typedef of the iterator type used to iterate over a set of indicator variables.

Definition at line 48 of file lp_inference_base.hxx.

template<class LP_INFERENCE_TYPE>
opengm::LPInferenceBase< LP_INFERENCE_TYPE >::IndicatorVariableType

Typedef of the indicator variable type used within linear constraints.

Definition at line 46 of file lp_inference_base.hxx.

template<class LP_INFERENCE_TYPE>
opengm::LPInferenceBase< LP_INFERENCE_TYPE >::IntegerSolutionSubsequenceIterator

Typedef of the iterator type used to iterate over a subset of the computed solution. This iterator type is used to challenge the linear constraint functions present in the model. Only used when the problem is solved as a MIP.

Definition at line 60 of file lp_inference_base.hxx.

template<class LP_INFERENCE_TYPE>
opengm::LPInferenceBase< LP_INFERENCE_TYPE >::LinearConstraintFunctionTypeList
protected

Typelist of all linear constraint function types which are present in the graphical model type.

Note
LinearConstraintFunctionTypeList might be an empty type list containing only meta::ListEnd elements. This happens if GraphicalModelType::FunctionTypeList does not contain any linear constraint function.

Definition at line 221 of file lp_inference_base.hxx.

template<class LP_INFERENCE_TYPE>
opengm::LPInferenceBase< LP_INFERENCE_TYPE >::LinearConstraintsContainerType

Typedef of the container type used to store a set of linear constraints.

Definition at line 44 of file lp_inference_base.hxx.

template<class LP_INFERENCE_TYPE>
opengm::LPInferenceBase< LP_INFERENCE_TYPE >::LinearConstraintsIteratorType

Typedef of the iterator type used to iterate over a set of linear constraints.

Definition at line 45 of file lp_inference_base.hxx.

template<class LP_INFERENCE_TYPE>
opengm::LPInferenceBase< LP_INFERENCE_TYPE >::LinearConstraintType

Typedef of the opengm::LinearConstraint class with appropriate template parameter. Used to represent linear constraints.

Definition at line 43 of file lp_inference_base.hxx.

template<class LP_INFERENCE_TYPE>
opengm::LPInferenceBase< LP_INFERENCE_TYPE >::LPFunctionTransferType

Typedef of the opengm::LPFunctionTransfer class with appropriate template parameter.

Definition at line 51 of file lp_inference_base.hxx.

template<class LP_INFERENCE_TYPE>
opengm::LPInferenceBase< LP_INFERENCE_TYPE >::LPInferenceBaseType

Typedef of the opengm::LPInferenceBase class with appropriate template parameter.

Definition at line 34 of file lp_inference_base.hxx.

template<class LP_INFERENCE_TYPE>
opengm::LPInferenceBase< LP_INFERENCE_TYPE >::LPInferenceTraitsType

Typedef of the opengm::LPInferenceTraits class with appropriate template parameter.

Definition at line 33 of file lp_inference_base.hxx.

template<class LP_INFERENCE_TYPE>
opengm::LPInferenceBase< LP_INFERENCE_TYPE >::LPInferenceType

Typedef of the child class which inherits from opengm::LPInferenceBase.

Definition at line 32 of file lp_inference_base.hxx.

template<class LP_INFERENCE_TYPE>
opengm::LPInferenceBase< LP_INFERENCE_TYPE >::RelaxedSolutionSubsequenceIterator

Typedef of the iterator type used to iterate over a subset of the computed solution. This iterator type is used to challenge the linear constraint functions present in the model. Only used when the problem is solved as a LP.

Definition at line 61 of file lp_inference_base.hxx.

template<class LP_INFERENCE_TYPE>
opengm::LPInferenceBase< LP_INFERENCE_TYPE >::SolverIndexType

Typedef of the index type used by the LP/MIP solver.

Definition at line 54 of file lp_inference_base.hxx.

template<class LP_INFERENCE_TYPE>
opengm::LPInferenceBase< LP_INFERENCE_TYPE >::SolverParameterType

Typedef of the parameter class used by the LP/MIP solver.

Definition at line 58 of file lp_inference_base.hxx.

template<class LP_INFERENCE_TYPE>
opengm::LPInferenceBase< LP_INFERENCE_TYPE >::SolverSolutionIteratorType

Typedef of the iterator type used to iterate over the computed solution from the LP/MIP solver.

Definition at line 56 of file lp_inference_base.hxx.

template<class LP_INFERENCE_TYPE>
opengm::LPInferenceBase< LP_INFERENCE_TYPE >::SolverTimingType

Typedef of the type used by the LP/MIP solver to measure timings.

Definition at line 57 of file lp_inference_base.hxx.

template<class LP_INFERENCE_TYPE>
opengm::LPInferenceBase< LP_INFERENCE_TYPE >::SolverType

Typedef of the solver type used to solve the LP or MIP which is generated from the graphical model.

Definition at line 53 of file lp_inference_base.hxx.

template<class LP_INFERENCE_TYPE>
opengm::LPInferenceBase< LP_INFERENCE_TYPE >::SolverValueType

Typedef of the value type used by the LP/MIP solver.

Definition at line 55 of file lp_inference_base.hxx.

template<class LP_INFERENCE_TYPE>
opengm::LPInferenceBase< LP_INFERENCE_TYPE >::SortedViolatedConstraintsListType
protected

Typedef of the map type used to store a set of violated constraints sorted by their weights. Is only used when LPInferenceBase::Parameter::Weighted is selected as challenge heuristic.

Note
  1. The weights of the violated constraints are used as the key of the map thus using a reverse iterator to access the violated constraints will result in accessing the violated constraints with the highest weight first.
  2. As there are two possible sources for linear constraints, the local polytope constraints and the constraints from the linear constraint functions, the value of the map stores an iterator pointer pair where either the iterator points to an element of LPInferenceBase::InactiveConstraintsListType and the pointer is set to NULL or the iterator points to LPInferenceBase::InactiveConstraintsListType.end() and the pointer points to an violated constraint of a linear constraint function.

Definition at line 110 of file lp_inference_base.hxx.

template<class LP_INFERENCE_TYPE>
opengm::LPInferenceBase< LP_INFERENCE_TYPE >::TimingVisitorType

Typedef of the opengm::visitors::TimingVisitor class with appropriate template parameter.

Definition at line 41 of file lp_inference_base.hxx.

template<class LP_INFERENCE_TYPE>
opengm::LPInferenceBase< LP_INFERENCE_TYPE >::VariableLabelPairsIteratorType

Typedef of the iterator type used to iterate over a set of varible label pairs used within an indicator variable.

Definition at line 49 of file lp_inference_base.hxx.

template<class LP_INFERENCE_TYPE>
opengm::LPInferenceBase< LP_INFERENCE_TYPE >::VerboseVisitorType

Typedef of the opengm::visitors::VerboseVisitor class with appropriate template parameter.

Definition at line 39 of file lp_inference_base.hxx.

Constructor & Destructor Documentation

template<class LP_INFERENCE_TYPE >
opengm::LPInferenceBase< LP_INFERENCE_TYPE >::LPInferenceBase ( const GraphicalModelType gm,
const Parameter parameter = Parameter() 
)
inlineprotected

LPInferenceBase constructor.

Parameters
[in]gmThe graphical model which will be solved.
[in]parameterParameter providing the settings for the inference.
Note
Constructor is protected as no instance of LPInferenceBase is allowed.

Definition at line 1828 of file lp_inference_base.hxx.

+ Here is the call graph for this function:

template<class LP_INFERENCE_TYPE >
opengm::LPInferenceBase< LP_INFERENCE_TYPE >::~LPInferenceBase ( )
inlineprotectedvirtual

LPInferenceBase destructor.

Note
Destructor is protected as no instance of LPInferenceBase is allowed.

Definition at line 1892 of file lp_inference_base.hxx.

Member Function Documentation

template<class LP_INFERENCE_TYPE >
void opengm::LPInferenceBase< LP_INFERENCE_TYPE >::addInactiveConstraint ( const ConstraintStorage constraint)
inlineprotected

Add a linear constraint from the local polytope constraint to the LP/MIP model.

Parameters
[in]constraintThe linear constraint which will be added to the LP/MIP model.

Definition at line 3225 of file lp_inference_base.hxx.

template<class LP_INFERENCE_TYPE >
void opengm::LPInferenceBase< LP_INFERENCE_TYPE >::addIndicatorVariableConstraints ( const IndexType  factor,
const IndicatorVariableType indicatorVariable,
const SolverIndexType  indicatorVariableLPVariable,
const bool  addToModel 
)
inlineprotected

Add constraints for an indicator variable to the lp model.

Depending on the selected logical ooperator type there are three possibilities for an indicator variable:

  1. An indicator variable corresponds to the logical conjunction of several other lp variables $(v_1 \wedge ... \wedge v_n)$. Hence the indicator variable $I$ is one if all lp variables $\{v_1, ..., v_n\}$ are one and zero if at least one lp variable $v_i$ is zero. The constraints which are added to achieve the logical conjunction are:
    1. \[I - v_i \leq 0 \quad \forall i\]

    2. \[\sum_i v_i - I \leq n - 1\]

  2. An indicator variable corresponds to the logical disjunction of several other lp variables $(v_1 \wedge ... \wedge v_n)$. Hence the indicator variable $I$ is one if at least one lp variable $v_i \in \{v_1, ..., v_n\}$ is one and zero if all lp variables are zero. The constraints which are added to achieve the logical disjunction are:
    1. \[I - v_i \geq 0 \quad \forall i\]

    2. \[\sum_i v_i - I \geq 0\]

  3. An indicator variable corresponds to the logical not of several other lp variables $(v_1 \wedge ... \wedge v_n)$. Hence the indicator variable $I$ is one if all lp variables $\{v_1, ..., v_n\}$ are zero and zero if at least one lp variable $v_i$ is one. The constraints which are added to achieve the logical not are:
    1. \[I + v_i \leq 1 \quad \forall i\]

    2. \[\sum_i v_i + I \geq 1\]

Parameters
[in]factorThe index of the factor for which the indicator variable constraints will be added.
[in]indicatorVariableThe index of the indicator variable from the factor for which the constraints will be added.
[in]indicatorVariableLPVariableThe index of the lp variable which represents the indicator variable.
[in]addToModelIndicator to tell if the constraints shall be added directly to the LP/MIP model. If set to false the constraints will be added to LPInferenceBase::inactiveConstraints_.

Definition at line 2557 of file lp_inference_base.hxx.

+ Here is the call graph for this function:

template<class LP_INFERENCE_TYPE >
void opengm::LPInferenceBase< LP_INFERENCE_TYPE >::addLinearConstraint ( const IndexType  linearConstraintFactor,
const LinearConstraintType constraint 
)
inlineprotected

Add a new linear constraint from a linear constraint function to the lp model.

Parameters
[in]linearConstraintFactorThe index of the linear constraint factor for which the linear constraint will be added.
[in]constraintThe new linear constraint factor.

Definition at line 2743 of file lp_inference_base.hxx.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<class LP_INFERENCE_TYPE >
void opengm::LPInferenceBase< LP_INFERENCE_TYPE >::addLocalPolytopeConstraints ( )
inlineprotected

Add all constraints to the lp model which are required by the local polytope relaxation.

Definition at line 2199 of file lp_inference_base.hxx.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<class LP_INFERENCE_TYPE >
void opengm::LPInferenceBase< LP_INFERENCE_TYPE >::addLocalPolytopeFactorConstraint ( const IndexType  factor,
const IndexType  variable,
const LabelType  label,
const bool  addToModel 
)
inlineprotected

Add a new factor constraint to the lp model.

The new factor constraint has the form $\sum_i \mu\{f;i_1,...,i_n\} - \mu\{b;j\} = 0$ where $\mu\{b;j\}$ is the lp variable corresponding to the $j$-th label of variable $b$ from the graphical model and $\mu\{f;i_1,...,i_n\}$ is the lp variable which corresponds to the $i$-th variable of the factor where variable $b$ is fixed to the label $j$.

Parameters
[in]factorThe factor for which the constraint will be added to the lp model.
[in]variableThe variable of the factor for which the constraint will be added to the lp model.
[in]labelThe label of the variable of the factor for which the constraint will be added to the lp model.
[in]addToModelIndicator to tell if the constraint shall be added directly to the LP/MIP model. If set to false the constraint will be added to LPInferenceBase::inactiveConstraints_.

Definition at line 2501 of file lp_inference_base.hxx.

+ Here is the call graph for this function:

template<class LP_INFERENCE_TYPE >
void opengm::LPInferenceBase< LP_INFERENCE_TYPE >::addLocalPolytopeVariableConstraint ( const IndexType  variableID,
const bool  addToModel 
)
inlineprotected

Add a new variable constraint to the lp model.

The new variable constraint has the form $\sum_i \mu_i = 1$ where $\mu_i$ is the lp variable corresponding to the $i$-th label of the graphical model variable.

Parameters
[in]variableIDThe variable for which the new constraint will be added.
[in]addToModelIndicator to tell if the constraint shall be added directly to the LP/MIP model. If set to false the constraint will be added to LPInferenceBase::inactiveConstraints_.

Definition at line 2468 of file lp_inference_base.hxx.

template<class LP_INFERENCE_TYPE >
void opengm::LPInferenceBase< LP_INFERENCE_TYPE >::addLoosePolytopeConstraints ( )
inlineprotected

Add all constraints to the lp model which are required by the loose polytope relaxation.

Definition at line 2279 of file lp_inference_base.hxx.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<class LP_INFERENCE_TYPE >
void opengm::LPInferenceBase< LP_INFERENCE_TYPE >::addLPVariables ( )
inlineprotected

Add the number of lp variables computed by LPInferenceBase::countLPVariables to the lp model.

Definition at line 2124 of file lp_inference_base.hxx.

+ Here is the caller graph for this function:

template<class LP_INFERENCE_TYPE >
void opengm::LPInferenceBase< LP_INFERENCE_TYPE >::addTightPolytopeConstraints ( )
inlineprotected

Add all constraints to the lp model which are required by the tight polytope relaxation.

Definition at line 2357 of file lp_inference_base.hxx.

+ Here is the caller graph for this function:

template<class LP_INFERENCE_TYPE >
InferenceTermination opengm::LPInferenceBase< LP_INFERENCE_TYPE >::arg ( std::vector< LabelType > &  x,
const size_t  N = 1 
) const
inlinevirtual

Get the current argument.

Parameters
[out]xWill be filled with the current argument.
[in]NUNKNOWN????
Returns
The status code of the current argument.

Reimplemented from opengm::Inference< LPInferenceTraits< LP_INFERENCE_TYPE >::GraphicalModelType, LPInferenceTraits< LP_INFERENCE_TYPE >::AccumulationType >.

Definition at line 1800 of file lp_inference_base.hxx.

+ Here is the caller graph for this function:

template<class LP_INFERENCE_TYPE >
LPInferenceBase< LP_INFERENCE_TYPE >::ValueType opengm::LPInferenceBase< LP_INFERENCE_TYPE >::bound ( ) const
inlinevirtual
template<class LP_INFERENCE_TYPE >
void opengm::LPInferenceBase< LP_INFERENCE_TYPE >::checkInactiveConstraint ( const ConstraintStorage constraint,
double &  weight 
) const
inlineprotected

Check if a given linear constraint from the local polytope constraints is violated.

Parameters
[in]constraintThe linear constraint which will be checked for violation.
[out]weightThe weight by which the constraint is violated. Will be set to 0.0 if the constraint is not violated.

Definition at line 3189 of file lp_inference_base.hxx.

+ Here is the call graph for this function:

template<class LP_INFERENCE_TYPE >
void opengm::LPInferenceBase< LP_INFERENCE_TYPE >::countLPVariables ( )
inlineprotected

Count the number of lp variables required to build a lp model for inference of the graphical model.

Definition at line 1917 of file lp_inference_base.hxx.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<class LP_INFERENCE_TYPE >
void opengm::LPInferenceBase< LP_INFERENCE_TYPE >::createObjectiveFunction ( )
inlineprotected

Create the objective function for the lp model.

Definition at line 2146 of file lp_inference_base.hxx.

+ Here is the caller graph for this function:

template<class LP_INFERENCE_TYPE >
LPInferenceBase< LP_INFERENCE_TYPE >::SolverIndexType opengm::LPInferenceBase< LP_INFERENCE_TYPE >::factorLPVariableIndex ( const IndexType  factorID,
const size_t  labelingIndex 
) const
inlineprotected

Get the lp variable which corresponds to the labeling of the factor.

Parameters
[in]factorIDThe index of the factor.
[in]labelingIndexThe index describing the selected labeling.
Returns
The index of the requested lp variable.

Definition at line 2384 of file lp_inference_base.hxx.

template<class LP_INFERENCE_TYPE >
template<class LABELING_ITERATOR_TYPE >
LPInferenceBase< LP_INFERENCE_TYPE >::SolverIndexType opengm::LPInferenceBase< LP_INFERENCE_TYPE >::factorLPVariableIndex ( const IndexType  factorID,
LABELING_ITERATOR_TYPE  labelingBegin,
const LABELING_ITERATOR_TYPE  labelingEnd 
) const
inlineprotected

Get the lp variable which corresponds to the labeling of the factor.

Template Parameters
LABELING_ITERATOR_TYPEIterator type to iterate over the selected labeling.
Parameters
[in]factorIDThe index of the factor.
[in]labelingBeginIterator pointing to the begin of the selected labeling.
[in]labelingEndIterator pointing to the end of the selected labeling.
Returns
The index of the requested lp variable.

Definition at line 2393 of file lp_inference_base.hxx.

template<class LP_INFERENCE_TYPE >
void opengm::LPInferenceBase< LP_INFERENCE_TYPE >::fillLinearConstraintLPVariablesSubsequenceIndices ( )
inlineprotected

Fill the variable LPInferenceBase::linearConstraintLPVariablesSubsequenceIndices_ with the appropriate indices of the subset of the solution variables which are relevant for each linear constraint.

Definition at line 2086 of file lp_inference_base.hxx.

+ Here is the caller graph for this function:

template<class LP_INFERENCE_TYPE >
template<class HIGHER_ORDER_FACTORS_MAP_TYPE , class INDICATOR_VARIABLES_MAP_TYPE >
bool opengm::LPInferenceBase< LP_INFERENCE_TYPE >::getLPVariableIndexFromIndicatorVariable ( const HIGHER_ORDER_FACTORS_MAP_TYPE &  higherOrderFactorVariablesLookupTable,
const INDICATOR_VARIABLES_MAP_TYPE &  indicatorVariablesLookupTable,
const IndicatorVariableType indicatorVariable,
const IndexType  linearConstraintFactorIndex,
SolverIndexType lpVariableIndex 
) const
inlineprotected

Get the index of the lp variable associated with an indicator variable.

Template Parameters
HIGHER_ORDER_FACTORS_MAP_TYPEThe type of the map which is used as a lookup table for the higher order factors.
INDICATOR_VARIABLES_MAP_TYPEThe type of the map which is used as a lookup table for the indicator variables.
Parameters
[in]higherOrderFactorVariablesLookupTableThe lookup table which is used to check if another factor is connected to the exact same variables of the graphical model as the indicator variable.
[in]indicatorVariablesLookupTableThe lookup table which is used to check if another indicator variable with the same set of variable label pairs exists.
[in]indicatorVariableThe indicator variable for which the corresponding lp variable is searched.
[in]linearConstraintFactorIndexThe index of the linear constraint factor to which the indicator variable belongs.
[out]lpVariableIndexIf a lp variable which is associated with the indicator variable is found the corresponding index will be stored in this variable.
Returns
True if a lp variable which is associated with the indicator variable is found, false otherwise.

Definition at line 2415 of file lp_inference_base.hxx.

+ Here is the call graph for this function:

template<class LP_INFERENCE_TYPE >
const LPInferenceBase< LP_INFERENCE_TYPE >::GraphicalModelType & opengm::LPInferenceBase< LP_INFERENCE_TYPE >::graphicalModel ( ) const
inlinevirtual
template<class LP_INFERENCE_TYPE >
InferenceTermination opengm::LPInferenceBase< LP_INFERENCE_TYPE >::infer ( )
inlinevirtual

Run inference with empty visitor.

Returns
Termination code of the inference.

Implements opengm::Inference< LPInferenceTraits< LP_INFERENCE_TYPE >::GraphicalModelType, LPInferenceTraits< LP_INFERENCE_TYPE >::AccumulationType >.

Definition at line 1768 of file lp_inference_base.hxx.

template<class LP_INFERENCE_TYPE >
template<class VISITOR_TYPE >
InferenceTermination opengm::LPInferenceBase< LP_INFERENCE_TYPE >::infer ( VISITOR_TYPE &  visitor)
inline

Run inference with provided visitor.

Template Parameters
VISITOR_TYPEThe visitor type used to log inference.
Parameters
[in,out]visitorThe provided inference visitor.
Returns
Termination code of the inference.
Note
If timing visitor is used an additional field for the timings required by the LP / ILP solver to solve the current model in each iteration is added.

Definition at line 1775 of file lp_inference_base.hxx.

+ Here is the call graph for this function:

template<class LP_INFERENCE_TYPE >
template<class VISITOR_TYPE , typename LPInferenceBase< LP_INFERENCE_TYPE >::Parameter::Relaxation RELAXATION, typename LPInferenceBase< LP_INFERENCE_TYPE >::Parameter::ChallengeHeuristic HEURISTIC, bool USE_INFINITE_ITERATIONS, bool ADD_ALL_VIOLATED_CONSTRAINTS, bool USE_INTEGER_CONSTRAINTS>
InferenceTermination opengm::LPInferenceBase< LP_INFERENCE_TYPE >::infer_impl ( VISITOR_TYPE &  visitor)
inlineprotected

The implementation of the inference method.

Template Parameters
VISITOR_TYPEThe type of the visitor.
RELAXATIONThe selected relaxation type.
HEURISTICThe selected Heuristic type.
USE_INFINITE_ITERATIONSTell if inference is performed until no more violated constraints are found.
ADD_ALL_VIOLATED_CONSTRAINTSTell if all violated constraints which were found during one iteration are added to the lp model.
USE_INTEGER_CONSTRAINTSTell if the current model is a LP or a MIP model.
Parameters
[in,out]visitorThe visitor used during inference.
Returns
The inference termination code.
Note
The large amount of parameters which can affect how inference is performed can lead to large if ... else statement blocks which would result in unreadable code. Therefore the parameters are evaluated in a chain of template functions where each function evaluates a specific parameter and tells the result of this evaluation to the next function in the chain via a template parameter. The chain which leads to the call of LPInferenceBase::infer_impl is:
  1. LPInferenceBase::infer_impl_selectRelaxation
  2. LPInferenceBase::infer_impl_selectHeuristic
  3. LPInferenceBase::infer_impl_selectIterations
  4. LPInferenceBase::infer_impl_selectViolatedConstraints
  5. LPInferenceBase::infer_impl_selectLPType
  6. LPInferenceBase::infer_impl.

Definition at line 2832 of file lp_inference_base.hxx.

+ Here is the call graph for this function:

template<class LP_INFERENCE_TYPE >
template<class VISITOR_TYPE , typename LPInferenceBase< LP_INFERENCE_TYPE >::Parameter::Relaxation RELAXATION>
InferenceTermination opengm::LPInferenceBase< LP_INFERENCE_TYPE >::infer_impl_selectHeuristic ( VISITOR_TYPE &  visitor)
inlineprotected

Helper function for LPInferenceBase::infer_impl to select the challenge heuristic template parameter.

Template Parameters
VISITOR_TYPEThe type of the visitor.
RELAXATIONThe selected relaxation type.
Parameters
[in,out]visitorThe visitor which will be passed to LPInferenceBase::infer_impl.
Returns
The inference termination code of LPInferenceBase::infer_impl.
Note
The large amount of parameters which can affect how inference is performed can lead to large if ... else statement blocks which would result in unreadable code. Therefore the parameters are evaluated in a chain of template functions where each function evaluates a specific parameter and tells the result of this evaluation to the next function in the chain via a template parameter. The chain which leads to the call of LPInferenceBase::infer_impl is:
  1. LPInferenceBase::infer_impl_selectRelaxation
  2. LPInferenceBase::infer_impl_selectHeuristic
  3. LPInferenceBase::infer_impl_selectIterations
  4. LPInferenceBase::infer_impl_selectViolatedConstraints
  5. LPInferenceBase::infer_impl_selectLPType
  6. LPInferenceBase::infer_impl.

Definition at line 2786 of file lp_inference_base.hxx.

template<class LP_INFERENCE_TYPE >
template<class VISITOR_TYPE , typename LPInferenceBase< LP_INFERENCE_TYPE >::Parameter::Relaxation RELAXATION, typename LPInferenceBase< LP_INFERENCE_TYPE >::Parameter::ChallengeHeuristic HEURISTIC>
InferenceTermination opengm::LPInferenceBase< LP_INFERENCE_TYPE >::infer_impl_selectIterations ( VISITOR_TYPE &  visitor)
inlineprotected

Helper function for LPInferenceBase::infer_impl to select the use infinite iterations template parameter.

Template Parameters
VISITOR_TYPEThe type of the visitor.
RELAXATIONThe selected relaxation type.
HEURISTICThe selected Heuristic type.
Parameters
[in,out]visitorThe visitor which will be passed to LPInferenceBase::infer_impl.
Returns
The inference termination code of LPInferenceBase::infer_impl.
Note
The large amount of parameters which can affect how inference is performed can lead to large if ... else statement blocks which would result in unreadable code. Therefore the parameters are evaluated in a chain of template functions where each function evaluates a specific parameter and tells the result of this evaluation to the next function in the chain via a template parameter. The chain which leads to the call of LPInferenceBase::infer_impl is:
  1. LPInferenceBase::infer_impl_selectRelaxation
  2. LPInferenceBase::infer_impl_selectHeuristic
  3. LPInferenceBase::infer_impl_selectIterations
  4. LPInferenceBase::infer_impl_selectViolatedConstraints
  5. LPInferenceBase::infer_impl_selectLPType
  6. LPInferenceBase::infer_impl.

Definition at line 2802 of file lp_inference_base.hxx.

template<class LP_INFERENCE_TYPE >
template<class VISITOR_TYPE , typename LPInferenceBase< LP_INFERENCE_TYPE >::Parameter::Relaxation RELAXATION, typename LPInferenceBase< LP_INFERENCE_TYPE >::Parameter::ChallengeHeuristic HEURISTIC, bool USE_INFINITE_ITERATIONS, bool ADD_ALL_VIOLATED_CONSTRAINTS>
InferenceTermination opengm::LPInferenceBase< LP_INFERENCE_TYPE >::infer_impl_selectLPType ( VISITOR_TYPE &  visitor)
inlineprotected

Helper function for LPInferenceBase::infer_impl to select the use integer constraints template parameter.

Template Parameters
VISITOR_TYPEThe type of the visitor.
RELAXATIONThe selected relaxation type.
HEURISTICThe selected Heuristic type.
USE_INFINITE_ITERATIONSTell if inference is performed until no more violated constraints are found.
ADD_ALL_VIOLATED_CONSTRAINTSTell if all violated constraints which were found during one iteration are added to the lp model.
Parameters
[in,out]visitorThe visitor which will be passed to LPInferenceBase::infer_impl.
Returns
The inference termination code of LPInferenceBase::infer_impl.
Note
The large amount of parameters which can affect how inference is performed can lead to large if ... else statement blocks which would result in unreadable code. Therefore the parameters are evaluated in a chain of template functions where each function evaluates a specific parameter and tells the result of this evaluation to the next function in the chain via a template parameter. The chain which leads to the call of LPInferenceBase::infer_impl is:
  1. LPInferenceBase::infer_impl_selectRelaxation
  2. LPInferenceBase::infer_impl_selectHeuristic
  3. LPInferenceBase::infer_impl_selectIterations
  4. LPInferenceBase::infer_impl_selectViolatedConstraints
  5. LPInferenceBase::infer_impl_selectLPType
  6. LPInferenceBase::infer_impl.

Definition at line 2822 of file lp_inference_base.hxx.

template<class LP_INFERENCE_TYPE >
template<class VISITOR_TYPE >
InferenceTermination opengm::LPInferenceBase< LP_INFERENCE_TYPE >::infer_impl_selectRelaxation ( VISITOR_TYPE &  visitor)
inlineprotected

Helper function for LPInferenceBase::infer_impl to select the relaxation template parameter.

Template Parameters
VISITOR_TYPEThe type of the visitor.
Parameters
[in,out]visitorThe visitor which will be passed to LPInferenceBase::infer_impl.
Returns
The inference termination code of LPInferenceBase::infer_impl.
Note
The large amount of parameters which can affect how inference is performed can lead to large if ... else statement blocks which would result in unreadable code. Therefore the parameters are evaluated in a chain of template functions where each function evaluates a specific parameter and tells the result of this evaluation to the next function in the chain via a template parameter. The chain which leads to the call of LPInferenceBase::infer_impl is:
  1. LPInferenceBase::infer_impl_selectRelaxation
  2. LPInferenceBase::infer_impl_selectHeuristic
  3. LPInferenceBase::infer_impl_selectIterations
  4. LPInferenceBase::infer_impl_selectViolatedConstraints
  5. LPInferenceBase::infer_impl_selectLPType
  6. LPInferenceBase::infer_impl.

Definition at line 2767 of file lp_inference_base.hxx.

+ Here is the caller graph for this function:

template<class LP_INFERENCE_TYPE >
template<class VISITOR_TYPE , typename LPInferenceBase< LP_INFERENCE_TYPE >::Parameter::Relaxation RELAXATION, typename LPInferenceBase< LP_INFERENCE_TYPE >::Parameter::ChallengeHeuristic HEURISTIC, bool USE_INFINITE_ITERATIONS>
InferenceTermination opengm::LPInferenceBase< LP_INFERENCE_TYPE >::infer_impl_selectViolatedConstraints ( VISITOR_TYPE &  visitor)
inlineprotected

Helper function for LPInferenceBase::infer_impl to select the add all violated constraints template parameter.

Template Parameters
VISITOR_TYPEThe type of the visitor.
RELAXATIONThe selected relaxation type.
HEURISTICThe selected Heuristic type.
USE_INFINITE_ITERATIONSTell if inference is performed until no more violated constraints are found.
Parameters
[in,out]visitorThe visitor which will be passed to LPInferenceBase::infer_impl.
Returns
The inference termination code of LPInferenceBase::infer_impl.
Note
The large amount of parameters which can affect how inference is performed can lead to large if ... else statement blocks which would result in unreadable code. Therefore the parameters are evaluated in a chain of template functions where each function evaluates a specific parameter and tells the result of this evaluation to the next function in the chain via a template parameter. The chain which leads to the call of LPInferenceBase::infer_impl is:
  1. LPInferenceBase::infer_impl_selectRelaxation
  2. LPInferenceBase::infer_impl_selectHeuristic
  3. LPInferenceBase::infer_impl_selectIterations
  4. LPInferenceBase::infer_impl_selectViolatedConstraints
  5. LPInferenceBase::infer_impl_selectLPType
  6. LPInferenceBase::infer_impl.

Definition at line 2812 of file lp_inference_base.hxx.

template<class LP_INFERENCE_TYPE >
LPInferenceBase< LP_INFERENCE_TYPE >::SolverIndexType opengm::LPInferenceBase< LP_INFERENCE_TYPE >::nodeLPVariableIndex ( const IndexType  nodeID,
const LabelType  label 
) const
inlineprotected

Get the lp variable which corresponds to the variable label pair of the graphical model.

Parameters
[in]nodeIDThe variable of the graphical model.
[in]labelThe label of the variable.
Returns
The index of the requested lp variable.

Definition at line 2377 of file lp_inference_base.hxx.

template<class LP_INFERENCE_TYPE >
void opengm::LPInferenceBase< LP_INFERENCE_TYPE >::setAccumulation ( )
inlineprotected

Set the accumulation for the lp solver.

Definition at line 2113 of file lp_inference_base.hxx.

+ Here is the caller graph for this function:

template<class LP_INFERENCE_TYPE >
void opengm::LPInferenceBase< LP_INFERENCE_TYPE >::sortFactors ( )
inlineprotected

Sorts the factors of the graphical model into the lists unaryFactors_, higherOrderFactors_, linearConstraintFactors_ and transferableFactors_.

Definition at line 1897 of file lp_inference_base.hxx.

+ Here is the caller graph for this function:

template<class LP_INFERENCE_TYPE >
template<typename LPInferenceBase< LP_INFERENCE_TYPE >::Parameter::Relaxation RELAXATION, typename LPInferenceBase< LP_INFERENCE_TYPE >::Parameter::ChallengeHeuristic HEURISTIC, bool ADD_ALL_VIOLATED_CONSTRAINTS>
bool opengm::LPInferenceBase< LP_INFERENCE_TYPE >::tightenPolytope ( )
inlineprotected

Search for linear constraints which are violated by the current integer solution and add them to the MIP model.

Template Parameters
RELAXATIONTell which relaxation is used and therefore which constraints have to be evaluated to check if they are violated.
HEURISTICTell which challenge heuristic will be used to add violated constraints.
ADD_ALL_VIOLATED_CONSTRAINTSIf set to true all violated constraints will be added to the MIP model. Otherwise only the number of violated constraints specified by the LPInferenceBase::parameter_ will be added.

Definition at line 2900 of file lp_inference_base.hxx.

template<class LP_INFERENCE_TYPE >
template<typename LPInferenceBase< LP_INFERENCE_TYPE >::Parameter::Relaxation RELAXATION, typename LPInferenceBase< LP_INFERENCE_TYPE >::Parameter::ChallengeHeuristic HEURISTIC, bool ADD_ALL_VIOLATED_CONSTRAINTS>
bool opengm::LPInferenceBase< LP_INFERENCE_TYPE >::tightenPolytopeRelaxed ( )
inlineprotected

Search for linear constraints which are violated by the current relaxed solution and add them to the LP model.

Template Parameters
RELAXATIONTell which relaxation is used and therefore which constraints have to be evaluated to check if they are violated.
HEURISTICTell which challenge heuristic will be used to add violated constraints.
ADD_ALL_VIOLATED_CONSTRAINTSIf set to true all violated constraints will be added to the LP model. Otherwise only the number of violated constraints specified by the LPInferenceBase::parameter_ will be added.

Definition at line 3044 of file lp_inference_base.hxx.

template<class LP_INFERENCE_TYPE >
LPInferenceBase< LP_INFERENCE_TYPE >::ValueType opengm::LPInferenceBase< LP_INFERENCE_TYPE >::value ( ) const
inlinevirtual

Get the current value.

Returns
The current value.

Reimplemented from opengm::Inference< LPInferenceTraits< LP_INFERENCE_TYPE >::GraphicalModelType, LPInferenceTraits< LP_INFERENCE_TYPE >::AccumulationType >.

Definition at line 1793 of file lp_inference_base.hxx.

+ Here is the call graph for this function:

Member Data Documentation

template<class LP_INFERENCE_TYPE>
opengm::LPInferenceBase< LP_INFERENCE_TYPE >::addLocalPolytopeFactorConstraintCacheFactorLPVariableIDs_
protected

Lookup table for the factor lp variable ids required by the LPInferenceBase::addLocalPolytopeFactorConstraint function. This lookup table is cached as it may not be necessary to create a new lookup table at each function call. This is only required if the factor id of the previous function call and the factor id of the current function call differ. The factor id of the previous function call is stored in the variable LPInferenceBase::addLocalPolytopeFactorConstraintCachePreviousFactorID_.

Definition at line 249 of file lp_inference_base.hxx.

template<class LP_INFERENCE_TYPE>
opengm::LPInferenceBase< LP_INFERENCE_TYPE >::addLocalPolytopeFactorConstraintCachePreviousFactorID_
protected

Cache for the function LPInferenceBase::addLocalPolytopeFactorConstraint. It is used to store the factor id used for the last call of this function. If the previous factor id and the factor id of the current call to LPInferenceBase::addLocalPolytopeFactorConstraint are the same, the variable LPInferenceBase::addLocalPolytopeFactorConstraintCacheFactorLPVariableIDs_ does not have to be updated.

Definition at line 248 of file lp_inference_base.hxx.

template<class LP_INFERENCE_TYPE>
opengm::LPInferenceBase< LP_INFERENCE_TYPE >::constValue_
protected

Constant value offset.

Definition at line 226 of file lp_inference_base.hxx.

template<class LP_INFERENCE_TYPE>
opengm::LPInferenceBase< LP_INFERENCE_TYPE >::factorsLPVariablesOffset_
protected

The offsets for the indices of the lp variables for each factor of the graphical model.

Definition at line 241 of file lp_inference_base.hxx.

template<class LP_INFERENCE_TYPE>
opengm::LPInferenceBase< LP_INFERENCE_TYPE >::gm_
protected

Reference to the graphical model.

Definition at line 224 of file lp_inference_base.hxx.

template<class LP_INFERENCE_TYPE>
opengm::LPInferenceBase< LP_INFERENCE_TYPE >::higherOrderFactors_
protected

List of all higher order factors.

Definition at line 228 of file lp_inference_base.hxx.

template<class LP_INFERENCE_TYPE>
opengm::LPInferenceBase< LP_INFERENCE_TYPE >::inactiveConstraints_
protected

Storage for all linear constraints representing the local polytope constraints. They are generated and stored for later use if LPInferenceBase::Parameter::LoosePolytope is selected as relaxation method. The constraints are removed from this list when they are added to the LP/MIP model.

Definition at line 250 of file lp_inference_base.hxx.

template<class LP_INFERENCE_TYPE>
opengm::LPInferenceBase< LP_INFERENCE_TYPE >::inferenceStarted_
protected

Tell if inference was already started.

Definition at line 231 of file lp_inference_base.hxx.

template<class LP_INFERENCE_TYPE>
opengm::LPInferenceBase< LP_INFERENCE_TYPE >::linearConstraintFactors_
protected

List of all linear constraint factors.

Definition at line 229 of file lp_inference_base.hxx.

template<class LP_INFERENCE_TYPE>
opengm::LPInferenceBase< LP_INFERENCE_TYPE >::linearConstraintLPVariablesSubsequenceIndices_
protected

The indices of the subset of the solution variables which are relevant for each linear constraint.

Definition at line 245 of file lp_inference_base.hxx.

template<class LP_INFERENCE_TYPE>
opengm::LPInferenceBase< LP_INFERENCE_TYPE >::linearConstraintsLPVariablesIndicesLookupTable_
protected

Lookup table for the lp variable indices of each linear constraint.

Definition at line 243 of file lp_inference_base.hxx.

template<class LP_INFERENCE_TYPE>
opengm::LPInferenceBase< LP_INFERENCE_TYPE >::nodesLPVariablesOffset_
protected

The offsets for the indices of the lp variables for each node of the graphical model.

Definition at line 240 of file lp_inference_base.hxx.

template<class LP_INFERENCE_TYPE>
opengm::LPInferenceBase< LP_INFERENCE_TYPE >::numFactorsLPVariables_
protected

The number of lp variables for the factors of the graphical model.

Definition at line 234 of file lp_inference_base.hxx.

template<class LP_INFERENCE_TYPE>
opengm::LPInferenceBase< LP_INFERENCE_TYPE >::numLinearConstraintsLPVariables_
protected

The number of lp variables for the linear constraint factors of the graphical model.

Definition at line 235 of file lp_inference_base.hxx.

template<class LP_INFERENCE_TYPE>
opengm::LPInferenceBase< LP_INFERENCE_TYPE >::numLPVariables_
protected

The total number of lp variables except slack variables.

Definition at line 232 of file lp_inference_base.hxx.

template<class LP_INFERENCE_TYPE>
opengm::LPInferenceBase< LP_INFERENCE_TYPE >::numNodesLPVariables_
protected

The number of lp variables for the nodes of the graphical model.

Definition at line 233 of file lp_inference_base.hxx.

template<class LP_INFERENCE_TYPE>
opengm::LPInferenceBase< LP_INFERENCE_TYPE >::numSlackVariables_
protected

The number of slack variables for the transferable factors of the graphical model.

Definition at line 237 of file lp_inference_base.hxx.

template<class LP_INFERENCE_TYPE>
opengm::LPInferenceBase< LP_INFERENCE_TYPE >::numTransferedFactorsLPVariables
protected

The number of lp variables for the transferable factors of the graphical model.

Definition at line 236 of file lp_inference_base.hxx.

template<class LP_INFERENCE_TYPE>
opengm::LPInferenceBase< LP_INFERENCE_TYPE >::OPENGM_GM_TYPE_TYPEDEFS

Definition at line 37 of file lp_inference_base.hxx.

template<class LP_INFERENCE_TYPE>
opengm::LPInferenceBase< LP_INFERENCE_TYPE >::parameter_
protected

Parameter which stores the settings for the inference.

Definition at line 225 of file lp_inference_base.hxx.

template<class LP_INFERENCE_TYPE>
opengm::LPInferenceBase< LP_INFERENCE_TYPE >::transferableFactors_
protected

List of all transferable factors.

Definition at line 230 of file lp_inference_base.hxx.

template<class LP_INFERENCE_TYPE>
opengm::LPInferenceBase< LP_INFERENCE_TYPE >::transferedFactorsLPVariablesIndicesLookupTable_
protected

Lookup table for the lp variable indices of each transferable factor.

Definition at line 244 of file lp_inference_base.hxx.

template<class LP_INFERENCE_TYPE>
opengm::LPInferenceBase< LP_INFERENCE_TYPE >::unaryFactors_
protected

List of all unary factors.

Definition at line 227 of file lp_inference_base.hxx.