MATH-707
"SimpleScalarValueChecker" renamed to "SimpleValueChecker". git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1243366 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
0bee543107
commit
1b8959c711
|
@ -26,7 +26,7 @@ package org.apache.commons.math.optimization;
|
|||
*
|
||||
* @param <PAIR> Type of the (point, objective value) pair.
|
||||
*
|
||||
* @see org.apache.commons.math.optimization.SimpleScalarValueChecker
|
||||
* @see org.apache.commons.math.optimization.SimpleValueChecker
|
||||
* @see org.apache.commons.math.optimization.SimplePointChecker<PointValuePair>
|
||||
*
|
||||
* @version $Id$
|
||||
|
|
|
@ -31,12 +31,12 @@ import org.apache.commons.math.util.FastMath;
|
|||
* @version $Id$
|
||||
* @since 3.0
|
||||
*/
|
||||
public class SimpleScalarValueChecker
|
||||
public class SimpleValueChecker
|
||||
extends AbstractConvergenceChecker<PointValuePair> {
|
||||
/**
|
||||
* Build an instance with default thresholds.
|
||||
*/
|
||||
public SimpleScalarValueChecker() {}
|
||||
public SimpleValueChecker() {}
|
||||
|
||||
/** Build an instance with specified thresholds.
|
||||
*
|
||||
|
@ -47,7 +47,7 @@ public class SimpleScalarValueChecker
|
|||
* @param relativeThreshold relative tolerance threshold
|
||||
* @param absoluteThreshold absolute tolerance threshold
|
||||
*/
|
||||
public SimpleScalarValueChecker(final double relativeThreshold,
|
||||
public SimpleValueChecker(final double relativeThreshold,
|
||||
final double absoluteThreshold) {
|
||||
super(relativeThreshold, absoluteThreshold);
|
||||
}
|
|
@ -26,7 +26,7 @@ import org.apache.commons.math.optimization.BaseMultivariateOptimizer;
|
|||
import org.apache.commons.math.optimization.GoalType;
|
||||
import org.apache.commons.math.optimization.ConvergenceChecker;
|
||||
import org.apache.commons.math.optimization.PointValuePair;
|
||||
import org.apache.commons.math.optimization.SimpleScalarValueChecker;
|
||||
import org.apache.commons.math.optimization.SimpleValueChecker;
|
||||
|
||||
/**
|
||||
* Base class for implementing optimizers for multivariate scalar functions.
|
||||
|
@ -53,11 +53,11 @@ public abstract class BaseAbstractMultivariateOptimizer<FUNC extends Multivariat
|
|||
|
||||
/**
|
||||
* Simple constructor with default settings.
|
||||
* The convergence check is set to a {@link SimpleScalarValueChecker} and
|
||||
* The convergence check is set to a {@link SimpleValueChecker} and
|
||||
* the allowed number of evaluations is set to {@link Integer#MAX_VALUE}.
|
||||
*/
|
||||
protected BaseAbstractMultivariateOptimizer() {
|
||||
this(new SimpleScalarValueChecker());
|
||||
this(new SimpleValueChecker());
|
||||
}
|
||||
/**
|
||||
* @param checker Convergence checker.
|
||||
|
|
|
@ -51,7 +51,7 @@ public abstract class BaseAbstractMultivariateSimpleBoundsOptimizer<FUNC extends
|
|||
/**
|
||||
* Simple constructor with default settings.
|
||||
* The convergence checker is set to a
|
||||
* {@link org.apache.commons.math.optimization.SimpleScalarValueChecker} and
|
||||
* {@link org.apache.commons.math.optimization.SimpleValueChecker} and
|
||||
* the allowed number of evaluations is set to {@link Integer#MAX_VALUE}.
|
||||
*
|
||||
* @see BaseAbstractMultivariateOptimizer#BaseAbstractMultivariateOptimizer()
|
||||
|
|
|
@ -35,7 +35,7 @@ import org.apache.commons.math.optimization.ConvergenceChecker;
|
|||
import org.apache.commons.math.optimization.GoalType;
|
||||
import org.apache.commons.math.optimization.MultivariateOptimizer;
|
||||
import org.apache.commons.math.optimization.PointValuePair;
|
||||
import org.apache.commons.math.optimization.SimpleScalarValueChecker;
|
||||
import org.apache.commons.math.optimization.SimpleValueChecker;
|
||||
import org.apache.commons.math.random.MersenneTwister;
|
||||
import org.apache.commons.math.random.RandomGenerator;
|
||||
import org.apache.commons.math.util.MathArrays;
|
||||
|
@ -280,7 +280,7 @@ public class CMAESOptimizer
|
|||
RandomGenerator random, boolean generateStatistics) {
|
||||
this(lambda, inputSigma, boundaries, maxIterations, stopFitness, isActiveCMA,
|
||||
diagonalOnly, checkFeasableCount, random, generateStatistics,
|
||||
new SimpleScalarValueChecker());
|
||||
new SimpleValueChecker());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -24,7 +24,7 @@ import org.apache.commons.math.exception.NullArgumentException;
|
|||
import org.apache.commons.math.optimization.GoalType;
|
||||
import org.apache.commons.math.optimization.ConvergenceChecker;
|
||||
import org.apache.commons.math.optimization.PointValuePair;
|
||||
import org.apache.commons.math.optimization.SimpleScalarValueChecker;
|
||||
import org.apache.commons.math.optimization.SimpleValueChecker;
|
||||
import org.apache.commons.math.optimization.MultivariateOptimizer;
|
||||
|
||||
/**
|
||||
|
@ -90,11 +90,11 @@ public class SimplexOptimizer
|
|||
private AbstractSimplex simplex;
|
||||
|
||||
/**
|
||||
* Constructor using a default {@link SimpleScalarValueChecker convergence
|
||||
* Constructor using a default {@link SimpleValueChecker convergence
|
||||
* checker}.
|
||||
*/
|
||||
public SimplexOptimizer() {
|
||||
this(new SimpleScalarValueChecker());
|
||||
this(new SimpleValueChecker());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -109,7 +109,7 @@ public class SimplexOptimizer
|
|||
* @param abs Absolute threshold.
|
||||
*/
|
||||
public SimplexOptimizer(double rel, double abs) {
|
||||
this(new SimpleScalarValueChecker(rel, abs));
|
||||
this(new SimpleValueChecker(rel, abs));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -44,8 +44,8 @@ public abstract class AbstractScalarDifferentiableOptimizer
|
|||
/**
|
||||
* Simple constructor with default settings.
|
||||
* The convergence check is set to a
|
||||
* {@link org.apache.commons.math.optimization.SimpleScalarValueChecker
|
||||
* SimpleScalarValueChecker}.
|
||||
* {@link org.apache.commons.math.optimization.SimpleValueChecker
|
||||
* SimpleValueChecker}.
|
||||
*/
|
||||
protected AbstractScalarDifferentiableOptimizer() {}
|
||||
/**
|
||||
|
|
|
@ -24,7 +24,7 @@ import org.apache.commons.math.analysis.solvers.UnivariateSolver;
|
|||
import org.apache.commons.math.exception.util.LocalizedFormats;
|
||||
import org.apache.commons.math.optimization.GoalType;
|
||||
import org.apache.commons.math.optimization.PointValuePair;
|
||||
import org.apache.commons.math.optimization.SimpleScalarValueChecker;
|
||||
import org.apache.commons.math.optimization.SimpleValueChecker;
|
||||
import org.apache.commons.math.optimization.ConvergenceChecker;
|
||||
import org.apache.commons.math.util.FastMath;
|
||||
|
||||
|
@ -54,7 +54,7 @@ public class NonLinearConjugateGradientOptimizer
|
|||
private double[] point;
|
||||
|
||||
/**
|
||||
* Constructor with default {@link SimpleScalarValueChecker checker},
|
||||
* Constructor with default {@link SimpleValueChecker checker},
|
||||
* {@link BrentSolver line search solver} and
|
||||
* {@link IdentityPreconditioner preconditioner}.
|
||||
*
|
||||
|
@ -64,7 +64,7 @@ public class NonLinearConjugateGradientOptimizer
|
|||
*/
|
||||
public NonLinearConjugateGradientOptimizer(final ConjugateGradientFormula updateFormula) {
|
||||
this(updateFormula,
|
||||
new SimpleScalarValueChecker());
|
||||
new SimpleValueChecker());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -45,7 +45,7 @@ public class DifferentiableMultivariateMultiStartOptimizerTest {
|
|||
circle.addPoint( 45.0, 97.0);
|
||||
NonLinearConjugateGradientOptimizer underlying =
|
||||
new NonLinearConjugateGradientOptimizer(ConjugateGradientFormula.POLAK_RIBIERE,
|
||||
new SimpleScalarValueChecker(1.0e-10, 1.0e-10));
|
||||
new SimpleValueChecker(1.0e-10, 1.0e-10));
|
||||
JDKRandomGenerator g = new JDKRandomGenerator();
|
||||
g.setSeed(753289573253l);
|
||||
RandomVectorGenerator generator =
|
||||
|
|
|
@ -33,7 +33,7 @@ public class MultivariateMultiStartOptimizerTest {
|
|||
public void testRosenbrock() {
|
||||
Rosenbrock rosenbrock = new Rosenbrock();
|
||||
SimplexOptimizer underlying
|
||||
= new SimplexOptimizer(new SimpleScalarValueChecker(-1, 1.0e-3));
|
||||
= new SimplexOptimizer(new SimpleValueChecker(-1, 1.0e-3));
|
||||
NelderMeadSimplex simplex = new NelderMeadSimplex(new double[][] {
|
||||
{ -1.2, 1.0 }, { 0.9, 1.2 } , { 3.5, -2.3 }
|
||||
});
|
||||
|
|
|
@ -20,7 +20,7 @@ package org.apache.commons.math.optimization.direct;
|
|||
import org.apache.commons.math.analysis.MultivariateFunction;
|
||||
import org.apache.commons.math.optimization.GoalType;
|
||||
import org.apache.commons.math.optimization.PointValuePair;
|
||||
import org.apache.commons.math.optimization.SimpleScalarValueChecker;
|
||||
import org.apache.commons.math.optimization.SimpleValueChecker;
|
||||
import org.apache.commons.math.util.FastMath;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
@ -73,7 +73,7 @@ public class SimplexOptimizerMultiDirectionalTest {
|
|||
|
||||
@Test
|
||||
public void testMaximize2() {
|
||||
SimplexOptimizer optimizer = new SimplexOptimizer(new SimpleScalarValueChecker(1e-15, 1e-30));
|
||||
SimplexOptimizer optimizer = new SimplexOptimizer(new SimpleValueChecker(1e-15, 1e-30));
|
||||
optimizer.setSimplex(new MultiDirectionalSimplex(new double[] { 0.2, 0.2 }));
|
||||
final FourExtrema fourExtrema = new FourExtrema();
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ import org.apache.commons.math.linear.BlockRealMatrix;
|
|||
import org.apache.commons.math.linear.RealMatrix;
|
||||
import org.apache.commons.math.optimization.GoalType;
|
||||
import org.apache.commons.math.optimization.PointValuePair;
|
||||
import org.apache.commons.math.optimization.SimpleScalarValueChecker;
|
||||
import org.apache.commons.math.optimization.SimpleValueChecker;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -100,7 +100,7 @@ public class NonLinearConjugateGradientOptimizerTest {
|
|||
new LinearProblem(new double[][] { { 2 } }, new double[] { 3 });
|
||||
NonLinearConjugateGradientOptimizer optimizer =
|
||||
new NonLinearConjugateGradientOptimizer(ConjugateGradientFormula.POLAK_RIBIERE,
|
||||
new SimpleScalarValueChecker(1e-6, 1e-6));
|
||||
new SimpleValueChecker(1e-6, 1e-6));
|
||||
PointValuePair optimum =
|
||||
optimizer.optimize(100, problem, GoalType.MINIMIZE, new double[] { 0 });
|
||||
Assert.assertEquals(1.5, optimum.getPoint()[0], 1.0e-10);
|
||||
|
@ -115,7 +115,7 @@ public class NonLinearConjugateGradientOptimizerTest {
|
|||
|
||||
NonLinearConjugateGradientOptimizer optimizer =
|
||||
new NonLinearConjugateGradientOptimizer(ConjugateGradientFormula.POLAK_RIBIERE,
|
||||
new SimpleScalarValueChecker(1e-6, 1e-6));
|
||||
new SimpleValueChecker(1e-6, 1e-6));
|
||||
PointValuePair optimum =
|
||||
optimizer.optimize(100, problem, GoalType.MINIMIZE, new double[] { 0, 0 });
|
||||
Assert.assertEquals(7.0, optimum.getPoint()[0], 1.0e-10);
|
||||
|
@ -136,7 +136,7 @@ public class NonLinearConjugateGradientOptimizerTest {
|
|||
}, new double[] { 0.0, 1.1, 2.2, 3.3, 4.4, 5.5 });
|
||||
NonLinearConjugateGradientOptimizer optimizer =
|
||||
new NonLinearConjugateGradientOptimizer(ConjugateGradientFormula.POLAK_RIBIERE,
|
||||
new SimpleScalarValueChecker(1e-6, 1e-6));
|
||||
new SimpleValueChecker(1e-6, 1e-6));
|
||||
PointValuePair optimum =
|
||||
optimizer.optimize(100, problem, GoalType.MINIMIZE, new double[] { 0, 0, 0, 0, 0, 0 });
|
||||
for (int i = 0; i < problem.target.length; ++i) {
|
||||
|
@ -153,7 +153,7 @@ public class NonLinearConjugateGradientOptimizerTest {
|
|||
}, new double[] { 1, 1, 1});
|
||||
NonLinearConjugateGradientOptimizer optimizer =
|
||||
new NonLinearConjugateGradientOptimizer(ConjugateGradientFormula.POLAK_RIBIERE,
|
||||
new SimpleScalarValueChecker(1e-6, 1e-6));
|
||||
new SimpleValueChecker(1e-6, 1e-6));
|
||||
PointValuePair optimum =
|
||||
optimizer.optimize(100, problem, GoalType.MINIMIZE, new double[] { 0, 0, 0 });
|
||||
Assert.assertEquals(1.0, optimum.getPoint()[0], 1.0e-10);
|
||||
|
@ -190,7 +190,7 @@ public class NonLinearConjugateGradientOptimizerTest {
|
|||
|
||||
NonLinearConjugateGradientOptimizer optimizer =
|
||||
new NonLinearConjugateGradientOptimizer(ConjugateGradientFormula.POLAK_RIBIERE,
|
||||
new SimpleScalarValueChecker(1e-13, 1e-13),
|
||||
new SimpleValueChecker(1e-13, 1e-13),
|
||||
new BrentSolver(),
|
||||
preconditioner);
|
||||
|
||||
|
@ -214,7 +214,7 @@ public class NonLinearConjugateGradientOptimizerTest {
|
|||
}, new double[] { 1, 1, 1 });
|
||||
NonLinearConjugateGradientOptimizer optimizer =
|
||||
new NonLinearConjugateGradientOptimizer(ConjugateGradientFormula.POLAK_RIBIERE,
|
||||
new SimpleScalarValueChecker(1e-6, 1e-6));
|
||||
new SimpleValueChecker(1e-6, 1e-6));
|
||||
PointValuePair optimum =
|
||||
optimizer.optimize(100, problem, GoalType.MINIMIZE, new double[] { 0, 0, 0 });
|
||||
Assert.assertTrue(optimum.getValue() > 0.5);
|
||||
|
@ -230,7 +230,7 @@ public class NonLinearConjugateGradientOptimizerTest {
|
|||
}, new double[] { 32, 23, 33, 31 });
|
||||
NonLinearConjugateGradientOptimizer optimizer =
|
||||
new NonLinearConjugateGradientOptimizer(ConjugateGradientFormula.POLAK_RIBIERE,
|
||||
new SimpleScalarValueChecker(1e-13, 1e-13),
|
||||
new SimpleValueChecker(1e-13, 1e-13),
|
||||
new BrentSolver(1e-15, 1e-15));
|
||||
PointValuePair optimum1 =
|
||||
optimizer.optimize(200, problem1, GoalType.MINIMIZE, new double[] { 0, 1, 2, 3 });
|
||||
|
@ -264,7 +264,7 @@ public class NonLinearConjugateGradientOptimizerTest {
|
|||
|
||||
NonLinearConjugateGradientOptimizer optimizer =
|
||||
new NonLinearConjugateGradientOptimizer(ConjugateGradientFormula.POLAK_RIBIERE,
|
||||
new SimpleScalarValueChecker(1e-6, 1e-6));
|
||||
new SimpleValueChecker(1e-6, 1e-6));
|
||||
PointValuePair optimum =
|
||||
optimizer.optimize(100, problem, GoalType.MINIMIZE, new double[] { 7, 6, 5, 4 });
|
||||
Assert.assertEquals(0, optimum.getValue(), 1.0e-10);
|
||||
|
@ -282,7 +282,7 @@ public class NonLinearConjugateGradientOptimizerTest {
|
|||
}, new double[] { 3.0, 12.0, -1.0, 7.0, 1.0 });
|
||||
NonLinearConjugateGradientOptimizer optimizer =
|
||||
new NonLinearConjugateGradientOptimizer(ConjugateGradientFormula.POLAK_RIBIERE,
|
||||
new SimpleScalarValueChecker(1e-6, 1e-6));
|
||||
new SimpleValueChecker(1e-6, 1e-6));
|
||||
PointValuePair optimum =
|
||||
optimizer.optimize(100, problem, GoalType.MINIMIZE, new double[] { 2, 2, 2, 2, 2, 2 });
|
||||
Assert.assertEquals(0, optimum.getValue(), 1.0e-10);
|
||||
|
@ -298,7 +298,7 @@ public class NonLinearConjugateGradientOptimizerTest {
|
|||
|
||||
NonLinearConjugateGradientOptimizer optimizer =
|
||||
new NonLinearConjugateGradientOptimizer(ConjugateGradientFormula.POLAK_RIBIERE,
|
||||
new SimpleScalarValueChecker(1e-6, 1e-6));
|
||||
new SimpleValueChecker(1e-6, 1e-6));
|
||||
PointValuePair optimum =
|
||||
optimizer.optimize(100, problem, GoalType.MINIMIZE, new double[] { 1, 1 });
|
||||
Assert.assertEquals(2.0, optimum.getPoint()[0], 1.0e-8);
|
||||
|
@ -316,7 +316,7 @@ public class NonLinearConjugateGradientOptimizerTest {
|
|||
|
||||
NonLinearConjugateGradientOptimizer optimizer =
|
||||
new NonLinearConjugateGradientOptimizer(ConjugateGradientFormula.POLAK_RIBIERE,
|
||||
new SimpleScalarValueChecker(1e-6, 1e-6));
|
||||
new SimpleValueChecker(1e-6, 1e-6));
|
||||
PointValuePair optimum =
|
||||
optimizer.optimize(100, problem, GoalType.MINIMIZE, new double[] { 1, 1 });
|
||||
Assert.assertTrue(optimum.getValue() > 0.1);
|
||||
|
@ -333,7 +333,7 @@ public class NonLinearConjugateGradientOptimizerTest {
|
|||
circle.addPoint( 45.0, 97.0);
|
||||
NonLinearConjugateGradientOptimizer optimizer =
|
||||
new NonLinearConjugateGradientOptimizer(ConjugateGradientFormula.POLAK_RIBIERE,
|
||||
new SimpleScalarValueChecker(1e-30, 1e-30),
|
||||
new SimpleValueChecker(1e-30, 1e-30),
|
||||
new BrentSolver(1e-15, 1e-13));
|
||||
PointValuePair optimum =
|
||||
optimizer.optimize(100, circle, GoalType.MINIMIZE, new double[] { 98.680, 47.345 });
|
||||
|
|
Loading…
Reference in New Issue