0033661: Data Exchange, Step Import - Tessellated GDTs are not imported
[occt.git] / src / math / math_NewtonMinimum.hxx
CommitLineData
42cf5bc1 1// Created on: 1996-02-28
2// Created by: Philippe MANGIN
3// Copyright (c) 1996-1999 Matra Datavision
4// Copyright (c) 1999-2014 OPEN CASCADE SAS
5//
6// This file is part of Open CASCADE Technology software library.
7//
8// This library is free software; you can redistribute it and/or modify it under
9// the terms of the GNU Lesser General Public License version 2.1 as published
10// by the Free Software Foundation, with special exception defined in the file
11// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12// distribution for complete text of the license and disclaimer of any warranty.
13//
14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
16
17#ifndef _math_NewtonMinimum_HeaderFile
18#define _math_NewtonMinimum_HeaderFile
19
20#include <Standard.hxx>
21#include <Standard_DefineAlloc.hxx>
42cf5bc1 22
f79b19a1 23#include <Precision.hxx>
42cf5bc1 24#include <math_Status.hxx>
25#include <math_Vector.hxx>
26#include <math_Matrix.hxx>
42cf5bc1 27#include <Standard_Integer.hxx>
28#include <Standard_OStream.hxx>
42cf5bc1 29class math_MultipleVarFunctionWithHessian;
30
31
32
33class math_NewtonMinimum
34{
35public:
36
37 DEFINE_STANDARD_ALLOC
38
39
40
41 //! The tolerance required on the solution is given by Tolerance.
42 //! Iteration are stopped if (!WithSingularity) and H(F(Xi)) is not definite
43 //! positive (if the smaller eigenvalue of H < Convexity)
44 //! or IsConverged() returns True for 2 successives Iterations.
45 //! Warning: This constructor does not perform computation.
f79b19a1 46 Standard_EXPORT math_NewtonMinimum(const math_MultipleVarFunctionWithHessian& theFunction,
47 const Standard_Real theTolerance = Precision::Confusion(),
48 const Standard_Integer theNbIterations = 40,
49 const Standard_Real theConvexity = 1.0e-6,
50 const Standard_Boolean theWithSingularity = Standard_True);
42cf5bc1 51
52 //! Search the solution.
53 Standard_EXPORT void Perform (math_MultipleVarFunctionWithHessian& theFunction, const math_Vector& theStartingPoint);
54
e6f550da 55 //! Destructor
42cf5bc1 56 Standard_EXPORT virtual ~math_NewtonMinimum();
57
58
59 //! This method is called at the end of each iteration to check the convergence:
60 //! || Xi+1 - Xi || < Tolerance or || F(Xi+1) - F(Xi)|| < Tolerance * || F(Xi) ||
61 //! It can be redefined in a sub-class to implement a specific test.
62 virtual Standard_Boolean IsConverged() const;
63
a25d5aaa 64 //! Tests if an error has occurred.
42cf5bc1 65 Standard_Boolean IsDone() const;
66
67 //! Tests if the Function is convexe during optimization.
68 Standard_Boolean IsConvex() const;
69
70 //! returns the location vector of the minimum.
a25d5aaa 71 //! Exception NotDone is raised if an error has occurred.
42cf5bc1 72 const math_Vector& Location() const;
73
74 //! outputs the location vector of the minimum in Loc.
a25d5aaa 75 //! Exception NotDone is raised if an error has occurred.
42cf5bc1 76 //! Exception DimensionError is raised if the range of Loc is not
77 //! equal to the range of the StartingPoint.
78 void Location (math_Vector& Loc) const;
79
80 //! Set boundaries.
81 Standard_EXPORT void SetBoundary (const math_Vector& theLeftBorder, const math_Vector& theRightBorder);
82
83 //! returns the value of the minimum.
84 //! Exception NotDone is raised if the minimum was not found.
85 Standard_Real Minimum() const;
86
87 //! returns the gradient vector at the minimum.
a25d5aaa 88 //! Exception NotDone is raised if an error has occurred.
89 //! The minimum was not found.
42cf5bc1 90 const math_Vector& Gradient() const;
91
92 //! outputs the gradient vector at the minimum in Grad.
93 //! Exception NotDone is raised if the minimum was not found.
94 //! Exception DimensionError is raised if the range of Grad is not
95 //! equal to the range of the StartingPoint.
96 void Gradient (math_Vector& Grad) const;
97
98 //! returns the number of iterations really done in the
99 //! calculation of the minimum.
a25d5aaa 100 //! The exception NotDone is raised if an error has occurred.
42cf5bc1 101 Standard_Integer NbIterations() const;
243505b8 102
103 //! Returns the Status of computation.
a25d5aaa 104 //! The exception NotDone is raised if an error has occurred.
243505b8 105 math_Status GetStatus() const;
106
42cf5bc1 107
108 //! Prints on the stream o information on the current state
109 //! of the object.
110 //! Is used to redefine the operator <<.
111 Standard_EXPORT void Dump (Standard_OStream& o) const;
112
113
114
115
116protected:
117
118
119
120 math_Status TheStatus;
121 math_Vector TheLocation;
122 math_Vector TheGradient;
123 math_Vector TheStep;
124 math_Matrix TheHessian;
125 Standard_Real PreviousMinimum;
126 Standard_Real TheMinimum;
127 Standard_Real MinEigenValue;
128 Standard_Real XTol;
129 Standard_Real CTol;
130 Standard_Integer nbiter;
131 Standard_Boolean NoConvexTreatement;
132 Standard_Boolean Convex;
133 Standard_Boolean myIsBoundsDefined;
134 math_Vector myLeft;
135 math_Vector myRight;
136
137
138private:
139
140
141
142 Standard_Boolean Done;
143 Standard_Integer Itermax;
144
145
146};
147
148
149#include <math_NewtonMinimum.lxx>
150
151
152
153
154
155#endif // _math_NewtonMinimum_HeaderFile