|
||||
File indexing completed on 2025-01-18 10:04:14
0001 // Created on: 1991-05-14 0002 // Created by: Laurent PAINNOT 0003 // Copyright (c) 1991-1999 Matra Datavision 0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS 0005 // 0006 // This file is part of Open CASCADE Technology software library. 0007 // 0008 // This library is free software; you can redistribute it and/or modify it under 0009 // the terms of the GNU Lesser General Public License version 2.1 as published 0010 // by the Free Software Foundation, with special exception defined in the file 0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT 0012 // distribution for complete text of the license and disclaimer of any warranty. 0013 // 0014 // Alternatively, this file may be used under the terms of Open CASCADE 0015 // commercial license or contractual agreement. 0016 0017 #ifndef _math_BrentMinimum_HeaderFile 0018 #define _math_BrentMinimum_HeaderFile 0019 0020 #include <Standard.hxx> 0021 #include <Standard_DefineAlloc.hxx> 0022 #include <Standard_Handle.hxx> 0023 0024 #include <Standard_Real.hxx> 0025 #include <Standard_OStream.hxx> 0026 class math_Function; 0027 0028 0029 0030 //! This class implements the Brent's method to find the minimum of 0031 //! a function of a single variable. 0032 //! No knowledge of the derivative is required. 0033 class math_BrentMinimum 0034 { 0035 public: 0036 0037 DEFINE_STANDARD_ALLOC 0038 0039 0040 0041 //! This constructor should be used in a sub-class to initialize 0042 //! correctly all the fields of this class. 0043 Standard_EXPORT math_BrentMinimum(const Standard_Real TolX, const Standard_Integer NbIterations = 100, const Standard_Real ZEPS = 1.0e-12); 0044 0045 0046 //! This constructor should be used in a sub-class to initialize 0047 //! correctly all the fields of this class. 0048 //! It has to be used if F(Bx) is known. 0049 Standard_EXPORT math_BrentMinimum(const Standard_Real TolX, const Standard_Real Fbx, const Standard_Integer NbIterations = 100, const Standard_Real ZEPS = 1.0e-12); 0050 0051 //! Destructor 0052 Standard_EXPORT virtual ~math_BrentMinimum(); 0053 0054 0055 //! Brent minimization is performed on function F from a given 0056 //! bracketing triplet of abscissas Ax, Bx, Cx (such that Bx is 0057 //! between Ax and Cx, F(Bx) is less than both F(Bx) and F(Cx)) 0058 //! The solution is found when: abs(Xi - Xi-1) <= TolX * abs(Xi) + ZEPS; 0059 Standard_EXPORT void Perform (math_Function& F, const Standard_Real Ax, const Standard_Real Bx, const Standard_Real Cx); 0060 0061 0062 //! This method is called at the end of each iteration to check if the 0063 //! solution is found. 0064 //! It can be redefined in a sub-class to implement a specific test to 0065 //! stop the iterations. 0066 virtual Standard_Boolean IsSolutionReached (math_Function& theFunction); 0067 0068 //! Returns true if the computations are successful, otherwise returns false. 0069 Standard_Boolean IsDone() const; 0070 0071 //! returns the location value of the minimum. 0072 //! Exception NotDone is raised if the minimum was not found. 0073 Standard_Real Location() const; 0074 0075 //! returns the value of the minimum. 0076 //! Exception NotDone is raised if the minimum was not found. 0077 Standard_Real Minimum() const; 0078 0079 //! returns the number of iterations really done during the 0080 //! computation of the minimum. 0081 //! Exception NotDone is raised if the minimum was not found. 0082 Standard_Integer NbIterations() const; 0083 0084 //! Prints on the stream o information on the current state 0085 //! of the object. 0086 //! Is used to redefine the operator <<. 0087 Standard_EXPORT void Dump (Standard_OStream& o) const; 0088 0089 0090 0091 0092 protected: 0093 0094 0095 0096 Standard_Real a; 0097 Standard_Real b; 0098 Standard_Real x; 0099 Standard_Real fx; 0100 Standard_Real fv; 0101 Standard_Real fw; 0102 Standard_Real XTol; 0103 Standard_Real EPSZ; 0104 0105 0106 private: 0107 0108 0109 0110 Standard_Boolean Done; 0111 Standard_Integer iter; 0112 Standard_Integer Itermax; 0113 Standard_Boolean myF; 0114 0115 0116 }; 0117 0118 0119 #include <math_BrentMinimum.lxx> 0120 0121 0122 0123 0124 0125 #endif // _math_BrentMinimum_HeaderFile
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |