ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/branches/development/src/optimization/EndCriteria.hpp
Revision: 1741
Committed: Tue Jun 5 18:02:44 2012 UTC (12 years, 11 months ago) by gezelter
File size: 4478 byte(s)
Log Message:
Adding initial import of optimization library

File Contents

# Content
1 /* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3 /*
4 Copyright (C) 2006, 2007 Ferdinando Ametrano
5 Copyright (C) 2007 Marco Bianchetti
6 Copyright (C) 2001, 2002, 2003 Nicolas Di Césaré
7
8 This file is part of QuantLib, a free-software/open-source library
9 for financial quantitative analysts and developers - http://quantlib.org/
10
11 QuantLib is free software: you can redistribute it and/or modify it
12 under the terms of the QuantLib license. You should have received a
13 copy of the license along with this program; if not, please email
14 <quantlib-dev@lists.sf.net>. The license is also available online at
15 <http://quantlib.org/license.shtml>.
16
17 This program is distributed in the hope that it will be useful, but WITHOUT
18 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
19 FOR A PARTICULAR PURPOSE. See the license for more details.
20 */
21
22 /*! \file endcriteria.hpp
23 \brief Optimization criteria class
24 */
25
26 #ifndef quantlib_optimization_criteria_hpp
27 #define quantlib_optimization_criteria_hpp
28
29 #include "config.h"
30 #include <ostream>
31
32 namespace QuantLib {
33
34 //! Criteria to end optimization process:
35 /*! - maximum number of iterations AND minimum number of iterations around stationary point
36 - x (independent variable) stationary point
37 - y=f(x) (dependent variable) stationary point
38 - stationary gradient
39 */
40 class EndCriteria {
41 public:
42 enum Type {None,
43 MaxIterations,
44 StationaryPoint,
45 StationaryFunctionValue,
46 StationaryFunctionAccuracy,
47 ZeroGradientNorm,
48 Unknown};
49
50 //! Initialization constructor
51 EndCriteria(size_t maxIterations,
52 size_t maxStationaryStateIterations,
53 RealType rootEpsilon,
54 RealType functionEpsilon,
55 RealType gradientNormEpsilon);
56
57 // Inspectors
58 size_t maxIterations() const;
59 size_t maxStationaryStateIterations() const;
60 RealType rootEpsilon() const;
61 RealType functionEpsilon() const;
62 RealType gradientNormEpsilon() const;
63
64 /*! Test if the number of iterations is not too big
65 and if a minimum point is not reached */
66 bool operator()(const size_t iteration,
67 size_t& statState,
68 const bool positiveOptimization,
69 const RealType fold,
70 const RealType normgold,
71 const RealType fnew,
72 const RealType normgnew,
73 EndCriteria::Type& ecType) const;
74
75 /*! Test if the number of iteration is below MaxIterations */
76 bool checkMaxIterations(const size_t iteration,
77 EndCriteria::Type& ecType) const;
78 /*! Test if the root variation is below rootEpsilon */
79 bool checkStationaryPoint(const RealType xOld,
80 const RealType xNew,
81 size_t& statStateIterations,
82 EndCriteria::Type& ecType) const;
83 /*! Test if the function variation is below functionEpsilon */
84 bool checkStationaryFunctionValue(const RealType fxOld,
85 const RealType fxNew,
86 size_t& statStateIterations,
87 EndCriteria::Type& ecType) const;
88 /*! Test if the function value is below functionEpsilon */
89 bool checkStationaryFunctionAccuracy(const RealType f,
90 const bool positiveOptimization,
91 EndCriteria::Type& ecType) const;
92 /*! Test if the gradient norm value is below gradientNormEpsilon */
93 bool checkZeroGradientNorm(const RealType gNorm,
94 EndCriteria::Type& ecType) const;
95
96 protected:
97 //! Maximum number of iterations
98 size_t maxIterations_;
99 //! Maximun number of iterations in stationary state
100 mutable size_t maxStationaryStateIterations_;
101 //! root, function and gradient epsilons
102 RealType rootEpsilon_, functionEpsilon_, gradientNormEpsilon_;
103
104 };
105
106 std::ostream& operator<<(std::ostream& out, EndCriteria::Type ecType);
107
108 }
109
110 #endif

Properties

Name Value
svn:eol-style native