1 #ifndef OPENGM_LINEAR_CONSTRAINT_HXX_ 2 #define OPENGM_LINEAR_CONSTRAINT_HXX_ 20 template<
class VALUE_TYPE,
class INDEX_TYPE =
size_t,
class LABEL_TYPE =
size_t>
41 LinearConstraint(
const IndicatorVariablesContainerType& indicatorVariables,
const CoefficientsContainerType& coefficients,
const BoundType bound = 0.0,
const LinearConstraintOperatorValueType constraintOperator = LinearConstraintOperatorType::LessEqual);
42 template<
class INDICATOR_VARIABLES_ITERATOR_TYPE,
class COEFFICIENTS_ITERATOR_TYPE>
43 LinearConstraint(
const INDICATOR_VARIABLES_ITERATOR_TYPE indicatorVariablesBegin,
const INDICATOR_VARIABLES_ITERATOR_TYPE indicatorVariablesEnd,
const COEFFICIENTS_ITERATOR_TYPE coefficientsBegin,
const BoundType bound = 0.0,
const LinearConstraintOperatorValueType constraintOperator = LinearConstraintOperatorType::LessEqual);
47 void reserve(
const size_t numIndicatorVariables);
48 void add(
const IndicatorVariableType& indicatorVariable,
const ValueType coefficient);
49 void add(
const IndicatorVariablesContainerType& indicatorVariables,
const CoefficientsContainerType& coefficients);
50 template<
class INDICATOR_VARIABLES_ITERATOR_TYPE,
class COEFFICIENTS_ITERATOR_TYPE>
51 void add(
const INDICATOR_VARIABLES_ITERATOR_TYPE indicatorVariablesBegin,
const INDICATOR_VARIABLES_ITERATOR_TYPE indicatorVariablesEnd,
const COEFFICIENTS_ITERATOR_TYPE coefficientsBegin);
52 void setBound(
const BoundType bound);
53 void setConstraintOperator(
const LinearConstraintOperatorValueType constraintOperator);
56 template<
class ITERATOR_TYPE>
57 ValueType operator()(
const ITERATOR_TYPE statesBegin)
const;
60 IndicatorVariablesIteratorType indicatorVariablesBegin()
const;
61 IndicatorVariablesIteratorType indicatorVariablesEnd()
const;
62 CoefficientsIteratorType coefficientsBegin()
const;
63 CoefficientsIteratorType coefficientsEnd()
const;
64 BoundType getBound()
const;
65 LinearConstraintOperatorValueType getConstraintOperator()
const;
390 template<
class VALUE_TYPE,
class INDEX_TYPE,
class LABEL_TYPE>
392 coefficients_(), bound_(0.0),
397 template<
class VALUE_TYPE,
class INDEX_TYPE,
class LABEL_TYPE>
404 template<
class VALUE_TYPE,
class INDEX_TYPE,
class LABEL_TYPE>
405 template<
class INDICATOR_VARIABLES_ITERATOR_TYPE,
class COEFFICIENTS_ITERATOR_TYPE>
408 coefficients_(coefficientsBegin, coefficientsBegin +
std::distance(indicatorVariablesBegin, indicatorVariablesEnd)),
413 template<
class VALUE_TYPE,
class INDEX_TYPE,
class LABEL_TYPE>
422 template<
class VALUE_TYPE,
class INDEX_TYPE,
class LABEL_TYPE>
428 template<
class VALUE_TYPE,
class INDEX_TYPE,
class LABEL_TYPE>
434 template<
class VALUE_TYPE,
class INDEX_TYPE,
class LABEL_TYPE>
440 template<
class VALUE_TYPE,
class INDEX_TYPE,
class LABEL_TYPE>
441 template<
class INDICATOR_VARIABLES_ITERATOR_TYPE,
class COEFFICIENTS_ITERATOR_TYPE>
447 template<
class VALUE_TYPE,
class INDEX_TYPE,
class LABEL_TYPE>
452 template<
class VALUE_TYPE,
class INDEX_TYPE,
class LABEL_TYPE>
457 template<
class VALUE_TYPE,
class INDEX_TYPE,
class LABEL_TYPE>
458 template<
class ITERATOR_TYPE>
481 }
else if(weight < 0.0) {
506 template<
class VALUE_TYPE,
class INDEX_TYPE,
class LABEL_TYPE>
511 template<
class VALUE_TYPE,
class INDEX_TYPE,
class LABEL_TYPE>
516 template<
class VALUE_TYPE,
class INDEX_TYPE,
class LABEL_TYPE>
521 template<
class VALUE_TYPE,
class INDEX_TYPE,
class LABEL_TYPE>
526 template<
class VALUE_TYPE,
class INDEX_TYPE,
class LABEL_TYPE>
531 template<
class VALUE_TYPE,
class INDEX_TYPE,
class LABEL_TYPE>
IndicatorVariablesIteratorType indicatorVariablesBegin() const
Get the begin iterator to the set of indicator variables.
CoefficientsContainerType::const_iterator CoefficientsIteratorType
Defines the const iterator type to iterate over the set of coefficients for the indicator variables...
CoefficientsIteratorType coefficientsBegin() const
Get the begin iterator to the set of coefficients for the indicator variables.
IndicatorVariablesContainerType::const_iterator IndicatorVariablesIteratorType
Defines the const iterator type to iterate over the set of indicator variables.
ValueType operator()(const ITERATOR_TYPE statesBegin) const
Evaluation operator to check if the linear constraint is violated by the given labeling.
ValueType BoundType
Defines the data type for the bound.
IndicatorVariableType::IteratorType VariableLabelPairsIteratorType
Defines the const iterator type to iterate over the variable label pairs of an indicator variable...
Defines the linear constraint operator type to be . Hence the left hand side of the constraint will b...
CoefficientsIteratorType coefficientsEnd() const
Get the end iterator to the set of coefficients for the indicator variables.
CoefficientsContainerType coefficients_
Storage for the set of coefficients for the indicator variables.
std::vector< IndicatorVariableType > IndicatorVariablesContainerType
Defines the storage type for the set of indicator variables.
VariableLabelPairContainerType::const_iterator IteratorType
A const iterator to iterate over the VariableLabelPair elements.
Provides implementation for class IndicatorVariable.
INDEX_TYPE IndexType
Typedef of the INDEX_TYPE template parameter type from the class LinearConstraint.
This struct is used to create an own scope for the LinearConstraintTraits::LinearConstraintOperator::...
Defines the linear constraint operator type to be . Hence the left hand side of the constraint will b...
std::vector< ValueType > CoefficientsContainerType
Defines the storage type for the set of coefficients for the indicator variables. ...
IndicatorVariable< IndexType, LabelType > IndicatorVariableType
Typedef of the IndicatorVariable class with appropriate template parameter.
LinearConstraintTraits::LinearConstraintOperator LinearConstraintOperatorType
Defines the linear constraint operator.
void add(const IndicatorVariableType &indicatorVariable, const ValueType coefficient)
Add a single indicator variable and the corresponding coefficient to the linear constraint.
IndicatorVariablesIteratorType indicatorVariablesEnd() const
Get the end iterator to the set of indicator variables.
Combine a group of variables to a new variable.
LinearConstraint()
LinearConstraint constructor.
LABEL_TYPE LabelType
Typedef of the LABEL_TYPE template parameter type from the class LinearConstraint.
BoundType bound_
Storage for the bound of the linear constraint.
LinearConstraintOperatorType::ValueType LinearConstraintOperatorValueType
Defines the linear constraint operator type.
LinearConstraintOperatorValueType getConstraintOperator() const
Get the constraint operator of the linear constraint.
void reserve(const size_t numIndicatorVariables)
Preallocate memory.
ValueType
This enum defines the operator type for the linear constraint.
LinearConstraintOperatorValueType constraintOperator_
Storage for the constraint operator of the linear constraint.
IndicatorVariablesContainerType indicatorVariables_
Storage for the set of indicator variables.
void setConstraintOperator(const LinearConstraintOperatorValueType constraintOperator)
Set the constraint operator for the linear constraint.
Defines the linear constraint operator type to be . Hence the left hand side of the constraint will b...
Define a linear constraint for a set of indicatorVariables.
VALUE_TYPE ValueType
Typedef of the VALUE_TYPE template parameter type from the class LinearConstraint.
void setBound(const BoundType bound)
Set the bound of the linear constraint.
Traits class for LinearConstraint to provide template independent enum for ConstraintOperatorType.
BoundType getBound() const
Get the bound of the linear constraint.