OpenGM  2.3.x
Discrete Graphical Model Library
Public Types | Public Member Functions | Protected Attributes | Friends | List of all members
opengm::IndicatorVariable< INDEX_TYPE, LABEL_TYPE > Class Template Reference

Combine a group of variables to a new variable. More...

#include <indicator_variable.hxx>

+ Collaboration diagram for opengm::IndicatorVariable< INDEX_TYPE, LABEL_TYPE >:

Public Types

enum  LogicalOperatorType { And, Or, Not }
 This enum defines the logical operator types which are supported by the indicator variables. More...
 
typedef INDEX_TYPE IndexType
 Typedef of the INDEX_TYPE template parameter type from the class IndicatorVariable. More...
 
typedef LABEL_TYPE LabelType
 Typedef of the LABEL_TYPE template parameter type from the class IndicatorVariable. More...
 
typedef std::pair< IndexType, LabelTypeVariableLabelPair
 A pair representing a single state of a variable. More...
 
typedef std::vector< VariableLabelPairVariableLabelPairContainerType
 A vector containing VariableLabelPair elements. More...
 
typedef VariableLabelPairContainerType::const_iterator IteratorType
 A const iterator to iterate over the VariableLabelPair elements. More...
 

Public Member Functions

 IndicatorVariable ()
 IndicatorVariable constructor. More...
 
 IndicatorVariable (const IndexType variable, const LabelType label, const LogicalOperatorType logicalOperatorType=And)
 IndicatorVariable constructor. More...
 
 IndicatorVariable (const VariableLabelPair &variableLabelPair, const LogicalOperatorType logicalOperatorType=And)
 IndicatorVariable constructor. More...
 
 IndicatorVariable (const VariableLabelPairContainerType &variableLabelPairs, const LogicalOperatorType logicalOperatorType=And)
 
template<class ITERATOR_TYPE >
 IndicatorVariable (const ITERATOR_TYPE variableLabelPairsBegin, const ITERATOR_TYPE variableLabelPairsEnd, const LogicalOperatorType logicalOperatorType=And)
 IndicatorVariable constructor. More...
 
void reserve (const size_t numPairs)
 Preallocate memory. More...
 
void add (const IndexType variable, const LabelType label)
 Add a variable label pair to the indicator variable. More...
 
void add (const VariableLabelPair &variableLabelPair)
 Add a variable label pair to the indicator variable. More...
 
void add (const VariableLabelPairContainerType &variableLabelPairs)
 Add a sequence of variable label pairs to the indicator variable. More...
 
template<class ITERATOR_TYPE >
void add (const ITERATOR_TYPE variableLabelPairsBegin, const ITERATOR_TYPE variableLabelPairsEnd)
 Add a sequence of variable label pairs to the indicator variable. More...
 
void setLogicalOperatorType (const LogicalOperatorType logicalOperatorType)
 Set the logical operator type of the indicator variable. More...
 
template<class ITERATOR_TYPE >
bool operator() (const ITERATOR_TYPE statesBegin) const
 Evaluation operator to check if the indicator variable is active for the given labeling. More...
 
IteratorType begin () const
 Get the iterator over the sequence of variable label pairs from the indicator variable. More...
 
IteratorType end () const
 Get the end iterator of the sequence of variable label pairs from the indicator variable. More...
 
LogicalOperatorType getLogicalOperatorType () const
 Get the logical operator type of the indicator variable. More...
 

Protected Attributes

VariableLabelPairContainerType variableLabelPairs_
 Storage for the variable label pairs. More...
 
LogicalOperatorType logicalOperatorType_
 Storage for the logical operator type of the indicator variable. More...
 

Friends

template<class INDEX1_TYPE , class LABEL1_TYPE , class INDEX2_TYPE , class LABEL2_TYPE >
bool operator== (const IndicatorVariable< INDEX1_TYPE, LABEL1_TYPE > &indicatorVar1, const IndicatorVariable< INDEX2_TYPE, LABEL2_TYPE > &indicatorVar2)
 Equality operator for IndicatorVariable. More...
 
