0026332: BRepOffsetAPI_ThruSections algorithm fails on two wires with different numbe...
[occt.git] / src / math / math_GlobOptMin.hxx
CommitLineData
4bbaf12b 1// Created on: 2014-01-20
2// Created by: Alexaner Malyshev
3// Copyright (c) 2014-2014 OPEN CASCADE SAS
4//
5// This file is part of Open CASCADE Technology software library.
6//
7// This library is free software; you can redistribute it and/or modify it under
8// the terms of the GNU Lesser General Public License version 2.1 as published
9// by the Free Software Foundation, with special exception defined in the file
10// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11// distribution for complete text of the license and disclaimer of any warranty.
12//
13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
15
16#ifndef _math_GlobOptMin_HeaderFile
17#define _math_GlobOptMin_HeaderFile
18
19#include <math_MultipleVarFunction.hxx>
20#include <NCollection_Sequence.hxx>
21#include <Standard_Type.hxx>
22
23//! This class represents Evtushenko's algorithm of global optimization based on nonuniform mesh.<br>
24//! Article: Yu. Evtushenko. Numerical methods for finding global extreme (case of a non-uniform mesh). <br>
25//! U.S.S.R. Comput. Maths. Math. Phys., Vol. 11, N 6, pp. 38-54.
26
27class math_GlobOptMin
28{
29public:
30
31 Standard_EXPORT math_GlobOptMin(math_MultipleVarFunction* theFunc,
3f733bb1 32 const math_Vector& theLowerBorder,
33 const math_Vector& theUpperBorder,
5493d334 34 const Standard_Real theC = 9,
35 const Standard_Real theDiscretizationTol = 1.0e-2,
36 const Standard_Real theSameTol = 1.0e-7);
4bbaf12b 37
38 Standard_EXPORT void SetGlobalParams(math_MultipleVarFunction* theFunc,
3f733bb1 39 const math_Vector& theLowerBorder,
40 const math_Vector& theUpperBorder,
5493d334 41 const Standard_Real theC = 9,
42 const Standard_Real theDiscretizationTol = 1.0e-2,
43 const Standard_Real theSameTol = 1.0e-7);
4bbaf12b 44
45 Standard_EXPORT void SetLocalParams(const math_Vector& theLocalA,
46 const math_Vector& theLocalB);
47
5493d334 48 Standard_EXPORT void SetTol(const Standard_Real theDiscretizationTol,
49 const Standard_Real theSameTol);
50
51 Standard_EXPORT void GetTol(Standard_Real& theDiscretizationTol,
52 Standard_Real& theSameTol);
53
4bbaf12b 54 Standard_EXPORT ~math_GlobOptMin();
55
78e7cada 56 //! @param isFindSingleSolution - defines whether to find single solution or all solutions.
57 Standard_EXPORT void Perform(const Standard_Boolean isFindSingleSolution = Standard_False);
4bbaf12b 58
59 //! Get best functional value.
60 Standard_EXPORT Standard_Real GetF();
61
797d11c6 62 //! Return count of global extremas.
4bbaf12b 63 Standard_EXPORT Standard_Integer NbExtrema();
64
3f733bb1 65 //! Return solution theIndex, 1 <= theIndex <= NbExtrema.
4bbaf12b 66 Standard_EXPORT void Points(const Standard_Integer theIndex, math_Vector& theSol);
67
5493d334 68 Standard_Boolean isDone();
69
4bbaf12b 70private:
71
72 math_GlobOptMin & operator = (const math_GlobOptMin & theOther);
73
74 Standard_Boolean computeLocalExtremum(const math_Vector& thePnt, Standard_Real& theVal, math_Vector& theOutPnt);
75
76 void computeGlobalExtremum(Standard_Integer theIndex);
77
797d11c6 78 //! Computes starting value / approximation:
3f733bb1 79 //! myF - initial best value.
80 //! myY - initial best point.
81 //! myC - approximation of Lipschitz constant.
82 //! to imporve convergence speed.
797d11c6 83 void computeInitialValues();
84
3f733bb1 85 //! Check that myA <= thePnt <= myB
4bbaf12b 86 Standard_Boolean isInside(const math_Vector& thePnt);
87
3f733bb1 88 //! Check presence of thePnt in GlobOpt sequence.
4bbaf12b 89 Standard_Boolean isStored(const math_Vector &thePnt);
4bbaf12b 90
91 // Input.
92 math_MultipleVarFunction* myFunc;
93 Standard_Integer myN;
94 math_Vector myA; // Left border on current C2 interval.
95 math_Vector myB; // Right border on current C2 interval.
96 math_Vector myGlobA; // Global left border.
97 math_Vector myGlobB; // Global right border.
5493d334 98 Standard_Real myTol; // Discretization tolerance, default 1.0e-2.
99 Standard_Real mySameTol; // points with ||p1 - p2|| < mySameTol is equal,
100 // function values |val1 - val2| * 0.01 < mySameTol is equal,
101 // default value is 1.0e-7.
102 Standard_Real myC; //Lipschitz constant, default 9
78e7cada 103 Standard_Boolean myIsFindSingleSolution; // Default value is false.
4bbaf12b 104
105 // Output.
106 Standard_Boolean myDone;
107 NCollection_Sequence<Standard_Real> myY;// Current solutions.
108 Standard_Integer mySolCount; // Count of solutions.
109
110 // Algorithm data.
111 Standard_Real myZ;
4bbaf12b 112 Standard_Real myE1; // Border coeff.
113 Standard_Real myE2; // Minimum step size.
114 Standard_Real myE3; // Local extrema starting parameter.
115
5493d334 116 math_Vector myX; // Current modified solution.
117 math_Vector myTmp; // Current modified solution.
4bbaf12b 118 math_Vector myV; // Steps array.
5493d334 119 math_Vector myMaxV; // Max Steps array.
3f733bb1 120 math_Vector myExpandCoeff; // Define expand coefficient between neighboring indiced dimensions.
4bbaf12b 121
122 Standard_Real myF; // Current value of Global optimum.
123};
124
4bbaf12b 125#endif