1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +03:00

0026674: Performance regression in BRepExtrema_DistShapeShape in OCCT 6.9.0 in compare with OCCT 6.7.1

Creation the test case for current issue.

Added flag for single extrema computation. Now implemented only for parametric solver GenExtCC.
Default behavior of curve/curve solver in distmini command changed to "find one solution".
This commit is contained in:
nbv
2015-09-17 13:55:39 +03:00
committed by bugmaster
parent 1f0adf314d
commit 836d7b64ba
11 changed files with 282 additions and 88 deletions

View File

@@ -54,6 +54,7 @@ math_GlobOptMin::math_GlobOptMin(math_MultipleVarFunction* theFunc,
myFunc = theFunc;
myC = theC;
myIsFindSingleSolution = Standard_False;
myFunctionalMinimalValue = -Precision::Infinite();
myZ = -1;
mySolCount = 0;
@@ -247,6 +248,13 @@ void math_GlobOptMin::Perform(const Standard_Boolean isFindSingleSolution)
myE3 = - maxLength * myTol * myC / 4.0;
}
// Search single solution and current solution in its neighbourhood.
if (CheckFunctionalStopCriteria())
{
myDone = Standard_True;
return;
}
isFirstCellFilterInvoke = Standard_True;
computeGlobalExtremum(myN);
@@ -409,7 +417,7 @@ void math_GlobOptMin::computeGlobalExtremum(Standard_Integer j)
Standard_Real r;
Standard_Boolean isReached = Standard_False;
for(myX(j) = myA(j) + myE1;
for(myX(j) = myA(j) + myE1;
(myX(j) < myB(j) + myE1) && (!isReached);
myX(j) += myV(j))
{
@@ -419,6 +427,9 @@ void math_GlobOptMin::computeGlobalExtremum(Standard_Integer j)
isReached = Standard_True;
}
if (CheckFunctionalStopCriteria())
return; // Best possible value is obtained.
if (j == 1)
{
isInside = Standard_False;
@@ -463,6 +474,9 @@ void math_GlobOptMin::computeGlobalExtremum(Standard_Integer j)
isFirstCellFilterInvoke = Standard_True;
}
if (CheckFunctionalStopCriteria())
return; // Best possible value is obtained.
aRealStep = myE2 + Abs(myF - d) / myC;
myV(1) = Min(aRealStep, myMaxV(1));
}
@@ -588,6 +602,24 @@ Standard_Real math_GlobOptMin::GetF()
return myF;
}
//=======================================================================
//function : SetFunctionalMinimalValue
//purpose :
//=======================================================================
void math_GlobOptMin::SetFunctionalMinimalValue(const Standard_Real theMinimalValue)
{
myFunctionalMinimalValue = theMinimalValue;
}
//=======================================================================
//function : GetFunctionalMinimalValue
//purpose :
//=======================================================================
Standard_Real math_GlobOptMin::GetFunctionalMinimalValue()
{
return myFunctionalMinimalValue;
}
//=======================================================================
//function : IsDone
//purpose :
@@ -621,3 +653,17 @@ void math_GlobOptMin::initCellSize()
* Precision::PConfusion() / (2.0 * Sqrt(2.0));
}
}
//=======================================================================
//function : CheckFunctionalStopCriteria
//purpose :
//=======================================================================
Standard_Boolean math_GlobOptMin::CheckFunctionalStopCriteria()
{
// Search single solution and current solution in its neighbourhood.
if (myIsFindSingleSolution &&
Abs (myF - myFunctionalMinimalValue) < mySameTol * 0.01)
return Standard_True;
return Standard_False;
}

View File

@@ -141,7 +141,13 @@ public:
//! Return solution theIndex, 1 <= theIndex <= NbExtrema.
Standard_EXPORT void Points(const Standard_Integer theIndex, math_Vector& theSol);
Standard_Boolean isDone();
Standard_EXPORT Standard_Boolean isDone();
//! Set functional minimal value.
Standard_EXPORT void SetFunctionalMinimalValue(const Standard_Real theMinimalValue);
//! Get functional minimal value.
Standard_EXPORT Standard_Real GetFunctionalMinimalValue();
private:
@@ -154,6 +160,10 @@ private:
void computeGlobalExtremum(Standard_Integer theIndex);
//! Check possibility to stop computations.
//! Find single solution + in neighbourhood of best possible solution.
Standard_Boolean CheckFunctionalStopCriteria();
//! Computes starting value / approximation:
//! myF - initial best value.
//! myY - initial best point.
@@ -180,6 +190,7 @@ private:
// default value is 1.0e-7.
Standard_Real myC; //Lipschitz constant, default 9
Standard_Boolean myIsFindSingleSolution; // Default value is false.
Standard_Real myFunctionalMinimalValue; // Default value is -Precision::Infinite
// Output.
Standard_Boolean myDone;