ANIMA  4.0
animaBLMLambdaCostFunction.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <vnl/vnl_matrix.h>
4 #include <vector>
5 
6 #include <itkSingleValuedCostFunction.h>
7 #include "AnimaOptimizersExport.h"
8 
9 namespace anima
10 {
16 class ANIMAOPTIMIZERS_EXPORT BLMLambdaCostFunction:
17  public itk::SingleValuedCostFunction
18 {
19 public:
22  typedef itk::SingleValuedCostFunction Superclass;
23  typedef itk::SmartPointer <Self> Pointer;
24  typedef itk::SmartPointer <const Self> ConstPointer;
25 
27  itkNewMacro(Self)
28 
29 
30  itkTypeMacro(BLMLambdaCostFunction, SingleValuedCostFunction)
31 
32  typedef Superclass::MeasureType MeasureType;
33  typedef Superclass::DerivativeType DerivativeType;
34  typedef Superclass::ParametersType ParametersType;
35 
36  virtual MeasureType GetValue(const ParametersType &parameters) const ITK_OVERRIDE;
37  virtual void GetDerivative(const ParametersType &parameters, DerivativeType &derivative) const ITK_OVERRIDE;
38 
39  virtual unsigned int GetNumberOfParameters() const ITK_OVERRIDE {return 1;}
40 
41  itkSetMacro(JRank, unsigned int)
42  itkSetMacro(DeltaParameter, double)
43  itkGetMacro(SolutionInBounds, bool)
44 
45  void SetDValues(ParametersType &dVal) {m_DValues = dVal;}
46  void SetInversePivotVector(std::vector <unsigned int> &invPiv) {m_InversePivotVector = invPiv;}
47  void SetPivotVector(std::vector <unsigned int> &piv) {m_PivotVector = piv;}
48  void SetLowerBoundsPermutted(ParametersType &lb) {m_LowerBoundsPermutted = lb;}
49  void SetUpperBoundsPermutted(ParametersType &ub) {m_UpperBoundsPermutted = ub;}
50  void SetPreviousParametersPermutted(ParametersType &val) {m_PreviousParametersPermutted = val;}
51 
52  void SetInputWorkMatricesAndVectorsFromQRDerivative(vnl_matrix <double> &qrDerivative,
53  ParametersType &qtResiduals, unsigned int rank);
54 
55  ParametersType &GetSolutionVector() {return m_SolutionVector;}
56 
57 protected:
59  {
60  }
61 
62  virtual ~BLMLambdaCostFunction() ITK_OVERRIDE {}
63 
64  bool CheckSolutionIsInBounds(ParametersType &solutionVector) const;
65 
66 private:
67  ITK_DISALLOW_COPY_AND_ASSIGN(BLMLambdaCostFunction);
68 
69  ParametersType m_DValues, m_InputWResiduals, m_ZeroWResiduals;
70  mutable ParametersType m_PPermutted, m_PPermuttedShrunk;
71  mutable ParametersType m_WResiduals;
72  std::vector <unsigned int> m_InversePivotVector, m_PivotVector;
73  ParametersType m_LowerBoundsPermutted, m_UpperBoundsPermutted;
74  ParametersType m_PreviousParametersPermutted;
75  vnl_matrix <double> m_InputWorkMatrix;
76  mutable vnl_matrix <double> m_RAlphaTranspose;
77  mutable vnl_matrix <double> m_WorkMatrix;
78  mutable vnl_matrix <double> m_ZeroWorkMatrix;
79  mutable ParametersType m_SolutionVector;
80  mutable bool m_SolutionInBounds;
81  double m_DeltaParameter;
82  unsigned int m_JRank;
83 };
84 
85 } // end namespace anima
itk::SingleValuedCostFunction Superclass
void SetLowerBoundsPermutted(ParametersType &lb)
itk::SmartPointer< const Self > ConstPointer
void SetInversePivotVector(std::vector< unsigned int > &invPiv)
Superclass::DerivativeType DerivativeType
virtual ~BLMLambdaCostFunction() ITK_OVERRIDE
Levenberg-Marquardt lambda update cost function (phi) used for bounded levenberg marquardt optimizer ...
void SetPreviousParametersPermutted(ParametersType &val)
Superclass::ParametersType ParametersType
void SetUpperBoundsPermutted(ParametersType &ub)
void SetPivotVector(std::vector< unsigned int > &piv)