0024044: Performance improvements: Foundation Classes (math)
[occt.git] / src / math / math_FRPR.cdl
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
5 --
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.
10 --
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.
13 --
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.
20
21
22
23
24 class FRPR from math
25         ---Purpose:
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.
29
30 uses Vector from math, Matrix from math, 
31      MultipleVarFunctionWithGradient from math,
32      Status from math,
33      OStream from Standard
34      
35 raises DimensionError from Standard,
36        NotDone from StdFail
37
38 is
39
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
47         -- by NbIterations.
48     returns FRPR;
49     
50     
51     Create(F: in out MultipleVarFunctionWithGradient;
52            Tolerance: Real;
53            NbIterations: Integer = 200;
54            ZEPS: Real = 1.0e-12)
55         ---Purpose: Purpose
56         -- Initializes the computation of the minimum of F.
57         -- Warning
58         -- A call to the Perform method must be made after this
59         -- initialization to compute the minimum of the function.
60     returns FRPR;
61
62
63     Delete(me:out) is virtual;
64     ---C++: alias "Standard_EXPORT virtual ~math_FRPR(){Delete();}"
65     
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.
70         -- Warning
71         -- The initialization constructor must have been called before
72         -- the Perform method is called
73
74     is static;
75
76
77     IsSolutionReached(me: in out; F: in out MultipleVarFunctionWithGradient)
78         ---Purpose:
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.
82     
83     returns Boolean
84     is virtual;
85     
86     
87     IsDone(me)
88         ---Purpose: Returns true if the computations are successful, otherwise returns false.
89         ---C++: inline
90     returns Boolean
91     is static;
92     
93     
94
95     Location(me)
96         ---Purpose: returns the location vector of the minimum.
97         -- Exception NotDone is raised if the minimum was not found.
98         ---C++: inline
99         ---C++: return const&
100     
101     returns Vector
102     raises NotDone
103     is static;
104
105
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.
111         ---C++: inline
112     raises DimensionError,
113            NotDone
114     is static;
115     
116
117     Minimum(me)
118         ---Purpose: returns the value of the minimum.
119         -- Exception NotDone is raised if the minimum was not found.
120         ---C++: inline
121     returns Real
122     raises NotDone
123     is static;
124     
125     
126     Gradient(me)
127        ---Purpose: returns the gradient vector at the minimum.
128        -- Exception NotDone is raised if the minimum was not found.
129        ---C++: inline
130        ---C++: return const&
131     returns Vector
132     raises NotDone
133     is static;
134     
135     
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.
141         ---C++: inline
142     
143     raises DimensionError,
144            NotDone
145     is static;
146     
147     
148     
149     NbIterations(me)
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.
153         ---C++: inline
154     
155     returns Integer
156     raises NotDone
157     is static;
158     
159
160     Dump(me; o: in out OStream)
161         ---Purpose: Prints on the stream o information on the current state 
162         --          of the object.
163         --          Is used to redefine the operator <<.
164
165     is static;
166
167
168
169 fields
170 Done:            Boolean;
171 TheLocation:     Vector is protected;
172 TheGradient:     Vector is protected;
173 TheMinimum:      Real is protected;
174 PreviousMinimum: Real is protected;
175 Iter:            Integer;
176 State:           Integer;
177 XTol:            Real is protected;
178 EPSZ:            Real is protected;
179 TheStatus:       Status;
180 Itermax:         Integer;
181
182 end FRPR;