1 -- Created on: 1991-05-14
2 -- Created by: Laurent PAINNOT
3 -- Copyright (c) 1991-1999 Matra Datavision
4 -- Copyright (c) 1999-2014 OPEN CASCADE SAS
6 -- This file is part of Open CASCADE Technology software library.
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.
14 -- Alternatively, this file may be used under the terms of Open CASCADE
15 -- commercial license or contractual agreement.
17 class NewtonFunctionSetRoot from math
19 -- This class computes the root of a set of N functions of N variables,
20 -- knowing an initial guess at the solution and using the
21 -- Newton Raphson algorithm. Knowledge of all the partial
22 -- derivatives (Jacobian) is required.
24 uses Vector from math, Matrix from math, IntegerVector from math,
25 FunctionSetWithDerivatives from math,
28 raises NotDone from StdFail,
29 DimensionError from Standard
33 Create(theFunction: in out FunctionSetWithDerivatives;
34 theXTolerance: Vector; theFTolerance: Real;
35 tehNbIterations: Integer = 100)
37 -- Initialize correctly all the fields of this class.
38 -- The range (1, F.NbVariables()) must be especially respected for
39 -- all vectors and matrix declarations.
40 returns NewtonFunctionSetRoot;
43 Create(theFunction: in out FunctionSetWithDerivatives;
44 theFTolerance: Real; theNbIterations: Integer = 100)
46 -- This constructor should be used in a sub-class to initialize
47 -- correctly all the fields of this class.
48 -- The range (1, F.NbVariables()) must be especially respected for
49 -- all vectors and matrix declarations.
50 -- The method SetTolerance must be called before performing the algorithm.
51 returns NewtonFunctionSetRoot;
55 ---Purpose: Destructor alias.
56 ---C++: alias " Standard_EXPORT virtual ~math_NewtonFunctionSetRoot();"
59 SetTolerance(me: in out; XTol: Vector)
60 ---Purpose: Initializes the tolerance values for the unknowns.
64 Perform(me: in out; theFunction: in out FunctionSetWithDerivatives; theStartingPoint: Vector)
66 -- The Newton method is done to improve the root of the function
67 -- from the initial guess point. The solution is found when:
68 -- abs(Xj - Xj-1)(i) <= XTol(i) and abs(Fi) <= FTol for all i;
72 Perform(me: in out; theFunction: in out FunctionSetWithDerivatives;
73 theStartingPoint: Vector; theInfBound, theSupBound: Vector)
75 -- The Newton method is done to improve the root of the function
76 -- from the initial guess point. Bounds may be given, to constrain the solution.
77 -- The solution is found when:
78 -- abs(Xj - Xj-1)(i) <= XTol(i) and abs(Fi) <= FTol for all i;
82 IsSolutionReached(me: in out; F: in out FunctionSetWithDerivatives)
84 -- This method is called at the end of each iteration to check if the
86 -- Vectors DeltaX, Fvalues and Jacobian Matrix are consistent with the
87 -- possible solution Vector Sol and can be inspected to decide whether
88 -- the solution is reached or not.
90 returns Boolean is virtual;
94 ---Purpose: Returns true if the computations are successful, otherwise returns false.
101 ---Purpose: Returns the value of the root of function F.
103 -- StdFail_NotDone if the algorithm fails (and IsDone returns false).
105 ---C++: return const&
111 Root(me; Root: out Vector)
112 ---Purpose: outputs the root vector in Root.
113 -- Exception NotDone is raised if the root was not found.
114 -- Exception DimensionError is raised if the range of Root is
115 -- not equal to the range of the StartingPoint.
124 ---Purpose: Outputs the state number associated with the solution
133 ---Purpose: Returns the matrix value of the derivative at the root.
134 -- Exception NotDone is raised if the root was not found.
136 ---C++: return const&
142 Derivative(me; Der: out Matrix)
143 ---Purpose: Outputs the matrix value of the derivative at the root in
145 -- Exception NotDone is raised if the root was not found.
146 -- Exception DimensionError is raised if the range of Der is
147 -- not equal to the range of the StartingPoint.
154 FunctionSetErrors(me)
155 ---Purpose: Returns the vector value of the error done on the
156 -- functions at the root.
157 -- Exception NotDone is raised if the root was not found.
159 ---C++: return const&
165 FunctionSetErrors(me; Err: out Vector)
166 ---Purpose: Outputs the vector value of the error done on the
167 -- functions at the root in Err.
168 -- Exception NotDone is raised if the root was not found.
169 -- Exception DimensionError is raised if the range of Err is
170 -- not equal to the range of the StartingPoint.
178 ---Purpose: Returns the number of iterations really done
179 -- during the computation of the Root.
180 -- Exception NotDone is raised if the root was not found.
187 Dump(me; o: in out OStream)
188 ---Purpose: Prints information on the current state of the object.
189 -- Is used to redefine the operator <<.
198 TolX: Vector is protected;
199 TolF: Real is protected;
201 Indx: IntegerVector is protected;
202 Scratch: Vector is protected;
203 Sol: Vector is protected;
204 DeltaX: Vector is protected;
205 FValues: Vector is protected;
206 Jacobian: Matrix is protected;
209 end NewtonFunctionSetRoot;