Open bt-88 opened 3 years ago
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.
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.
I also encountered this problem. @diluculo is correct; it is hard baked into the algorithm. @RichardMelito's work-around works great.
The function
ScalarMinimizationResult FindMinimum(IScalarObjectiveFunction objective, double lowerBound, double upperBound)
(in Numerics.Optimization) does not respect thelowerBound
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:
Is this indeed a bug?