Browse Source

Adjusted Neldermead

Adjusted the algorithm such that after a reflection it will also try to expand or shrink (as said in the documentation). Now it also works for the 1 dimensional issue I stated
pull/506/head
MMAvanEnkhuizen 9 years ago
parent
commit
cc86b8bfd2
  1. 20
      src/Numerics/Optimization/NelderMeadSimplex.cs

20
src/Numerics/Optimization/NelderMeadSimplex.cs

@ -148,9 +148,25 @@ namespace MathNet.Numerics.Optimization
if (reflectionPointValue <= errorValues[errorProfile.LowestIndex])
{
// it's better than the best point, so attempt an expansion of the simplex
double expansionPointValue = TryToScaleSimplex(2.0, ref errorProfile, vertices, errorValues, objectiveFunction);
double currentWorst = errorValues[errorProfile.HighestIndex];
double expansionValue = TryToScaleSimplex(2.0, ref errorProfile, vertices, errorValues, objectiveFunction);
++evaluationCount;
}
if (expansionValue >= currentWorst)
{
// it would be worse than the second best point, so attempt a contraction to look
// for an intermediate point
double currentWorst2 = errorValues[errorProfile.HighestIndex];
double contractionPointValue = TryToScaleSimplex(0.5, ref errorProfile, vertices, errorValues, objectiveFunction);
++evaluationCount;
if (contractionPointValue >= currentWorst2)
{
// that would be even worse, so let's try to contract uniformly towards the low point;
// don't bother to update the error profile, we'll do it at the start of the
// next iteration
ShrinkSimplex(errorProfile, vertices, errorValues, objectiveFunction);
evaluationCount += numVertices; // that required one function evaluation for each vertex; keep track
}
}
else if (reflectionPointValue >= errorValues[errorProfile.NextHighestIndex])
{
// it would be worse than the second best point, so attempt a contraction to look

Loading…
Cancel
Save