|
|
|||
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_FRPR_HeaderFile 0018 #define _math_FRPR_HeaderFile 0019 0020 #include <Standard.hxx> 0021 #include <Standard_DefineAlloc.hxx> 0022 0023 #include <math_Vector.hxx> 0024 #include <math_Status.hxx> 0025 #include <Standard_OStream.hxx> 0026 class math_MultipleVarFunctionWithGradient; 0027 0028 //! this class implements the Fletcher-Reeves-Polak_Ribiere minimization 0029 //! algorithm of a function of multiple variables. 0030 //! Knowledge of the function's gradient is required. 0031 class math_FRPR 0032 { 0033 public: 0034 DEFINE_STANDARD_ALLOC 0035 0036 //! Initializes the computation of the minimum of F. 0037 //! Warning: constructor does not perform computations. 0038 Standard_EXPORT math_FRPR(const math_MultipleVarFunctionWithGradient& theFunction, 0039 const double theTolerance, 0040 const int theNbIterations = 200, 0041 const double theZEPS = 1.0e-12); 0042 0043 //! Destructor 0044 Standard_EXPORT virtual ~math_FRPR(); 0045 0046 //! The solution F = Fi is found when 0047 //! 2.0 * abs(Fi - Fi-1) <= Tolerance * (abs(Fi) + abs(Fi-1) + ZEPS). 0048 Standard_EXPORT void Perform(math_MultipleVarFunctionWithGradient& theFunction, 0049 const math_Vector& theStartingPoint); 0050 0051 //! The solution F = Fi is found when: 0052 //! 2.0 * abs(Fi - Fi-1) <= Tolerance * (abs(Fi) + abs(Fi-1)) + ZEPS. 0053 //! The maximum number of iterations allowed is given by NbIterations. 0054 virtual bool IsSolutionReached(math_MultipleVarFunctionWithGradient& theFunction); 0055 0056 //! Returns true if the computations are successful, otherwise returns false. 0057 bool IsDone() const; 0058 0059 //! returns the location vector of the minimum. 0060 //! Exception NotDone is raised if the minimum was not found. 0061 const math_Vector& Location() const; 0062 0063 //! outputs the location vector of the minimum in Loc. 0064 //! Exception NotDone is raised if the minimum was not found. 0065 //! Exception DimensionError is raised if the range of Loc is not 0066 //! equal to the range of the StartingPoint. 0067 void Location(math_Vector& Loc) const; 0068 0069 //! returns the value of the minimum. 0070 //! Exception NotDone is raised if the minimum was not found. 0071 double Minimum() const; 0072 0073 //! returns the gradient vector at the minimum. 0074 //! Exception NotDone is raised if the minimum was not found. 0075 const math_Vector& Gradient() const; 0076 0077 //! outputs the gradient vector at the minimum in Grad. 0078 //! Exception NotDone is raised if the minimum was not found. 0079 //! Exception DimensionError is raised if the range of Grad is not 0080 //! equal to the range of the StartingPoint. 0081 void Gradient(math_Vector& Grad) const; 0082 0083 //! returns the number of iterations really done during the 0084 //! computation of the minimum. 0085 //! Exception NotDone is raised if the minimum was not found. 0086 int NbIterations() const; 0087 0088 //! Prints on the stream o information on the current state 0089 //! of the object. 0090 //! Is used to redefine the operator <<. 0091 Standard_EXPORT void Dump(Standard_OStream& o) const; 0092 0093 protected: 0094 math_Vector TheLocation; 0095 math_Vector TheGradient; 0096 double TheMinimum; 0097 double PreviousMinimum; 0098 double XTol; 0099 double EPSZ; 0100 0101 private: 0102 bool Done; 0103 int Iter; 0104 int State; 0105 math_Status TheStatus; 0106 int Itermax; 0107 }; 0108 0109 #include <math_FRPR.lxx> 0110 0111 #endif // _math_FRPR_HeaderFile
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|