|
|
|||
File indexing completed on 2026-09-17 09:21:12
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_BracketMinimum_HeaderFile 0018 #define _math_BracketMinimum_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 //! Given two distinct initial points, BracketMinimum 0029 //! implements the computation of three points (a, b, c) which 0030 //! bracket the minimum of the function and verify A less than 0031 //! B, B less than C and F(B) less than F(A), F(B) less than F(C). 0032 //! 0033 //! The algorithm supports conditional optimization. By default no limits are 0034 //! applied to the parameter change. The method SetLimits defines the allowed range. 0035 //! If no minimum is found in limits then IsDone() will return false. The user 0036 //! is in charge of providing A and B to be in limits. 0037 class math_BracketMinimum 0038 { 0039 public: 0040 DEFINE_STANDARD_ALLOC 0041 0042 //! Constructor preparing A and B parameters only. It does not perform the job. 0043 math_BracketMinimum(const double A, const double B); 0044 0045 //! Given two initial values this class computes a 0046 //! bracketing triplet of abscissae Ax, Bx, Cx 0047 //! (such that Bx is between Ax and Cx, F(Bx) is 0048 //! less than both F(Bx) and F(Cx)) the Brent minimization is done 0049 //! on the function F. 0050 Standard_EXPORT math_BracketMinimum(math_Function& F, const double A, const double B); 0051 0052 //! Given two initial values this class computes a 0053 //! bracketing triplet of abscissae Ax, Bx, Cx 0054 //! (such that Bx is between Ax and Cx, F(Bx) is 0055 //! less than both F(Bx) and F(Cx)) the Brent minimization is done 0056 //! on the function F. 0057 //! This constructor has to be used if F(A) is known. 0058 Standard_EXPORT math_BracketMinimum(math_Function& F, 0059 const double A, 0060 const double B, 0061 const double FA); 0062 0063 //! Given two initial values this class computes a 0064 //! bracketing triplet of abscissae Ax, Bx, Cx 0065 //! (such that Bx is between Ax and Cx, F(Bx) is 0066 //! less than both F(Bx) and F(Cx)) the Brent minimization is done 0067 //! on the function F. 0068 //! This constructor has to be used if F(A) and F(B) are known. 0069 Standard_EXPORT math_BracketMinimum(math_Function& F, 0070 const double A, 0071 const double B, 0072 const double FA, 0073 const double FB); 0074 0075 //! Set limits of the parameter. By default no limits are applied to the parameter change. 0076 //! If no minimum is found in limits then IsDone() will return false. The user 0077 //! is in charge of providing A and B to be in limits. 0078 void SetLimits(const double theLeft, const double theRight); 0079 0080 //! Set function value at A 0081 void SetFA(const double theValue); 0082 0083 //! Set function value at B 0084 void SetFB(const double theValue); 0085 0086 //! The method performing the job. It is called automatically by constructors with the function. 0087 Standard_EXPORT void Perform(math_Function& F); 0088 0089 //! Returns true if the computations are successful, otherwise returns false. 0090 bool IsDone() const; 0091 0092 //! Returns the bracketed triplet of abscissae. 0093 //! Exceptions 0094 //! StdFail_NotDone if the algorithm fails (and IsDone returns false). 0095 Standard_EXPORT void Values(double& A, double& B, double& C) const; 0096 0097 //! returns the bracketed triplet function values. 0098 //! Exceptions 0099 //! StdFail_NotDone if the algorithm fails (and IsDone returns false). 0100 Standard_EXPORT void FunctionValues(double& FA, double& FB, double& FC) const; 0101 0102 //! Prints on the stream o information on the current state 0103 //! of the object. 0104 //! Is used to redefine the operator <<. 0105 Standard_EXPORT void Dump(Standard_OStream& o) const; 0106 0107 private: 0108 //! Limit the given value to become within the range [myLeft, myRight]. 0109 double Limited(const double theValue) const; 0110 0111 //! Limit the value of C (see Limited) and compute the function in it. 0112 //! If C occurs to be between A and B then swap parameters and function 0113 //! values of B and C. 0114 //! Return false in the case of C becomes equal to B or function calculation 0115 //! failure. 0116 bool LimitAndMayBeSwap(math_Function& F, 0117 const double theA, 0118 double& theB, 0119 double& theFB, 0120 double& theC, 0121 double& theFC) const; 0122 0123 private: 0124 bool Done; 0125 double Ax; 0126 double Bx; 0127 double Cx; 0128 double FAx; 0129 double FBx; 0130 double FCx; 0131 double myLeft; 0132 double myRight; 0133 bool myIsLimited; 0134 bool myFA; 0135 bool myFB; 0136 }; 0137 0138 #include <math_BracketMinimum.lxx> 0139 0140 #endif // _math_BracketMinimum_HeaderFile
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|