Medical Imaging Interaction Toolkit  2022.10.99-122321bb
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  {
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;
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
mitk::SimpleBarrierConstraintChecker::Constraint::upperBarrier
bool upperBarrier
Definition: mitkSimpleBarrierConstraintChecker.h:67
mitk::SimpleBarrierConstraintChecker::Constraint::barrier
BarrierValueType barrier
Definition: mitkSimpleBarrierConstraintChecker.h:65
mitk::SimpleBarrierConstraintChecker::BarrierValueType
double BarrierValueType
Definition: mitkSimpleBarrierConstraintChecker.h:57
mitk::ConstraintCheckerBase::PenaltyValueType
Superclass::PenaltyValueType PenaltyValueType
Definition: mitkConstraintCheckerBase.h:40
mitk::SimpleBarrierConstraintChecker::Constraint::parameters
ParameterIndexVectorType parameters
Definition: mitkSimpleBarrierConstraintChecker.h:64
MitkModelFitExports.h
mitk::SimpleBarrierConstraintChecker::Superclass
ConstraintCheckerBase Superclass
Definition: mitkSimpleBarrierConstraintChecker.h:46
mitkConstraintCheckerBase.h
mitk::SimpleBarrierConstraintChecker::Constraint
Definition: mitkSimpleBarrierConstraintChecker.h:62
mitk::SimpleBarrierConstraintChecker::SimpleBarrierConstraintChecker
SimpleBarrierConstraintChecker()
Definition: mitkSimpleBarrierConstraintChecker.h:114
mitk::SimpleBarrierConstraintChecker
This class implements constraints as simple barrier functions.
Definition: mitkSimpleBarrierConstraintChecker.h:42
mitk::ConstraintCheckerBase
This class is the base class for constraint checker.
Definition: mitkConstraintCheckerBase.h:31
itk::SmartPointer< Self >
mitk::SimpleBarrierConstraintChecker::ParametersType
Superclass::ParametersType ParametersType
Definition: mitkSimpleBarrierConstraintChecker.h:55
mitk::SimpleBarrierConstraintChecker::ParameterIndexVectorType
std::vector< ParameterIndexType > ParameterIndexVectorType
Definition: mitkSimpleBarrierConstraintChecker.h:60
MITKMODELFIT_EXPORT
#define MITKMODELFIT_EXPORT
Definition: MitkModelFitExports.h:15
mitk
DataCollection - Class to facilitate loading/accessing structured data.
Definition: RenderingTests.dox:1
mitk::SimpleBarrierConstraintChecker::SignalType
Superclass::SignalType SignalType
Definition: mitkSimpleBarrierConstraintChecker.h:54
mitk::SimpleBarrierConstraintChecker::ParameterIndexType
ParametersType::SizeValueType ParameterIndexType
Definition: mitkSimpleBarrierConstraintChecker.h:59
mitk::ConstraintCheckerInterface::SignalType
itk::Array< double > SignalType
Definition: mitkConstraintCheckerInterface.h:34
mitk::SimpleBarrierConstraintChecker::PenaltyArrayType
Superclass::PenaltyArrayType PenaltyArrayType
Definition: mitkSimpleBarrierConstraintChecker.h:53
mitk::ConstraintCheckerBase::ParametersType
Superclass::ParametersType ParametersType
Definition: mitkConstraintCheckerBase.h:43
mitk::SimpleBarrierConstraintChecker::~SimpleBarrierConstraintChecker
~SimpleBarrierConstraintChecker() override
Definition: mitkSimpleBarrierConstraintChecker.h:118
mitk::SimpleBarrierConstraintChecker::m_Constraints
ConstraintVectorType m_Constraints
Definition: mitkSimpleBarrierConstraintChecker.h:110
mitk::SimpleBarrierConstraintChecker::Pointer
itk::SmartPointer< Self > Pointer
Definition: mitkSimpleBarrierConstraintChecker.h:47
mitk::SimpleBarrierConstraintChecker::Constraint::Constraint
Constraint()
Definition: mitkSimpleBarrierConstraintChecker.h:68
mitk::SimpleBarrierConstraintChecker::Constraint::width
BarrierWidthType width
Definition: mitkSimpleBarrierConstraintChecker.h:66
mitk::SimpleBarrierConstraintChecker::BarrierWidthType
double BarrierWidthType
Definition: mitkSimpleBarrierConstraintChecker.h:58
mitk::SimpleBarrierConstraintChecker::PenaltyValueType
Superclass::PenaltyValueType PenaltyValueType
Definition: mitkSimpleBarrierConstraintChecker.h:50
mitk::ConstraintCheckerInterface::PenaltyArrayType
itk::Array< PenaltyValueType > PenaltyArrayType
Definition: mitkConstraintCheckerInterface.h:33
mitk::SimpleBarrierConstraintChecker::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: mitkSimpleBarrierConstraintChecker.h:48
mitk::SimpleBarrierConstraintChecker::Self
SimpleBarrierConstraintChecker Self
Definition: mitkSimpleBarrierConstraintChecker.h:45
mitk::SimpleBarrierConstraintChecker::ConstraintVectorType
std::vector< Constraint > ConstraintVectorType
Definition: mitkSimpleBarrierConstraintChecker.h:105