本文整理汇总了Java中org.apache.commons.math3.optim.PointVectorValuePair类的典型用法代码示例。如果您正苦于以下问题:Java PointVectorValuePair类的具体用法?Java PointVectorValuePair怎么用?Java PointVectorValuePair使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PointVectorValuePair类属于org.apache.commons.math3.optim包,在下文中一共展示了PointVectorValuePair类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: evaluationChecker
import org.apache.commons.math3.optim.PointVectorValuePair; //导入依赖的package包/类
/**
* View a convergence checker specified for a {@link PointVectorValuePair} as one
* specified for an {@link Evaluation}.
*
* @param checker the convergence checker to adapt.
* @return a convergence checker that delegates to {@code checker}.
*/
public static ConvergenceChecker<Evaluation> evaluationChecker(final ConvergenceChecker<PointVectorValuePair> checker) {
return new ConvergenceChecker<Evaluation>() {
/** {@inheritDoc} */
public boolean converged(final int iteration,
final Evaluation previous,
final Evaluation current) {
return checker.converged(
iteration,
new PointVectorValuePair(
previous.getPoint().toArray(),
previous.getResiduals().toArray(),
false),
new PointVectorValuePair(
current.getPoint().toArray(),
current.getResiduals().toArray(),
false)
);
}
};
}
开发者ID:biocompibens,项目名称:SME,代码行数:28,代码来源:LeastSquaresFactory.java
示例2: evaluationChecker
import org.apache.commons.math3.optim.PointVectorValuePair; //导入依赖的package包/类
/**
* View a convergence checker specified for a {@link PointVectorValuePair} as one
* specified for an {@link Evaluation}.
*
* @param checker the convergence checker to adapt.
* @return a convergence checker that delegates to {@code checker}.
*/
public static ConvergenceChecker<Evaluation> evaluationChecker(final ConvergenceChecker<PointVectorValuePair> checker) {
return new ConvergenceChecker<Evaluation>() {
public boolean converged(final int iteration,
final Evaluation previous,
final Evaluation current) {
return checker.converged(
iteration,
new PointVectorValuePair(
previous.getPoint().toArray(),
previous.getResiduals().toArray(),
false),
new PointVectorValuePair(
current.getPoint().toArray(),
current.getResiduals().toArray(),
false)
);
}
};
}
开发者ID:Quanticol,项目名称:CARMA,代码行数:27,代码来源:LeastSquaresFactory.java
示例3: getPairComparator
import org.apache.commons.math3.optim.PointVectorValuePair; //导入依赖的package包/类
/**
* @return a comparator for sorting the optima.
*/
private Comparator<PointVectorValuePair> getPairComparator() {
return new Comparator<PointVectorValuePair>() {
private final RealVector target = new ArrayRealVector(optimizer.getTarget(), false);
private final RealMatrix weight = optimizer.getWeight();
public int compare(final PointVectorValuePair o1,
final PointVectorValuePair o2) {
if (o1 == null) {
return (o2 == null) ? 0 : 1;
} else if (o2 == null) {
return -1;
}
return Double.compare(weightedResidual(o1),
weightedResidual(o2));
}
private double weightedResidual(final PointVectorValuePair pv) {
final RealVector v = new ArrayRealVector(pv.getValueRef(), false);
final RealVector r = target.subtract(v);
return r.dotProduct(weight.operate(r));
}
};
}
开发者ID:Quanticol,项目名称:CARMA,代码行数:27,代码来源:MultiStartMultivariateVectorOptimizer.java
示例4: testNonInvertible
import org.apache.commons.math3.optim.PointVectorValuePair; //导入依赖的package包/类
@Override
@Test(expected=SingularMatrixException.class)
public void testNonInvertible() {
/*
* Overrides the method from parent class, since the default singularity
* threshold (1e-14) does not trigger the expected exception.
*/
LinearProblem problem = new LinearProblem(new double[][] {
{ 1, 2, -3 },
{ 2, 1, 3 },
{ -3, 0, -9 }
}, new double[] { 1, 1, 1 });
AbstractLeastSquaresOptimizer optimizer = createOptimizer();
PointVectorValuePair optimum
= optimizer.optimize(new MaxEval(100),
problem.getModelFunction(),
problem.getModelFunctionJacobian(),
problem.getTarget(),
new Weight(new double[] { 1, 1, 1 }),
new InitialGuess(new double[] { 0, 0, 0 }));
Assert.assertTrue(FastMath.sqrt(optimizer.getTargetSize()) * optimizer.getRMS() > 0.6);
optimizer.computeCovariances(optimum.getPoint(), 1.5e-14);
}
开发者ID:Quanticol,项目名称:CARMA,代码行数:26,代码来源:LevenbergMarquardtOptimizerTest.java
示例5: testTrivial
import org.apache.commons.math3.optim.PointVectorValuePair; //导入依赖的package包/类
@Test
public void testTrivial() {
LinearProblem problem
= new LinearProblem(new double[][] { { 2 } }, new double[] { 3 });
AbstractLeastSquaresOptimizer optimizer = createOptimizer();
PointVectorValuePair optimum =
optimizer.optimize(new MaxEval(100),
problem.getModelFunction(),
problem.getModelFunctionJacobian(),
problem.getTarget(),
new Weight(new double[] { 1 }),
new InitialGuess(new double[] { 0 }));
Assert.assertEquals(0, optimizer.getRMS(), 1e-10);
Assert.assertEquals(1.5, optimum.getPoint()[0], 1e-10);
Assert.assertEquals(3.0, optimum.getValue()[0], 1e-10);
}
开发者ID:Quanticol,项目名称:CARMA,代码行数:17,代码来源:AbstractLeastSquaresOptimizerAbstractTest.java
示例6: testQRColumnsPermutation
import org.apache.commons.math3.optim.PointVectorValuePair; //导入依赖的package包/类
@Test
public void testQRColumnsPermutation() {
LinearProblem problem
= new LinearProblem(new double[][] { { 1, -1 }, { 0, 2 }, { 1, -2 } },
new double[] { 4, 6, 1 });
AbstractLeastSquaresOptimizer optimizer = createOptimizer();
PointVectorValuePair optimum =
optimizer.optimize(new MaxEval(100),
problem.getModelFunction(),
problem.getModelFunctionJacobian(),
problem.getTarget(),
new Weight(new double[] { 1, 1, 1 }),
new InitialGuess(new double[] { 0, 0 }));
Assert.assertEquals(0, optimizer.getRMS(), 1e-10);
Assert.assertEquals(7, optimum.getPoint()[0], 1e-10);
Assert.assertEquals(3, optimum.getPoint()[1], 1e-10);
Assert.assertEquals(4, optimum.getValue()[0], 1e-10);
Assert.assertEquals(6, optimum.getValue()[1], 1e-10);
Assert.assertEquals(1, optimum.getValue()[2], 1e-10);
}
开发者ID:Quanticol,项目名称:CARMA,代码行数:23,代码来源:AbstractLeastSquaresOptimizerAbstractTest.java
示例7: testNoDependency
import org.apache.commons.math3.optim.PointVectorValuePair; //导入依赖的package包/类
@Test
public void testNoDependency() {
LinearProblem problem = new LinearProblem(new double[][] {
{ 2, 0, 0, 0, 0, 0 },
{ 0, 2, 0, 0, 0, 0 },
{ 0, 0, 2, 0, 0, 0 },
{ 0, 0, 0, 2, 0, 0 },
{ 0, 0, 0, 0, 2, 0 },
{ 0, 0, 0, 0, 0, 2 }
}, new double[] { 0, 1.1, 2.2, 3.3, 4.4, 5.5 });
AbstractLeastSquaresOptimizer optimizer = createOptimizer();
PointVectorValuePair optimum =
optimizer.optimize(new MaxEval(100),
problem.getModelFunction(),
problem.getModelFunctionJacobian(),
problem.getTarget(),
new Weight(new double[] { 1, 1, 1, 1, 1, 1 }),
new InitialGuess(new double[] { 0, 0, 0, 0, 0, 0 }));
Assert.assertEquals(0, optimizer.getRMS(), 1e-10);
for (int i = 0; i < problem.target.length; ++i) {
Assert.assertEquals(0.55 * i, optimum.getPoint()[i], 1e-10);
}
}
开发者ID:Quanticol,项目名称:CARMA,代码行数:24,代码来源:AbstractLeastSquaresOptimizerAbstractTest.java
示例8: testOneSet
import org.apache.commons.math3.optim.PointVectorValuePair; //导入依赖的package包/类
@Test
public void testOneSet() {
LinearProblem problem = new LinearProblem(new double[][] {
{ 1, 0, 0 },
{ -1, 1, 0 },
{ 0, -1, 1 }
}, new double[] { 1, 1, 1});
AbstractLeastSquaresOptimizer optimizer = createOptimizer();
PointVectorValuePair optimum =
optimizer.optimize(new MaxEval(100),
problem.getModelFunction(),
problem.getModelFunctionJacobian(),
problem.getTarget(),
new Weight(new double[] { 1, 1, 1 }),
new InitialGuess(new double[] { 0, 0, 0 }));
Assert.assertEquals(0, optimizer.getRMS(), 1e-10);
Assert.assertEquals(1, optimum.getPoint()[0], 1e-10);
Assert.assertEquals(2, optimum.getPoint()[1], 1e-10);
Assert.assertEquals(3, optimum.getPoint()[2], 1e-10);
}
开发者ID:Quanticol,项目名称:CARMA,代码行数:22,代码来源:AbstractLeastSquaresOptimizerAbstractTest.java
示例9: testMoreEstimatedParametersUnsorted
import org.apache.commons.math3.optim.PointVectorValuePair; //导入依赖的package包/类
@Test
public void testMoreEstimatedParametersUnsorted() {
LinearProblem problem = new LinearProblem(new double[][] {
{ 1, 1, 0, 0, 0, 0 },
{ 0, 0, 1, 1, 1, 0 },
{ 0, 0, 0, 0, 1, -1 },
{ 0, 0, -1, 1, 0, 1 },
{ 0, 0, 0, -1, 1, 0 }
}, new double[] { 3, 12, -1, 7, 1 });
AbstractLeastSquaresOptimizer optimizer = createOptimizer();
PointVectorValuePair optimum =
optimizer.optimize(new MaxEval(100),
problem.getModelFunction(),
problem.getModelFunctionJacobian(),
problem.getTarget(),
new Weight(new double[] { 1, 1, 1, 1, 1 }),
new InitialGuess(new double[] { 2, 2, 2, 2, 2, 2 }));
Assert.assertEquals(0, optimizer.getRMS(), 1e-10);
Assert.assertEquals(3, optimum.getPointRef()[2], 1e-10);
Assert.assertEquals(4, optimum.getPointRef()[3], 1e-10);
Assert.assertEquals(5, optimum.getPointRef()[4], 1e-10);
Assert.assertEquals(6, optimum.getPointRef()[5], 1e-10);
}
开发者ID:Quanticol,项目名称:CARMA,代码行数:25,代码来源:AbstractLeastSquaresOptimizerAbstractTest.java
示例10: testRedundantEquations
import org.apache.commons.math3.optim.PointVectorValuePair; //导入依赖的package包/类
@Test
public void testRedundantEquations() {
LinearProblem problem = new LinearProblem(new double[][] {
{ 1, 1 },
{ 1, -1 },
{ 1, 3 }
}, new double[] { 3, 1, 5 });
AbstractLeastSquaresOptimizer optimizer = createOptimizer();
PointVectorValuePair optimum =
optimizer.optimize(new MaxEval(100),
problem.getModelFunction(),
problem.getModelFunctionJacobian(),
problem.getTarget(),
new Weight(new double[] { 1, 1, 1 }),
new InitialGuess(new double[] { 1, 1 }));
Assert.assertEquals(0, optimizer.getRMS(), 1e-10);
Assert.assertEquals(2, optimum.getPointRef()[0], 1e-10);
Assert.assertEquals(1, optimum.getPointRef()[1], 1e-10);
}
开发者ID:Quanticol,项目名称:CARMA,代码行数:21,代码来源:AbstractLeastSquaresOptimizerAbstractTest.java
示例11: testInconsistentSizes1
import org.apache.commons.math3.optim.PointVectorValuePair; //导入依赖的package包/类
@Test(expected=DimensionMismatchException.class)
public void testInconsistentSizes1() {
LinearProblem problem
= new LinearProblem(new double[][] { { 1, 0 }, { 0, 1 } },
new double[] { -1, 1 });
AbstractLeastSquaresOptimizer optimizer = createOptimizer();
PointVectorValuePair optimum =
optimizer.optimize(new MaxEval(100),
problem.getModelFunction(),
problem.getModelFunctionJacobian(),
problem.getTarget(),
new Weight(new double[] { 1, 1 }),
new InitialGuess(new double[] { 0, 0 }));
Assert.assertEquals(0, optimizer.getRMS(), 1e-10);
Assert.assertEquals(-1, optimum.getPoint()[0], 1e-10);
Assert.assertEquals(1, optimum.getPoint()[1], 1e-10);
optimizer.optimize(new MaxEval(100),
problem.getModelFunction(),
problem.getModelFunctionJacobian(),
problem.getTarget(),
new Weight(new double[] { 1 }),
new InitialGuess(new double[] { 0, 0 }));
}
开发者ID:Quanticol,项目名称:CARMA,代码行数:25,代码来源:AbstractLeastSquaresOptimizerAbstractTest.java
示例12: testInconsistentSizes2
import org.apache.commons.math3.optim.PointVectorValuePair; //导入依赖的package包/类
@Test(expected=DimensionMismatchException.class)
public void testInconsistentSizes2() {
LinearProblem problem
= new LinearProblem(new double[][] { { 1, 0 }, { 0, 1 } },
new double[] { -1, 1 });
AbstractLeastSquaresOptimizer optimizer = createOptimizer();
PointVectorValuePair optimum
= optimizer.optimize(new MaxEval(100),
problem.getModelFunction(),
problem.getModelFunctionJacobian(),
problem.getTarget(),
new Weight(new double[] { 1, 1 }),
new InitialGuess(new double[] { 0, 0 }));
Assert.assertEquals(0, optimizer.getRMS(), 1e-10);
Assert.assertEquals(-1, optimum.getPoint()[0], 1e-10);
Assert.assertEquals(1, optimum.getPoint()[1], 1e-10);
optimizer.optimize(new MaxEval(100),
problem.getModelFunction(),
problem.getModelFunctionJacobian(),
new Target(new double[] { 1 }),
new Weight(new double[] { 1 }),
new InitialGuess(new double[] { 0, 0 }));
}
开发者ID:Quanticol,项目名称:CARMA,代码行数:25,代码来源:AbstractLeastSquaresOptimizerAbstractTest.java
示例13: testCircleFittingBadInit
import org.apache.commons.math3.optim.PointVectorValuePair; //导入依赖的package包/类
@Test
public void testCircleFittingBadInit() {
CircleVectorial circle = new CircleVectorial();
double[][] points = circlePoints;
double[] target = new double[points.length];
Arrays.fill(target, 0);
double[] weights = new double[points.length];
Arrays.fill(weights, 2);
for (int i = 0; i < points.length; ++i) {
circle.addPoint(points[i][0], points[i][1]);
}
AbstractLeastSquaresOptimizer optimizer = createOptimizer();
PointVectorValuePair optimum
= optimizer.optimize(new MaxEval(100),
circle.getModelFunction(),
circle.getModelFunctionJacobian(),
new Target(target),
new Weight(weights),
new InitialGuess(new double[] { -12, -12 }));
Vector2D center = new Vector2D(optimum.getPointRef()[0], optimum.getPointRef()[1]);
Assert.assertTrue(optimizer.getEvaluations() < 25);
Assert.assertEquals( 0.043, optimizer.getRMS(), 1e-3);
Assert.assertEquals( 0.292235, circle.getRadius(center), 1e-6);
Assert.assertEquals(-0.151738, center.getX(), 1e-6);
Assert.assertEquals( 0.2075001, center.getY(), 1e-6);
}
开发者ID:Quanticol,项目名称:CARMA,代码行数:27,代码来源:AbstractLeastSquaresOptimizerAbstractTest.java
示例14: testCircleFittingGoodInit
import org.apache.commons.math3.optim.PointVectorValuePair; //导入依赖的package包/类
@Test
public void testCircleFittingGoodInit() {
CircleVectorial circle = new CircleVectorial();
double[][] points = circlePoints;
double[] target = new double[points.length];
Arrays.fill(target, 0);
double[] weights = new double[points.length];
Arrays.fill(weights, 2);
for (int i = 0; i < points.length; ++i) {
circle.addPoint(points[i][0], points[i][1]);
}
AbstractLeastSquaresOptimizer optimizer = createOptimizer();
PointVectorValuePair optimum =
optimizer.optimize(new MaxEval(100),
circle.getModelFunction(),
circle.getModelFunctionJacobian(),
new Target(target),
new Weight(weights),
new InitialGuess(new double[] { 0, 0 }));
Assert.assertEquals(-0.1517383071957963, optimum.getPointRef()[0], 1e-6);
Assert.assertEquals(0.2074999736353867, optimum.getPointRef()[1], 1e-6);
Assert.assertEquals(0.04268731682389561, optimizer.getRMS(), 1e-8);
}
开发者ID:Quanticol,项目名称:CARMA,代码行数:24,代码来源:AbstractLeastSquaresOptimizerAbstractTest.java
示例15: doTestStRD
import org.apache.commons.math3.optim.PointVectorValuePair; //导入依赖的package包/类
public void doTestStRD(final StatisticalReferenceDataset dataset,
final double errParams,
final double errParamsSd) {
final AbstractLeastSquaresOptimizer optimizer = createOptimizer();
final double[] w = new double[dataset.getNumObservations()];
Arrays.fill(w, 1);
final double[][] data = dataset.getData();
final double[] initial = dataset.getStartingPoint(0);
final StatisticalReferenceDataset.LeastSquaresProblem problem = dataset.getLeastSquaresProblem();
final PointVectorValuePair optimum
= optimizer.optimize(new MaxEval(100),
problem.getModelFunction(),
problem.getModelFunctionJacobian(),
new Target(data[1]),
new Weight(w),
new InitialGuess(initial));
final double[] actual = optimum.getPoint();
for (int i = 0; i < actual.length; i++) {
double expected = dataset.getParameter(i);
double delta = FastMath.abs(errParams * expected);
Assert.assertEquals(dataset.getName() + ", param #" + i,
expected, actual[i], delta);
}
}
开发者ID:Quanticol,项目名称:CARMA,代码行数:27,代码来源:AbstractLeastSquaresOptimizerAbstractTest.java
示例16: minpackTest
import org.apache.commons.math3.optim.PointVectorValuePair; //导入依赖的package包/类
private void minpackTest(MinpackFunction function, boolean exceptionExpected) {
LevenbergMarquardtOptimizer optimizer
= new LevenbergMarquardtOptimizer(FastMath.sqrt(2.22044604926e-16),
FastMath.sqrt(2.22044604926e-16),
2.22044604926e-16);
try {
PointVectorValuePair optimum
= optimizer.optimize(new MaxEval(400 * (function.getN() + 1)),
function.getModelFunction(),
function.getModelFunctionJacobian(),
new Target(function.getTarget()),
new Weight(function.getWeight()),
new InitialGuess(function.getStartPoint()));
Assert.assertFalse(exceptionExpected);
function.checkTheoreticalMinCost(optimizer.getRMS());
function.checkTheoreticalMinParams(optimum);
} catch (TooManyEvaluationsException e) {
Assert.assertTrue(exceptionExpected);
}
}
开发者ID:Quanticol,项目名称:CARMA,代码行数:21,代码来源:MinpackTest.java
示例17: testTrivial
import org.apache.commons.math3.optim.PointVectorValuePair; //导入依赖的package包/类
@Test
public void testTrivial() {
LinearProblem problem
= new LinearProblem(new double[][] { { 2 } },
new double[] { 3 });
T optimizer = createOptimizer()
.withMaxEvaluations(100)
.withMaxIterations(getMaxIterations())
.withModelAndJacobian(problem.getModelFunction(),
problem.getModelFunctionJacobian())
.withTarget(problem.getTarget())
.withWeight(new DiagonalMatrix(new double[] { 1 }))
.withStartPoint(new double[] { 0 });
PointVectorValuePair optimum = optimizer.optimize();
Assert.assertEquals(0, optimizer.computeRMS(optimum.getPoint()), 1e-10);
Assert.assertEquals(1.5, optimum.getPoint()[0], 1e-10);
Assert.assertEquals(3.0, optimum.getValue()[0], 1e-10);
}
开发者ID:SpoonLabs,项目名称:astor,代码行数:21,代码来源:AbstractLeastSquaresOptimizerAbstractTest.java
注:本文中的org.apache.commons.math3.optim.PointVectorValuePair类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论