本文整理汇总了Java中org.apache.commons.math3.optim.SimpleVectorValueChecker类的典型用法代码示例。如果您正苦于以下问题:Java SimpleVectorValueChecker类的具体用法?Java SimpleVectorValueChecker怎么用?Java SimpleVectorValueChecker使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SimpleVectorValueChecker类属于org.apache.commons.math3.optim包,在下文中一共展示了SimpleVectorValueChecker类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: SmoothingPolynomialBicubicSplineInterpolator
import org.apache.commons.math3.optim.SimpleVectorValueChecker; //导入依赖的package包/类
/**
* @param xDegree Degree of the polynomial fitting functions along the
* x-dimension.
* @param yDegree Degree of the polynomial fitting functions along the
* y-dimension.
* @exception NotPositiveException if degrees are not positive
*/
public SmoothingPolynomialBicubicSplineInterpolator(int xDegree, int yDegree)
throws NotPositiveException {
if (xDegree < 0) {
throw new NotPositiveException(xDegree);
}
if (yDegree < 0) {
throw new NotPositiveException(yDegree);
}
this.xDegree = xDegree;
this.yDegree = yDegree;
final double safeFactor = 1e2;
final SimpleVectorValueChecker checker
= new SimpleVectorValueChecker(safeFactor * Precision.EPSILON,
safeFactor * Precision.SAFE_MIN);
xFitter = new PolynomialFitter(new GaussNewtonOptimizer(false, checker));
yFitter = new PolynomialFitter(new GaussNewtonOptimizer(false, checker));
}
开发者ID:biocompibens,项目名称:SME,代码行数:26,代码来源:SmoothingPolynomialBicubicSplineInterpolator.java
示例2: testMaxEvaluations
import org.apache.commons.math3.optim.SimpleVectorValueChecker; //导入依赖的package包/类
@Test
public void testMaxEvaluations() throws Exception {
try{
CircleVectorial circle = new CircleVectorial();
circle.addPoint( 30.0, 68.0);
circle.addPoint( 50.0, -6.0);
circle.addPoint(110.0, -20.0);
circle.addPoint( 35.0, 15.0);
circle.addPoint( 45.0, 97.0);
LeastSquaresProblem lsp = builder(circle)
.checkerPair(new SimpleVectorValueChecker(1e-30, 1e-30))
.maxIterations(Integer.MAX_VALUE)
.start(new double[]{98.680, 47.345})
.build();
optimizer.optimize(lsp);
fail(optimizer);
}catch (TooManyEvaluationsException e){
//expected
}
}
开发者ID:Quanticol,项目名称:CARMA,代码行数:24,代码来源:GaussNewtonOptimizerWithCholeskyTest.java
示例3: testNoOptimum
import org.apache.commons.math3.optim.SimpleVectorValueChecker; //导入依赖的package包/类
/**
* Test demonstrating that the user exception is finally thrown if none
* of the runs succeed.
*/
@Test(expected=TestException.class)
public void testNoOptimum() {
JacobianMultivariateVectorOptimizer underlyingOptimizer
= new GaussNewtonOptimizer(true, new SimpleVectorValueChecker(1e-6, 1e-6));
JDKRandomGenerator g = new JDKRandomGenerator();
g.setSeed(12373523445l);
RandomVectorGenerator generator
= new UncorrelatedRandomVectorGenerator(1, new GaussianRandomGenerator(g));
MultiStartMultivariateVectorOptimizer optimizer
= new MultiStartMultivariateVectorOptimizer(underlyingOptimizer, 10, generator);
optimizer.optimize(new MaxEval(100),
new Target(new double[] { 0 }),
new Weight(new double[] { 1 }),
new InitialGuess(new double[] { 0 }),
new ModelFunction(new MultivariateVectorFunction() {
public double[] value(double[] point) {
throw new TestException();
}
}));
}
开发者ID:Quanticol,项目名称:CARMA,代码行数:25,代码来源:MultiStartMultivariateVectorOptimizerTest.java
示例4: testMaxEvaluations
import org.apache.commons.math3.optim.SimpleVectorValueChecker; //导入依赖的package包/类
@Test(expected=TooManyEvaluationsException.class)
public void testMaxEvaluations() throws Exception {
CircleVectorial circle = new CircleVectorial();
circle.addPoint( 30.0, 68.0);
circle.addPoint( 50.0, -6.0);
circle.addPoint(110.0, -20.0);
circle.addPoint( 35.0, 15.0);
circle.addPoint( 45.0, 97.0);
GaussNewtonOptimizer optimizer
= new GaussNewtonOptimizer(new SimpleVectorValueChecker(1e-30, 1e-30));
optimizer.optimize(new MaxEval(100),
circle.getModelFunction(),
circle.getModelFunctionJacobian(),
new Target(new double[] { 0, 0, 0, 0, 0 }),
new Weight(new double[] { 1, 1, 1, 1, 1 }),
new InitialGuess(new double[] { 98.680, 47.345 }));
}
开发者ID:Quanticol,项目名称:CARMA,代码行数:20,代码来源:GaussNewtonOptimizerTest.java
示例5: testMaxEvaluations
import org.apache.commons.math3.optim.SimpleVectorValueChecker; //导入依赖的package包/类
@Test(expected=TooManyEvaluationsException.class)
public void testMaxEvaluations() throws Exception {
CircleVectorial circle = new CircleVectorial();
circle.addPoint( 30.0, 68.0);
circle.addPoint( 50.0, -6.0);
circle.addPoint(110.0, -20.0);
circle.addPoint( 35.0, 15.0);
circle.addPoint( 45.0, 97.0);
GaussNewtonOptimizer optimizer = createOptimizer()
.withConvergenceChecker(new SimpleVectorValueChecker(1e-30, 1e-30))
.withMaxIterations(Integer.MAX_VALUE)
.withMaxEvaluations(100)
.withModelAndJacobian(circle.getModelFunction(),
circle.getModelFunctionJacobian())
.withTarget(new double[] { 0, 0, 0, 0, 0 })
.withWeight(new DiagonalMatrix(new double[] { 1, 1, 1, 1, 1 }))
.withStartPoint(new double[] { 98.680, 47.345 });
optimizer.optimize();
}
开发者ID:SpoonLabs,项目名称:astor,代码行数:22,代码来源:GaussNewtonOptimizerTest.java
示例6: SmoothingPolynomialBicubicSplineInterpolator
import org.apache.commons.math3.optim.SimpleVectorValueChecker; //导入依赖的package包/类
/**
* @param xDegree Degree of the polynomial fitting functions along the
* x-dimension.
* @param yDegree Degree of the polynomial fitting functions along the
* y-dimension.
*/
public SmoothingPolynomialBicubicSplineInterpolator(int xDegree,
int yDegree) {
if (xDegree < 0) {
throw new NotPositiveException(xDegree);
}
if (yDegree < 0) {
throw new NotPositiveException(yDegree);
}
this.xDegree = xDegree;
this.yDegree = yDegree;
final double safeFactor = 1e2;
final SimpleVectorValueChecker checker
= new SimpleVectorValueChecker(safeFactor * Precision.EPSILON,
safeFactor * Precision.SAFE_MIN);
xFitter = new PolynomialFitter(new GaussNewtonOptimizer(false, checker));
yFitter = new PolynomialFitter(new GaussNewtonOptimizer(false, checker));
}
开发者ID:charles-cooper,项目名称:idylfin,代码行数:25,代码来源:SmoothingPolynomialBicubicSplineInterpolator.java
示例7: testMath798
import org.apache.commons.math3.optim.SimpleVectorValueChecker; //导入依赖的package包/类
@Test
public void testMath798() {
final double tol = 1e-14;
final SimpleVectorValueChecker checker = new SimpleVectorValueChecker(tol, tol);
final double[] init = new double[] { 0, 0 };
final int maxEval = 3;
final double[] lm = doMath798(new LevenbergMarquardtOptimizer(checker), maxEval, init);
final double[] gn = doMath798(new GaussNewtonOptimizer(checker), maxEval, init);
for (int i = 0; i <= 1; i++) {
Assert.assertEquals(lm[i], gn[i], tol);
}
}
开发者ID:Quanticol,项目名称:CARMA,代码行数:15,代码来源:PolynomialFitterTest.java
示例8: testMath798WithToleranceTooLow
import org.apache.commons.math3.optim.SimpleVectorValueChecker; //导入依赖的package包/类
/**
* This test shows that the user can set the maximum number of iterations
* to avoid running for too long.
* But in the test case, the real problem is that the tolerance is way too
* stringent.
*/
@Test(expected=TooManyEvaluationsException.class)
public void testMath798WithToleranceTooLow() {
final double tol = 1e-100;
final SimpleVectorValueChecker checker = new SimpleVectorValueChecker(tol, tol);
final double[] init = new double[] { 0, 0 };
final int maxEval = 10000; // Trying hard to fit.
@SuppressWarnings("unused")
final double[] gn = doMath798(new GaussNewtonOptimizer(checker), maxEval, init);
}
开发者ID:Quanticol,项目名称:CARMA,代码行数:17,代码来源:PolynomialFitterTest.java
示例9: testMath798WithToleranceTooLowButNoException
import org.apache.commons.math3.optim.SimpleVectorValueChecker; //导入依赖的package包/类
/**
* This test shows that the user can set the maximum number of iterations
* to avoid running for too long.
* Even if the real problem is that the tolerance is way too stringent, it
* is possible to get the best solution so far, i.e. a checker will return
* the point when the maximum iteration count has been reached.
*/
@Test
public void testMath798WithToleranceTooLowButNoException() {
final double tol = 1e-100;
final double[] init = new double[] { 0, 0 };
final int maxEval = 10000; // Trying hard to fit.
final SimpleVectorValueChecker checker = new SimpleVectorValueChecker(tol, tol, maxEval);
final double[] lm = doMath798(new LevenbergMarquardtOptimizer(checker), maxEval, init);
final double[] gn = doMath798(new GaussNewtonOptimizer(checker), maxEval, init);
for (int i = 0; i <= 1; i++) {
Assert.assertEquals(lm[i], gn[i], 1e-15);
}
}
开发者ID:Quanticol,项目名称:CARMA,代码行数:22,代码来源:PolynomialFitterTest.java
示例10: testGetOptimaBeforeOptimize
import org.apache.commons.math3.optim.SimpleVectorValueChecker; //导入依赖的package包/类
@Test(expected=NullPointerException.class)
public void testGetOptimaBeforeOptimize() {
JacobianMultivariateVectorOptimizer underlyingOptimizer
= new GaussNewtonOptimizer(true, new SimpleVectorValueChecker(1e-6, 1e-6));
JDKRandomGenerator g = new JDKRandomGenerator();
g.setSeed(16069223052l);
RandomVectorGenerator generator
= new UncorrelatedRandomVectorGenerator(1, new GaussianRandomGenerator(g));
MultiStartMultivariateVectorOptimizer optimizer
= new MultiStartMultivariateVectorOptimizer(underlyingOptimizer, 10, generator);
optimizer.getOptima();
}
开发者ID:Quanticol,项目名称:CARMA,代码行数:15,代码来源:MultiStartMultivariateVectorOptimizerTest.java
示例11: testTrivial
import org.apache.commons.math3.optim.SimpleVectorValueChecker; //导入依赖的package包/类
@Test
public void testTrivial() {
LinearProblem problem
= new LinearProblem(new double[][] { { 2 } }, new double[] { 3 });
JacobianMultivariateVectorOptimizer underlyingOptimizer
= new GaussNewtonOptimizer(true, new SimpleVectorValueChecker(1e-6, 1e-6));
JDKRandomGenerator g = new JDKRandomGenerator();
g.setSeed(16069223052l);
RandomVectorGenerator generator
= new UncorrelatedRandomVectorGenerator(1, new GaussianRandomGenerator(g));
MultiStartMultivariateVectorOptimizer optimizer
= new MultiStartMultivariateVectorOptimizer(underlyingOptimizer, 10, generator);
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(1.5, optimum.getPoint()[0], 1e-10);
Assert.assertEquals(3.0, optimum.getValue()[0], 1e-10);
PointVectorValuePair[] optima = optimizer.getOptima();
Assert.assertEquals(10, optima.length);
for (int i = 0; i < optima.length; i++) {
Assert.assertEquals(1.5, optima[i].getPoint()[0], 1e-10);
Assert.assertEquals(3.0, optima[i].getValue()[0], 1e-10);
}
Assert.assertTrue(optimizer.getEvaluations() > 20);
Assert.assertTrue(optimizer.getEvaluations() < 50);
Assert.assertEquals(100, optimizer.getMaxEvaluations());
}
开发者ID:Quanticol,项目名称:CARMA,代码行数:33,代码来源:MultiStartMultivariateVectorOptimizerTest.java
示例12: testIssue914
import org.apache.commons.math3.optim.SimpleVectorValueChecker; //导入依赖的package包/类
@Test
public void testIssue914() {
LinearProblem problem = new LinearProblem(new double[][] { { 2 } }, new double[] { 3 });
JacobianMultivariateVectorOptimizer underlyingOptimizer =
new GaussNewtonOptimizer(true, new SimpleVectorValueChecker(1e-6, 1e-6)) {
@Override
public PointVectorValuePair optimize(OptimizationData... optData) {
// filter out simple bounds, as they are not supported
// by the underlying optimizer, and we don't really care for this test
OptimizationData[] filtered = optData.clone();
for (int i = 0; i < filtered.length; ++i) {
if (filtered[i] instanceof SimpleBounds) {
filtered[i] = null;
}
}
return super.optimize(filtered);
}
};
JDKRandomGenerator g = new JDKRandomGenerator();
g.setSeed(16069223052l);
RandomVectorGenerator generator =
new UncorrelatedRandomVectorGenerator(1, new GaussianRandomGenerator(g));
MultiStartMultivariateVectorOptimizer optimizer =
new MultiStartMultivariateVectorOptimizer(underlyingOptimizer, 10, generator);
optimizer.optimize(new MaxEval(100),
problem.getModelFunction(),
problem.getModelFunctionJacobian(),
problem.getTarget(),
new Weight(new double[] { 1 }),
new InitialGuess(new double[] { 0 }),
new SimpleBounds(new double[] { -1.0e-10 }, new double[] { 1.0e-10 }));
PointVectorValuePair[] optima = optimizer.getOptima();
// only the first start should have succeeded
Assert.assertEquals(1, optima.length);
}
开发者ID:Quanticol,项目名称:CARMA,代码行数:38,代码来源:MultiStartMultivariateVectorOptimizerTest.java
示例13: applyToNetwork
import org.apache.commons.math3.optim.SimpleVectorValueChecker; //导入依赖的package包/类
@Override
public double applyToNetwork(final MixedClearingNetwork network) {
Preconditions.checkNotNull(network);
final VectorCostFunction function = super.getVectorCostFunction(network);
final MultivariateJacobianFunction model =
LeastSquaresFactory.model(function, super.getJacobianMatrixFunction(network));
final RealVector
observed = new ArrayRealVector(super.calculateTarget(network)),
start = new ArrayRealVector(network.getNumberOfEdges());
for(int i = 0; i< network.getNumberOfEdges(); ++i)
start.setEntry(i, network.getEdges().get(i).getMaximumRateAdmissibleByBothParties());
start.set(1.0);
final ConvergenceChecker<LeastSquaresProblem.Evaluation> evaluationChecker =
LeastSquaresFactory.evaluationChecker(
new SimpleVectorValueChecker(relErrorTarget, absErrorTarget));
final LeastSquaresProblem problem =
LeastSquaresFactory.create(
model, observed, start, evaluationChecker, maximumEvaluations, maximumIterations);
final LevenbergMarquardtOptimizer optimizer = new LevenbergMarquardtOptimizer();
final Optimum result = optimizer.optimize(problem);
final double residualCost = result.getRMS();
System.out.println("Network cleared: residual cost: " + residualCost + ".");
return residualCost;
}
开发者ID:crisis-economics,项目名称:CRISIS,代码行数:30,代码来源:LevenbergMarquardtClearingAlgorithm.java
注:本文中的org.apache.commons.math3.optim.SimpleVectorValueChecker类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论