template<class INDEX1_TYPE , class LABEL1_TYPE , class INDEX2_TYPE , class LABEL2_TYPE >
bool operator!= (const IndicatorVariable< INDEX1_TYPE, LABEL1_TYPE > &indicatorVar1, const IndicatorVariable< INDEX2_TYPE, LABEL2_TYPE > &indicatorVar2)
 Inequality operator for IndicatorVariable. More...
 
template<class INDEX1_TYPE , class LABEL1_TYPE , class INDEX2_TYPE , class LABEL2_TYPE >
bool operator< (const IndicatorVariable< INDEX1_TYPE, LABEL1_TYPE > &indicatorVar1, const IndicatorVariable< INDEX2_TYPE, LABEL2_TYPE > &indicatorVar2)
 Less operator for IndicatorVariable. More...
 
template<class INDEX1_TYPE , class LABEL1_TYPE , class INDEX2_TYPE , class LABEL2_TYPE >
bool operator> (const IndicatorVariable< INDEX1_TYPE, LABEL1_TYPE > &indicatorVar1, const IndicatorVariable< INDEX2_TYPE, LABEL2_TYPE > &indicatorVar2)
 Greater operator for IndicatorVariable. More...
 
template<class INDEX1_TYPE , class LABEL1_TYPE , class INDEX2_TYPE , class LABEL2_TYPE >
bool operator<= (const IndicatorVariable< INDEX1_TYPE, LABEL1_TYPE > &indicatorVar1, const IndicatorVariable< INDEX2_TYPE, LABEL2_TYPE > &indicatorVar2)
 Less equal operator for IndicatorVariable. More...
 
template<class INDEX1_TYPE , class LABEL1_TYPE , class INDEX2_TYPE , class LABEL2_TYPE >
bool operator>= (const IndicatorVariable< INDEX1_TYPE, LABEL1_TYPE > &indicatorVar1, const IndicatorVariable< INDEX2_TYPE, LABEL2_TYPE > &indicatorVar2)
 Greater equal operator for IndicatorVariable. More...
 

Detailed Description

template<class INDEX_TYPE = size_t, class LABEL_TYPE = size_t>
class opengm::IndicatorVariable< INDEX_TYPE, LABEL_TYPE >

Combine a group of variables to a new variable.

An indicator variable defines a new boolean variable from a set of variable label pairs. Depending on the selected logical operator type an indicator variable will be interpreted as 1 if all (logical and), at least one (logical or) or none (logical not) of the variables take the labels stated by the variable label pairs.

Template Parameters
INDEX_TYPEIndex type.
LABEL_TYPELabel type.
Note
The set of variable label pairs will be stored in an ordered sequence. This means a variable label pair will come in the sequence before all other variable label pairs whose variable index is greater. And if two variable label pairs have the same variable index the one with the smaller label will come first.

Definition at line 14 of file indicator_variable.hxx.

Member Typedef Documentation

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

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

Definition at line 17 of file indicator_variable.hxx.

template<class INDEX_TYPE = size_t, class LABEL_TYPE = size_t>
opengm::IndicatorVariable< INDEX_TYPE, LABEL_TYPE >::IteratorType

A const iterator to iterate over the VariableLabelPair elements.

Definition at line 25 of file indicator_variable.hxx.

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

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

Definition at line 18 of file indicator_variable.hxx.

template<class INDEX_TYPE = size_t, class LABEL_TYPE = size_t>
opengm::IndicatorVariable< INDEX_TYPE, LABEL_TYPE >::VariableLabelPair

A pair representing a single state of a variable.

Definition at line 22 of file indicator_variable.hxx.

template<class INDEX_TYPE = size_t, class LABEL_TYPE = size_t>
opengm::IndicatorVariable< INDEX_TYPE, LABEL_TYPE >::VariableLabelPairContainerType

A vector containing VariableLabelPair elements.

Definition at line 23 of file indicator_variable.hxx.

Member Enumeration Documentation

template<class INDEX_TYPE = size_t, class LABEL_TYPE = size_t>
enum opengm::IndicatorVariable::LogicalOperatorType

This enum defines the logical operator types which are supported by the indicator variables.

Enumerator
And 

