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.
17 class Powell from math
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).
22 uses Vector from math, Matrix from math, MultipleVarFunction from math,
23 Status from math, OStream from Standard
25 raises NotDone from StdFail,
26 DimensionError from Standard
30 Create(F: in out MultipleVarFunction; StartingPoint: Vector;
31 StartingDirections: Matrix; Tolerance: Real;
32 NbIterations: Integer=200; ZEPS: Real=1.0e-12)
34 -- Computes Powell minimization on the function F given
35 -- StartingPoint, and an initial matrix StartingDirection
36 -- whose columns contain the initial set of directions. The
37 -- solution F = Fi is found when 2.0 * abs(Fi - Fi-1) =
38 -- <Tolerance * (abs(Fi) + abs(Fi-1) + ZEPS). The maximum
39 -- number of iterations allowed is given by NbIterations.
43 Create(F: in out MultipleVarFunction;
45 NbIterations: Integer = 200;
47 ---Purpose: is used in a sub-class to initialize correctly all the fields
52 ---C++: alias " Standard_EXPORT virtual ~math_Powell();"
54 Perform(me: in out;F: in out MultipleVarFunction;
55 StartingPoint: Vector;
56 StartingDirections: Matrix)
57 ---Purpose: Use this method after a call to the initialization constructor
58 -- to compute the minimum of function F.
60 -- The initialization constructor must have been called before
61 -- the Perform method is called.
66 IsSolutionReached(me: in out; F: in out MultipleVarFunction)
68 -- solution F = Fi is found when :
69 -- 2.0 * abs(Fi - Fi-1) <= Tolerance * (abs(Fi) + abs(Fi-1)) + ZEPS.
70 -- The maximum number of iterations allowed is given by NbIterations.
77 ---Purpose: Returns true if the computations are successful, otherwise returns false.
84 ---Purpose: returns the location vector of the minimum.
85 -- Exception NotDone is raised if the minimum was not found.
94 Location(me; Loc: out Vector)
95 ---Purpose: outputs the location vector of the minimum in Loc.
96 -- Exception NotDone is raised if the minimum was not found.
97 -- Exception DimensionError is raised if the range of Loc is not
98 -- equal to the range of the StartingPoint.
108 ---Purpose: Returns the value of the minimum.
109 -- Exception NotDone is raised if the minimum was not found.
119 ---Purpose: Returns the number of iterations really done during the
120 -- computation of the minimum.
121 -- Exception NotDone is raised if the minimum was not found.
129 Dump(me; o: in out OStream)
130 ---Purpose: Prints information on the current state of the object.
131 -- Is used to redefine the operator <<.
140 TheLocation: Vector is protected;
141 TheMinimum: Real is protected;
142 TheLocationError: Real is protected;
145 TheDirections: Matrix;
146 PreviousMinimum: Real is protected;
147 XTol: Real is protected;
148 EPSZ: Real is protected;