mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-04 18:06:22 +03:00
0025719: Boolean operations can crash
Suppress math_BFGS constructor that calls the method Perform that in its turn calls the virtual method IsSolutionReached.
This commit is contained in:
parent
618617fe06
commit
07f1a2e68c
@ -23,7 +23,7 @@ AppParCurves_BSpGradient_BFGS::AppParCurves_BSpGradient_BFGS(math_MultipleVarFun
|
||||
const Standard_Real Tolerance2d,
|
||||
const Standard_Real Eps,
|
||||
const Standard_Integer NbIterations):
|
||||
math_BFGS(F, Eps, NbIterations, Eps),
|
||||
math_BFGS(F.NbVariables(), Eps, NbIterations, Eps),
|
||||
myTol3d(Tolerance3d),
|
||||
myTol2d(Tolerance2d)
|
||||
{
|
||||
|
@ -24,7 +24,7 @@ AppParCurves_Gradient_BFGS::AppParCurves_Gradient_BFGS(math_MultipleVarFunctionW
|
||||
const Standard_Real Tolerance2d,
|
||||
const Standard_Real Eps,
|
||||
const Standard_Integer NbIterations ):
|
||||
math_BFGS(F, Eps, NbIterations, Eps),
|
||||
math_BFGS(F.NbVariables(), Eps, NbIterations, Eps),
|
||||
myTol3d(Tolerance3d),
|
||||
myTol2d(Tolerance2d)
|
||||
{
|
||||
|
@ -29,31 +29,18 @@ raises NotDone from StdFail,
|
||||
DimensionError from Standard
|
||||
|
||||
is
|
||||
|
||||
|
||||
Create(F: in out MultipleVarFunctionWithGradient;
|
||||
StartingPoint: Vector; Tolerance: Real=1.0e-8;
|
||||
NbIterations: Integer=200; ZEPS: Real=1.0e-12)
|
||||
---Purpose:
|
||||
-- Given the starting point StartingPoint,
|
||||
-- the Broyden-Fletcher-Goldfarb-Shanno variant of Davidson-Fletcher-Powell
|
||||
-- minimization is done on the function F.
|
||||
-- The tolerance required on F is given by Tolerance.
|
||||
-- The solution F = Fi is found when :
|
||||
-- 2.0 * abs(Fi - Fi-1) <= Tolerance * (abs(Fi) + abs(Fi-1) + ZEPS).
|
||||
-- The maximum number of iterations allowed is given by NbIterations.
|
||||
|
||||
returns BFGS;
|
||||
|
||||
Create(F: in out MultipleVarFunctionWithGradient;
|
||||
Tolerance: Real = 1.0e-8;
|
||||
NbIterations: Integer = 200;
|
||||
ZEPS: Real = 1.0e-12)
|
||||
---Purpose: Initializes the computation of the minimum of F.
|
||||
-- Warning
|
||||
-- A call to the Perform method must be made after this
|
||||
-- initialization to effectively compute the minimum of the
|
||||
-- function F.
|
||||
Create(NbVariables: Integer;
|
||||
Tolerance: Real = 1.0e-8;
|
||||
NbIterations: Integer = 200;
|
||||
ZEPS: Real = 1.0e-12)
|
||||
---Purpose: Initializes the computation of the minimum of a function with
|
||||
-- NbVariables.
|
||||
-- Tolerance, ZEPS and NbIterations are described in the method Perform.
|
||||
-- Warning:
|
||||
-- A call to the Perform method must be made after this
|
||||
-- initialization to effectively compute the minimum of the
|
||||
-- function F.
|
||||
returns BFGS;
|
||||
|
||||
|
||||
@ -61,8 +48,13 @@ is
|
||||
---C++: alias "Standard_EXPORT virtual ~math_BFGS(){Delete() ; }"
|
||||
|
||||
Perform(me: in out; F: in out MultipleVarFunctionWithGradient;
|
||||
StartingPoint: Vector)
|
||||
---Purpose: Is used internally by the constructors.
|
||||
StartingPoint: Vector)
|
||||
---Purpose: Given the starting point StartingPoint,
|
||||
-- minimization is done on the function F.
|
||||
-- The solution F = Fi is found when :
|
||||
-- 2.0 * abs(Fi - Fi-1) <= Tolerance * (abs(Fi) + abs(Fi-1) + ZEPS).
|
||||
-- Tolerance, ZEPS and maximum number of iterations are given
|
||||
-- in the constructor.
|
||||
|
||||
is static;
|
||||
|
||||
|
@ -267,27 +267,13 @@ void math_BFGS::Perform(math_MultipleVarFunctionWithGradient& F,
|
||||
return 2.0 * fabs(TheMinimum - PreviousMinimum) <=
|
||||
XTol * (fabs(TheMinimum) + fabs(PreviousMinimum) + EPSZ);
|
||||
}
|
||||
|
||||
math_BFGS::math_BFGS(math_MultipleVarFunctionWithGradient& F,
|
||||
const math_Vector& StartingPoint,
|
||||
const Standard_Real Tolerance,
|
||||
const Standard_Integer NbIterations,
|
||||
const Standard_Real ZEPS)
|
||||
: TheLocation(1, StartingPoint.Length()),
|
||||
TheGradient(1, StartingPoint.Length()) {
|
||||
|
||||
XTol = Tolerance;
|
||||
EPSZ = ZEPS;
|
||||
Itermax = NbIterations;
|
||||
Perform(F, StartingPoint);
|
||||
}
|
||||
|
||||
math_BFGS::math_BFGS(math_MultipleVarFunctionWithGradient& F,
|
||||
math_BFGS::math_BFGS(const Standard_Integer NbVariables,
|
||||
const Standard_Real Tolerance,
|
||||
const Standard_Integer NbIterations,
|
||||
const Standard_Real ZEPS)
|
||||
: TheLocation(1, F.NbVariables()),
|
||||
TheGradient(1, F.NbVariables()) {
|
||||
: TheLocation(1, NbVariables),
|
||||
TheGradient(1, NbVariables) {
|
||||
|
||||
XTol = Tolerance;
|
||||
EPSZ = ZEPS;
|
||||
|
@ -232,7 +232,8 @@ Standard_Boolean math_GlobOptMin::computeLocalExtremum(const math_Vector& thePnt
|
||||
{
|
||||
math_MultipleVarFunctionWithGradient* myTmp =
|
||||
dynamic_cast<math_MultipleVarFunctionWithGradient*> (myFunc);
|
||||
math_BFGS bfgs(*myTmp, thePnt);
|
||||
math_BFGS bfgs(myTmp->NbVariables());
|
||||
bfgs.Perform(*myTmp, thePnt);
|
||||
if (bfgs.IsDone())
|
||||
{
|
||||
bfgs.Location(theOutPnt);
|
||||
|
Loading…
x
Reference in New Issue
Block a user