MATH-707
Renamed "SimpleVectorialValueChecker" to "SimpleVectorValueChecker". git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1243370 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
1b8959c711
commit
0f2ef2d954
|
@ -31,12 +31,12 @@ import org.apache.commons.math.util.FastMath;
|
|||
* @version $Id$
|
||||
* @since 3.0
|
||||
*/
|
||||
public class SimpleVectorialValueChecker
|
||||
public class SimpleVectorValueChecker
|
||||
extends AbstractConvergenceChecker<PointVectorValuePair> {
|
||||
/**
|
||||
* Build an instance with default thresholds.
|
||||
*/
|
||||
public SimpleVectorialValueChecker() {}
|
||||
public SimpleVectorValueChecker() {}
|
||||
|
||||
/**
|
||||
* Build an instance with specified thresholds.
|
||||
|
@ -48,7 +48,7 @@ public class SimpleVectorialValueChecker
|
|||
* @param relativeThreshold relative tolerance threshold
|
||||
* @param absoluteThreshold absolute tolerance threshold
|
||||
*/
|
||||
public SimpleVectorialValueChecker(final double relativeThreshold,
|
||||
public SimpleVectorValueChecker(final double relativeThreshold,
|
||||
final double absoluteThreshold) {
|
||||
super(relativeThreshold, absoluteThreshold);
|
||||
}
|
|
@ -24,7 +24,7 @@ package org.apache.commons.math.optimization;
|
|||
* user should provide a class implementing this interface to allow the optimization
|
||||
* algorithm to stop its search according to the problem at hand.</p>
|
||||
* <p>For convenience, two implementations that fit simple needs are already provided:
|
||||
* {@link SimpleVectorialValueChecker} and {@link SimplePointChecker<PointVectorValuePair>}. The first
|
||||
* {@link SimpleVectorValueChecker} and {@link SimplePointChecker<PointVectorValuePair>}. The first
|
||||
* one considers convergence is reached when the objective function value does not
|
||||
* change much anymore, it does not use the point set at all. The second one
|
||||
* considers convergence is reached when the input point set does not change
|
||||
|
|
|
@ -26,7 +26,7 @@ import org.apache.commons.math.analysis.MultivariateVectorFunction;
|
|||
import org.apache.commons.math.optimization.BaseMultivariateVectorOptimizer;
|
||||
import org.apache.commons.math.optimization.ConvergenceChecker;
|
||||
import org.apache.commons.math.optimization.PointVectorValuePair;
|
||||
import org.apache.commons.math.optimization.SimpleVectorialValueChecker;
|
||||
import org.apache.commons.math.optimization.SimpleVectorValueChecker;
|
||||
|
||||
/**
|
||||
* Base class for implementing optimizers for multivariate scalar functions.
|
||||
|
@ -55,11 +55,11 @@ public abstract class BaseAbstractMultivariateVectorOptimizer<FUNC extends Multi
|
|||
|
||||
/**
|
||||
* Simple constructor with default settings.
|
||||
* The convergence check is set to a {@link SimpleVectorialValueChecker} and
|
||||
* The convergence check is set to a {@link SimpleVectorValueChecker} and
|
||||
* the allowed number of evaluations is set to {@link Integer#MAX_VALUE}.
|
||||
*/
|
||||
protected BaseAbstractMultivariateVectorOptimizer() {
|
||||
this(new SimpleVectorialValueChecker());
|
||||
this(new SimpleVectorValueChecker());
|
||||
}
|
||||
/**
|
||||
* @param checker Convergence checker.
|
||||
|
|
|
@ -83,7 +83,7 @@ public abstract class AbstractLeastSquaresOptimizer
|
|||
/**
|
||||
* Simple constructor with default settings.
|
||||
* The convergence check is set to a {@link
|
||||
* org.apache.commons.math.optimization.SimpleVectorialValueChecker}.
|
||||
* org.apache.commons.math.optimization.SimpleVectorValueChecker}.
|
||||
*/
|
||||
protected AbstractLeastSquaresOptimizer() {}
|
||||
/**
|
||||
|
|
|
@ -27,7 +27,7 @@ import org.apache.commons.math.linear.QRDecomposition;
|
|||
import org.apache.commons.math.linear.RealMatrix;
|
||||
import org.apache.commons.math.linear.SingularMatrixException;
|
||||
import org.apache.commons.math.optimization.ConvergenceChecker;
|
||||
import org.apache.commons.math.optimization.SimpleVectorialValueChecker;
|
||||
import org.apache.commons.math.optimization.SimpleVectorValueChecker;
|
||||
import org.apache.commons.math.optimization.PointVectorValuePair;
|
||||
|
||||
/**
|
||||
|
@ -51,7 +51,7 @@ public class GaussNewtonOptimizer extends AbstractLeastSquaresOptimizer {
|
|||
/**
|
||||
* Simple constructor with default settings.
|
||||
* The normal equations will be solved using LU decomposition and the
|
||||
* convergence check is set to a {@link SimpleVectorialValueChecker}
|
||||
* convergence check is set to a {@link SimpleVectorValueChecker}
|
||||
* with default tolerances.
|
||||
*/
|
||||
public GaussNewtonOptimizer() {
|
||||
|
@ -70,7 +70,7 @@ public class GaussNewtonOptimizer extends AbstractLeastSquaresOptimizer {
|
|||
|
||||
/**
|
||||
* Simple constructor with default settings.
|
||||
* The convergence check is set to a {@link SimpleVectorialValueChecker}
|
||||
* The convergence check is set to a {@link SimpleVectorValueChecker}
|
||||
* with default tolerances.
|
||||
*
|
||||
* @param useLU If {@code true}, the normal equations will be solved
|
||||
|
@ -78,7 +78,7 @@ public class GaussNewtonOptimizer extends AbstractLeastSquaresOptimizer {
|
|||
* decomposition.
|
||||
*/
|
||||
public GaussNewtonOptimizer(final boolean useLU) {
|
||||
this(useLU, new SimpleVectorialValueChecker());
|
||||
this(useLU, new SimpleVectorValueChecker());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -101,7 +101,7 @@ public class DifferentiableMultivariateVectorMultiStartOptimizerTest {
|
|||
new LinearProblem(new double[][] { { 2 } }, new double[] { 3 });
|
||||
DifferentiableMultivariateVectorOptimizer underlyingOptimizer =
|
||||
new GaussNewtonOptimizer(true,
|
||||
new SimpleVectorialValueChecker(1.0e-6, 1.0e-6));
|
||||
new SimpleVectorValueChecker(1.0e-6, 1.0e-6));
|
||||
JDKRandomGenerator g = new JDKRandomGenerator();
|
||||
g.setSeed(16069223052l);
|
||||
RandomVectorGenerator generator =
|
||||
|
@ -136,7 +136,7 @@ public class DifferentiableMultivariateVectorMultiStartOptimizerTest {
|
|||
public void testNoOptimum() {
|
||||
DifferentiableMultivariateVectorOptimizer underlyingOptimizer =
|
||||
new GaussNewtonOptimizer(true,
|
||||
new SimpleVectorialValueChecker(1.0e-6, 1.0e-6));
|
||||
new SimpleVectorValueChecker(1.0e-6, 1.0e-6));
|
||||
JDKRandomGenerator g = new JDKRandomGenerator();
|
||||
g.setSeed(12373523445l);
|
||||
RandomVectorGenerator generator =
|
||||
|
|
|
@ -29,7 +29,7 @@ import org.apache.commons.math.analysis.DifferentiableMultivariateVectorFunction
|
|||
import org.apache.commons.math.analysis.MultivariateMatrixFunction;
|
||||
import org.apache.commons.math.linear.BlockRealMatrix;
|
||||
import org.apache.commons.math.linear.RealMatrix;
|
||||
import org.apache.commons.math.optimization.SimpleVectorialValueChecker;
|
||||
import org.apache.commons.math.optimization.SimpleVectorValueChecker;
|
||||
import org.apache.commons.math.optimization.PointVectorValuePair;
|
||||
import org.apache.commons.math.util.FastMath;
|
||||
import org.junit.Assert;
|
||||
|
@ -105,7 +105,7 @@ public class GaussNewtonOptimizerTest {
|
|||
new LinearProblem(new double[][] { { 2 } }, new double[] { 3 });
|
||||
|
||||
GaussNewtonOptimizer optimizer
|
||||
= new GaussNewtonOptimizer(new SimpleVectorialValueChecker(1.0e-6, 1.0e-6));
|
||||
= new GaussNewtonOptimizer(new SimpleVectorValueChecker(1.0e-6, 1.0e-6));
|
||||
|
||||
PointVectorValuePair optimum =
|
||||
optimizer.optimize(100, problem, problem.target, new double[] { 1 }, new double[] { 0 });
|
||||
|
@ -122,7 +122,7 @@ public class GaussNewtonOptimizerTest {
|
|||
new double[] { 4.0, 6.0, 1.0 });
|
||||
|
||||
GaussNewtonOptimizer optimizer
|
||||
= new GaussNewtonOptimizer(new SimpleVectorialValueChecker(1.0e-6, 1.0e-6));
|
||||
= new GaussNewtonOptimizer(new SimpleVectorValueChecker(1.0e-6, 1.0e-6));
|
||||
|
||||
PointVectorValuePair optimum =
|
||||
optimizer.optimize(100, problem, problem.target, new double[] { 1, 1, 1 }, new double[] { 0, 0 });
|
||||
|
@ -147,7 +147,7 @@ public class GaussNewtonOptimizerTest {
|
|||
}, new double[] { 0.0, 1.1, 2.2, 3.3, 4.4, 5.5 });
|
||||
|
||||
GaussNewtonOptimizer optimizer
|
||||
= new GaussNewtonOptimizer(new SimpleVectorialValueChecker(1.0e-6, 1.0e-6));
|
||||
= new GaussNewtonOptimizer(new SimpleVectorValueChecker(1.0e-6, 1.0e-6));
|
||||
|
||||
PointVectorValuePair optimum =
|
||||
optimizer.optimize(100, problem, problem.target, new double[] { 1, 1, 1, 1, 1, 1 },
|
||||
|
@ -168,7 +168,7 @@ public class GaussNewtonOptimizerTest {
|
|||
}, new double[] { 1, 1, 1});
|
||||
|
||||
GaussNewtonOptimizer optimizer
|
||||
= new GaussNewtonOptimizer(new SimpleVectorialValueChecker(1.0e-6, 1.0e-6));
|
||||
= new GaussNewtonOptimizer(new SimpleVectorValueChecker(1.0e-6, 1.0e-6));
|
||||
|
||||
PointVectorValuePair optimum =
|
||||
optimizer.optimize(100, problem, problem.target, new double[] { 1, 1, 1 }, new double[] { 0, 0, 0 });
|
||||
|
@ -192,7 +192,7 @@ public class GaussNewtonOptimizerTest {
|
|||
}, new double[] { 2, -9, 2, 2, 1 + epsilon * epsilon, 2});
|
||||
|
||||
GaussNewtonOptimizer optimizer
|
||||
= new GaussNewtonOptimizer(new SimpleVectorialValueChecker(1.0e-6, 1.0e-6));
|
||||
= new GaussNewtonOptimizer(new SimpleVectorValueChecker(1.0e-6, 1.0e-6));
|
||||
|
||||
PointVectorValuePair optimum =
|
||||
optimizer.optimize(100, problem, problem.target, new double[] { 1, 1, 1, 1, 1, 1 },
|
||||
|
@ -217,7 +217,7 @@ public class GaussNewtonOptimizerTest {
|
|||
}, new double[] { 1, 1, 1 });
|
||||
|
||||
GaussNewtonOptimizer optimizer
|
||||
= new GaussNewtonOptimizer(new SimpleVectorialValueChecker(1.0e-6, 1.0e-6));
|
||||
= new GaussNewtonOptimizer(new SimpleVectorValueChecker(1.0e-6, 1.0e-6));
|
||||
|
||||
optimizer.optimize(100, problem, problem.target, new double[] { 1, 1, 1 }, new double[] { 0, 0, 0 });
|
||||
}
|
||||
|
@ -232,7 +232,7 @@ public class GaussNewtonOptimizerTest {
|
|||
}, new double[] { 32, 23, 33, 31 });
|
||||
|
||||
GaussNewtonOptimizer optimizer
|
||||
= new GaussNewtonOptimizer(new SimpleVectorialValueChecker(1.0e-6, 1.0e-6));
|
||||
= new GaussNewtonOptimizer(new SimpleVectorValueChecker(1.0e-6, 1.0e-6));
|
||||
|
||||
PointVectorValuePair optimum1 =
|
||||
optimizer.optimize(100, problem1, problem1.target, new double[] { 1, 1, 1, 1 },
|
||||
|
@ -270,7 +270,7 @@ public class GaussNewtonOptimizerTest {
|
|||
}, new double[] { 7.0, 3.0, 5.0 });
|
||||
|
||||
GaussNewtonOptimizer optimizer
|
||||
= new GaussNewtonOptimizer(new SimpleVectorialValueChecker(1.0e-6, 1.0e-6));
|
||||
= new GaussNewtonOptimizer(new SimpleVectorValueChecker(1.0e-6, 1.0e-6));
|
||||
|
||||
optimizer.optimize(100, problem, problem.target, new double[] { 1, 1, 1 },
|
||||
new double[] { 7, 6, 5, 4 });
|
||||
|
@ -287,7 +287,7 @@ public class GaussNewtonOptimizerTest {
|
|||
}, new double[] { 3.0, 12.0, -1.0, 7.0, 1.0 });
|
||||
|
||||
GaussNewtonOptimizer optimizer
|
||||
= new GaussNewtonOptimizer(new SimpleVectorialValueChecker(1.0e-6, 1.0e-6));
|
||||
= new GaussNewtonOptimizer(new SimpleVectorValueChecker(1.0e-6, 1.0e-6));
|
||||
|
||||
optimizer.optimize(100, problem, problem.target, new double[] { 1, 1, 1, 1, 1 },
|
||||
new double[] { 2, 2, 2, 2, 2, 2 });
|
||||
|
@ -302,7 +302,7 @@ public class GaussNewtonOptimizerTest {
|
|||
}, new double[] { 3.0, 1.0, 5.0 });
|
||||
|
||||
GaussNewtonOptimizer optimizer
|
||||
= new GaussNewtonOptimizer(new SimpleVectorialValueChecker(1.0e-6, 1.0e-6));
|
||||
= new GaussNewtonOptimizer(new SimpleVectorValueChecker(1.0e-6, 1.0e-6));
|
||||
|
||||
PointVectorValuePair optimum =
|
||||
optimizer.optimize(100, problem, problem.target, new double[] { 1, 1, 1 },
|
||||
|
@ -321,7 +321,7 @@ public class GaussNewtonOptimizerTest {
|
|||
}, new double[] { 3.0, 1.0, 4.0 });
|
||||
|
||||
GaussNewtonOptimizer optimizer
|
||||
= new GaussNewtonOptimizer(new SimpleVectorialValueChecker(1.0e-6, 1.0e-6));
|
||||
= new GaussNewtonOptimizer(new SimpleVectorValueChecker(1.0e-6, 1.0e-6));
|
||||
|
||||
optimizer.optimize(100, problem, problem.target, new double[] { 1, 1, 1 }, new double[] { 1, 1 });
|
||||
Assert.assertTrue(optimizer.getRMS() > 0.1);
|
||||
|
@ -334,7 +334,7 @@ public class GaussNewtonOptimizerTest {
|
|||
new LinearProblem(new double[][] { { 1, 0 }, { 0, 1 } }, new double[] { -1, 1 });
|
||||
|
||||
GaussNewtonOptimizer optimizer
|
||||
= new GaussNewtonOptimizer(new SimpleVectorialValueChecker(1.0e-6, 1.0e-6));
|
||||
= new GaussNewtonOptimizer(new SimpleVectorValueChecker(1.0e-6, 1.0e-6));
|
||||
|
||||
PointVectorValuePair optimum =
|
||||
optimizer.optimize(100, problem, problem.target, new double[] { 1, 1 }, new double[] { 0, 0 });
|
||||
|
@ -353,7 +353,7 @@ public class GaussNewtonOptimizerTest {
|
|||
new LinearProblem(new double[][] { { 1, 0 }, { 0, 1 } }, new double[] { -1, 1 });
|
||||
|
||||
GaussNewtonOptimizer optimizer
|
||||
= new GaussNewtonOptimizer(new SimpleVectorialValueChecker(1.0e-6, 1.0e-6));
|
||||
= new GaussNewtonOptimizer(new SimpleVectorValueChecker(1.0e-6, 1.0e-6));
|
||||
|
||||
PointVectorValuePair optimum =
|
||||
optimizer.optimize(100, problem, problem.target, new double[] { 1, 1 }, new double[] { 0, 0 });
|
||||
|
@ -376,7 +376,7 @@ public class GaussNewtonOptimizerTest {
|
|||
circle.addPoint( 45.0, 97.0);
|
||||
|
||||
GaussNewtonOptimizer optimizer
|
||||
= new GaussNewtonOptimizer(new SimpleVectorialValueChecker(1.0e-30, 1.0e-30));
|
||||
= new GaussNewtonOptimizer(new SimpleVectorValueChecker(1.0e-30, 1.0e-30));
|
||||
|
||||
optimizer.optimize(100, circle, new double[] { 0, 0, 0, 0, 0 },
|
||||
new double[] { 1, 1, 1, 1, 1 },
|
||||
|
@ -393,7 +393,7 @@ public class GaussNewtonOptimizerTest {
|
|||
circle.addPoint( 45.0, 97.0);
|
||||
|
||||
GaussNewtonOptimizer optimizer
|
||||
= new GaussNewtonOptimizer(new SimpleVectorialValueChecker(1.0e-13, 1.0e-13));
|
||||
= new GaussNewtonOptimizer(new SimpleVectorValueChecker(1.0e-13, 1.0e-13));
|
||||
|
||||
PointVectorValuePair optimum =
|
||||
optimizer.optimize(100, circle, new double[] { 0, 0, 0, 0, 0 },
|
||||
|
@ -419,7 +419,7 @@ public class GaussNewtonOptimizerTest {
|
|||
}
|
||||
|
||||
GaussNewtonOptimizer optimizer
|
||||
= new GaussNewtonOptimizer(new SimpleVectorialValueChecker(1.0e-6, 1.0e-6));
|
||||
= new GaussNewtonOptimizer(new SimpleVectorValueChecker(1.0e-6, 1.0e-6));
|
||||
|
||||
optimizer.optimize(100, circle, target, weights, new double[] { -12, -12 });
|
||||
}
|
||||
|
@ -437,7 +437,7 @@ public class GaussNewtonOptimizerTest {
|
|||
}
|
||||
|
||||
GaussNewtonOptimizer optimizer
|
||||
= new GaussNewtonOptimizer(new SimpleVectorialValueChecker(1.0e-6, 1.0e-6));
|
||||
= new GaussNewtonOptimizer(new SimpleVectorValueChecker(1.0e-6, 1.0e-6));
|
||||
|
||||
PointVectorValuePair optimum =
|
||||
optimizer.optimize(100, circle, target, weights, new double[] { 0, 0 });
|
||||
|
|
|
@ -33,7 +33,7 @@ import org.apache.commons.math.analysis.MultivariateMatrixFunction;
|
|||
import org.apache.commons.math.linear.BlockRealMatrix;
|
||||
import org.apache.commons.math.linear.RealMatrix;
|
||||
import org.apache.commons.math.linear.SingularMatrixException;
|
||||
import org.apache.commons.math.optimization.SimpleVectorialValueChecker;
|
||||
import org.apache.commons.math.optimization.SimpleVectorValueChecker;
|
||||
import org.apache.commons.math.optimization.PointVectorValuePair;
|
||||
import org.apache.commons.math.util.Precision;
|
||||
import org.apache.commons.math.util.FastMath;
|
||||
|
@ -480,7 +480,7 @@ public class LevenbergMarquardtOptimizerTest {
|
|||
circle.addPoint(points[i][0], points[i][1]);
|
||||
}
|
||||
LevenbergMarquardtOptimizer optimizer
|
||||
= new LevenbergMarquardtOptimizer(new SimpleVectorialValueChecker(1.0e-8, 1.0e-8));
|
||||
= new LevenbergMarquardtOptimizer(new SimpleVectorValueChecker(1.0e-8, 1.0e-8));
|
||||
PointVectorValuePair optimum =
|
||||
optimizer.optimize(100, circle, target, weights, new double[] { -12, -12 });
|
||||
Point2D.Double center = new Point2D.Double(optimum.getPointRef()[0], optimum.getPointRef()[1]);
|
||||
|
|
Loading…
Reference in New Issue