BrentLineSearch.h
1 /*
2  * Medical Image Registration ToolKit (MIRTK)
3  *
4  * Copyright 2013-2015 Imperial College London
5  * Copyright 2013-2015 Andreas Schuh
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 
20 #ifndef MIRTK_BrentLineSearch_H
21 #define MIRTK_BrentLineSearch_H
22 
23 #include "mirtk/InexactLineSearch.h"
24 
25 
26 namespace mirtk {
27 
28 
29 /**
30  * Performs a line search using Brent's method
31  *
32  * This line search strategy uses Brent's method to find an optimal step length
33  * within a given search interval. It initially brackets the minimum when the
34  * user specified step length range does not need to be strictly followed.
35  */
37 {
38  mirtkLineSearchMacro(BrentLineSearch, LS_Brent);
39 
40  // ---------------------------------------------------------------------------
41  // Constants
42 
43  static const double _MinificationRatio;
44  static const double _MagnificationRatio;
45  static const double _MaxMagnificationRatio;
46 
47  // ---------------------------------------------------------------------------
48  // Attributes
49 
50  /// Tolerance value for interval
51  mirtkPublicAttributeMacro(double, Tolerance);
52 
53  /// Copy attributes of this class from another instance
54  void CopyAttributes(const BrentLineSearch &);
55 
56  // ---------------------------------------------------------------------------
57  // Construction/Destruction
58 public:
59 
60  /// Constructor
62 
63  /// Copy constructor
65 
66  /// Assignment operator
68 
69  /// Destructor
70  virtual ~BrentLineSearch();
71 
72  // ---------------------------------------------------------------------------
73  // Parameters
75 
76  /// Set parameter value from string
77  virtual bool Set(const char *, const char *);
78 
79  /// Get parameters as key/value as string map
80  virtual ParameterList Parameter() const;
81 
82  // ---------------------------------------------------------------------------
83  // Optimization
84 
85  /// Make optimal step along search direction
86  virtual double Run();
87 
88 protected:
89 
90  /// Bracket extremum of objective function
91  ///
92  /// This function finds an initial triplet (a, b, c) of step lengths which
93  /// brackets a minimum (or maximum if \p _Descent is \c false) of the
94  /// objective function.
95  ///
96  /// \param[out] a Minimum step length.
97  /// \param[out] b Step length for which objective function achieves an
98  /// extremum in the step length interval [a, b].
99  /// \param[out] c Maximum step length.
100  /// \param[out] delta Maximum change of objective function parameter for
101  /// step length equal to \p b. Not returned if \c NULL.
102  ///
103  /// \returns Objective function value for step length \p b.
104  double BracketExtremum(double &a, double &b, double &c, double *delta = NULL);
105 
106 };
107 
108 
109 } // namespace mirtk
110 
111 #endif // MIRTK_BrentLineSearch_H
BrentLineSearch & operator=(const BrentLineSearch &)
Assignment operator.
double BracketExtremum(double &a, double &b, double &c, double *delta=NULL)
virtual ParameterList Parameter() const
Get parameters as key/value as string map.
virtual ParameterList Parameter() const
Get parameters as key/value as string map.
virtual ~BrentLineSearch()
Destructor.
Array< Pair< string, string > > ParameterList
Ordered list of parameter name/value pairs.
Definition: Object.h:38
Definition: IOConfig.h:41
Numerical recipes linmin function using Brent&#39;s method.
Definition: LineSearch.h:37
virtual bool Set(const char *, const char *)
Set parameter value from string.
virtual double Run()
Make optimal step along search direction.
BrentLineSearch(ObjectiveFunction *=NULL)
Constructor.