The indicator variable will be interpreted as 1 if all variables associated by the indicator variable take the labels stated by the variable label pairs of the indicator variable. Otherwise it will be interpreted as 0.

Or 

The indicator variable will be interpreted as 1 if at least one of the variables associated by the indicator variable takes the label stated by the variable label pairs of the indicator variable. Otherwise it will be interpreted as 0.

Not 

The indicator variable will be interpreted as 1 if none of the variables associated by the indicator variable takes the label stated by the variable label pairs of the indicator variable. Otherwise it will be interpreted as 0.

Definition at line 20 of file indicator_variable.hxx.

Constructor & Destructor Documentation

template<class INDEX_TYPE , class LABEL_TYPE >
opengm::IndicatorVariable< INDEX_TYPE, LABEL_TYPE >::IndicatorVariable ( )
inline

IndicatorVariable constructor.

This constructor will create an empty IndicatorVariable.

Definition at line 435 of file indicator_variable.hxx.

template<class INDEX_TYPE , class LABEL_TYPE >
opengm::IndicatorVariable< INDEX_TYPE, LABEL_TYPE >::IndicatorVariable ( const IndexType  variable,
const LabelType  label,
const LogicalOperatorType  logicalOperatorType = And 
)
inline

IndicatorVariable constructor.

This constructor will create an IndicatorVariable containing just one variable label pair.

Parameters
[in]variableIndex of the variable.
[in]labelLabel of the variable.
[in]logicalOperatorTypeThe logical operator type by which the indicator variable is evaluated.

Definition at line 441 of file indicator_variable.hxx.

template<class INDEX_TYPE , class LABEL_TYPE >
opengm::IndicatorVariable< INDEX_TYPE, LABEL_TYPE >::IndicatorVariable ( const VariableLabelPair variableLabelPair,
const LogicalOperatorType  logicalOperatorType = And 
)
inline

IndicatorVariable constructor.

This constructor will create an IndicatorVariable containing just one variable label pair.

Parameters
[in]variableLabelPairA pair containing index and label of a variable.
[in]logicalOperatorTypeThe logical operator type by which the indicator variable is evaluated.

Definition at line 448 of file indicator_variable.hxx.

template<class INDEX_TYPE , class LABEL_TYPE >
opengm::IndicatorVariable< INDEX_TYPE, LABEL_TYPE >::IndicatorVariable ( const VariableLabelPairContainerType variableLabelPairs,
const LogicalOperatorType  logicalOperatorType = And 
)
inline

Definition at line 455 of file indicator_variable.hxx.

template<class INDEX_TYPE , class LABEL_TYPE >
template<class ITERATOR_TYPE >
opengm::IndicatorVariable< INDEX_TYPE, LABEL_TYPE >::IndicatorVariable ( const ITERATOR_TYPE  variableLabelPairsBegin,
const ITERATOR_TYPE  variableLabelPairsEnd,
const LogicalOperatorType  logicalOperatorType = And 
)
inline

IndicatorVariable constructor.

This constructor will create an IndicatorVariable by copying variable label pairs.

Template Parameters
ITERATOR_TYPEIterator type.
Parameters
[in]variableLabelPairsBeginIterator pointing to the begin of a sequence of variable label pairs.
[in]variableLabelPairsEndIterator pointing to the end of a sequence of variable label pairs.
[in]logicalOperatorTypeThe logical operator type by which the indicator variable is evaluated.

Definition at line 463 of file indicator_variable.hxx.

Member Function Documentation

template<class INDEX_TYPE , class LABEL_TYPE >
void opengm::IndicatorVariable< INDEX_TYPE, LABEL_TYPE >::add ( const IndexType  variable,
const LabelType  label 
)
inline

Add a variable label pair to the indicator variable.

Parameters
[in]variableIndex of the variable.
[in]labelLabel of the variable.

Definition at line 476 of file indicator_variable.hxx.

+ Here is the caller graph for this function:

template<class INDEX_TYPE , class LABEL_TYPE >
void opengm::IndicatorVariable< INDEX_TYPE, LABEL_TYPE >::add ( const VariableLabelPair variableLabelPair)
inline

Add a variable label pair to the indicator variable.

