|
||||
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_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 0029 0030 //! this class implements the Fletcher-Reeves-Polak_Ribiere minimization 0031 //! algorithm of a function of multiple variables. 0032 //! Knowledge of the function's gradient is required. 0033 class math_FRPR 0034 { 0035 public: 0036 0037 DEFINE_STANDARD_ALLOC 0038 0039 0040 0041 //! Initializes the computation of the minimum of F. 0042 //! Warning: constructor does not perform computations. 0043 Standard_EXPORT math_FRPR(const math_MultipleVarFunctionWithGradient& theFunction, const Standard_Real theTolerance, const Standard_Integer theNbIterations = 200, const Standard_Real theZEPS = 1.0e-12); 0044 0045 //! Destructor 0046 Standard_EXPORT virtual ~math_FRPR(); 0047 0048 0049 //! The solution F = Fi is found when 0050 //! 2.0 * abs(Fi - Fi-1) <= Tolerance * (abs(Fi) + abs(Fi-1) + ZEPS). 0051 Standard_EXPORT void Perform (math_MultipleVarFunctionWithGradient& theFunction, const math_Vector& theStartingPoint); 0052 0053 0054 //! The solution F = Fi is found when: 0055 //! 2.0 * abs(Fi - Fi-1) <= Tolerance * (abs(Fi) + abs(Fi-1)) + ZEPS. 0056 //! The maximum number of iterations allowed is given by NbIterations. 0057 virtual Standard_Boolean IsSolutionReached (math_MultipleVarFunctionWithGradient& theFunction); 0058 0059 //! Returns true if the computations are successful, otherwise returns false. 0060 Standard_Boolean IsDone() const; 0061 0062 //! returns the location vector of the minimum. 0063 //! Exception NotDone is raised if the minimum was not found. 0064 const math_Vector& Location() const; 0065 0066 //! outputs the location vector of the minimum in Loc. 0067 //! Exception NotDone is raised if the minimum was not found. 0068 //! Exception DimensionError is raised if the range of Loc is not 0069 //! equal to the range of the StartingPoint. 0070 void Location (math_Vector& Loc) const; 0071 0072 //! returns the value of the minimum. 0073 //! Exception NotDone is raised if the minimum was not found. 0074 Standard_Real Minimum() const; 0075 0076 //! returns the gradient vector at the minimum. 0077 //! Exception NotDone is raised if the minimum was not found. 0078 const math_Vector& Gradient() const; 0079 0080 //! outputs the gradient vector at the minimum in Grad. 0081 //! Exception NotDone is raised if the minimum was not found. 0082 //! Exception DimensionError is raised if the range of Grad is not 0083 //! equal to the range of the StartingPoint. 0084 void Gradient (math_Vector& Grad) const; 0085 0086 //! returns the number of iterations really done during the 0087 //! computation of the minimum. 0088 //! Exception NotDone is raised if the minimum was not found. 0089 Standard_Integer NbIterations() const; 0090 0091 //! Prints on the stream o information on the current state 0092 //! of the object. 0093 //! Is used to redefine the operator <<. 0094 Standard_EXPORT void Dump (Standard_OStream& o) const; 0095 0096 0097 0098 0099 protected: 0100 0101 0102 0103 math_Vector TheLocation; 0104 math_Vector TheGradient; 0105 Standard_Real TheMinimum; 0106 Standard_Real PreviousMinimum; 0107 Standard_Real XTol; 0108 Standard_Real EPSZ; 0109 0110 0111 private: 0112 0113 0114 0115 Standard_Boolean Done; 0116 Standard_Integer Iter; 0117 Standard_Integer State; 0118 math_Status TheStatus; 0119 Standard_Integer Itermax; 0120 0121 0122 }; 0123 0124 0125 #include <math_FRPR.lxx> 0126 0127 0128 0129 0130 0131 #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 |