0027067: Avoid use of virtual methods for implementation of destructors in legacy...
[occt.git] / src / math / math_Powell.hxx
CommitLineData
42cf5bc1 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
5//
6// This file is part of Open CASCADE Technology software library.
7//
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.
13//
14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
16
17#ifndef _math_Powell_HeaderFile
18#define _math_Powell_HeaderFile
19
20#include <Standard.hxx>
21#include <Standard_DefineAlloc.hxx>
22#include <Standard_Handle.hxx>
23
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>
31class StdFail_NotDone;
32class Standard_DimensionError;
33class math_MultipleVarFunction;
34class math_Matrix;
35
36
37
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).
40class math_Powell
41{
42public:
43
44 DEFINE_STANDARD_ALLOC
45
46
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);
49
e6f550da 50 //! Destructor
42cf5bc1 51 Standard_EXPORT virtual ~math_Powell();
52
53
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);
60
61
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);
66
67 //! Returns true if the computations are successful, otherwise returns false.
68 Standard_Boolean IsDone() const;
69
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;
73
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;
79
80 //! Returns the value of the minimum.
81 //! Exception NotDone is raised if the minimum was not found.
82 Standard_Real Minimum() const;
83
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;
88
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;
92
93
94
95
96protected:
97
98
99
100 math_Vector TheLocation;
101 Standard_Real TheMinimum;
102 Standard_Real TheLocationError;
103 Standard_Real PreviousMinimum;
104 Standard_Real XTol;
105 Standard_Real EPSZ;
106
107
108private:
109
110
111
112 Standard_Boolean Done;
113 Standard_Integer Iter;
114 math_Status TheStatus;
115 math_Matrix TheDirections;
116 Standard_Integer State;
117 Standard_Integer Itermax;
118
119
120};
121
122
123#include <math_Powell.lxx>
124
125
126
127
128
129#endif // _math_Powell_HeaderFile