Parameters
[in]variableLabelPairA pair containing index and label of a variable.

Definition at line 482 of file indicator_variable.hxx.

template<class INDEX_TYPE , class LABEL_TYPE >
void opengm::IndicatorVariable< INDEX_TYPE, LABEL_TYPE >::add ( const VariableLabelPairContainerType indicatorVariable)
inline

Add a sequence of variable label pairs to the indicator variable.

Parameters
[in]indicatorVariableA vector of VariableLabelPair elements which define an IndicatorVariable.

Definition at line 488 of file indicator_variable.hxx.

template<class INDEX_TYPE , class LABEL_TYPE >
template<class ITERATOR_TYPE >
void opengm::IndicatorVariable< INDEX_TYPE, LABEL_TYPE >::add ( const ITERATOR_TYPE  variableLabelPairsBegin,
const ITERATOR_TYPE  variableLabelPairsEnd 
)
inline

Add a sequence of variable label pairs to the indicator variable.

Template Parameters
ITERATOR_TYPEIterator type.
Parameters
[in]variableLabelPairsBeginIterator pointing to the begin of a sequence of variable label pairs.
[in]variableLabelPairsEndIterator pointing to the end of a sequence of variable label pairs.

Definition at line 495 of file indicator_variable.hxx.

template<class INDEX_TYPE , class LABEL_TYPE >
IndicatorVariable< INDEX_TYPE, LABEL_TYPE >::IteratorType opengm::IndicatorVariable< INDEX_TYPE, LABEL_TYPE >::begin ( ) const
inline

Get the iterator over the sequence of variable label pairs from the indicator variable.

Returns
Returns a const iterator to the begin of the sequence of variable label pairs from the indicator variable.

Definition at line 539 of file indicator_variable.hxx.

+ Here is the caller graph for this function:

template<class INDEX_TYPE , class LABEL_TYPE >
IndicatorVariable< INDEX_TYPE, LABEL_TYPE >::IteratorType opengm::IndicatorVariable< INDEX_TYPE, LABEL_TYPE >::end ( ) const
inline

Get the end iterator of the sequence of variable label pairs from the indicator variable.

Returns
Returns a const iterator to the end of the sequence of variable label pairs from the indicator variable.

Definition at line 544 of file indicator_variable.hxx.

+ Here is the caller graph for this function:

template<class INDEX_TYPE , class LABEL_TYPE >
IndicatorVariable< INDEX_TYPE, LABEL_TYPE >::LogicalOperatorType opengm::IndicatorVariable< INDEX_TYPE, LABEL_TYPE >::getLogicalOperatorType ( ) const
inline

Get the logical operator type of the indicator variable.

Returns
The current logical operator type of the indicator variable.

Definition at line 549 of file indicator_variable.hxx.

+ Here is the caller graph for this function:

template<class INDEX_TYPE , class LABEL_TYPE >
template<class ITERATOR_TYPE >
bool opengm::IndicatorVariable< INDEX_TYPE, LABEL_TYPE >::operator() ( const ITERATOR_TYPE  statesBegin) const
inline

Evaluation operator to check if the indicator variable is active for the given labeling.

Template Parameters
ITERATOR_TYPEIterator type.
Parameters
[in]statesBeginIterator pointing to the begin of the labeling.
Returns
True if the indicator variable is active for the given labeling, false otherwise.
Warning
No boundary check is performed.

Definition at line 508 of file indicator_variable.hxx.

template<class INDEX_TYPE , class LABEL_TYPE >
void opengm::IndicatorVariable< INDEX_TYPE, LABEL_TYPE >::reserve ( const size_t  numPairs)
inline

Preallocate memory.

The reserve function fill preallocate enough memory to store at least the stated number of variable label pairs.

Parameters
[in]numPairsThe number of variable label pairs for which memory will be allocated.

Definition at line 471 of file indicator_variable.hxx.

template<class INDEX_TYPE , class LABEL_TYPE >
void opengm::IndicatorVariable< INDEX_TYPE, LABEL_TYPE >::setLogicalOperatorType ( const LogicalOperatorType  logicalOperatorType)
inline

Set the logical operator type of the indicator variable.

