|
|
|||
File indexing completed on 2026-09-22 08:58:35
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 //! This class implements the Brent's method to find the minimum of 0029 //! a function of a single variable. 0030 //! No knowledge of the derivative is required. 0031 class math_BrentMinimum 0032 { 0033 public: 0034 DEFINE_STANDARD_ALLOC 0035 0036 //! This constructor should be used in a sub-class to initialize 0037 //! correctly all the fields of this class. 0038 Standard_EXPORT math_BrentMinimum(const double TolX, 0039 const int NbIterations = 100, 0040 const double ZEPS = 1.0e-12); 0041 0042 //! This constructor should be used in a sub-class to initialize 0043 //! correctly all the fields of this class. 0044 //! It has to be used if F(Bx) is known. 0045 Standard_EXPORT math_BrentMinimum(const double TolX, 0046 const double Fbx, 0047 const int NbIterations = 100, 0048 const double ZEPS = 1.0e-12); 0049 0050 //! Destructor 0051 Standard_EXPORT virtual ~math_BrentMinimum(); 0052 0053 //! Brent minimization is performed on function F from a given 0054 //! bracketing triplet of abscissas Ax, Bx, Cx (such that Bx is 0055 //! between Ax and Cx, F(Bx) is less than both F(Bx) and F(Cx)) 0056 //! The solution is found when: abs(Xi - Xi-1) <= TolX * abs(Xi) + ZEPS; 0057 Standard_EXPORT void Perform(math_Function& F, const double Ax, const double Bx, const double Cx); 0058 0059 //! This method is called at the end of each iteration to check if the 0060 //! solution is found. 0061 //! It can be redefined in a sub-class to implement a specific test to 0062 //! stop the iterations. 0063 virtual bool IsSolutionReached(math_Function& theFunction); 0064 0065 //! Returns true if the computations are successful, otherwise returns false. 0066 bool IsDone() const; 0067 0068 //! returns the location value of the minimum. 0069 //! Exception NotDone is raised if the minimum was not found. 0070 double Location() const; 0071 0072 //! returns the value of the minimum. 0073 //! Exception NotDone is raised if the minimum was not found. 0074 double Minimum() const; 0075 0076 //! returns the number of iterations really done during the 0077 //! computation of the minimum. 0078 //! Exception NotDone is raised if the minimum was not found. 0079 int NbIterations() const; 0080 0081 //! Prints on the stream o information on the current state 0082 //! of the object. 0083 //! Is used to redefine the operator <<. 0084 Standard_EXPORT void Dump(Standard_OStream& o) const; 0085 0086 protected: 0087 double a; 0088 double b; 0089 double x; 0090 double fx; 0091 double fv; 0092 double fw; 0093 double XTol; 0094 double EPSZ; 0095 0096 private: 0097 bool Done; 0098 int iter; 0099 int Itermax; 0100 bool myF; 0101 }; 0102 0103 #include <math_BrentMinimum.lxx> 0104 0105 #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 |
|