OpenGM  2.3.x
Discrete Graphical Model Library
Classes | Public Types | Static Public Member Functions | List of all members
opengm::LPFunctionTransfer< VALUE_TYPE, INDEX_TYPE, LABEL_TYPE > Class Template Reference

Provides transformations for some function types when they are used in inference algorithms which use linear programming. More...

#include <lp_functiontransfer.hxx>

+ Collaboration diagram for opengm::LPFunctionTransfer< VALUE_TYPE, INDEX_TYPE, LABEL_TYPE >:

Classes

struct  GetIndicatorVariablesFunctor
 Functor to call LPFunctionTransfer::getIndicatorVariables() for a factor of the graphical model. More...
 
struct  GetLinearConstraintsFunctor
 Functor to call LPFunctionTransfer::getLinearConstraints() for a factor of the graphical model. More...
 
struct  GetSlackVariablesObjectiveCoefficientsFunctor
 Functor to call LPFunctionTransfer::getSlackVariablesObjectiveCoefficients() for a factor of the graphical model. More...
 
struct  GetSlackVariablesOrderFunctor
 Functor to call LPFunctionTransfer::getSlackVariablesOrder() for a factor of the graphical model. More...
 
struct  IsTransferableFunctor
 Functor to call LPFunctionTransfer::isTransferable() for a factor of the graphical model. More...
 
struct  NumSlackVariablesFunctor
 Functor to call LPFunctionTransfer::numSlackVariables() for a graphical model factor. More...
 

Public Types

typedef VALUE_TYPE ValueType
 Typedef of the VALUE_TYPE template parameter type from the class LPFunctionTransfer. More...
 
typedef INDEX_TYPE IndexType
 Typedef of the INDEX_TYPE template parameter type from the class LPFunctionTransfer. More...
 
typedef LABEL_TYPE LabelType
 Typedef of the LABEL_TYPE template parameter type from the class LPFunctionTransfer. More...
 
typedef LinearConstraint< ValueType, IndexType, LabelTypeLinearConstraintType
 Typedef of the LinearConstraint class with appropriate template parameter. More...
 
typedef std::vector< LinearConstraintTypeLinearConstraintsContainerType
 Defines the linear constraints container type which is used to store multiple linear constraints. More...
 
typedef LinearConstraintType::IndicatorVariableType IndicatorVariableType
 Defines the indicator variable type which is used within linear constraints. More...
 
typedef std::vector< IndicatorVariableTypeIndicatorVariablesContainerType
 Defines the indicator variables container type which is used to store multiple indicator variables. More...
 
typedef std::vector< ValueTypeSlackVariablesObjectiveCoefficientsContainerType
 Defines the container type which is used to store the coefficients of the slack variables for the objective function. More...
 

Static Public Member Functions

template<class FUNCTION_TYPE >
static bool isTransferable ()
 This function will tell if the function type provided via the template parameter can be transfered into a more efficient LP formulation. More...
 
template<class FUNCTION_TYPE >
static IndexType numSlackVariables (const FUNCTION_TYPE &function)
 This function will tell the number of required slack variables for the function transfer. More...
 
template<class FUNCTION_TYPE >
static void getSlackVariablesOrder (const FUNCTION_TYPE &function, IndicatorVariablesContainerType &order)
 This function will tell the order of the slack variables which are required for the function transfer. More...
 
template<class FUNCTION_TYPE >
static void getSlackVariablesObjectiveCoefficients (const FUNCTION_TYPE &function, SlackVariablesObjectiveCoefficientsContainerType &coefficients)
 This function will tell the coefficients of the slack variables for the objective function of the linear program. More...
 
template<class FUNCTION_TYPE >
static void getIndicatorVariables (const FUNCTION_TYPE &function, IndicatorVariablesContainerType &variables)
 This function will tell all the indicator variables which are used in the linear constraints which are used for the function transfer. More...
 
template<class FUNCTION_TYPE >
static void getLinearConstraints (const FUNCTION_TYPE &function, LinearConstraintsContainerType &constraints)
 This function will create the necessary linear constraints which are used to represent the function within the LP. More...
 

Detailed Description

template<class VALUE_TYPE, class INDEX_TYPE = size_t, class LABEL_TYPE = size_t>
class opengm::LPFunctionTransfer< VALUE_TYPE, INDEX_TYPE, LABEL_TYPE >

Provides transformations for some function types when they are used in inference algorithms which use linear programming.

In inference algorithms like opengm::LPCplex which rely on opengm::LPBase the inference task is reformulated as a linear program. Therefore all factors which are not linear constraint factors are added the same way to the LP no matter what function type is used for these factors. However some function types like opengm::LabelCostFunction can be added in a more efficient formulation to the LP. This class provides an interface to transform the function behind a factor so opengm::LPBase can benefit from the more efficient representation of the factor.

Template Parameters
VALUE_TYPEValue type.
INDEX_TYPEIndex type.
LABEL_TYPELabel type.

Definition at line 15 of file lp_functiontransfer.hxx.

Member Typedef Documentation

template<class VALUE_TYPE, class INDEX_TYPE = size_t, class LABEL_TYPE = size_t>
opengm::LPFunctionTransfer< VALUE_TYPE, INDEX_TYPE, LABEL_TYPE >::IndexType

Typedef of the INDEX_TYPE template parameter type from the class LPFunctionTransfer.

Definition at line 19 of file lp_functiontransfer.hxx.

template<class VALUE_TYPE, class INDEX_TYPE = size_t, class LABEL_TYPE = size_t>
opengm::LPFunctionTransfer< VALUE_TYPE, INDEX_TYPE, LABEL_TYPE >::IndicatorVariablesContainerType

Defines the indicator variables container type which is used to store multiple indicator variables.

Definition at line 24 of file lp_functiontransfer.hxx.

template<class VALUE_TYPE, class INDEX_TYPE = size_t, class LABEL_TYPE = size_t>
opengm::LPFunctionTransfer< VALUE_TYPE, INDEX_TYPE, LABEL_TYPE >::IndicatorVariableType

Defines the indicator variable type which is used within linear constraints.

Definition at line 23 of file lp_functiontransfer.hxx.

template<class VALUE_TYPE, class INDEX_TYPE = size_t, class LABEL_TYPE = size_t>
opengm::LPFunctionTransfer< VALUE_TYPE, INDEX_TYPE, LABEL_TYPE >::LabelType

Typedef of the LABEL_TYPE template parameter type from the class LPFunctionTransfer.

Definition at line 20 of file lp_functiontransfer.hxx.

template<class VALUE_TYPE, class INDEX_TYPE = size_t, class LABEL_TYPE = size_t>
opengm::LPFunctionTransfer< VALUE_TYPE, INDEX_TYPE, LABEL_TYPE >::LinearConstraintsContainerType

Defines the linear constraints container type which is used to store multiple linear constraints.

Definition at line 22 of file lp_functiontransfer.hxx.

template<class VALUE_TYPE, class INDEX_TYPE = size_t, class LABEL_TYPE = size_t>
opengm::LPFunctionTransfer< VALUE_TYPE, INDEX_TYPE, LABEL_TYPE >::LinearConstraintType

Typedef of the LinearConstraint class with appropriate template parameter.

Definition at line 21 of file lp_functiontransfer.hxx.

template<class VALUE_TYPE, class INDEX_TYPE = size_t, class LABEL_TYPE = size_t>
opengm::LPFunctionTransfer< VALUE_TYPE, INDEX_TYPE, LABEL_TYPE >::SlackVariablesObjectiveCoefficientsContainerType

Defines the container type which is used to store the coefficients of the slack variables for the objective function.

Definition at line 25 of file lp_functiontransfer.hxx.

template<class VALUE_TYPE, class INDEX_TYPE = size_t, class LABEL_TYPE = size_t>
opengm::LPFunctionTransfer< VALUE_TYPE, INDEX_TYPE, LABEL_TYPE >::ValueType

Typedef of the VALUE_TYPE template parameter type from the class LPFunctionTransfer.

Definition at line 18 of file lp_functiontransfer.hxx.

Member Function Documentation

template<class VALUE_TYPE , class INDEX_TYPE , class LABEL_TYPE >
template<class FUNCTION_TYPE >
void opengm::LPFunctionTransfer< VALUE_TYPE, INDEX_TYPE, LABEL_TYPE >::getIndicatorVariables ( const FUNCTION_TYPE &  function,
IndicatorVariablesContainerType variables 
)
inlinestatic

This function will tell all the indicator variables which are used in the linear constraints which are used for the function transfer.

Note
This function will call LPFunctionTransfer_impl::getIndicatorVariables() which by default will throw a runtime error for a not supported function type unless a partial template specialization of the class opengm::LPFunctionTransfer_impl is provided for the FUNCTION_TYPE type.
Template Parameters
FUNCTION_TYPEThe type of the function.
Parameters
[in]functionThe function which will be transfered to the LP.
[out]variablesThis container will be filled with the indicator variables which are used in the linear constraints.

Definition at line 614 of file lp_functiontransfer.hxx.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<class VALUE_TYPE , class INDEX_TYPE , class LABEL_TYPE >
template<class FUNCTION_TYPE >
void opengm::LPFunctionTransfer< VALUE_TYPE, INDEX_TYPE, LABEL_TYPE >::getLinearConstraints ( const FUNCTION_TYPE &  function,
LinearConstraintsContainerType constraints 
)
inlinestatic

