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:
75
78 using Pointer = SmartPointer<Self>;
79 using ConstPointer = SmartPointer<const Self>;
80
81 itkNewMacro(Self);
83
84 using Superclass::MeasureType;
85 using Superclass::ParametersType;
86 using Superclass::DerivativeType;
87 using Superclass::CostFunctionType;
88
90 {
100 };
101
102 void
104
105 virtual void
107
111 void
112 SetInitialDerivative(const DerivativeType & derivative) override;
113
114 void
115 SetInitialValue(MeasureType value) override;
116
120 void
121 GetCurrentValueAndDerivative(MeasureType & value, DerivativeType & derivative) const override;
122
123 void
124 GetCurrentDerivative(DerivativeType & derivative) const override;
125
126 MeasureType
127 GetCurrentValue() const override;
128
129 virtual double
131
133 itkGetConstMacro(CurrentIteration, unsigned long);
134 itkGetConstReferenceMacro(StopCondition, StopConditionType);
135 itkGetConstMacro(SufficientDecreaseConditionSatisfied, bool);
136 itkGetConstMacro(CurvatureConditionSatisfied, bool);
137
139 itkGetConstMacro(MaximumNumberOfIterations, unsigned long);
140 itkSetClampMacro(MaximumNumberOfIterations, unsigned long, 1, NumericTraits<unsigned long>::max());
141
151 itkSetClampMacro(ValueTolerance, double, 0.0, NumericTraits<double>::max());
152 itkGetConstMacro(ValueTolerance, double);
153
163 itkSetClampMacro(GradientTolerance, double, 0.0, NumericTraits<double>::max());
164 itkGetConstMacro(GradientTolerance, double);
165
174 itkSetClampMacro(IntervalTolerance, double, 0.0, NumericTraits<double>::max());
175 itkGetConstMacro(IntervalTolerance, double);
176
177protected:
180
181 void
182 PrintSelf(std::ostream & os, Indent indent) const override;
183
184 unsigned long m_CurrentIteration;
188 bool m_Stop;
191
193 virtual void
195
197 virtual int
199
201 void
203
207 virtual void
209
211 void
212 BoundStep(double & step) const;
213
215 virtual void
217
219 virtual void
221
223 virtual void
224 TestConvergence(bool & stop);
225
227 virtual void
229
231 virtual void
233
237 virtual int
238 SafeGuardedStep(double & stx,
239 double & fx,
240 double & dx,
241 double & sty,
242 double & fy,
243 double & dy,
244 double & stp,
245 const double fp,
246 const double dp,
247 bool & brackt,
248 const double stpmin,
249 const double stpmax) const;
250
251 double m_step;
252 double m_stepx;
253 double m_stepy;
254 double m_stepmin;
255 double m_stepmax;
256
257 MeasureType m_f; // CurrentValue
258 MeasureType m_fx;
259 MeasureType m_fy;
260 MeasureType m_finit;
261
262 DerivativeType m_g; // CurrentDerivative
263 double m_dg; // CurrentDirectionalDerivative
264 double m_dginit;
265 double m_dgx;
266 double m_dgy;
267 double m_dgtest;
268
269 double m_width;
270 double m_width1;
271
275
276private:
281};
282
283} // end namespace itk
284
291/* SUBROUTINE MCSRCH */
292
293/* A slight modification of the subroutine CSRCH of More' and Thuente. */
294/* The changes are to allow reverse communication, and do not affect */
295/* the performance of the routine. */
296
297/* THE PURPOSE OF MCSRCH IS TO FIND A STEP WHICH SATISFIES */
298/* A SUFFICIENT DECREASE CONDITION AND A CURVATURE CONDITION. */
299
300/* AT EACH STAGE THE SUBROUTINE UPDATES AN INTERVAL OF */
301/* UNCERTAINTY WITH ENDPOINTS STX AND STY. THE INTERVAL OF */
302/* UNCERTAINTY IS INITIALLY CHOSEN SO THAT IT CONTAINS A */
303/* MINIMIZER OF THE MODIFIED FUNCTION */
304
305/* F(X+STP*S) - F(X) - FTOL*STP*(GRADF(X)'S). */
306
307/* IF A STEP IS OBTAINED FOR WHICH THE MODIFIED FUNCTION */
308/* HAS A NONPOSITIVE FUNCTION VALUE AND NONNEGATIVE DERIVATIVE, */
309/* THEN THE INTERVAL OF UNCERTAINTY IS CHOSEN SO THAT IT */
310/* CONTAINS A MINIMIZER OF F(X+STP*S). */
311
312/* THE ALGORITHM IS DESIGNED TO FIND A STEP WHICH SATISFIES */
313/* THE SUFFICIENT DECREASE CONDITION */
314
315/* F(X+STP*S) .LE. F(X) + FTOL*STP*(GRADF(X)'S), */
316
317/* AND THE CURVATURE CONDITION */
318
319/* ABS(GRADF(X+STP*S)'S)) .LE. GTOL*ABS(GRADF(X)'S). */
320
321/* IF FTOL IS LESS THAN GTOL AND IF, FOR EXAMPLE, THE FUNCTION */
322/* IS BOUNDED BELOW, THEN THERE IS ALWAYS A STEP WHICH SATISFIES */
323/* BOTH CONDITIONS. IF NO STEP CAN BE FOUND WHICH SATISFIES BOTH */
324/* CONDITIONS, THEN THE ALGORITHM USUALLY STOPS WHEN ROUNDING */
325/* ERRORS PREVENT FURTHER PROGRESS. IN THIS CASE STP ONLY */
326/* SATISFIES THE SUFFICIENT DECREASE CONDITION. */
327
328/* THE SUBROUTINE STATEMENT IS */
329
330/* SUBROUTINE MCSRCH(N,X,F,G,S,STP,FTOL,XTOL, MAXFEV,INFO,NFEV,WA) */
331/* WHERE */
332
333/* N IS A POSITIVE INTEGER INPUT VARIABLE SET TO THE NUMBER */
334/* OF VARIABLES. */
335
336/* X IS AN ARRAY OF LENGTH N. ON INPUT IT MUST CONTAIN THE */
337/* BASE POINT FOR THE LINE SEARCH. ON OUTPUT IT CONTAINS */
338/* X + STP*S. */
339
340/* F IS A VARIABLE. ON INPUT IT MUST CONTAIN THE VALUE OF F */
341/* AT X. ON OUTPUT IT CONTAINS THE VALUE OF F AT X + STP*S. */
342
343/* G IS AN ARRAY OF LENGTH N. ON INPUT IT MUST CONTAIN THE */
344/* GRADIENT OF F AT X. ON OUTPUT IT CONTAINS THE GRADIENT */
345/* OF F AT X + STP*S. */
346
347/* S IS AN INPUT ARRAY OF LENGTH N WHICH SPECIFIES THE */
348/* SEARCH DIRECTION. */
349
350/* STP IS A NONNEGATIVE VARIABLE. ON INPUT STP CONTAINS AN */
351/* INITIAL ESTIMATE OF A SATISFACTORY STEP. ON OUTPUT */
352/* STP CONTAINS THE FINAL ESTIMATE. */
353
354/* FTOL AND GTOL ARE NONNEGATIVE INPUT VARIABLES. (In this reverse */
355/* communication implementation GTOL is defined in a COMMON */
356/* statement.) TERMINATION OCCURS WHEN THE SUFFICIENT DECREASE */
357/* CONDITION AND THE DIRECTIONAL DERIVATIVE CONDITION ARE */
358/* SATISFIED. */
359
360/* XTOL IS A NONNEGATIVE INPUT VARIABLE. TERMINATION OCCURS */
361/* WHEN THE RELATIVE WIDTH OF THE INTERVAL OF UNCERTAINTY */
362/* IS AT MOST XTOL. */
363
364/* STPMIN AND STPMAX ARE NONNEGATIVE INPUT VARIABLES WHICH */
365/* SPECIFY LOWER AND UPPER BOUNDS FOR THE STEP. (In this reverse */
366/* communication implementatin they are defined in a COMMON */
367/* statement). */
368
369/* MAXFEV IS A POSITIVE INTEGER INPUT VARIABLE. TERMINATION */
370/* OCCURS WHEN THE NUMBER OF CALLS TO FCN IS AT LEAST */
371/* MAXFEV BY THE END OF AN ITERATION. */
372
373/* INFO IS AN INTEGER OUTPUT VARIABLE SET AS FOLLOWS: */
374
375/* INFO = 0 IMPROPER INPUT PARAMETERS. */
376
377/* INFO =-1 A RETURN IS MADE TO COMPUTE THE FUNCTION AND GRADIENT. */
378/* NFEV IS AN INTEGER OUTPUT VARIABLE SET TO THE NUMBER OF */
379/* CALLS TO FCN. */
380
381/* WA IS A WORK ARRAY OF LENGTH N. */
382
383/* SUBPROGRAMS CALLED */
384
385/* MCSTEP */
386
387/* FORTRAN-SUPPLIED...ABS,MAX,MIN */
388
389/* ARGONNE NATIONAL LABORATORY. MINPACK PROJECT. JUNE 1983 */
390/* JORGE J. MORE', DAVID J. THUENTE */
391
392/* ********** */
393
394#endif // #ifndef itkMoreThuenteLineSearchOptimizer_h
A base class for LineSearch optimizers.
ITK version of the MoreThuente line search algorithm.
void GetCurrentValueAndDerivative(MeasureType &value, DerivativeType &derivative) const override
void SetInitialDerivative(const DerivativeType &derivative) override
~MoreThuenteLineSearchOptimizer() override=default
virtual void ComputeCurrentValueAndDerivative()
MeasureType GetCurrentValue() const override
virtual void TestConvergence(bool &stop)
ITK_DISALLOW_COPY_AND_MOVE(MoreThuenteLineSearchOptimizer)
void BoundStep(double &step) const
void PrintSelf(std::ostream &os, Indent indent) const override
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 ForceSufficientDecreaseInIntervalWidth()
virtual void UpdateIntervalMinimumAndMaximum()
void GetCurrentDerivative(DerivativeType &derivative) const override
virtual double GetCurrentDirectionalDerivative() const
void SetInitialValue(MeasureType value) override


Generated on 2023-01-13 for elastix by doxygen 1.9.6 elastix logo