OpenGM  2.3.x
Discrete Graphical Model Library
linear_constraint_function_base.hxx
Go to the documentation of this file.
1 #ifndef OPENGM_LINEAR_CONSTRAINT_FUNCTION_BASE_HXX_
2 #define OPENGM_LINEAR_CONSTRAINT_FUNCTION_BASE_HXX_
3 
5 
6 namespace opengm {
7 
8 /*********************
9  * class definition *
10  *********************/
11 template <typename LINEAR_CONSTRAINT_FUNCTION_TYPE>
13 
14 template<class LINEAR_CONSTRAINT_FUNCTION_TYPE>
15 class LinearConstraintFunctionBase : public FunctionBase<LINEAR_CONSTRAINT_FUNCTION_TYPE, typename LinearConstraintFunctionTraits<LINEAR_CONSTRAINT_FUNCTION_TYPE>::ValueType, typename LinearConstraintFunctionTraits<LINEAR_CONSTRAINT_FUNCTION_TYPE>::IndexType, typename LinearConstraintFunctionTraits<LINEAR_CONSTRAINT_FUNCTION_TYPE>::LabelType> {
16 public:
17  // typedefs
18  typedef LINEAR_CONSTRAINT_FUNCTION_TYPE LinearConstraintFunctionType;
20  typedef typename LinearConstraintFunctionTraitsType::ValueType ValueType;
21  typedef typename LinearConstraintFunctionTraitsType::IndexType IndexType;
22  typedef typename LinearConstraintFunctionTraitsType::LabelType LabelType;
23  typedef typename LinearConstraintFunctionTraitsType::LinearConstraintType LinearConstraintType;
24  typedef typename LinearConstraintFunctionTraitsType::LinearConstraintsIteratorType LinearConstraintsIteratorType;
25  typedef typename LinearConstraintFunctionTraitsType::ViolatedLinearConstraintsIteratorType ViolatedLinearConstraintsIteratorType;
26  typedef typename LinearConstraintFunctionTraitsType::ViolatedLinearConstraintsWeightsIteratorType ViolatedLinearConstraintsWeightsIteratorType;
27  typedef typename LinearConstraintFunctionTraitsType::IndicatorVariablesIteratorType IndicatorVariablesIteratorType;
28 
29  // const access
30  LinearConstraintsIteratorType linearConstraintsBegin() const;
31  LinearConstraintsIteratorType linearConstraintsEnd() const;
32  IndicatorVariablesIteratorType indicatorVariablesOrderBegin() const;
33  IndicatorVariablesIteratorType indicatorVariablesOrderEnd() const;
34 
35  template <class LABEL_ITERATOR>
36  void challenge(ViolatedLinearConstraintsIteratorType& violatedConstraintsBegin, ViolatedLinearConstraintsIteratorType& violatedConstraintsEnd, ViolatedLinearConstraintsWeightsIteratorType& violatedConstraintsWeightsBegin, LABEL_ITERATOR labelingBegin, const ValueType tolerance = 0.0) const;
37  template <class LABEL_ITERATOR>
38  void challengeRelaxed(ViolatedLinearConstraintsIteratorType& violatedConstraintsBegin, ViolatedLinearConstraintsIteratorType& violatedConstraintsEnd, ViolatedLinearConstraintsWeightsIteratorType& violatedConstraintsWeightsBegin, LABEL_ITERATOR labelingBegin, const ValueType tolerance = 0.0) const;
39 
40  // specializations
41  bool isLinearConstraint() const;
42 };
43 
44 /***********************
45  * class documentation *
46  ***********************/
247 /******************
248  * implementation *
249  ******************/
250 template<class LINEAR_CONSTRAINT_FUNCTION_TYPE>
252  return static_cast<const LinearConstraintFunctionType*>(this)->linearConstraintsBegin_impl();
253 }
254 
255 template<class LINEAR_CONSTRAINT_FUNCTION_TYPE>
257  return static_cast<const LinearConstraintFunctionType*>(this)->linearConstraintsEnd_impl();
258 }
259 
260 template<class LINEAR_CONSTRAINT_FUNCTION_TYPE>
262  return static_cast<const LinearConstraintFunctionType*>(this)->indicatorVariablesOrderBegin_impl();
263 }
264 
265 template<class LINEAR_CONSTRAINT_FUNCTION_TYPE>
267  return static_cast<const LinearConstraintFunctionType*>(this)->indicatorVariablesOrderEnd_impl();
268 }
269 
270 template<class LINEAR_CONSTRAINT_FUNCTION_TYPE>
271 template <class LABEL_ITERATOR>
272 inline void LinearConstraintFunctionBase<LINEAR_CONSTRAINT_FUNCTION_TYPE>::challenge(ViolatedLinearConstraintsIteratorType& violatedConstraintsBegin, ViolatedLinearConstraintsIteratorType& violatedConstraintsEnd, ViolatedLinearConstraintsWeightsIteratorType& violatedConstraintsWeightsBegin, LABEL_ITERATOR labelingBegin, const ValueType tolerance) const {
273  return static_cast<const LinearConstraintFunctionType*>(this)->challenge_impl(violatedConstraintsBegin, violatedConstraintsEnd, violatedConstraintsWeightsBegin, labelingBegin, tolerance);
274 }
275 
276 template<class LINEAR_CONSTRAINT_FUNCTION_TYPE>
277 template <class LABEL_ITERATOR>
278 inline void LinearConstraintFunctionBase<LINEAR_CONSTRAINT_FUNCTION_TYPE>::challengeRelaxed(ViolatedLinearConstraintsIteratorType& violatedConstraintsBegin, ViolatedLinearConstraintsIteratorType& violatedConstraintsEnd, ViolatedLinearConstraintsWeightsIteratorType& violatedConstraintsWeightsBegin, LABEL_ITERATOR labelingBegin, const ValueType tolerance) const {
279  return static_cast<const LinearConstraintFunctionType*>(this)->challengeRelaxed_impl(violatedConstraintsBegin, violatedConstraintsEnd, violatedConstraintsWeightsBegin, labelingBegin, tolerance);
280 }
281 
282 template<class LINEAR_CONSTRAINT_FUNCTION_TYPE>
284  return true;
285 }
286 
287 } // namespace opengm
288 
289 #endif /* OPENGM_LINEAR_CONSTRAINT_FUNCTION_BASE_HXX_ */
LinearConstraintFunctionTraitsType::ViolatedLinearConstraintsWeightsIteratorType ViolatedLinearConstraintsWeightsIteratorType
Typedef of the violated linear constraints weights iterator type used by the linear constraint functi...
The OpenGM namespace.
Definition: config.hxx:43
void challenge(ViolatedLinearConstraintsIteratorType &violatedConstraintsBegin, ViolatedLinearConstraintsIteratorType &violatedConstraintsEnd, ViolatedLinearConstraintsWeightsIteratorType &violatedConstraintsWeightsBegin, LABEL_ITERATOR labelingBegin, const ValueType tolerance=0.0) const
Challenge the linear constraint function and get all linear constraints which are violated by a given...
Fallback implementation of member functions of OpenGM functions.
IndicatorVariablesIteratorType indicatorVariablesOrderBegin() const
Get the begin iterator to the set of indicator variables used by the linear constraint function...
LinearConstraintsIteratorType linearConstraintsBegin() const
Get the begin iterator to the set of linear constraints represented by the linear constraint function...
bool isLinearConstraint() const
Function specialization for each linear constraint function.
void challengeRelaxed(ViolatedLinearConstraintsIteratorType &violatedConstraintsBegin, ViolatedLinearConstraintsIteratorType &violatedConstraintsEnd, ViolatedLinearConstraintsWeightsIteratorType &violatedConstraintsWeightsBegin, LABEL_ITERATOR labelingBegin, const ValueType tolerance=0.0) const
Challenge the linear constraint function and get all linear constraints which are violated by a given...
LinearConstraintFunctionTraits< LinearConstraintFunctionType > LinearConstraintFunctionTraitsType
Typedef of the LinearConstraintFunctionTraits class with appropriate template parameter.
IndicatorVariablesIteratorType indicatorVariablesOrderEnd() const
Get the end iterator to the set of indicator variables used by the linear constraint function...
LinearConstraintFunctionTraitsType::LinearConstraintsIteratorType LinearConstraintsIteratorType
Typedef of the linear constraints iterator type used by the linear constraint function to iterate ove...
Base class for linear constraint functions.
Traits class for linear constraint functions.
LinearConstraintFunctionTraitsType::IndexType IndexType
Typedef of the index type used by the linear constraint function.
LinearConstraintFunctionTraitsType::LabelType LabelType
Typedef of the label type used by the linear constraint function.
LinearConstraintsIteratorType linearConstraintsEnd() const
Get the end iterator to the set of linear constraints represented by the linear constraint function...
LinearConstraintFunctionTraitsType::ViolatedLinearConstraintsIteratorType ViolatedLinearConstraintsIteratorType
Typedef of the violated linear constraints iterator type used by the linear constraint function to it...
LINEAR_CONSTRAINT_FUNCTION_TYPE LinearConstraintFunctionType
Typedef of the LINEAR_CONSTRAINT_FUNCTION_TYPE template parameter from the class LinearConstraintFunc...
LinearConstraintFunctionTraitsType::LinearConstraintType LinearConstraintType
Typedef of the linear constraint type used by the linear constraint function.
LinearConstraintFunctionTraitsType::ValueType ValueType
Typedef of the value type used by the linear constraint function.
LinearConstraintFunctionTraitsType::IndicatorVariablesIteratorType IndicatorVariablesIteratorType
Typedef of the indicator variables iterator type used by the linear constraint function to iterate ov...