This function will create the necessary linear constraints which are used to represent the function within the LP.

Note
This function will call LPFunctionTransfer_impl::getLinearConstraints() which by default will throw a runtime error for a not supported function type unless a partial template specialization of the class opengm::LPFunctionTransfer_impl is provided for the FUNCTION_TYPE type.
Template Parameters
FUNCTION_TYPEThe type of the function.
Parameters
[in]functionThe function which will be transfered to the LP.
[out]constraintsThis container will be filled with the linear constraints which are required to add the function to the LP. Slack variables which are required for the transfer will be represented by opengm::IndicatorVariables consisting of exactly one variable-label-pair where the variable id is set to a value greater or equal to the number of variables of the function and the label is set to 0.

Definition at line 620 of file lp_functiontransfer.hxx.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<class VALUE_TYPE , class INDEX_TYPE , class LABEL_TYPE >
template<class FUNCTION_TYPE >
void opengm::LPFunctionTransfer< VALUE_TYPE, INDEX_TYPE, LABEL_TYPE >::getSlackVariablesObjectiveCoefficients ( const FUNCTION_TYPE &  function,
SlackVariablesObjectiveCoefficientsContainerType coefficients 
)
inlinestatic

This function will tell the coefficients of the slack variables for the objective function of the linear program.

Note
This function will call LPFunctionTransfer_impl::getSlackVariablesObjectiveCoefficients() which by default will throw a runtime error for a not supported function type unless a partial template specialization of the class opengm::LPFunctionTransfer_impl is provided for the FUNCTION_TYPE type.
Template Parameters
FUNCTION_TYPEThe type of the function.
Parameters
[in]functionThe function which will be transfered to the LP.
[out]coefficientsThis container will be filled with the coefficients of the slack variables for the objective function of the linear program.

Definition at line 608 of file lp_functiontransfer.hxx.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<class VALUE_TYPE , class INDEX_TYPE , class LABEL_TYPE >
template<class FUNCTION_TYPE >
void opengm::LPFunctionTransfer< VALUE_TYPE, INDEX_TYPE, LABEL_TYPE >::getSlackVariablesOrder ( const FUNCTION_TYPE &  function,
IndicatorVariablesContainerType order 
)
inlinestatic

This function will tell the order of the slack variables which are required for the function transfer.

Note
This function will call LPFunctionTransfer_impl::getSlackVariablesOrder() which by default will throw a runtime error for a not supported function type unless a partial template specialization of the class opengm::LPFunctionTransfer_impl is provided for the FUNCTION_TYPE type.
Template Parameters
FUNCTION_TYPEThe type of the function.
Parameters
[in]functionThe function which will be transfered to the LP.
[out]orderThis container will be filled with the indicator variables representing the slack variables.

Definition at line 602 of file lp_functiontransfer.hxx.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<class VALUE_TYPE , class INDEX_TYPE , class LABEL_TYPE >
template<class FUNCTION_TYPE >
bool opengm::LPFunctionTransfer< VALUE_TYPE, INDEX_TYPE, LABEL_TYPE >::isTransferable ( )
inlinestatic

This function will tell if the function type provided via the template parameter can be transfered into a more efficient LP formulation.

Note
This function will call LPFunctionTransfer_impl::isTransferable() which by default will return false unless a partial template specialization of the class opengm::LPFunctionTransfer_impl is provided for the FUNCTION_TYPE type.
Template Parameters
FUNCTION_TYPEThe type of the function.
Returns
True if the function can be transfered, false otherwise.

Definition at line 590 of file lp_functiontransfer.hxx.

+ Here is the call graph for this function:

template<class VALUE_TYPE , class INDEX_TYPE , class LABEL_TYPE >
template<class FUNCTION_TYPE >
LPFunctionTransfer< VALUE_TYPE, INDEX_TYPE, LABEL_TYPE >::IndexType opengm::LPFunctionTransfer< VALUE_TYPE, INDEX_TYPE, LABEL_TYPE >::numSlackVariables ( const FUNCTION_TYPE &  function)
inlinestatic

This function will tell the number of required slack variables for the function transfer.

Note
This function will call LPFunctionTransfer_impl::numSlackVariables() which by default will throw a runtime error for a not supported function type unless a partial template specialization of the class opengm::LPFunctionTransfer_impl is provided for the FUNCTION_TYPE type.
Template Parameters
FUNCTION_TYPEThe type of the function.
Parameters
[in]functionThe function which will be transfered to the LP.
Returns
The number of required slack variables.

Definition at line 596 of file lp_functiontransfer.hxx.

+ Here is the call graph for this function:

+ Here is the caller graph for this function: