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