1 #ifndef OPENGM_INDICATOR_VARIABLE_HXX_ 2 #define OPENGM_INDICATOR_VARIABLE_HXX_ 13 template <
class INDEX_TYPE =
size_t,
class LABEL_TYPE =
size_t>
25 typedef typename VariableLabelPairContainerType::const_iterator
IteratorType;
32 template<
class ITERATOR_TYPE>
36 void reserve(
const size_t numPairs);
37 void add(
const IndexType variable,
const LabelType label);
38 void add(
const VariableLabelPair& variableLabelPair);
39 void add(
const VariableLabelPairContainerType& variableLabelPairs);
40 template<
class ITERATOR_TYPE>
41 void add(
const ITERATOR_TYPE variableLabelPairsBegin,
const ITERATOR_TYPE variableLabelPairsEnd);
45 template<
class ITERATOR_TYPE>
46 bool operator()(
const ITERATOR_TYPE statesBegin)
const;
49 IteratorType
begin()
const;
50 IteratorType
end()
const;
58 template<
class INDEX1_TYPE,
class LABEL1_TYPE,
class INDEX2_TYPE,
class LABEL2_TYPE>
60 template<
class INDEX1_TYPE,
class LABEL1_TYPE,
class INDEX2_TYPE,
class LABEL2_TYPE>
62 template<
class INDEX1_TYPE,
class LABEL1_TYPE,
class INDEX2_TYPE,
class LABEL2_TYPE>
64 template<
class INDEX1_TYPE,
class LABEL1_TYPE,
class INDEX2_TYPE,
class LABEL2_TYPE>
66 template<
class INDEX1_TYPE,
class LABEL1_TYPE,
class INDEX2_TYPE,
class LABEL2_TYPE>
68 template<
class INDEX1_TYPE,
class LABEL1_TYPE,
class INDEX2_TYPE,
class LABEL2_TYPE>
73 template<
class INDEX1_TYPE,
class LABEL1_TYPE,
class INDEX2_TYPE,
class LABEL2_TYPE>
76 template<
class INDEX1_TYPE,
class LABEL1_TYPE,
class INDEX2_TYPE,
class LABEL2_TYPE>
79 template<
class INDEX1_TYPE,
class LABEL1_TYPE,
class INDEX2_TYPE,
class LABEL2_TYPE>
82 template<
class INDEX1_TYPE,
class LABEL1_TYPE,
class INDEX2_TYPE,
class LABEL2_TYPE>
85 template<
class INDEX1_TYPE,
class LABEL1_TYPE,
class INDEX2_TYPE,
class LABEL2_TYPE>
88 template<
class INDEX1_TYPE,
class LABEL1_TYPE,
class INDEX2_TYPE,
class LABEL2_TYPE>
434 template <
class INDEX_TYPE,
class LABEL_TYPE>
440 template <
class INDEX_TYPE,
class LABEL_TYPE>
447 template <
class INDEX_TYPE,
class LABEL_TYPE>
454 template <
class INDEX_TYPE,
class LABEL_TYPE>
461 template <
class INDEX_TYPE,
class LABEL_TYPE>
462 template<
class ITERATOR_TYPE>
470 template <
class INDEX_TYPE,
class LABEL_TYPE>
475 template <
class INDEX_TYPE,
class LABEL_TYPE>
481 template <
class INDEX_TYPE,
class LABEL_TYPE>
487 template <
class INDEX_TYPE,
class LABEL_TYPE>
493 template <
class INDEX_TYPE,
class LABEL_TYPE>
494 template<
class ITERATOR_TYPE>
500 template <
class INDEX_TYPE,
class LABEL_TYPE>
506 template <
class INDEX_TYPE,
class LABEL_TYPE>
507 template<
class ITERATOR_TYPE>
511 for(
IteratorType indicatorVariableIter =
begin(); indicatorVariableIter !=
end(); ++indicatorVariableIter) {
512 if(indicatorVariableIter->second != statesBegin[indicatorVariableIter->first]) {
519 for(
IteratorType indicatorVariableIter =
begin(); indicatorVariableIter !=
end(); ++indicatorVariableIter) {
520 if(indicatorVariableIter->second == statesBegin[indicatorVariableIter->first]) {
527 for(
IteratorType indicatorVariableIter =
begin(); indicatorVariableIter !=
end(); ++indicatorVariableIter) {
528 if(indicatorVariableIter->second == statesBegin[indicatorVariableIter->first]) {
538 template <
class INDEX_TYPE,
class LABEL_TYPE>
543 template <
class INDEX_TYPE,
class LABEL_TYPE>
548 template <
class INDEX_TYPE,
class LABEL_TYPE>
553 template<
class INDEX1_TYPE,
class LABEL1_TYPE,
class INDEX2_TYPE,
class LABEL2_TYPE>
558 template<
class INDEX1_TYPE,
class LABEL1_TYPE,
class INDEX2_TYPE,
class LABEL2_TYPE>
563 template<
class INDEX1_TYPE,
class LABEL1_TYPE,
class INDEX2_TYPE,
class LABEL2_TYPE>
565 if(indicatorVar1.logicalOperatorType_ < indicatorVar2.logicalOperatorType_) {
567 }
else if(indicatorVar1.logicalOperatorType_ > indicatorVar2.logicalOperatorType_) {
570 if(indicatorVar1.variableLabelPairs_.size() > indicatorVar2.variableLabelPairs_.size()) {
573 if(indicatorVar1.variableLabelPairs_.size() == indicatorVar2.variableLabelPairs_.size()) {
574 if(indicatorVar1.variableLabelPairs_.size() == 0) {
577 for(
size_t i = 0; i < indicatorVar1.variableLabelPairs_.size(); ++i) {
578 if(indicatorVar1.variableLabelPairs_[i].first > indicatorVar2.variableLabelPairs_[i].first) {
580 }
else if(indicatorVar1.variableLabelPairs_[i].first == indicatorVar2.variableLabelPairs_[i].first) {
581 if(indicatorVar1.variableLabelPairs_[i].second >= indicatorVar2.variableLabelPairs_[i].second) {
591 template<
class INDEX1_TYPE,
class LABEL1_TYPE,
class INDEX2_TYPE,
class LABEL2_TYPE>
619 template<
class INDEX1_TYPE,
class LABEL1_TYPE,
class INDEX2_TYPE,
class LABEL2_TYPE>
621 if(indicatorVar1.logicalOperatorType_ < indicatorVar2.logicalOperatorType_) {
623 }
else if(indicatorVar1.logicalOperatorType_ > indicatorVar2.logicalOperatorType_) {
626 if(indicatorVar1.variableLabelPairs_.size() > indicatorVar2.variableLabelPairs_.size()) {
629 if(indicatorVar1.variableLabelPairs_.size() == indicatorVar2.variableLabelPairs_.size()) {
630 for(
size_t i = 0; i < indicatorVar1.variableLabelPairs_.size(); ++i) {
631 if(indicatorVar1.variableLabelPairs_[i].first > indicatorVar2.variableLabelPairs_[i].first) {
633 }
else if(indicatorVar1.variableLabelPairs_[i].first == indicatorVar2.variableLabelPairs_[i].first) {
634 if(indicatorVar1.variableLabelPairs_[i].second > indicatorVar2.variableLabelPairs_[i].second) {
644 template<
class INDEX1_TYPE,
class LABEL1_TYPE,
class INDEX2_TYPE,
class LABEL2_TYPE>
friend bool operator!=(const IndicatorVariable< INDEX1_TYPE, LABEL1_TYPE > &indicatorVar1, const IndicatorVariable< INDEX2_TYPE, LABEL2_TYPE > &indicatorVar2)
Inequality operator for IndicatorVariable.
friend bool operator>=(const IndicatorVariable< INDEX1_TYPE, LABEL1_TYPE > &indicatorVar1, const IndicatorVariable< INDEX2_TYPE, LABEL2_TYPE > &indicatorVar2)
Greater equal operator for IndicatorVariable.
LABEL_TYPE LabelType
Typedef of the LABEL_TYPE template parameter type from the class IndicatorVariable.
IteratorType begin() const
Get the iterator over the sequence of variable label pairs from the indicator variable.
The indicator variable will be interpreted as 1 if none of the variables associated by the indicator ...
VariableLabelPairContainerType::const_iterator IteratorType
A const iterator to iterate over the VariableLabelPair elements.
VariableLabelPairContainerType variableLabelPairs_
Storage for the variable label pairs.
friend bool operator==(const IndicatorVariable< INDEX1_TYPE, LABEL1_TYPE > &indicatorVar1, const IndicatorVariable< INDEX2_TYPE, LABEL2_TYPE > &indicatorVar2)
Equality operator for IndicatorVariable.
std::vector< VariableLabelPair > VariableLabelPairContainerType
A vector containing VariableLabelPair elements.
IndicatorVariable()
IndicatorVariable constructor.
void setLogicalOperatorType(const LogicalOperatorType logicalOperatorType)
Set the logical operator type of the indicator variable.
friend bool operator>(const IndicatorVariable< INDEX1_TYPE, LABEL1_TYPE > &indicatorVar1, const IndicatorVariable< INDEX2_TYPE, LABEL2_TYPE > &indicatorVar2)
Greater operator for IndicatorVariable.
LogicalOperatorType getLogicalOperatorType() const
Get the logical operator type of the indicator variable.
bool operator()(const ITERATOR_TYPE statesBegin) const
Evaluation operator to check if the indicator variable is active for the given labeling.
void reserve(const size_t numPairs)
Preallocate memory.
IteratorType end() const
Get the end iterator of the sequence of variable label pairs from the indicator variable.
void add(const IndexType variable, const LabelType label)
Add a variable label pair to the indicator variable.
Combine a group of variables to a new variable.
std::pair< IndexType, LabelType > VariableLabelPair
A pair representing a single state of a variable.
LogicalOperatorType logicalOperatorType_
Storage for the logical operator type of the indicator variable.
The indicator variable will be interpreted as 1 if all variables associated by the indicator variable...
The indicator variable will be interpreted as 1 if at least one of the variables associated by the in...
LogicalOperatorType
This enum defines the logical operator types which are supported by the indicator variables...
Disjunction as a binary operation.
Conjunction as a binary operation.
INDEX_TYPE IndexType
Typedef of the INDEX_TYPE template parameter type from the class IndicatorVariable.