0025720: Incorrect code of math classes can lead to unpredicted behavior of algorithms
[occt.git] / src / math / math_Powell.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 Powell from math
18 ---Purpose:
19 -- This class implements the Powell method to find the minimum of
20 -- function of multiple variables (the gradient does not have to be known).
21
22uses Vector from math, Matrix from math, MultipleVarFunction from math,
23 Status from math, OStream from Standard
24
25raises NotDone from StdFail,
26 DimensionError from Standard
27
28is
29
859a47c3 30 Create(theFunction: in MultipleVarFunction;
31 theTolerance: Real; theNbIterations: Integer = 200; theZEPS: Real = 1.0e-12)
32 ---Purpose: Constructor. Initialize new entity.
7fd59977 33 returns Powell;
7fd59977 34
6da30ff1 35
859a47c3 36 Delete(me) is static;
37 ---Purpose: Destructor alias
38 ---C++: inline
6da30ff1 39 ---C++: alias " Standard_EXPORT virtual ~math_Powell();"
7fd59977 40
859a47c3 41
42 Perform(me: in out; theFunction: in out MultipleVarFunction; theStartingPoint: Vector; theStartingDirections: Matrix)
43 ---Purpose:
44 -- Computes Powell minimization on the function F given
45 -- theStartingPoint, and an initial matrix theStartingDirection
46 -- whose columns contain the initial set of directions.
47 -- The solution F = Fi is found when:
48 -- 2.0 * abs(Fi - Fi-1) =< Tolerance * (abs(Fi) + abs(Fi-1) + ZEPS).
7fd59977 49 is static;
50
51
859a47c3 52 IsSolutionReached(me: in out; theFunction: in out MultipleVarFunction)
53 ---Purpose:
54 -- Solution F = Fi is found when:
55 -- 2.0 * abs(Fi - Fi-1) <= Tolerance * (abs(Fi) + abs(Fi-1)) + ZEPS.
56 -- The maximum number of iterations allowed is given by NbIterations.
57 ---C++: inline
58 returns Boolean is virtual;
59
60
7fd59977 61 IsDone(me)
62 ---Purpose: Returns true if the computations are successful, otherwise returns false.
63 ---C++: inline
64 returns Boolean
65 is static;
66
67
68 Location(me)
69 ---Purpose: returns the location vector of the minimum.
70 -- Exception NotDone is raised if the minimum was not found.
71 ---C++: inline
72 ---C++: return const&
73
74 returns Vector
75 raises NotDone
76 is static;
77
78
79 Location(me; Loc: out Vector)
80 ---Purpose: outputs the location vector of the minimum in Loc.
81 -- Exception NotDone is raised if the minimum was not found.
82 -- Exception DimensionError is raised if the range of Loc is not
83 -- equal to the range of the StartingPoint.
84 ---C++: inline
85
86 raises NotDone,
87 DimensionError
88 is static;
89
90
91
92 Minimum(me)
93 ---Purpose: Returns the value of the minimum.
94 -- Exception NotDone is raised if the minimum was not found.
95 ---C++: inline
96
97 returns Real
98 raises NotDone
99 is static;
100
101
102
103 NbIterations(me)
104 ---Purpose: Returns the number of iterations really done during the
105 -- computation of the minimum.
106 -- Exception NotDone is raised if the minimum was not found.
107 ---C++: inline
108
109 returns Integer
110 raises NotDone
111 is static;
112
113
114 Dump(me; o: in out OStream)
115 ---Purpose: Prints information on the current state of the object.
116 -- Is used to redefine the operator <<.
117
118 is static;
119
120
121
122fields
123
124Done: Boolean;
125TheLocation: Vector is protected;
126TheMinimum: Real is protected;
127TheLocationError: Real is protected;
128Iter: Integer;
129TheStatus: Status;
130TheDirections: Matrix;
131PreviousMinimum: Real is protected;
132XTol: Real is protected;
133EPSZ: Real is protected;
134State: Integer;
135Itermax: Integer;
136
137end Powell;