Medical Imaging Interaction Toolkit  2021.10.99-9c07a326
Medical Imaging Interaction Toolkit
mitkSimpleBarrierConstraintChecker.h
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #ifndef SIMPLE_BARRIER_CONSTRAINT_CHECKER_H
14 #define SIMPLE_BARRIER_CONSTRAINT_CHECKER_H
15 
17 
18 #include "MitkModelFitExports.h"
19 
20 namespace mitk
21 {
22 
43  {
44  public:
49 
50  itkFactorylessNewMacro(Self);
51 
56 
57  typedef double BarrierValueType;
58  typedef double BarrierWidthType;
59  typedef ParametersType::SizeValueType ParameterIndexType;
60  typedef std::vector<ParameterIndexType> ParameterIndexVectorType;
61 
62  struct Constraint
63  {
64  ParameterIndexVectorType parameters;
65  BarrierValueType barrier;
66  BarrierWidthType width;
68  Constraint(): barrier(0), width(0), upperBarrier(true)
69  {};
70  };
71 
72  PenaltyArrayType GetPenalties(const ParametersType& parameters) const override;
73 
74  unsigned int GetNumberOfConstraints() const override;
75 
76  PenaltyValueType GetFailedConstraintValue() const override;
77 
79  void SetLowerBarrier(ParameterIndexType parameterID, BarrierValueType barrier,
80  BarrierWidthType width = 0.0);
82  void SetUpperBarrier(ParameterIndexType parameterID, BarrierValueType barrier,
83  BarrierWidthType width = 0.0);
85  void SetLowerSumBarrier(const ParameterIndexVectorType& parameterIDs, BarrierValueType barrier,
86  BarrierWidthType width = 0.0);
88  void SetUpperSumBarrier(const ParameterIndexVectorType& parameterIDs, BarrierValueType barrier,
89  BarrierWidthType width = 0.0);
90 
91  /*returns the constraint with the given index.
92  @pre The index must exist.*/
93  Constraint& GetConstraint(unsigned int index);
94  /*returns the constraint with the given index.
95  @pre The index must exist.*/
96  const Constraint& GetConstraint(unsigned int index) const;
97 
98  /*removes a constraint. Indicated by the index. If the index does not exist,
99  nothing will be removed and the state of the checker stays untouched.*/
100  void DeleteConstraint(unsigned int index);
101 
102  void ResetConstraints();
103 
104  itkSetMacro(MaxConstraintPenalty, PenaltyValueType);
105  itkGetConstMacro(MaxConstraintPenalty, PenaltyValueType);
106 
107  protected:
108 
109  typedef std::vector<Constraint> ConstraintVectorType;
110  ConstraintVectorType m_Constraints;
111 
112  PenaltyValueType CalcPenalty(const ParametersType& parameters, const Constraint& constraint) const;
113 
114  SimpleBarrierConstraintChecker() : m_MaxConstraintPenalty(1e15)
115  {
116  }
117 
119 
120  private:
121  PenaltyValueType m_MaxConstraintPenalty;
122  };
123 
124 }
125 
126 #endif // SimpleBarrierConstraintChecker_H
Superclass::PenaltyValueType PenaltyValueType
This class implements constraints as simple barrier functions.
DataCollection - Class to facilitate loading/accessing structured data.
std::vector< ParameterIndexType > ParameterIndexVectorType
#define MITKMODELFIT_EXPORT
itk::Array< PenaltyValueType > PenaltyArrayType
Superclass::ParametersType ParametersType
This class is the base class for constraint checker.