1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-10 18:51:21 +03:00
occt/src/AppParCurves/AppParCurves_Gradient_BFGS.gxx
msv 07f1a2e68c 0025719: Boolean operations can crash
Suppress math_BFGS constructor that calls the method Perform that in its turn calls the virtual method IsSolutionReached.
2015-01-29 13:13:59 +03:00

49 lines
1.8 KiB
Plaintext

// Created on: 1999-12-16
// Created by: Atelier CAS2000
// Copyright (c) 1999 Matra Datavision
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
// Redefinition de math_BFGS:
// ==========================
AppParCurves_Gradient_BFGS::AppParCurves_Gradient_BFGS(math_MultipleVarFunctionWithGradient& F,
const math_Vector& StartingPoint,
const Standard_Real Tolerance3d,
const Standard_Real Tolerance2d,
const Standard_Real Eps,
const Standard_Integer NbIterations ):
math_BFGS(F.NbVariables(), Eps, NbIterations, Eps),
myTol3d(Tolerance3d),
myTol2d(Tolerance2d)
{
Perform(F, StartingPoint);
}
Standard_Boolean AppParCurves_Gradient_BFGS::IsSolutionReached(math_MultipleVarFunctionWithGradient& F) const
{
AppParCurves_ParFunction *F1 = (AppParCurves_ParFunction*) &F;
Standard_Boolean Result, Result2;
Result = (2.0 * fabs(TheMinimum - PreviousMinimum) <=
1.e-10 * (fabs(TheMinimum) + fabs(PreviousMinimum))+1.e-12);
Standard_Real MErr3d = F1->MaxError3d();
Standard_Real MErr2d = F1->MaxError2d();
Result2 = ((MErr3d <= myTol3d) && (MErr2d <= myTol2d));
return (Result || Result2);
}