|
|
|||
File indexing completed on 2026-09-21 09:17:45
0001 // Created on: 1996-02-28 0002 // Created by: Philippe MANGIN 0003 // Copyright (c) 1996-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_NewtonMinimum_HeaderFile 0018 #define _math_NewtonMinimum_HeaderFile 0019 0020 #include <Standard.hxx> 0021 #include <Standard_DefineAlloc.hxx> 0022 0023 #include <Precision.hxx> 0024 #include <math_Status.hxx> 0025 #include <math_Vector.hxx> 0026 #include <math_Matrix.hxx> 0027 #include <Standard_Integer.hxx> 0028 #include <Standard_OStream.hxx> 0029 class math_MultipleVarFunctionWithHessian; 0030 0031 class math_NewtonMinimum 0032 { 0033 public: 0034 DEFINE_STANDARD_ALLOC 0035 0036 //! The tolerance required on the solution is given by Tolerance. 0037 //! Iteration are stopped if (!WithSingularity) and H(F(Xi)) is not definite 0038 //! positive (if the smaller eigenvalue of H < Convexity) 0039 //! or IsConverged() returns True for 2 successives Iterations. 0040 //! Warning: This constructor does not perform computation. 0041 Standard_EXPORT math_NewtonMinimum(const math_MultipleVarFunctionWithHessian& theFunction, 0042 const double theTolerance = Precision::Confusion(), 0043 const int theNbIterations = 40, 0044 const double theConvexity = 1.0e-6, 0045 const bool theWithSingularity = true); 0046 0047 //! Search the solution. 0048 Standard_EXPORT void Perform(math_MultipleVarFunctionWithHessian& theFunction, 0049 const math_Vector& theStartingPoint); 0050 0051 //! Destructor 0052 Standard_EXPORT virtual ~math_NewtonMinimum(); 0053 0054 //! This method is called at the end of each iteration to check the convergence: 0055 //! || Xi+1 - Xi || < Tolerance or || F(Xi+1) - F(Xi)|| < Tolerance * || F(Xi) || 0056 //! It can be redefined in a sub-class to implement a specific test. 0057 virtual bool IsConverged() const; 0058 0059 //! Tests if an error has occurred. 0060 bool IsDone() const; 0061 0062 //! Tests if the Function is convexe during optimization. 0063 bool IsConvex() const; 0064 0065 //! returns the location vector of the minimum. 0066 //! Exception NotDone is raised if an error has occurred. 0067 const math_Vector& Location() const; 0068 0069 //! outputs the location vector of the minimum in Loc. 0070 //! Exception NotDone is raised if an error has occurred. 0071 //! Exception DimensionError is raised if the range of Loc is not 0072 //! equal to the range of the StartingPoint. 0073 void Location(math_Vector& Loc) const; 0074 0075 //! Set boundaries. 0076 Standard_EXPORT void SetBoundary(const math_Vector& theLeftBorder, 0077 const math_Vector& theRightBorder); 0078 0079 //! returns the value of the minimum. 0080 //! Exception NotDone is raised if the minimum was not found. 0081 double Minimum() const; 0082 0083 //! returns the gradient vector at the minimum. 0084 //! Exception NotDone is raised if an error has occurred. 0085 //! The minimum was not found. 0086 const math_Vector& Gradient() const; 0087 0088 //! outputs the gradient vector at the minimum in Grad. 0089 //! Exception NotDone is raised if the minimum was not found. 0090 //! Exception DimensionError is raised if the range of Grad is not 0091 //! equal to the range of the StartingPoint. 0092 void Gradient(math_Vector& Grad) const; 0093 0094 //! returns the number of iterations really done in the 0095 //! calculation of the minimum. 0096 //! The exception NotDone is raised if an error has occurred. 0097 int NbIterations() const; 0098 0099 //! Returns the Status of computation. 0100 //! The exception NotDone is raised if an error has occurred. 0101 math_Status GetStatus() const; 0102 0103 //! Prints on the stream o information on the current state 0104 //! of the object. 0105 //! Is used to redefine the operator <<. 0106 Standard_EXPORT void Dump(Standard_OStream& o) const; 0107 0108 protected: 0109 math_Status TheStatus; 0110 math_Vector TheLocation; 0111 math_Vector TheGradient; 0112 math_Vector TheStep; 0113 math_Matrix TheHessian; 0114 double PreviousMinimum; 0115 double TheMinimum; 0116 double MinEigenValue; 0117 double XTol; 0118 double CTol; 0119 int nbiter; 0120 bool NoConvexTreatement; 0121 bool Convex; 0122 bool myIsBoundsDefined; 0123 math_Vector myLeft; 0124 math_Vector myRight; 0125 0126 private: 0127 bool Done; 0128 int Itermax; 0129 }; 0130 0131 #include <math_NewtonMinimum.lxx> 0132 0133 #endif // _math_NewtonMinimum_HeaderFile
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|