1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-16 10:08:36 +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:
msv 2015-01-23 18:07:15 +03:00 committed by bugmaster
parent 618617fe06
commit 07f1a2e68c
5 changed files with 25 additions and 46 deletions

View File

@ -23,7 +23,7 @@ AppParCurves_BSpGradient_BFGS::AppParCurves_BSpGradient_BFGS(math_MultipleVarFun
const Standard_Real Tolerance2d, const Standard_Real Tolerance2d,
const Standard_Real Eps, const Standard_Real Eps,
const Standard_Integer NbIterations): const Standard_Integer NbIterations):
math_BFGS(F, Eps, NbIterations, Eps), math_BFGS(F.NbVariables(), Eps, NbIterations, Eps),
myTol3d(Tolerance3d), myTol3d(Tolerance3d),
myTol2d(Tolerance2d) myTol2d(Tolerance2d)
{ {

View File

@ -24,7 +24,7 @@ AppParCurves_Gradient_BFGS::AppParCurves_Gradient_BFGS(math_MultipleVarFunctionW
const Standard_Real Tolerance2d, const Standard_Real Tolerance2d,
const Standard_Real Eps, const Standard_Real Eps,
const Standard_Integer NbIterations ): const Standard_Integer NbIterations ):
math_BFGS(F, Eps, NbIterations, Eps), math_BFGS(F.NbVariables(), Eps, NbIterations, Eps),
myTol3d(Tolerance3d), myTol3d(Tolerance3d),
myTol2d(Tolerance2d) myTol2d(Tolerance2d)
{ {

View File

@ -30,30 +30,17 @@ raises NotDone from StdFail,
is is
Create(NbVariables: Integer;
Create(F: in out MultipleVarFunctionWithGradient; Tolerance: Real = 1.0e-8;
StartingPoint: Vector; Tolerance: Real=1.0e-8; NbIterations: Integer = 200;
NbIterations: Integer=200; ZEPS: Real=1.0e-12) ZEPS: Real = 1.0e-12)
---Purpose: ---Purpose: Initializes the computation of the minimum of a function with
-- Given the starting point StartingPoint, -- NbVariables.
-- the Broyden-Fletcher-Goldfarb-Shanno variant of Davidson-Fletcher-Powell -- Tolerance, ZEPS and NbIterations are described in the method Perform.
-- minimization is done on the function F. -- Warning:
-- The tolerance required on F is given by Tolerance. -- A call to the Perform method must be made after this
-- The solution F = Fi is found when : -- initialization to effectively compute the minimum of the
-- 2.0 * abs(Fi - Fi-1) <= Tolerance * (abs(Fi) + abs(Fi-1) + ZEPS). -- function F.
-- 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.
returns BFGS; returns BFGS;
@ -61,8 +48,13 @@ is
---C++: alias "Standard_EXPORT virtual ~math_BFGS(){Delete() ; }" ---C++: alias "Standard_EXPORT virtual ~math_BFGS(){Delete() ; }"
Perform(me: in out; F: in out MultipleVarFunctionWithGradient; Perform(me: in out; F: in out MultipleVarFunctionWithGradient;
StartingPoint: Vector) StartingPoint: Vector)
---Purpose: Is used internally by the constructors. ---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; is static;

View File

@ -268,26 +268,12 @@ void math_BFGS::Perform(math_MultipleVarFunctionWithGradient& F,
XTol * (fabs(TheMinimum) + fabs(PreviousMinimum) + EPSZ); XTol * (fabs(TheMinimum) + fabs(PreviousMinimum) + EPSZ);
} }
math_BFGS::math_BFGS(math_MultipleVarFunctionWithGradient& F, math_BFGS::math_BFGS(const Standard_Integer NbVariables,
const math_Vector& StartingPoint,
const Standard_Real Tolerance, const Standard_Real Tolerance,
const Standard_Integer NbIterations, const Standard_Integer NbIterations,
const Standard_Real ZEPS) const Standard_Real ZEPS)
: TheLocation(1, StartingPoint.Length()), : TheLocation(1, NbVariables),
TheGradient(1, StartingPoint.Length()) { TheGradient(1, NbVariables) {
XTol = Tolerance;
EPSZ = ZEPS;
Itermax = NbIterations;
Perform(F, StartingPoint);
}
math_BFGS::math_BFGS(math_MultipleVarFunctionWithGradient& F,
const Standard_Real Tolerance,
const Standard_Integer NbIterations,
const Standard_Real ZEPS)
: TheLocation(1, F.NbVariables()),
TheGradient(1, F.NbVariables()) {
XTol = Tolerance; XTol = Tolerance;
EPSZ = ZEPS; EPSZ = ZEPS;

View File

@ -232,7 +232,8 @@ Standard_Boolean math_GlobOptMin::computeLocalExtremum(const math_Vector& thePnt
{ {
math_MultipleVarFunctionWithGradient* myTmp = math_MultipleVarFunctionWithGradient* myTmp =
dynamic_cast<math_MultipleVarFunctionWithGradient*> (myFunc); dynamic_cast<math_MultipleVarFunctionWithGradient*> (myFunc);
math_BFGS bfgs(*myTmp, thePnt); math_BFGS bfgs(myTmp->NbVariables());
bfgs.Perform(*myTmp, thePnt);
if (bfgs.IsDone()) if (bfgs.IsDone())
{ {
bfgs.Location(theOutPnt); bfgs.Location(theOutPnt);