1 -- Created on: 1991-05-14
2 -- Created by: Laurent PAINNOT
3 -- Copyright (c) 1991-1999 Matra Datavision
4 -- Copyright (c) 1999-2012 OPEN CASCADE SAS
6 -- The content of this file is subject to the Open CASCADE Technology Public
7 -- License Version 6.5 (the "License"). You may not use the content of this file
8 -- except in compliance with the License. Please obtain a copy of the License
9 -- at http://www.opencascade.org and read it completely before using this file.
11 -- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 -- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
14 -- The Original Code and all software distributed under the License is
15 -- distributed on an "AS IS" basis, without warranty of any kind, and the
16 -- Initial Developer hereby disclaims all such warranties, including without
17 -- limitation, any warranties of merchantability, fitness for a particular
18 -- purpose or non-infringement. Please see the License for the specific terms
19 -- and conditions governing the rights and limitations under the License.
26 -- this class implements the Fletcher-Reeves-Polak_Ribiere minimization
27 -- algorithm of a function of multiple variables.
28 -- Knowledge of the function's gradient is required.
30 uses Vector from math, Matrix from math,
31 MultipleVarFunctionWithGradient from math,
35 raises DimensionError from Standard,
40 Create(F: in out MultipleVarFunctionWithGradient;
41 StartingPoint: Vector; Tolerance: Real;
42 NbIterations: Integer=200; ZEPS: Real=1.0e-12)
43 ---Purpose: Computes FRPR minimization function F from input vector
44 -- StartingPoint. The solution F = Fi is found when 2.0 *
45 -- abs(Fi - Fi-1) <= Tolerance * (abs(Fi) + abs(Fi-1) +
46 -- ZEPS). The maximum number of iterations allowed is given
51 Create(F: in out MultipleVarFunctionWithGradient;
53 NbIterations: Integer = 200;
56 -- Initializes the computation of the minimum of F.
58 -- A call to the Perform method must be made after this
59 -- initialization to compute the minimum of the function.
63 Delete(me:out) is virtual;
64 ---C++: alias "Standard_EXPORT virtual ~math_FRPR(){Delete();}"
66 Perform(me: in out; F: in out MultipleVarFunctionWithGradient;
67 StartingPoint: Vector)
68 ---Purpose: Use this method after a call to the initialization constructor
69 -- to compute the minimum of function F.
71 -- The initialization constructor must have been called before
72 -- the Perform method is called
77 IsSolutionReached(me: in out; F: in out MultipleVarFunctionWithGradient)
79 -- The solution F = Fi is found when :
80 -- 2.0 * abs(Fi - Fi-1) <= Tolerance * (abs(Fi) + abs(Fi-1)) + ZEPS.
81 -- The maximum number of iterations allowed is given by NbIterations.
88 ---Purpose: Returns true if the computations are successful, otherwise returns false.
96 ---Purpose: returns the location vector of the minimum.
97 -- Exception NotDone is raised if the minimum was not found.
106 Location(me; Loc: out Vector)
107 ---Purpose: outputs the location vector of the minimum in Loc.
108 -- Exception NotDone is raised if the minimum was not found.
109 -- Exception DimensionError is raised if the range of Loc is not
110 -- equal to the range of the StartingPoint.
112 raises DimensionError,
118 ---Purpose: returns the value of the minimum.
119 -- Exception NotDone is raised if the minimum was not found.
127 ---Purpose: returns the gradient vector at the minimum.
128 -- Exception NotDone is raised if the minimum was not found.
130 ---C++: return const&
136 Gradient(me; Grad: out Vector)
137 ---Purpose: outputs the gradient vector at the minimum in Grad.
138 -- Exception NotDone is raised if the minimum was not found.
139 -- Exception DimensionError is raised if the range of Grad is not
140 -- equal to the range of the StartingPoint.
143 raises DimensionError,
150 ---Purpose: returns the number of iterations really done during the
151 -- computation of the minimum.
152 -- Exception NotDone is raised if the minimum was not found.
160 Dump(me; o: in out OStream)
161 ---Purpose: Prints on the stream o information on the current state
163 -- Is used to redefine the operator <<.
171 TheLocation: Vector is protected;
172 TheGradient: Vector is protected;
173 TheMinimum: Real is protected;
174 PreviousMinimum: Real is protected;
177 XTol: Real is protected;
178 EPSZ: Real is protected;