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
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 NewtonMinimum from math
21 uses Vector from math,
24 MultipleVarFunctionWithHessian from math,
27 raises NotDone, DimensionError
31 Create(theFunction: in MultipleVarFunctionWithHessian;
32 theTolerance: Real=1.0e-7;
33 theNbIterations: Integer=40;
34 theConvexity: Real=1.0e-6;
35 theWithSingularity: Boolean = Standard_True)
37 -- The tolerance required on the solution is given by Tolerance.
38 -- Iteration are stopped if (!WithSingularity) and H(F(Xi)) is not definite
39 -- positive (if the smaller eigenvalue of H < Convexity)
40 -- or IsConverged() returns True for 2 successives Iterations.
41 -- Warning: This constructor does not perform computation.
42 returns NewtonMinimum;
45 Perform(me: in out; theFunction: in out MultipleVarFunctionWithHessian;
46 theStartingPoint: Vector)
47 ---Purpose: Search the solution.
52 ---Purpose: Destructor alias.
54 ---C++: alias " Standard_EXPORT virtual ~math_NewtonMinimum();"
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.
63 returns Boolean is virtual;
67 ---Purpose: Tests if an error has occured.
74 ---Purpose: Tests if the Function is convexe during optimization.
80 ---Purpose: returns the location vector of the minimum.
81 -- Exception NotDone is raised if an error has occured.
90 Location(me; Loc: out Vector)
91 ---Purpose: outputs the location vector of the minimum in Loc.
92 -- Exception NotDone is raised if an error has occured.
93 -- Exception DimensionError is raised if the range of Loc is not
94 -- equal to the range of the StartingPoint.
97 raises DimensionError,
103 ---Purpose: returns the value of the minimum.
104 -- Exception NotDone is raised if the minimum was not found.
113 ---Purpose: returns the gradient vector at the minimum.
114 -- Exception NotDone is raised if an error has occured.the minimum was not found.
116 ---C++: return const&
123 Gradient(me; Grad: out Vector)
124 ---Purpose: outputs the gradient vector at the minimum in Grad.
125 -- Exception NotDone is raised if the minimum was not found.
126 -- Exception DimensionError is raised if the range of Grad is not
127 -- equal to the range of the StartingPoint.
130 raises DimensionError,
136 ---Purpose: returns the number of iterations really done in the
137 -- calculation of the minimum.
138 -- The exception NotDone is raised if an error has occured.
146 Dump(me; o: in out OStream)
147 ---Purpose: Prints on the stream o information on the current state
149 -- Is used to redefine the operator <<.
156 TheStatus: Status is protected;
157 TheLocation: Vector is protected;
158 TheGradient: Vector is protected;
159 TheStep: Vector is protected;
160 TheHessian : Matrix is protected;
161 PreviousMinimum: Real is protected;
162 TheMinimum: Real is protected;
163 MinEigenValue: Real is protected;
164 XTol: Real is protected;
165 CTol: Real is protected;
166 nbiter: Integer is protected;
167 NoConvexTreatement: Boolean is protected;
168 Convex : Boolean is protected;