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.
19 -- this class implements the Fletcher-Reeves-Polak_Ribiere minimization
20 -- algorithm of a function of multiple variables.
21 -- Knowledge of the function's gradient is required.
23 uses Vector from math, Matrix from math,
24 MultipleVarFunctionWithGradient from math,
28 raises DimensionError from Standard,
33 Create(theFunction: in MultipleVarFunctionWithGradient;
35 theNbIterations: Integer = 200;
36 theZEPS: Real = 1.0e-12)
38 -- Initializes the computation of the minimum of F.
39 -- Warning: constructor does not perform computations.
43 ---Purpose: Destructor alias.
44 ---C++: alias " Standard_EXPORT virtual ~math_FRPR();"
48 theFunction: in out MultipleVarFunctionWithGradient;
49 theStartingPoint: Vector)
51 -- The solution F = Fi is found when
52 -- 2.0 * abs(Fi - Fi-1) <= Tolerance * (abs(Fi) + abs(Fi-1) + ZEPS).
56 IsSolutionReached(me: in out; theFunction: in out MultipleVarFunctionWithGradient)
58 -- The solution F = Fi is found when:
59 -- 2.0 * abs(Fi - Fi-1) <= Tolerance * (abs(Fi) + abs(Fi-1)) + ZEPS.
60 -- The maximum number of iterations allowed is given by NbIterations.
62 returns Boolean is virtual;
66 ---Purpose: Returns true if the computations are successful, otherwise returns false.
74 ---Purpose: returns the location vector of the minimum.
75 -- Exception NotDone is raised if the minimum was not found.
84 Location(me; Loc: out Vector)
85 ---Purpose: outputs the location vector of the minimum in Loc.
86 -- Exception NotDone is raised if the minimum was not found.
87 -- Exception DimensionError is raised if the range of Loc is not
88 -- equal to the range of the StartingPoint.
90 raises DimensionError,
96 ---Purpose: returns the value of the minimum.
97 -- Exception NotDone is raised if the minimum was not found.
105 ---Purpose: returns the gradient vector at the minimum.
106 -- Exception NotDone is raised if the minimum was not found.
108 ---C++: return const&
114 Gradient(me; Grad: out Vector)
115 ---Purpose: outputs the gradient vector at the minimum in Grad.
116 -- Exception NotDone is raised if the minimum was not found.
117 -- Exception DimensionError is raised if the range of Grad is not
118 -- equal to the range of the StartingPoint.
121 raises DimensionError,
128 ---Purpose: returns the number of iterations really done during the
129 -- computation of the minimum.
130 -- Exception NotDone is raised if the minimum was not found.
138 Dump(me; o: in out OStream)
139 ---Purpose: Prints on the stream o information on the current state
141 -- Is used to redefine the operator <<.
150 TheLocation: Vector is protected;
151 TheGradient: Vector is protected;
152 TheMinimum: Real is protected;
153 PreviousMinimum: Real is protected;
156 XTol: Real is protected;
157 EPSZ: Real is protected;