changing multistart behaviour to rely on search domain boundary rather than on start point

the only implementation of the raw minimizer ignores the start point so the multistart optimizer always found the same point before the change

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@795607 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Luc Maisonobe 2009-07-19 20:04:56 +00:00
parent a10238de1d
commit 28bb294968
1 changed files with 12 additions and 9 deletions

View File

@ -198,13 +198,6 @@ public class MultiStartUnivariateRealOptimizer implements UnivariateRealOptimize
final double min, final double max)
throws ConvergenceException,
FunctionEvaluationException {
return optimize(f, goalType, min, max, min + generator.nextDouble() * (max - min));
}
/** {@inheritDoc} */
public double optimize(final UnivariateRealFunction f, final GoalType goalType,
final double min, final double max, final double startValue)
throws ConvergenceException, FunctionEvaluationException {
optima = new double[starts];
totalIterations = 0;
@ -216,8 +209,11 @@ public class MultiStartUnivariateRealOptimizer implements UnivariateRealOptimize
try {
optimizer.setMaximalIterationCount(maxIterations - totalIterations);
optimizer.setMaxEvaluations(maxEvaluations - totalEvaluations);
optima[i] = optimizer.optimize(f, goalType, min, max,
(i == 0) ? startValue : generator.nextDouble() * (max - min));
final double bound1 = min + generator.nextDouble() * (max - min);
final double bound2 = min + generator.nextDouble() * (max - min);
optima[i] = optimizer.optimize(f, goalType,
Math.min(bound1, bound2),
Math.max(bound1, bound2));
} catch (FunctionEvaluationException fee) {
optima[i] = Double.NaN;
} catch (ConvergenceException ce) {
@ -257,4 +253,11 @@ public class MultiStartUnivariateRealOptimizer implements UnivariateRealOptimize
}
/** {@inheritDoc} */
public double optimize(final UnivariateRealFunction f, final GoalType goalType,
final double min, final double max, final double startValue)
throws ConvergenceException, FunctionEvaluationException {
return optimize(f, goalType, min, max);
}
}