1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-05 18:16:23 +03:00

0026044: Optimize math_GlobOptMin class to enter options for solutions of some specified problems

Possibility to search single optimum added.
This commit is contained in:
aml 2015-05-19 14:27:06 +03:00 committed by bugmaster
parent ae9a414af0
commit 78e7cada5a
2 changed files with 29 additions and 9 deletions

View File

@ -51,6 +51,7 @@ math_GlobOptMin::math_GlobOptMin(math_MultipleVarFunction* theFunc,
myFunc = theFunc;
myC = theC;
myIsFindSingleSolution = Standard_False;
myZ = -1;
mySolCount = 0;
@ -191,7 +192,7 @@ math_GlobOptMin::~math_GlobOptMin()
//purpose : Compute Global extremum point
//=======================================================================
// In this algo indexes started from 1, not from 0.
void math_GlobOptMin::Perform()
void math_GlobOptMin::Perform(const Standard_Boolean isFindSingleSolution)
{
Standard_Integer i;
@ -221,10 +222,21 @@ void math_GlobOptMin::Perform()
myE1 = minLength * myTol;
myE2 = maxLength * myTol;
if (myC > 1.0)
myE3 = - maxLength * myTol / 4.0;
myIsFindSingleSolution = isFindSingleSolution;
if (isFindSingleSolution)
{
// Run local optimization
// if current value better than optimal.
myE3 = 0.0;
}
else
myE3 = - maxLength * myTol * myC / 4.0;
{
if (myC > 1.0)
myE3 = - maxLength * myTol / 4.0;
else
myE3 = - maxLength * myTol * myC / 4.0;
}
computeGlobalExtremum(myN);
@ -404,8 +416,10 @@ void math_GlobOptMin::computeGlobalExtremum(Standard_Integer j)
aStepBestValue = (isInside && (val < d))? val : d;
aStepBestPoint = (isInside && (val < d))? myTmp : myX;
// Solutions are close to each other.
if (Abs(aStepBestValue - myF) < mySameTol * 0.01)
// Solutions are close to each other
// and it is allowed to have more than one solution.
if (Abs(aStepBestValue - myF) < mySameTol * 0.01 &&
!myIsFindSingleSolution)
{
if (!isStored(aStepBestPoint))
{
@ -417,8 +431,12 @@ void math_GlobOptMin::computeGlobalExtremum(Standard_Integer j)
}
}
// New best solution.
if ((aStepBestValue - myF) * myZ > mySameTol * 0.01)
// New best solution:
// new point is out of (mySameTol * 0.01) surrounding or
// new point is better than old + single point search.
Standard_Real aFunctionalDelta = (aStepBestValue - myF) * myZ;
if (aFunctionalDelta > mySameTol * 0.01 ||
(aFunctionalDelta > 0.0 && myIsFindSingleSolution))
{
mySolCount = 0;
myF = aStepBestValue;

View File

@ -53,7 +53,8 @@ public:
Standard_EXPORT ~math_GlobOptMin();
Standard_EXPORT void Perform();
//! @param isFindSingleSolution - defines whether to find single solution or all solutions.
Standard_EXPORT void Perform(const Standard_Boolean isFindSingleSolution = Standard_False);
//! Get best functional value.
Standard_EXPORT Standard_Real GetF();
@ -99,6 +100,7 @@ private:
// function values |val1 - val2| * 0.01 < mySameTol is equal,
// default value is 1.0e-7.
Standard_Real myC; //Lipschitz constant, default 9
Standard_Boolean myIsFindSingleSolution; // Default value is false.
// Output.
Standard_Boolean myDone;