本文整理汇总了Java中org.apache.commons.math.optimization.RealPointValuePair类的典型用法代码示例。如果您正苦于以下问题:Java RealPointValuePair类的具体用法?Java RealPointValuePair怎么用?Java RealPointValuePair使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RealPointValuePair类属于org.apache.commons.math.optimization包,在下文中一共展示了RealPointValuePair类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: minimize
import org.apache.commons.math.optimization.RealPointValuePair; //导入依赖的package包/类
/**
* Resolve linear programming problem when minimizing the equation with current constraints. Returns
*
* @param solution Solution to minimize the objective the function from.
* @return Number of printings and cost value.
*/
public Result minimize(Solution solution) {
updateFunction(solution);
updateConstraints(solution);
try {
RealPointValuePair result = new SimplexSolver().optimize(function, constraints, GoalType.MINIMIZE, true);
double[] point = result.getPoint();
if (result.getValue() < 0) {
return null;
}
for (int i = 0; i < point.length; ++i) {
if (point[i] < 0) {
return null;
}
}
return new Result(point, context.getSheetCost(), context.getPatternCost());
} catch (OptimizationException e) {
logger.debug("LinearResolutionMethod.minimize: " + e.getMessage());
}
return null;
}
开发者ID:achaussende,项目名称:tp-2D-cutting-stock-problem,代码行数:27,代码来源:LinearResolutionMethod.java
示例2: testRosenbrock
import org.apache.commons.math.optimization.RealPointValuePair; //导入依赖的package包/类
@Test
public void testRosenbrock()
throws FunctionEvaluationException, ConvergenceException {
Rosenbrock rosenbrock = new Rosenbrock();
NelderMead optimizer = new NelderMead();
optimizer.setConvergenceChecker(new SimpleScalarValueChecker(-1, 1.0e-3));
optimizer.setMaxIterations(100);
optimizer.setStartConfiguration(new double[][] {
{ -1.2, 1.0 }, { 0.9, 1.2 } , { 3.5, -2.3 }
});
RealPointValuePair optimum =
optimizer.optimize(rosenbrock, GoalType.MINIMIZE, new double[] { -1.2, 1.0 });
assertEquals(rosenbrock.getCount(), optimizer.getEvaluations());
assertTrue(optimizer.getEvaluations() > 40);
assertTrue(optimizer.getEvaluations() < 50);
assertTrue(optimum.getValue() < 8.0e-4);
}
开发者ID:SpoonLabs,项目名称:astor,代码行数:21,代码来源:NelderMeadTest.java
示例3: testEpsilon
import org.apache.commons.math.optimization.RealPointValuePair; //导入依赖的package包/类
@Test
public void testEpsilon() throws OptimizationException {
LinearObjectiveFunction f =
new LinearObjectiveFunction(new double[] { 10, 5, 1 }, 0);
Collection<LinearConstraint> constraints = new ArrayList<LinearConstraint>();
constraints.add(new LinearConstraint(new double[] { 9, 8, 0 }, Relationship.EQ, 17));
constraints.add(new LinearConstraint(new double[] { 0, 7, 8 }, Relationship.LEQ, 7));
constraints.add(new LinearConstraint(new double[] { 10, 0, 2 }, Relationship.LEQ, 10));
SimplexSolver solver = new SimplexSolver();
RealPointValuePair solution = solver.optimize(f, constraints, GoalType.MAXIMIZE, false);
assertEquals(1.0, solution.getPoint()[0], 0.0);
assertEquals(1.0, solution.getPoint()[1], 0.0);
assertEquals(0.0, solution.getPoint()[2], 0.0);
assertEquals(15.0, solution.getValue(), 0.0);
}
开发者ID:SpoonLabs,项目名称:astor,代码行数:17,代码来源:SimplexSolverTest.java
示例4: testOneSet
import org.apache.commons.math.optimization.RealPointValuePair; //导入依赖的package包/类
public void testOneSet() throws FunctionEvaluationException, OptimizationException {
LinearProblem problem = new LinearProblem(new double[][] {
{ 1, 0, 0 },
{ -1, 1, 0 },
{ 0, -1, 1 }
}, new double[] { 1, 1, 1});
NonLinearConjugateGradientOptimizer optimizer =
new NonLinearConjugateGradientOptimizer(ConjugateGradientFormula.POLAK_RIBIERE);
optimizer.setMaxIterations(100);
optimizer.setConvergenceChecker(new SimpleScalarValueChecker(1.0e-6, 1.0e-6));
RealPointValuePair optimum =
optimizer.optimize(problem, GoalType.MINIMIZE, new double[] { 0, 0, 0 });
assertEquals(1.0, optimum.getPoint()[0], 1.0e-10);
assertEquals(2.0, optimum.getPoint()[1], 1.0e-10);
assertEquals(3.0, optimum.getPoint()[2], 1.0e-10);
}
开发者ID:SpoonLabs,项目名称:astor,代码行数:19,代码来源:NonLinearConjugateGradientOptimizerTest.java
示例5: testRedundantEquations
import org.apache.commons.math.optimization.RealPointValuePair; //导入依赖的package包/类
public void testRedundantEquations() throws FunctionEvaluationException, OptimizationException {
LinearProblem problem = new LinearProblem(new double[][] {
{ 1.0, 1.0 },
{ 1.0, -1.0 },
{ 1.0, 3.0 }
}, new double[] { 3.0, 1.0, 5.0 });
NonLinearConjugateGradientOptimizer optimizer =
new NonLinearConjugateGradientOptimizer(ConjugateGradientFormula.POLAK_RIBIERE);
optimizer.setMaxIterations(100);
optimizer.setConvergenceChecker(new SimpleScalarValueChecker(1.0e-6, 1.0e-6));
RealPointValuePair optimum =
optimizer.optimize(problem, GoalType.MINIMIZE, new double[] { 1, 1 });
assertEquals(2.0, optimum.getPoint()[0], 1.0e-8);
assertEquals(1.0, optimum.getPoint()[1], 1.0e-8);
}
开发者ID:SpoonLabs,项目名称:astor,代码行数:18,代码来源:NonLinearConjugateGradientOptimizerTest.java
示例6: testNoDependency
import org.apache.commons.math.optimization.RealPointValuePair; //导入依赖的package包/类
public void testNoDependency() throws FunctionEvaluationException, OptimizationException {
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.0, 1.1, 2.2, 3.3, 4.4, 5.5 });
NonLinearConjugateGradientOptimizer optimizer =
new NonLinearConjugateGradientOptimizer(ConjugateGradientFormula.POLAK_RIBIERE);
optimizer.setMaxIterations(100);
optimizer.setConvergenceChecker(new SimpleScalarValueChecker(1.0e-6, 1.0e-6));
RealPointValuePair optimum =
optimizer.optimize(problem, GoalType.MINIMIZE, new double[] { 0, 0, 0, 0, 0, 0 });
for (int i = 0; i < problem.target.length; ++i) {
assertEquals(0.55 * i, optimum.getPoint()[i], 1.0e-10);
}
}
开发者ID:SpoonLabs,项目名称:astor,代码行数:20,代码来源:NonLinearConjugateGradientOptimizerTest.java
示例7: optimize
import org.apache.commons.math.optimization.RealPointValuePair; //导入依赖的package包/类
/** {@inheritDoc} */
public RealPointValuePair optimize(final DifferentiableMultivariateRealFunction f,
final GoalType goalType,
final double[] startPoint)
throws FunctionEvaluationException, OptimizationException, IllegalArgumentException {
// reset counters
iterations = 0;
evaluations = 0;
gradientEvaluations = 0;
// store optimization problem characteristics
this.f = f;
gradient = f.gradient();
this.goalType = goalType;
point = startPoint.clone();
return doOptimize();
}
开发者ID:SpoonLabs,项目名称:astor,代码行数:21,代码来源:AbstractScalarDifferentiableOptimizer.java
示例8: testColumnsPermutation
import org.apache.commons.math.optimization.RealPointValuePair; //导入依赖的package包/类
public void testColumnsPermutation() throws FunctionEvaluationException, OptimizationException {
LinearProblem problem =
new LinearProblem(new double[][] { { 1.0, -1.0 }, { 0.0, 2.0 }, { 1.0, -2.0 } },
new double[] { 4.0, 6.0, 1.0 });
NonLinearConjugateGradientOptimizer optimizer =
new NonLinearConjugateGradientOptimizer(ConjugateGradientFormula.POLAK_RIBIERE);
optimizer.setMaxIterations(100);
optimizer.setConvergenceChecker(new SimpleScalarValueChecker(1.0e-6, 1.0e-6));
RealPointValuePair optimum =
optimizer.optimize(problem, GoalType.MINIMIZE, new double[] { 0, 0 });
assertEquals(7.0, optimum.getPoint()[0], 1.0e-10);
assertEquals(3.0, optimum.getPoint()[1], 1.0e-10);
assertEquals(0.0, optimum.getValue(), 1.0e-10);
}
开发者ID:SpoonLabs,项目名称:astor,代码行数:18,代码来源:NonLinearConjugateGradientOptimizerTest.java
示例9: testPowell
import org.apache.commons.math.optimization.RealPointValuePair; //导入依赖的package包/类
@Test
public void testPowell() {
MultivariateRealFunction powell =
new MultivariateRealFunction() {
public double value(double[] x) {
++count;
double a = x[0] + 10 * x[1];
double b = x[2] - x[3];
double c = x[1] - 2 * x[2];
double d = x[0] - x[3];
return a * a + 5 * b * b + c * c * c * c + 10 * d * d * d * d;
}
};
count = 0;
SimplexOptimizer optimizer = new SimplexOptimizer(-1, 1e-3);
optimizer.setSimplex(new MultiDirectionalSimplex(4));
RealPointValuePair optimum =
optimizer.optimize(1000, powell, GoalType.MINIMIZE, new double[] { 3, -1, 0, 1 });
Assert.assertEquals(count, optimizer.getEvaluations());
Assert.assertTrue(optimizer.getEvaluations() > 800);
Assert.assertTrue(optimizer.getEvaluations() < 900);
Assert.assertTrue(optimum.getValue() > 1e-2);
}
开发者ID:SpoonLabs,项目名称:astor,代码行数:25,代码来源:SimplexOptimizerMultiDirectionalTest.java
示例10: testMoreEstimatedParametersSimple
import org.apache.commons.math.optimization.RealPointValuePair; //导入依赖的package包/类
public void testMoreEstimatedParametersSimple()
throws FunctionEvaluationException, OptimizationException {
LinearProblem problem = new LinearProblem(new double[][] {
{ 3.0, 2.0, 0.0, 0.0 },
{ 0.0, 1.0, -1.0, 1.0 },
{ 2.0, 0.0, 1.0, 0.0 }
}, new double[] { 7.0, 3.0, 5.0 });
NonLinearConjugateGradientOptimizer optimizer =
new NonLinearConjugateGradientOptimizer(ConjugateGradientFormula.POLAK_RIBIERE);
optimizer.setMaxIterations(100);
optimizer.setConvergenceChecker(new SimpleScalarValueChecker(1.0e-6, 1.0e-6));
RealPointValuePair optimum =
optimizer.optimize(problem, GoalType.MINIMIZE, new double[] { 7, 6, 5, 4 });
assertEquals(0, optimum.getValue(), 1.0e-10);
}
开发者ID:SpoonLabs,项目名称:astor,代码行数:19,代码来源:NonLinearConjugateGradientOptimizerTest.java
示例11: buildSimplex
import org.apache.commons.math.optimization.RealPointValuePair; //导入依赖的package包/类
/** Build an initial simplex.
* @param startPoint the start point for optimization
* @exception IllegalArgumentException if the start point does not match
* simplex dimension
*/
private void buildSimplex(final double[] startPoint)
throws IllegalArgumentException {
final int n = startPoint.length;
if (n != startConfiguration.length) {
throw MathRuntimeException.createIllegalArgumentException(
"dimension mismatch {0} != {1}",
n, startConfiguration.length);
}
// set first vertex
simplex = new RealPointValuePair[n + 1];
simplex[0] = new RealPointValuePair(startPoint, Double.NaN);
// set remaining vertices
for (int i = 0; i < n; ++i) {
final double[] confI = startConfiguration[i];
final double[] vertexI = new double[n];
for (int k = 0; k < n; ++k) {
vertexI[k] = startPoint[k] + confI[k];
}
simplex[i + 1] = new RealPointValuePair(vertexI, Double.NaN);
}
}
开发者ID:SpoonLabs,项目名称:astor,代码行数:31,代码来源:DirectSearchOptimizer.java
示例12: testInconsistentEquations
import org.apache.commons.math.optimization.RealPointValuePair; //导入依赖的package包/类
public void testInconsistentEquations() throws FunctionEvaluationException, OptimizationException {
LinearProblem problem = new LinearProblem(new double[][] {
{ 1.0, 1.0 },
{ 1.0, -1.0 },
{ 1.0, 3.0 }
}, new double[] { 3.0, 1.0, 4.0 });
NonLinearConjugateGradientOptimizer optimizer =
new NonLinearConjugateGradientOptimizer(ConjugateGradientFormula.POLAK_RIBIERE);
optimizer.setMaxIterations(100);
optimizer.setConvergenceChecker(new SimpleScalarValueChecker(1.0e-6, 1.0e-6));
RealPointValuePair optimum =
optimizer.optimize(problem, GoalType.MINIMIZE, new double[] { 1, 1 });
assertTrue(optimum.getValue() > 0.1);
}
开发者ID:SpoonLabs,项目名称:astor,代码行数:17,代码来源:NonLinearConjugateGradientOptimizerTest.java
示例13: testEpsilon
import org.apache.commons.math.optimization.RealPointValuePair; //导入依赖的package包/类
@Test
public void testEpsilon() throws OptimizationException {
LinearObjectiveFunction f =
new LinearObjectiveFunction(new double[] { 10, 5, 1 }, 0);
Collection<LinearConstraint> constraints = new ArrayList<LinearConstraint>();
constraints.add(new LinearConstraint(new double[] { 9, 8, 0 }, Relationship.EQ, 17));
constraints.add(new LinearConstraint(new double[] { 0, 7, 8 }, Relationship.LEQ, 7));
constraints.add(new LinearConstraint(new double[] { 10, 0, 2 }, Relationship.LEQ, 10));
SimplexSolver solver = new SimplexSolver();
RealPointValuePair solution = solver.optimize(f, constraints, GoalType.MAXIMIZE, false);
Assert.assertEquals(1.0, solution.getPoint()[0], 0.0);
Assert.assertEquals(1.0, solution.getPoint()[1], 0.0);
Assert.assertEquals(0.0, solution.getPoint()[2], 0.0);
Assert.assertEquals(15.0, solution.getValue(), 0.0);
}
开发者ID:SpoonLabs,项目名称:astor,代码行数:17,代码来源:SimplexSolverTest.java
示例14: testCircleFitting
import org.apache.commons.math.optimization.RealPointValuePair; //导入依赖的package包/类
public void testCircleFitting() throws FunctionEvaluationException, OptimizationException {
Circle circle = new Circle();
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);
NonLinearConjugateGradientOptimizer optimizer =
new NonLinearConjugateGradientOptimizer(ConjugateGradientFormula.POLAK_RIBIERE);
optimizer.setMaxIterations(100);
optimizer.setConvergenceChecker(new SimpleScalarValueChecker(1.0e-30, 1.0e-30));
BrentSolver solver = new BrentSolver();
solver.setAbsoluteAccuracy(1.0e-13);
solver.setRelativeAccuracy(1.0e-15);
optimizer.setLineSearchSolver(solver);
RealPointValuePair optimum =
optimizer.optimize(circle, GoalType.MINIMIZE, new double[] { 98.680, 47.345 });
Point2D.Double center = new Point2D.Double(optimum.getPointRef()[0], optimum.getPointRef()[1]);
assertEquals(69.960161753, circle.getRadius(center), 1.0e-8);
assertEquals(96.075902096, center.x, 1.0e-8);
assertEquals(48.135167894, center.y, 1.0e-8);
}
开发者ID:SpoonLabs,项目名称:astor,代码行数:23,代码来源:NonLinearConjugateGradientOptimizerTest.java
示例15: testMath283
import org.apache.commons.math.optimization.RealPointValuePair; //导入依赖的package包/类
@Test
public void testMath283()
throws FunctionEvaluationException, OptimizationException {
// fails because MultiDirectional.iterateSimplex is looping forever
// the while(true) should be replaced with a convergence check
MultiDirectional multiDirectional = new MultiDirectional();
multiDirectional.setMaxIterations(100);
multiDirectional.setMaxEvaluations(1000);
final Gaussian2D function = new Gaussian2D(0.0, 0.0, 1.0);
RealPointValuePair estimate = multiDirectional.optimize(function,
GoalType.MAXIMIZE, function.getMaximumPosition());
final double EPSILON = 1e-5;
final double expectedMaximum = function.getMaximum();
final double actualMaximum = estimate.getValue();
Assert.assertEquals(expectedMaximum, actualMaximum, EPSILON);
final double[] expectedPosition = function.getMaximumPosition();
final double[] actualPosition = estimate.getPoint();
Assert.assertEquals(expectedPosition[0], actualPosition[0], EPSILON );
Assert.assertEquals(expectedPosition[1], actualPosition[1], EPSILON );
}
开发者ID:SpoonLabs,项目名称:astor,代码行数:27,代码来源:MultiDirectionalTest.java
示例16: testLeastSquares1
import org.apache.commons.math.optimization.RealPointValuePair; //导入依赖的package包/类
@Test
public void testLeastSquares1()
throws FunctionEvaluationException, ConvergenceException {
final RealMatrix factors =
new Array2DRowRealMatrix(new double[][] {
{ 1.0, 0.0 },
{ 0.0, 1.0 }
}, false);
LeastSquaresConverter ls = new LeastSquaresConverter(new MultivariateVectorialFunction() {
public double[] value(double[] variables) {
return factors.operate(variables);
}
}, new double[] { 2.0, -3.0 });
NelderMead optimizer = new NelderMead();
optimizer.setConvergenceChecker(new SimpleScalarValueChecker(-1.0, 1.0e-6));
optimizer.setMaxIterations(200);
RealPointValuePair optimum =
optimizer.optimize(ls, GoalType.MINIMIZE, new double[] { 10.0, 10.0 });
assertEquals( 2.0, optimum.getPointRef()[0], 3.0e-5);
assertEquals(-3.0, optimum.getPointRef()[1], 4.0e-4);
assertTrue(optimizer.getEvaluations() > 60);
assertTrue(optimizer.getEvaluations() < 80);
assertTrue(optimum.getValue() < 1.0e-6);
}
开发者ID:SpoonLabs,项目名称:astor,代码行数:26,代码来源:NelderMeadTest.java
示例17: testMath434PivotRowSelection2
import org.apache.commons.math.optimization.RealPointValuePair; //导入依赖的package包/类
@Test
public void testMath434PivotRowSelection2() throws OptimizationException
{
LinearObjectiveFunction f = new LinearObjectiveFunction(new double[] {0.0d, 1.0d, 1.0d, 0.0d, 0.0d, 0.0d, 0.0d}, 0.0d);
ArrayList<LinearConstraint> constraints = new ArrayList<LinearConstraint>();
constraints.add(new LinearConstraint(new double[] {1.0d, -0.1d, 0.0d, 0.0d, 0.0d, 0.0d, 0.0d}, Relationship.EQ, -0.1d));
constraints.add(new LinearConstraint(new double[] {1.0d, 0.0d, 0.0d, 0.0d, 0.0d, 0.0d, 0.0d}, Relationship.GEQ, -1e-18d));
constraints.add(new LinearConstraint(new double[] {0.0d, 1.0d, 0.0d, 0.0d, 0.0d, 0.0d, 0.0d}, Relationship.GEQ, 0.0d));
constraints.add(new LinearConstraint(new double[] {0.0d, 0.0d, 0.0d, 1.0d, 0.0d, -0.0128588d, 1e-5d}, Relationship.EQ, 0.0d));
constraints.add(new LinearConstraint(new double[] {0.0d, 0.0d, 0.0d, 0.0d, 1.0d, 1e-5d, -0.0128586d}, Relationship.EQ, 1e-10d));
constraints.add(new LinearConstraint(new double[] {0.0d, 0.0d, 1.0d, -1.0d, 0.0d, 0.0d, 0.0d}, Relationship.GEQ, 0.0d));
constraints.add(new LinearConstraint(new double[] {0.0d, 0.0d, 1.0d, 1.0d, 0.0d, 0.0d, 0.0d}, Relationship.GEQ, 0.0d));
constraints.add(new LinearConstraint(new double[] {0.0d, 0.0d, 1.0d, 0.0d, -1.0d, 0.0d, 0.0d}, Relationship.GEQ, 0.0d));
constraints.add(new LinearConstraint(new double[] {0.0d, 0.0d, 1.0d, 0.0d, 1.0d, 0.0d, 0.0d}, Relationship.GEQ, 0.0d));
double epsilon = 1e-7;
SimplexSolver simplex = new SimplexSolver();
RealPointValuePair solution = simplex.optimize(f, constraints, GoalType.MINIMIZE, false);
Assert.assertTrue(MathUtils.compareTo(solution.getPoint()[0], -1e-18d, epsilon) >= 0);
Assert.assertEquals(1.0d, solution.getPoint()[1], epsilon);
Assert.assertEquals(0.0d, solution.getPoint()[2], epsilon);
Assert.assertEquals(1.0d, solution.getValue(), epsilon);
}
开发者ID:SpoonLabs,项目名称:astor,代码行数:26,代码来源:SimplexSolverTest.java
示例18: testMath272
import org.apache.commons.math.optimization.RealPointValuePair; //导入依赖的package包/类
@Test
public void testMath272() throws OptimizationException {
LinearObjectiveFunction f = new LinearObjectiveFunction(new double[] { 2, 2, 1 }, 0);
Collection<LinearConstraint> constraints = new ArrayList<LinearConstraint>();
constraints.add(new LinearConstraint(new double[] { 1, 1, 0 }, Relationship.GEQ, 1));
constraints.add(new LinearConstraint(new double[] { 1, 0, 1 }, Relationship.GEQ, 1));
constraints.add(new LinearConstraint(new double[] { 0, 1, 0 }, Relationship.GEQ, 1));
SimplexSolver solver = new SimplexSolver();
RealPointValuePair solution = solver.optimize(f, constraints, GoalType.MINIMIZE, true);
Assert.assertEquals(0.0, solution.getPoint()[0], .0000001);
Assert.assertEquals(1.0, solution.getPoint()[1], .0000001);
Assert.assertEquals(1.0, solution.getPoint()[2], .0000001);
Assert.assertEquals(3.0, solution.getValue(), .0000001);
}
开发者ID:SpoonLabs,项目名称:astor,代码行数:17,代码来源:SimplexSolverTest.java
示例19: testLeastSquares3
import org.apache.commons.math.optimization.RealPointValuePair; //导入依赖的package包/类
@Test
public void testLeastSquares3() {
final RealMatrix factors =
new Array2DRowRealMatrix(new double[][] {
{ 1, 0 },
{ 0, 1 }
}, false);
LeastSquaresConverter ls = new LeastSquaresConverter(new MultivariateVectorialFunction() {
public double[] value(double[] variables) {
return factors.operate(variables);
}
}, new double[] { 2, -3 }, new Array2DRowRealMatrix(new double [][] {
{ 1, 1.2 }, { 1.2, 2 }
}));
SimplexOptimizer optimizer = new SimplexOptimizer(-1, 1e-6);
optimizer.setSimplex(new NelderMeadSimplex(2));
RealPointValuePair optimum =
optimizer.optimize(200, ls, GoalType.MINIMIZE, new double[] { 10, 10 });
Assert.assertEquals( 2, optimum.getPointRef()[0], 2e-3);
Assert.assertEquals(-3, optimum.getPointRef()[1], 8e-4);
Assert.assertTrue(optimizer.getEvaluations() > 60);
Assert.assertTrue(optimizer.getEvaluations() < 80);
Assert.assertTrue(optimum.getValue() < 1e-6);
}
开发者ID:SpoonLabs,项目名称:astor,代码行数:26,代码来源:SimplexOptimizerNelderMeadTest.java
示例20: testMoreEstimatedParametersUnsorted
import org.apache.commons.math.optimization.RealPointValuePair; //导入依赖的package包/类
public void testMoreEstimatedParametersUnsorted()
throws FunctionEvaluationException, OptimizationException {
LinearProblem problem = new LinearProblem(new double[][] {
{ 1.0, 1.0, 0.0, 0.0, 0.0, 0.0 },
{ 0.0, 0.0, 1.0, 1.0, 1.0, 0.0 },
{ 0.0, 0.0, 0.0, 0.0, 1.0, -1.0 },
{ 0.0, 0.0, -1.0, 1.0, 0.0, 1.0 },
{ 0.0, 0.0, 0.0, -1.0, 1.0, 0.0 }
}, new double[] { 3.0, 12.0, -1.0, 7.0, 1.0 });
NonLinearConjugateGradientOptimizer optimizer =
new NonLinearConjugateGradientOptimizer(ConjugateGradientFormula.POLAK_RIBIERE);
optimizer.setMaxIterations(100);
optimizer.setConvergenceChecker(new SimpleScalarValueChecker(1.0e-6, 1.0e-6));
RealPointValuePair optimum =
optimizer.optimize(problem, GoalType.MINIMIZE, new double[] { 2, 2, 2, 2, 2, 2 });
assertEquals(0, optimum.getValue(), 1.0e-10);
}
开发者ID:SpoonLabs,项目名称:astor,代码行数:18,代码来源:NonLinearConjugateGradientOptimizerTest.java
注:本文中的org.apache.commons.math.optimization.RealPointValuePair类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论