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 
13 {};
14 
15 template <typename LINEAR_CONSTRAINT_FUNCTION_TYPE>
17 {
19 };
20 
21 template<class LINEAR_CONSTRAINT_FUNCTION_TYPE>
22 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> {
23 public:
24  // typedefs
25  typedef LINEAR_CONSTRAINT_FUNCTION_TYPE LinearConstraintFunctionType;
28  typedef typename LinearConstraintFunctionTraitsType::IndexType IndexType;
29  typedef typename LinearConstraintFunctionTraitsType::LabelType LabelType;
30  typedef typename LinearConstraintFunctionTraitsType::LinearConstraintType LinearConstraintType;
31  typedef typename LinearConstraintFunctionTraitsType::LinearConstraintsIteratorType LinearConstraintsIteratorType;
32  typedef typename LinearConstraintFunctionTraitsType::ViolatedLinearConstraintsIteratorType ViolatedLinearConstraintsIteratorType;
33  typedef typename LinearConstraintFunctionTraitsType::ViolatedLinearConstraintsWeightsIteratorType ViolatedLinearConstraintsWeightsIteratorType;
34  typedef typename LinearConstraintFunctionTraitsType::IndicatorVariablesIteratorType IndicatorVariablesIteratorType;
35 
36  // const access
37  LinearConstraintsIteratorType linearConstraintsBegin() const;
38  LinearConstraintsIteratorType linearConstraintsEnd() const;
39  IndicatorVariablesIteratorType indicatorVariablesOrderBegin() const;
40  IndicatorVariablesIteratorType indicatorVariablesOrderEnd() const;
41 
42  template <class LABEL_ITERATOR>
43  void challenge(ViolatedLinearConstraintsIteratorType& violatedConstraintsBegin, ViolatedLinearConstraintsIteratorType& violatedConstraintsEnd, ViolatedLinearConstraintsWeightsIteratorType& violatedConstraintsWeightsBegin, LABEL_ITERATOR labelingBegin, const ValueType tolerance = 0.0) const;
44  template <class LABEL_ITERATOR>
45  void challengeRelaxed(ViolatedLinearConstraintsIteratorType& violatedConstraintsBegin, ViolatedLinearConstraintsIteratorType& violatedConstraintsEnd, ViolatedLinearConstraintsWeightsIteratorType& violatedConstraintsWeightsBegin, LABEL_ITERATOR labelingBegin, const ValueType tolerance = 0.0) const;
46 
47  // specializations
48  bool isLinearConstraint() const;
49 };
50 
51 /***********************
52  * class documentation *
53  ***********************/
254 /******************
255  * implementation *
256  ******************/
257 template<class LINEAR_CONSTRAINT_FUNCTION_TYPE>
259  return static_cast<const LinearConstraintFunctionType*>(this)->linearConstraintsBegin_impl();
260 }
261 
262 template<class LINEAR_CONSTRAINT_FUNCTION_TYPE>
264  return static_cast<const LinearConstraintFunctionType*>(this)->linearConstraintsEnd_impl();
265 }
266 
267 template<class LINEAR_CONSTRAINT_FUNCTION_TYPE>
269  return static_cast<const LinearConstraintFunctionType*>(this)->indicatorVariablesOrderBegin_impl();
270 }
271 
272 template<class LINEAR_CONSTRAINT_FUNCTION_TYPE>
274  return static_cast<const LinearConstraintFunctionType*>(this)->indicatorVariablesOrderEnd_impl();
275 }
276 
277 template<class LINEAR_CONSTRAINT_FUNCTION_TYPE>
278 template <class LABEL_ITERATOR>
279 inline void LinearConstraintFunctionBase<LINEAR_CONSTRAINT_FUNCTION_TYPE>::challenge(ViolatedLinearConstraintsIteratorType& violatedConstraintsBegin, ViolatedLinearConstraintsIteratorType& violatedConstraintsEnd, ViolatedLinearConstraintsWeightsIteratorType& violatedConstraintsWeightsBegin, LABEL_ITERATOR labelingBegin, const ValueType tolerance) const {
280  return static_cast<const LinearConstraintFunctionType*>(this)->challenge_impl(violatedConstraintsBegin, violatedConstraintsEnd, violatedConstraintsWeightsBegin, labelingBegin, tolerance);
281 }
282 
283 template<class LINEAR_CONSTRAINT_FUNCTION_TYPE>
284 template <class LABEL_ITERATOR>
285 inline void LinearConstraintFunctionBase<LINEAR_CONSTRAINT_FUNCTION_TYPE>::challengeRelaxed(ViolatedLinearConstraintsIteratorType& violatedConstraintsBegin, ViolatedLinearConstraintsIteratorType& violatedConstraintsEnd, ViolatedLinearConstraintsWeightsIteratorType& violatedConstraintsWeightsBegin, LABEL_ITERATOR labelingBegin, const ValueType tolerance) const {
286  return static_cast<const LinearConstraintFunctionType*>(this)->challengeRelaxed_impl(violatedConstraintsBegin, violatedConstraintsEnd, violatedConstraintsWeightsBegin, labelingBegin, tolerance);
287 }
288 
289 template<class LINEAR_CONSTRAINT_FUNCTION_TYPE>
291  return true;
292 }
293 
294 } // namespace opengm
295 
296 #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...
IndicatorVariablesIteratorType indicatorVariablesOrderBegin() const
Get the begin iterator to the set of indicator variables used by the linear constraint function...
The OpenGM namespace.
Definition: config.hxx:43
Fallback implementation of member functions of OpenGM functions.
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...
LinearConstraintFunctionTraits< LinearConstraintFunctionType > LinearConstraintFunctionTraitsType
Typedef of the LinearConstraintFunctionTraits class with appropriate template parameter.
LinearConstraintFunctionTraitsType::LinearConstraintsIteratorType LinearConstraintsIteratorType
Typedef of the linear constraints iterator type used by the linear constraint function to iterate ove...
LinearConstraintsIteratorType linearConstraintsEnd() const
Get the end iterator to the set of linear constraints represented by the 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...
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.
A linear constraint function class ensuring the correct label order for two variables.
LinearConstraintFunctionTraitsUndefined ValueType
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.
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...
IndicatorVariablesIteratorType indicatorVariablesOrderEnd() const
Get the end iterator to the set of indicator variables used by the linear constraint function...
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...