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