@Test
public void testQuinticMin() {
// The quintic function has zeros at 0, +-0.5 and +-1.
// The function has extrema (first derivative is zero) at 0.27195613 and 0.82221643,
UnivariateFunction f = new QuinticFunction();
UnivariateOptimizer underlying = new BrentOptimizer(1e-9, 1e-14);
JDKRandomGenerator g = new JDKRandomGenerator();
g.setSeed(4312000053L);
UnivariateMultiStartOptimizer<UnivariateFunction> optimizer =
new UnivariateMultiStartOptimizer<UnivariateFunction>(underlying, 5, g);
UnivariatePointValuePair optimum
= optimizer.optimize(300, f, GoalType.MINIMIZE, -0.3, -0.2);
Assert.assertEquals(-0.2719561293, optimum.getPoint(), 1e-9);
Assert.assertEquals(-0.0443342695, optimum.getValue(), 1e-9);
UnivariatePointValuePair[] optima = optimizer.getOptima();
for (int i = 0; i < optima.length; ++i) {
Assert.assertEquals(f.value(optima[i].getPoint()), optima[i].getValue(), 1e-9);
}
Assert.assertTrue(optimizer.getEvaluations() >= 50);
Assert.assertTrue(optimizer.getEvaluations() <= 100);
}