Parameters
[in]logicalOperatorTypeThe new logical operator type.

Definition at line 501 of file indicator_variable.hxx.

+ Here is the caller graph for this function:

Friends And Related Function Documentation

template<class INDEX_TYPE = size_t, class LABEL_TYPE = size_t>
template<class INDEX1_TYPE , class LABEL1_TYPE , class INDEX2_TYPE , class LABEL2_TYPE >
bool opengm::IndicatorVariable< INDEX_TYPE, LABEL_TYPE >::operator!= ( const IndicatorVariable< INDEX1_TYPE, LABEL1_TYPE > &  indicatorVar1,
const IndicatorVariable< INDEX2_TYPE, LABEL2_TYPE > &  indicatorVar2 
)
friend

Inequality operator for IndicatorVariable.

Template Parameters
INDEX1_TYPEIndex type of the first indicator variable.
LABEL1_TYPELabel type of the first indicator variable.
INDEX2_TYPEIndex type of the second indicator variable.
LABEL2_TYPELabel type of the second indicator variable.
Parameters
[in]indicatorVar1First indicator variable.
[in]indicatorVar2Second indicator variable.
Returns
Returns true if two IndicatorVariables are different. False otherwise.

Definition at line 559 of file indicator_variable.hxx.

template<class INDEX_TYPE = size_t, class LABEL_TYPE = size_t>
template<class INDEX1_TYPE , class LABEL1_TYPE , class INDEX2_TYPE , class LABEL2_TYPE >
bool opengm::IndicatorVariable< INDEX_TYPE, LABEL_TYPE >::operator< ( const IndicatorVariable< INDEX1_TYPE, LABEL1_TYPE > &  indicatorVar1,
const IndicatorVariable< INDEX2_TYPE, LABEL2_TYPE > &  indicatorVar2 
)
friend

Less operator for IndicatorVariable.

Template Parameters
INDEX1_TYPEIndex type of the first indicator variable.
LABEL1_TYPELabel type of the first indicator variable.
INDEX2_TYPEIndex type of the second indicator variable.
LABEL2_TYPELabel type of the second indicator variable.
Parameters
[in]indicatorVar1First indicator variable.
[in]indicatorVar2Second indicator variable.
Returns
Returns true if an IndicatorVariables is smaller than an other one. False otherwise.
Note
Indicator variables will be ordered first by the logical operator type (And < Or < Not), then by the number of variable label pairs. If both the logical operator type and the number of variable label pairs are equal the first variable label pairs which are different in the first and the second indicator variable will be used for comparison.

Definition at line 564 of file indicator_variable.hxx.

template<class INDEX_TYPE = size_t, class LABEL_TYPE = size_t>
template<class INDEX1_TYPE , class LABEL1_TYPE , class INDEX2_TYPE , class LABEL2_TYPE >
bool opengm::IndicatorVariable< INDEX_TYPE, LABEL_TYPE >::operator<= ( const IndicatorVariable< INDEX1_TYPE, LABEL1_TYPE > &  indicatorVar1,
const IndicatorVariable< INDEX2_TYPE, LABEL2_TYPE > &  indicatorVar2 
)
friend

Less equal operator for IndicatorVariable.

Template Parameters
INDEX1_TYPEIndex type of the first indicator variable.
LABEL1_TYPELabel type of the first indicator variable.
INDEX2_TYPEIndex type of the second indicator variable.
LABEL2_TYPELabel type of the second indicator variable.
Parameters
[in]indicatorVar1First indicator variable.
[in]indicatorVar2Second indicator variable.
Returns
Returns true if an IndicatorVariables is smaller than or equal to an other one. False otherwise.
Note
Indicator variables will be ordered first by the logical operator type (And < Or < Not), then by the number of variable label pairs. If both the logical operator type and the number of variable label pairs are equal the first variable label pairs which are different in the first and the second indicator variable will be used for comparison.

Definition at line 620 of file indicator_variable.hxx.

