|
||||
File indexing completed on 2025-01-18 10:04:15
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 0032 0033 class math_NewtonMinimum 0034 { 0035 public: 0036 0037 DEFINE_STANDARD_ALLOC 0038 0039 0040 0041 //! The tolerance required on the solution is given by Tolerance. 0042 //! Iteration are stopped if (!WithSingularity) and H(F(Xi)) is not definite 0043 //! positive (if the smaller eigenvalue of H < Convexity) 0044 //! or IsConverged() returns True for 2 successives Iterations. 0045 //! Warning: This constructor does not perform computation. 0046 Standard_EXPORT math_NewtonMinimum(const math_MultipleVarFunctionWithHessian& theFunction, 0047 const Standard_Real theTolerance = Precision::Confusion(), 0048 const Standard_Integer theNbIterations = 40, 0049 const Standard_Real theConvexity = 1.0e-6, 0050 const Standard_Boolean theWithSingularity = Standard_True); 0051 0052 //! Search the solution. 0053 Standard_EXPORT void Perform (math_MultipleVarFunctionWithHessian& theFunction, const math_Vector& theStartingPoint); 0054 0055 //! Destructor 0056 Standard_EXPORT virtual ~math_NewtonMinimum(); 0057 0058 0059 //! This method is called at the end of each iteration to check the convergence: 0060 //! || Xi+1 - Xi || < Tolerance or || F(Xi+1) - F(Xi)|| < Tolerance * || F(Xi) || 0061 //! It can be redefined in a sub-class to implement a specific test. 0062 virtual Standard_Boolean IsConverged() const; 0063 0064 //! Tests if an error has occurred. 0065 Standard_Boolean IsDone() const; 0066 0067 //! Tests if the Function is convexe during optimization. 0068 Standard_Boolean IsConvex() const; 0069 0070 //! returns the location vector of the minimum. 0071 //! Exception NotDone is raised if an error has occurred. 0072 const math_Vector& Location() const; 0073 0074 //! outputs the location vector of the minimum in Loc. 0075 //! Exception NotDone is raised if an error has occurred. 0076 //! Exception DimensionError is raised if the range of Loc is not 0077 //! equal to the range of the StartingPoint. 0078 void Location (math_Vector& Loc) const; 0079 0080 //! Set boundaries. 0081 Standard_EXPORT void SetBoundary (const math_Vector& theLeftBorder, const math_Vector& theRightBorder); 0082 0083 //! returns the value of the minimum. 0084 //! Exception NotDone is raised if the minimum was not found. 0085 Standard_Real Minimum() const; 0086 0087 //! returns the gradient vector at the minimum. 0088 //! Exception NotDone is raised if an error has occurred. 0089 //! The minimum was not found. 0090 const math_Vector& Gradient() const; 0091 0092 //! outputs the gradient vector at the minimum in Grad. 0093 //! Exception NotDone is raised if the minimum was not found. 0094 //! Exception DimensionError is raised if the range of Grad is not 0095 //! equal to the range of the StartingPoint. 0096 void Gradient (math_Vector& Grad) const; 0097 0098 //! returns the number of iterations really done in the 0099 //! calculation of the minimum. 0100 //! The exception NotDone is raised if an error has occurred. 0101 Standard_Integer NbIterations() const; 0102 0103 //! Returns the Status of computation. 0104 //! The exception NotDone is raised if an error has occurred. 0105 math_Status GetStatus() const; 0106 0107 0108 //! Prints on the stream o information on the current state 0109 //! of the object. 0110 //! Is used to redefine the operator <<. 0111 Standard_EXPORT void Dump (Standard_OStream& o) const; 0112 0113 0114 0115 0116 protected: 0117 0118 0119 0120 math_Status TheStatus; 0121 math_Vector TheLocation; 0122 math_Vector TheGradient; 0123 math_Vector TheStep; 0124 math_Matrix TheHessian; 0125 Standard_Real PreviousMinimum; 0126 Standard_Real TheMinimum; 0127 Standard_Real MinEigenValue; 0128 Standard_Real XTol; 0129 Standard_Real CTol; 0130 Standard_Integer nbiter; 0131 Standard_Boolean NoConvexTreatement; 0132 Standard_Boolean Convex; 0133 Standard_Boolean myIsBoundsDefined; 0134 math_Vector myLeft; 0135 math_Vector myRight; 0136 0137 0138 private: 0139 0140 0141 0142 Standard_Boolean Done; 0143 Standard_Integer Itermax; 0144 0145 0146 }; 0147 0148 0149 #include <math_NewtonMinimum.lxx> 0150 0151 0152 0153 0154 0155 #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 |