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 #ifndef _math_Powell_HeaderFile
18 #define _math_Powell_HeaderFile
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Handle.hxx>
24 #include <Standard_Boolean.hxx>
25 #include <math_Vector.hxx>
26 #include <Standard_Real.hxx>
27 #include <Standard_Integer.hxx>
28 #include <math_Status.hxx>
29 #include <math_Matrix.hxx>
30 #include <Standard_OStream.hxx>
31 class StdFail_NotDone;
32 class Standard_DimensionError;
33 class math_MultipleVarFunction;
38 //! This class implements the Powell method to find the minimum of
39 //! function of multiple variables (the gradient does not have to be known).
47 //! Constructor. Initialize new entity.
48 Standard_EXPORT math_Powell(const math_MultipleVarFunction& theFunction, const Standard_Real theTolerance, const Standard_Integer theNbIterations = 200, const Standard_Real theZEPS = 1.0e-12);
51 Standard_EXPORT virtual ~math_Powell();
54 //! Computes Powell minimization on the function F given
55 //! theStartingPoint, and an initial matrix theStartingDirection
56 //! whose columns contain the initial set of directions.
57 //! The solution F = Fi is found when:
58 //! 2.0 * abs(Fi - Fi-1) =< Tolerance * (abs(Fi) + abs(Fi-1) + ZEPS).
59 Standard_EXPORT void Perform (math_MultipleVarFunction& theFunction, const math_Vector& theStartingPoint, const math_Matrix& theStartingDirections);
62 //! Solution F = Fi is found when:
63 //! 2.0 * abs(Fi - Fi-1) <= Tolerance * (abs(Fi) + abs(Fi-1)) + ZEPS.
64 //! The maximum number of iterations allowed is given by NbIterations.
65 virtual Standard_Boolean IsSolutionReached (math_MultipleVarFunction& theFunction);
67 //! Returns true if the computations are successful, otherwise returns false.
68 Standard_Boolean IsDone() const;
70 //! returns the location vector of the minimum.
71 //! Exception NotDone is raised if the minimum was not found.
72 const math_Vector& Location() const;
74 //! outputs the location vector of the minimum in Loc.
75 //! Exception NotDone is raised if the minimum was not found.
76 //! Exception DimensionError is raised if the range of Loc is not
77 //! equal to the range of the StartingPoint.
78 void Location (math_Vector& Loc) const;
80 //! Returns the value of the minimum.
81 //! Exception NotDone is raised if the minimum was not found.
82 Standard_Real Minimum() const;
84 //! Returns the number of iterations really done during the
85 //! computation of the minimum.
86 //! Exception NotDone is raised if the minimum was not found.
87 Standard_Integer NbIterations() const;
89 //! Prints information on the current state of the object.
90 //! Is used to redefine the operator <<.
91 Standard_EXPORT void Dump (Standard_OStream& o) const;
100 math_Vector TheLocation;
101 Standard_Real TheMinimum;
102 Standard_Real TheLocationError;
103 Standard_Real PreviousMinimum;
112 Standard_Boolean Done;
113 Standard_Integer Iter;
114 math_Status TheStatus;
115 math_Matrix TheDirections;
116 Standard_Integer State;
117 Standard_Integer Itermax;
123 #include <math_Powell.lxx>
129 #endif // _math_Powell_HeaderFile