go home Home | Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals | Related Pages
itkMoreThuenteLineSearchOptimizer.h
Go to the documentation of this file.
1/*=========================================================================
2 *
3 * Copyright UMC Utrecht and contributors
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0.txt
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 *=========================================================================*/
18
19#ifndef __itkMoreThuenteLineSearchOptimizer_h
20#define __itkMoreThuenteLineSearchOptimizer_h
21
23
24namespace itk
25{
72{
73public:
74
78 typedef SmartPointer< const Self > ConstPointer;
79
80 itkNewMacro( Self );
82
87
88 typedef enum {
99
100 void StartOptimization( void ) override;
101
102 virtual void StopOptimization( void );
103
107 void SetInitialDerivative( const DerivativeType & derivative ) override;
108
109 void SetInitialValue( MeasureType value ) override;
110
115 MeasureType & value, DerivativeType & derivative ) const override;
116
117 void GetCurrentDerivative( DerivativeType & derivative ) const override;
118
119 MeasureType GetCurrentValue( void ) const override;
120
121 virtual double GetCurrentDirectionalDerivative( void ) const;
122
124 itkGetConstMacro( CurrentIteration, unsigned long );
125 itkGetConstReferenceMacro( StopCondition, StopConditionType );
126 itkGetConstMacro( SufficientDecreaseConditionSatisfied, bool );
127 itkGetConstMacro( CurvatureConditionSatisfied, bool );
128
130 itkGetConstMacro( MaximumNumberOfIterations, unsigned long );
131 itkSetClampMacro( MaximumNumberOfIterations, unsigned long,
132 1, NumericTraits< unsigned long >::max() );
133
143 itkSetClampMacro( ValueTolerance, double, 0.0, NumericTraits< double >::max() );
144 itkGetConstMacro( ValueTolerance, double );
145
155 itkSetClampMacro( GradientTolerance, double, 0.0, NumericTraits< double >::max() );
156 itkGetConstMacro( GradientTolerance, double );
157
166 itkSetClampMacro( IntervalTolerance, double, 0.0, NumericTraits< double >::max() );
167 itkGetConstMacro( IntervalTolerance, double );
168
169protected:
170
173
174 void PrintSelf( std::ostream & os, Indent indent ) const override;
175
176 unsigned long m_CurrentIteration;
180 bool m_Stop;
183
185 virtual void GetInitialValueAndDerivative( void );
186
188 virtual int CheckSettings( void );
189
191 virtual void InitializeLineSearch( void );
192
197
199 void BoundStep( double & step ) const;
200
202 virtual void PrepareForUnusualTermination( void );
203
206
208 virtual void TestConvergence( bool & stop );
209
211 virtual void ComputeNewStepAndInterval( void );
212
215
219 virtual int SafeGuardedStep(
220 double & stx, double & fx, double & dx,
221 double & sty, double & fy, double & dy,
222 double & stp, const double & fp, const double & dp,
223 bool & brackt,
224 const double & stpmin, const double & stpmax ) const;
225
226 double m_step;
227 double m_stepx;
228 double m_stepy;
229 double m_stepmin;
230 double m_stepmax;
231
232 MeasureType m_f; // CurrentValue
236
237 DerivativeType m_g; // CurrentDerivative
238 double m_dg; // CurrentDirectionalDerivative
239 double m_dginit;
240 double m_dgx;
241 double m_dgy;
242 double m_dgtest;
243
244 double m_width;
245 double m_width1;
246
250
251private:
252
253 MoreThuenteLineSearchOptimizer( const Self & ); // purposely not implemented
254 void operator=( const Self & ); // purposely not implemented
255
260
261};
262
263} // end namespace itk
264
271/* SUBROUTINE MCSRCH */
272
273/* A slight modification of the subroutine CSRCH of More' and Thuente. */
274/* The changes are to allow reverse communication, and do not affect */
275/* the performance of the routine. */
276
277/* THE PURPOSE OF MCSRCH IS TO FIND A STEP WHICH SATISFIES */
278/* A SUFFICIENT DECREASE CONDITION AND A CURVATURE CONDITION. */
279
280/* AT EACH STAGE THE SUBROUTINE UPDATES AN INTERVAL OF */
281/* UNCERTAINTY WITH ENDPOINTS STX AND STY. THE INTERVAL OF */
282/* UNCERTAINTY IS INITIALLY CHOSEN SO THAT IT CONTAINS A */
283/* MINIMIZER OF THE MODIFIED FUNCTION */
284
285/* F(X+STP*S) - F(X) - FTOL*STP*(GRADF(X)'S). */
286
287/* IF A STEP IS OBTAINED FOR WHICH THE MODIFIED FUNCTION */
288/* HAS A NONPOSITIVE FUNCTION VALUE AND NONNEGATIVE DERIVATIVE, */
289/* THEN THE INTERVAL OF UNCERTAINTY IS CHOSEN SO THAT IT */
290/* CONTAINS A MINIMIZER OF F(X+STP*S). */
291
292/* THE ALGORITHM IS DESIGNED TO FIND A STEP WHICH SATISFIES */
293/* THE SUFFICIENT DECREASE CONDITION */
294
295/* F(X+STP*S) .LE. F(X) + FTOL*STP*(GRADF(X)'S), */
296
297/* AND THE CURVATURE CONDITION */
298
299/* ABS(GRADF(X+STP*S)'S)) .LE. GTOL*ABS(GRADF(X)'S). */
300
301/* IF FTOL IS LESS THAN GTOL AND IF, FOR EXAMPLE, THE FUNCTION */
302/* IS BOUNDED BELOW, THEN THERE IS ALWAYS A STEP WHICH SATISFIES */
303/* BOTH CONDITIONS. IF NO STEP CAN BE FOUND WHICH SATISFIES BOTH */
304/* CONDITIONS, THEN THE ALGORITHM USUALLY STOPS WHEN ROUNDING */
305/* ERRORS PREVENT FURTHER PROGRESS. IN THIS CASE STP ONLY */
306/* SATISFIES THE SUFFICIENT DECREASE CONDITION. */
307
308/* THE SUBROUTINE STATEMENT IS */
309
310/* SUBROUTINE MCSRCH(N,X,F,G,S,STP,FTOL,XTOL, MAXFEV,INFO,NFEV,WA) */
311/* WHERE */
312
313/* N IS A POSITIVE INTEGER INPUT VARIABLE SET TO THE NUMBER */
314/* OF VARIABLES. */
315
316/* X IS AN ARRAY OF LENGTH N. ON INPUT IT MUST CONTAIN THE */
317/* BASE POINT FOR THE LINE SEARCH. ON OUTPUT IT CONTAINS */
318/* X + STP*S. */
319
320/* F IS A VARIABLE. ON INPUT IT MUST CONTAIN THE VALUE OF F */
321/* AT X. ON OUTPUT IT CONTAINS THE VALUE OF F AT X + STP*S. */
322
323/* G IS AN ARRAY OF LENGTH N. ON INPUT IT MUST CONTAIN THE */
324/* GRADIENT OF F AT X. ON OUTPUT IT CONTAINS THE GRADIENT */
325/* OF F AT X + STP*S. */
326
327/* S IS AN INPUT ARRAY OF LENGTH N WHICH SPECIFIES THE */
328/* SEARCH DIRECTION. */
329
330/* STP IS A NONNEGATIVE VARIABLE. ON INPUT STP CONTAINS AN */
331/* INITIAL ESTIMATE OF A SATISFACTORY STEP. ON OUTPUT */
332/* STP CONTAINS THE FINAL ESTIMATE. */
333
334/* FTOL AND GTOL ARE NONNEGATIVE INPUT VARIABLES. (In this reverse */
335/* communication implementation GTOL is defined in a COMMON */
336/* statement.) TERMINATION OCCURS WHEN THE SUFFICIENT DECREASE */
337/* CONDITION AND THE DIRECTIONAL DERIVATIVE CONDITION ARE */
338/* SATISFIED. */
339
340/* XTOL IS A NONNEGATIVE INPUT VARIABLE. TERMINATION OCCURS */
341/* WHEN THE RELATIVE WIDTH OF THE INTERVAL OF UNCERTAINTY */
342/* IS AT MOST XTOL. */
343
344/* STPMIN AND STPMAX ARE NONNEGATIVE INPUT VARIABLES WHICH */
345/* SPECIFY LOWER AND UPPER BOUNDS FOR THE STEP. (In this reverse */
346/* communication implementatin they are defined in a COMMON */
347/* statement). */
348
349/* MAXFEV IS A POSITIVE INTEGER INPUT VARIABLE. TERMINATION */
350/* OCCURS WHEN THE NUMBER OF CALLS TO FCN IS AT LEAST */
351/* MAXFEV BY THE END OF AN ITERATION. */
352
353/* INFO IS AN INTEGER OUTPUT VARIABLE SET AS FOLLOWS: */
354
355/* INFO = 0 IMPROPER INPUT PARAMETERS. */
356
357/* INFO =-1 A RETURN IS MADE TO COMPUTE THE FUNCTION AND GRADIENT. */
358/* NFEV IS AN INTEGER OUTPUT VARIABLE SET TO THE NUMBER OF */
359/* CALLS TO FCN. */
360
361/* WA IS A WORK ARRAY OF LENGTH N. */
362
363/* SUBPROGRAMS CALLED */
364
365/* MCSTEP */
366
367/* FORTRAN-SUPPLIED...ABS,MAX,MIN */
368
369/* ARGONNE NATIONAL LABORATORY. MINPACK PROJECT. JUNE 1983 */
370/* JORGE J. MORE', DAVID J. THUENTE */
371
372/* ********** */
373
374#endif // #ifndef __itkMoreThuenteLineSearchOptimizer_h
A base class for LineSearch optimizers.
Superclass::ParametersType ParametersType
Superclass::MeasureType MeasureType
Superclass::CostFunctionType CostFunctionType
Superclass::DerivativeType DerivativeType
ITK version of the MoreThuente line search algorithm.
void GetCurrentValueAndDerivative(MeasureType &value, DerivativeType &derivative) const override
void SetInitialDerivative(const DerivativeType &derivative) override
void StartOptimization(void) override
virtual void PrepareForUnusualTermination(void)
virtual void TestConvergence(bool &stop)
virtual void ComputeNewStepAndInterval(void)
virtual double GetCurrentDirectionalDerivative(void) const
virtual int SafeGuardedStep(double &stx, double &fx, double &dx, double &sty, double &fy, double &dy, double &stp, const double &fp, const double &dp, bool &brackt, const double &stpmin, const double &stpmax) const
virtual void UpdateIntervalMinimumAndMaximum(void)
virtual void ComputeCurrentValueAndDerivative(void)
void BoundStep(double &step) const
void PrintSelf(std::ostream &os, Indent indent) const override
virtual void ForceSufficientDecreaseInIntervalWidth(void)
virtual void InitializeLineSearch(void)
virtual void GetInitialValueAndDerivative(void)
MeasureType GetCurrentValue(void) const override
void GetCurrentDerivative(DerivativeType &derivative) const override
void SetInitialValue(MeasureType value) override


Generated on 1667476801 for elastix by doxygen 1.9.4 elastix logo