mathnet-numerics icon indicating copy to clipboard operation
mathnet-numerics copied to clipboard

GoldenSectionMinimizer.FindMinimum() does not respect the lowerBound argument

Open bt-88 opened this issue 5 years ago • 3 comments

The function ScalarMinimizationResult FindMinimum(IScalarObjectiveFunction objective, double lowerBound, double upperBound) (in Numerics.Optimization) does not respect the lowerBound argument.

In my example of FindMinimum(somefunction, 0.05, 0.4) the GS-algorithm expands below 0.05 and tries to check values that are outside of the boundary [0.05, 0.4].

In the source code, I have identified the 'problem': https://github.com/mathnet/mathnet-numerics/blob/ad05896d3b4e317c3e5418e5fadf3968604fdbcd/src/Numerics/Optimization/GoldenSectionMinimizer.cs#L75-L78

So, in my case, the new lower bound is set to:

lowerBound = 0.5*(0.4+0.05) - 2*0.5*(0.4-0.05); // This is -0.125

Is this indeed a bug?

bt-88 avatar Sep 22 '20 08:09 bt-88

I encountered the same thing with FindMinimum.OfScalarFunctionConstrained since it is implemented with GoldenSectionMinimizer.FindMinimum. A workaround is to edit the function being minimized so that it returns double.MaxValue if the given value is outside of the bounds.

RichardMelito avatar Jun 24 '21 20:06 RichardMelito

The bounds seems to be intended just as a starting interval to search. It is why there are LowerExpansionFactor UpperExpansionFactor arguments. Please see here. It might be better to change the names to avoid confusion.

diluculo avatar Jun 25 '21 02:06 diluculo

I also encountered this problem. @diluculo is correct; it is hard baked into the algorithm. @RichardMelito's work-around works great.

arielhammon avatar Dec 27 '21 23:12 arielhammon