template<class INDEX_TYPE = size_t, class LABEL_TYPE = size_t>
template<class INDEX1_TYPE , class LABEL1_TYPE , class INDEX2_TYPE , class LABEL2_TYPE >
bool opengm::IndicatorVariable< INDEX_TYPE, LABEL_TYPE >::operator== ( const IndicatorVariable< INDEX1_TYPE, LABEL1_TYPE > &  indicatorVar1,
const IndicatorVariable< INDEX2_TYPE, LABEL2_TYPE > &  indicatorVar2 
)
friend

Equality operator for IndicatorVariable.

Template Parameters
INDEX1_TYPEIndex type of the first indicator variable.
LABEL1_TYPELabel type of the first indicator variable.
INDEX2_TYPEIndex type of the second indicator variable.
LABEL2_TYPELabel type of the second indicator variable.
Parameters
[in]indicatorVar1First indicator variable.
[in]indicatorVar2Second indicator variable.
Returns
Returns true if two IndicatorVariables are equal. False otherwise.

Definition at line 554 of file indicator_variable.hxx.

template<class INDEX_TYPE = size_t, class LABEL_TYPE = size_t>
template<class INDEX1_TYPE , class LABEL1_TYPE , class INDEX2_TYPE , class LABEL2_TYPE >
bool opengm::IndicatorVariable< INDEX_TYPE, LABEL_TYPE >::operator> ( const IndicatorVariable< INDEX1_TYPE, LABEL1_TYPE > &  indicatorVar1,
const IndicatorVariable< INDEX2_TYPE, LABEL2_TYPE > &  indicatorVar2 
)
friend

Greater operator for IndicatorVariable.

Template Parameters
INDEX1_TYPEIndex type of the first indicator variable.
LABEL1_TYPELabel type of the first indicator variable.
INDEX2_TYPEIndex type of the second indicator variable.
LABEL2_TYPELabel type of the second indicator variable.
Parameters
[in]indicatorVar1First indicator variable.
[in]indicatorVar2Second indicator variable.
Returns
Returns true if an IndicatorVariables is greater than an other one. False otherwise.
Note
Indicator variables will be ordered first by the logical operator type (And < Or < Not), then by the number of variable label pairs. If both the logical operator type and the number of variable label pairs are equal the first variable label pairs which are different in the first and the second indicator variable will be used for comparison.

Definition at line 592 of file indicator_variable.hxx.

template<class INDEX_TYPE = size_t, class LABEL_TYPE = size_t>
template<class INDEX1_TYPE , class LABEL1_TYPE , class INDEX2_TYPE , class LABEL2_TYPE >
bool opengm::IndicatorVariable< INDEX_TYPE, LABEL_TYPE >::operator>= ( const IndicatorVariable< INDEX1_TYPE, LABEL1_TYPE > &  indicatorVar1,
const IndicatorVariable< INDEX2_TYPE, LABEL2_TYPE > &  indicatorVar2 
)
friend

Greater equal operator for IndicatorVariable.

Template Parameters
INDEX1_TYPEIndex type of the first indicator variable.
LABEL1_TYPELabel type of the first indicator variable.
INDEX2_TYPEIndex type of the second indicator variable.
LABEL2_TYPELabel type of the second indicator variable.
Parameters
[in]indicatorVar1First indicator variable.
[in]indicatorVar2Second indicator variable.
Returns
Returns true if an IndicatorVariables is greater than or equal to an other one. False otherwise.
Note
Indicator variables will be ordered first by the logical operator type (And < Or < Not), then by the number of variable label pairs. If both the logical operator type and the number of variable label pairs are equal the first variable label pairs which are different in the first and the second indicator variable will be used for comparison.

Definition at line 645 of file indicator_variable.hxx.

Member Data Documentation

template<class INDEX_TYPE = size_t, class LABEL_TYPE = size_t>
opengm::IndicatorVariable< INDEX_TYPE, LABEL_TYPE >::logicalOperatorType_
protected

Storage for the logical operator type of the indicator variable.

Definition at line 55 of file indicator_variable.hxx.

template<class INDEX_TYPE = size_t, class LABEL_TYPE = size_t>
opengm::IndicatorVariable< INDEX_TYPE, LABEL_TYPE >::variableLabelPairs_
protected

Storage for the variable label pairs.

Definition at line 54 of file indicator_variable.hxx.