Browse Source

Optimization: Fix bug in BisectionRootFinder

* Algorithm would incorrectly exit with MaximumIterationsException if the
root was bounded on the last permissible expansion step.
optimization-2
Scott Stephens 13 years ago
committed by Christoph Ruegg
parent
commit
0952f5145a
  1. 2
      src/Numerics/Optimization/BisectionRootFinder.cs

2
src/Numerics/Optimization/BisectionRootFinder.cs

@ -59,7 +59,7 @@ namespace MathNet.Numerics.Optimization
expansion_steps += 1;
}
if (expansion_steps == this.MaxExpansionSteps)
if (Math.Sign(lower_val) == Math.Sign(upper_val) && expansion_steps == this.MaxExpansionSteps)
throw new MaximumIterationsException("Could not bound root in maximum expansion iterations.");
while (Math.Abs(upper_val - lower_val) > 0.5 * this.ObjectiveTolerance || Math.Abs(upper_bound - lower_bound) > 0.5 * this.XTolerance)

Loading…
Cancel
Save