Suppress math_BFGS constructor that calls the method Perform that in its turn calls the virtual method IsSolutionReached.
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)
{
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)
{
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;
---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;
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;
{
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);