0025720: Incorrect code of math classes can lead to unpredicted behavior of algorithms
[occt.git] / src / math / math_FRPR.cdl
CommitLineData
b311480e 1-- Created on: 1991-05-14
2-- Created by: Laurent PAINNOT
3-- Copyright (c) 1991-1999 Matra Datavision
973c2be1 4-- Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 5--
973c2be1 6-- This file is part of Open CASCADE Technology software library.
b311480e 7--
d5f74e42 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
973c2be1 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.
b311480e 13--
973c2be1 14-- Alternatively, this file may be used under the terms of Open CASCADE
15-- commercial license or contractual agreement.
7fd59977 16
17class FRPR from math
18 ---Purpose:
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.
22
23uses Vector from math, Matrix from math,
24 MultipleVarFunctionWithGradient from math,
25 Status from math,
26 OStream from Standard
27
28raises DimensionError from Standard,
29 NotDone from StdFail
30
31is
32
859a47c3 33 Create(theFunction: in MultipleVarFunctionWithGradient;
34 theTolerance: Real;
35 theNbIterations: Integer = 200;
36 theZEPS: Real = 1.0e-12)
37 ---Purpose:
38 -- Initializes the computation of the minimum of F.
39 -- Warning: constructor does not perform computations.
7fd59977 40 returns FRPR;
41
859a47c3 42 Delete(me) is static;
43 ---Purpose: Destructor alias.
6da30ff1 44 ---C++: alias " Standard_EXPORT virtual ~math_FRPR();"
7fd59977 45
7fd59977 46
859a47c3 47 Perform(me: in out;
48 theFunction: in out MultipleVarFunctionWithGradient;
49 theStartingPoint: Vector)
50 ---Purpose:
51 -- The solution F = Fi is found when
52 -- 2.0 * abs(Fi - Fi-1) <= Tolerance * (abs(Fi) + abs(Fi-1) + ZEPS).
7fd59977 53 is static;
54
55
859a47c3 56 IsSolutionReached(me: in out; theFunction: in out MultipleVarFunctionWithGradient)
57 ---Purpose:
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.
61 ---C++:inline
62 returns Boolean is virtual;
63
64
7fd59977 65 IsDone(me)
859a47c3 66 ---Purpose: Returns true if the computations are successful, otherwise returns false.
7fd59977 67 ---C++: inline
68 returns Boolean
69 is static;
70
71
72
73 Location(me)
74 ---Purpose: returns the location vector of the minimum.
75 -- Exception NotDone is raised if the minimum was not found.
76 ---C++: inline
77 ---C++: return const&
78
79 returns Vector
80 raises NotDone
81 is static;
82
83
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.
89 ---C++: inline
90 raises DimensionError,
91 NotDone
92 is static;
93
94
95 Minimum(me)
96 ---Purpose: returns the value of the minimum.
97 -- Exception NotDone is raised if the minimum was not found.
98 ---C++: inline
99 returns Real
100 raises NotDone
101 is static;
102
103
104 Gradient(me)
105 ---Purpose: returns the gradient vector at the minimum.
106 -- Exception NotDone is raised if the minimum was not found.
107 ---C++: inline
108 ---C++: return const&
109 returns Vector
110 raises NotDone
111 is static;
112
113
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.
119 ---C++: inline
120
121 raises DimensionError,
122 NotDone
123 is static;
124
125
126
127 NbIterations(me)
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.
131 ---C++: inline
132
133 returns Integer
134 raises NotDone
135 is static;
136
137
138 Dump(me; o: in out OStream)
139 ---Purpose: Prints on the stream o information on the current state
140 -- of the object.
141 -- Is used to redefine the operator <<.
142
143 is static;
144
145
146
147fields
859a47c3 148
7fd59977 149Done: Boolean;
150TheLocation: Vector is protected;
151TheGradient: Vector is protected;
152TheMinimum: Real is protected;
153PreviousMinimum: Real is protected;
154Iter: Integer;
155State: Integer;
156XTol: Real is protected;
157EPSZ: Real is protected;
158TheStatus: Status;
159Itermax: Integer;
160
161end FRPR;