• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java GoalType类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.commons.math.optimization.GoalType的典型用法代码示例。如果您正苦于以下问题:Java GoalType类的具体用法?Java GoalType怎么用?Java GoalType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



GoalType类属于org.apache.commons.math.optimization包,在下文中一共展示了GoalType类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: minimize

import org.apache.commons.math.optimization.GoalType; //导入依赖的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: optimize

import org.apache.commons.math.optimization.GoalType; //导入依赖的package包/类
/** {@inheritDoc} */
public RealPointValuePair optimize(final LinearObjectiveFunction f,
                                   final Collection<LinearConstraint> constraints,
                                   final GoalType goalType, final boolean restrictToNonNegative)
     throws OptimizationException {

    // store linear problem characteristics
    this.function          = f;
    this.linearConstraints = constraints;
    this.goal              = goalType;
    this.nonNegative       = restrictToNonNegative;

    iterations  = 0;

    // solve the problem
    return doOptimize();

}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:19,代码来源:AbstractLinearOptimizer.java


示例3: testLeastSquares2

import org.apache.commons.math.optimization.GoalType; //导入依赖的package包/类
@Test
public void testLeastSquares2()
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 }, new double[] { 10.0, 0.1 });
    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], 5.0e-5);
    assertEquals(-3.0, optimum.getPointRef()[1], 8.0e-4);
    assertTrue(optimizer.getEvaluations() > 60);
    assertTrue(optimizer.getEvaluations() < 80);
    assertTrue(optimum.getValue() < 1.0e-6);
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:26,代码来源:NelderMeadTest.java


示例4: testQuinticMax

import org.apache.commons.math.optimization.GoalType; //导入依赖的package包/类
@Test
public void testQuinticMax() throws MathException {
    // The quintic function has zeros at 0, +-0.5 and +-1.
    // The function has extrema (first derivative is zero) at 0.27195613 and 0.82221643,
    UnivariateRealFunction f = new QuinticFunction();
    UnivariateRealOptimizer minimizer = new BrentOptimizer();
    assertEquals(0.27195613, minimizer.optimize(f, GoalType.MAXIMIZE, 0.2, 0.3), 1.0e-8);
    minimizer.setMaximalIterationCount(30);
    try {
        minimizer.optimize(f, GoalType.MAXIMIZE, 0.2, 0.3);
        fail("an exception should have been thrown");
    } catch (MaxIterationsExceededException miee) {
        // expected
    } catch (Exception e) {
        fail("wrong exception caught");
    }
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:18,代码来源:BrentMinimizerTest.java


示例5: SimplexTableau

import org.apache.commons.math.optimization.GoalType; //导入依赖的package包/类
/**
 * Build a tableau for a linear problem.
 * @param f linear objective function
 * @param constraints linear constraints
 * @param goalType type of optimization goal: either {@link GoalType#MAXIMIZE}
 * or {@link GoalType#MINIMIZE}
 * @param restrictToNonNegative whether to restrict the variables to non-negative values
 * @param epsilon amount of error to accept in floating point comparisons
 */
SimplexTableau(final LinearObjectiveFunction f,
               final Collection<LinearConstraint> constraints,
               final GoalType goalType, final boolean restrictToNonNegative,
               final double epsilon) {
    this.f                      = f;
    this.constraints            = normalizeConstraints(constraints);
    this.restrictToNonNegative  = restrictToNonNegative;
    this.epsilon                = epsilon;
    this.numDecisionVariables   = f.getCoefficients().getDimension() +
                                  (restrictToNonNegative ? 0 : 1);
    this.numSlackVariables      = getConstraintTypeCounts(Relationship.LEQ) +
                                  getConstraintTypeCounts(Relationship.GEQ);
    this.numArtificialVariables = getConstraintTypeCounts(Relationship.EQ) +
                                  getConstraintTypeCounts(Relationship.GEQ);
    this.tableau = createTableau(goalType == GoalType.MAXIMIZE);
    initializeColumnLabels();
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:27,代码来源:SimplexTableau.java


示例6: testMoreEstimatedParametersUnsorted

import org.apache.commons.math.optimization.GoalType; //导入依赖的package包/类
@Test
public void testMoreEstimatedParametersUnsorted() {
    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.setConvergenceChecker(new SimpleScalarValueChecker(1.0e-6, 1.0e-6));
    RealPointValuePair optimum =
        optimizer.optimize(100, problem, GoalType.MINIMIZE, new double[] { 2, 2, 2, 2, 2, 2 });
    Assert.assertEquals(0, optimum.getValue(), 1.0e-10);
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:17,代码来源:NonLinearConjugateGradientOptimizerTest.java


示例7: testTableauWithNoArtificialVars

import org.apache.commons.math.optimization.GoalType; //导入依赖的package包/类
@Test
public void testTableauWithNoArtificialVars() {
    LinearObjectiveFunction f = new LinearObjectiveFunction(new double[] {15, 10}, 0);
    Collection<LinearConstraint> constraints = new ArrayList<LinearConstraint>();
    constraints.add(new LinearConstraint(new double[] {1, 0}, Relationship.LEQ, 2));
    constraints.add(new LinearConstraint(new double[] {0, 1}, Relationship.LEQ, 3));
    constraints.add(new LinearConstraint(new double[] {1, 1}, Relationship.LEQ, 4));
    SimplexTableau tableau =
        new SimplexTableau(f, constraints, GoalType.MAXIMIZE, false, 1.0e-6);
    double[][] initialTableau = {
                                 {1, -15, -10, 25, 0, 0, 0, 0},
                                 {0,   1,   0, -1, 1, 0, 0, 2},
                                 {0,   0,   1, -1, 0, 1, 0, 3},
                                 {0,   1,   1, -2, 0, 0, 1, 4}
    };
    assertMatrixEquals(initialTableau, tableau.getData());
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:18,代码来源:SimplexTableauTest.java


示例8: testInconsistentEquations

import org.apache.commons.math.optimization.GoalType; //导入依赖的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


示例9: testOneSet

import org.apache.commons.math.optimization.GoalType; //导入依赖的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


示例10: testPowell

import org.apache.commons.math.optimization.GoalType; //导入依赖的package包/类
@Test
public void testPowell()
  throws FunctionEvaluationException, ConvergenceException {

  Powell powell = new Powell();
  NelderMead optimizer = new NelderMead();
  optimizer.setConvergenceChecker(new SimpleScalarValueChecker(-1.0, 1.0e-3));
  optimizer.setMaxIterations(200);
  RealPointValuePair optimum =
    optimizer.optimize(powell, GoalType.MINIMIZE, new double[] { 3.0, -1.0, 0.0, 1.0 });
  assertEquals(powell.getCount(), optimizer.getEvaluations());
  assertTrue(optimizer.getEvaluations() > 110);
  assertTrue(optimizer.getEvaluations() < 130);
  assertTrue(optimum.getValue() < 2.0e-3);

}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:17,代码来源:NelderMeadTest.java


示例11: testQuinticMin

import org.apache.commons.math.optimization.GoalType; //导入依赖的package包/类
@Test
public void testQuinticMin() {
    // The quintic function has zeros at 0, +-0.5 and +-1.
    // The function has extrema (first derivative is zero) at 0.27195613 and 0.82221643,
    UnivariateRealFunction f = new QuinticFunction();
    UnivariateRealOptimizer underlying = new BrentOptimizer(1e-9, 1e-14);
    JDKRandomGenerator g = new JDKRandomGenerator();
    g.setSeed(4312000053L);
    MultiStartUnivariateRealOptimizer<UnivariateRealFunction> optimizer =
        new MultiStartUnivariateRealOptimizer<UnivariateRealFunction>(underlying, 5, g);

    UnivariateRealPointValuePair optimum
        = optimizer.optimize(300, f, GoalType.MINIMIZE, -0.3, -0.2);
    Assert.assertEquals(-0.2719561293, optimum.getPoint(), 1e-9);
    Assert.assertEquals(-0.0443342695, optimum.getValue(), 1e-9);

    UnivariateRealPointValuePair[] optima = optimizer.getOptima();
    for (int i = 0; i < optima.length; ++i) {
        Assert.assertEquals(f.value(optima[i].getPoint()), optima[i].getValue(), 1e-9);
    }
    Assert.assertTrue(optimizer.getEvaluations() >= 50);
    Assert.assertTrue(optimizer.getEvaluations() <= 100);
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:24,代码来源:MultiStartUnivariateRealOptimizerTest.java


示例12: testLeastSquares1

import org.apache.commons.math.optimization.GoalType; //导入依赖的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


示例13: testBadFunction

import org.apache.commons.math.optimization.GoalType; //导入依赖的package包/类
@Test
public void testBadFunction() {
    UnivariateRealFunction f = new UnivariateRealFunction() {
            public double value(double x) {
                if (x < 0) {
                    throw new MathUserException();
                }
                return 0;
            }
        };
    UnivariateRealOptimizer underlying = new BrentOptimizer(1e-9, 1e-14);
    JDKRandomGenerator g = new JDKRandomGenerator();
    g.setSeed(4312000053L);
    MultiStartUnivariateRealOptimizer<UnivariateRealFunction> optimizer =
        new MultiStartUnivariateRealOptimizer<UnivariateRealFunction>(underlying, 5, g);
 
    try {
        optimizer.optimize(300, f, GoalType.MINIMIZE, -0.3, -0.2);
        Assert.fail();
    } catch (MathUserException e) {
        // Expected.
    }

    // Ensure that the exception was thrown because no optimum was found.
    Assert.assertTrue(optimizer.getOptima()[0] == null);
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:27,代码来源:MultiStartUnivariateRealOptimizerTest.java


示例14: testMath283

import org.apache.commons.math.optimization.GoalType; //导入依赖的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


示例15: testMath272

import org.apache.commons.math.optimization.GoalType; //导入依赖的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


示例16: doTest

import org.apache.commons.math.optimization.GoalType; //导入依赖的package包/类
/**
 * @param func Function to optimize.
 * @param optimum Expected optimum.
 * @param init Starting point.
 * @param goal Minimization or maximization.
 * @param fTol Tolerance (relative error on the objective function) for
 * "Powell" algorithm.
 * @param pointTol Tolerance for checking that the optimum is correct.
 */
private void doTest(MultivariateRealFunction func,
                    double[] optimum,
                    double[] init,
                    GoalType goal,
                    double fTol,
                    double pointTol) {
    final MultivariateRealOptimizer optim = new PowellOptimizer(fTol, Math.ulp(1d));

    final RealPointValuePair result = optim.optimize(1000, func, goal, init);
    final double[] found = result.getPoint();

    for (int i = 0, dim = optimum.length; i < dim; i++) {
        Assert.assertEquals(optimum[i], found[i], pointTol);
    }
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:25,代码来源:PowellOptimizerTest.java


示例17: testMath286

import org.apache.commons.math.optimization.GoalType; //导入依赖的package包/类
@Test
public void testMath286() throws OptimizationException {
    LinearObjectiveFunction f = new LinearObjectiveFunction(new double[] { 0.8, 0.2, 0.7, 0.3, 0.6, 0.4 }, 0 );
    Collection<LinearConstraint> constraints = new ArrayList<LinearConstraint>();
    constraints.add(new LinearConstraint(new double[] { 1, 0, 1, 0, 1, 0 }, Relationship.EQ, 23.0));
    constraints.add(new LinearConstraint(new double[] { 0, 1, 0, 1, 0, 1 }, Relationship.EQ, 23.0));
    constraints.add(new LinearConstraint(new double[] { 1, 0, 0, 0, 0, 0 }, Relationship.GEQ, 10.0));
    constraints.add(new LinearConstraint(new double[] { 0, 0, 1, 0, 0, 0 }, Relationship.GEQ, 8.0));
    constraints.add(new LinearConstraint(new double[] { 0, 0, 0, 0, 1, 0 }, Relationship.GEQ, 5.0));

    SimplexSolver solver = new SimplexSolver();
    RealPointValuePair solution = solver.optimize(f, constraints, GoalType.MAXIMIZE, true);

    Assert.assertEquals(25.8, solution.getValue(), .0000001);
    Assert.assertEquals(23.0, solution.getPoint()[0] + solution.getPoint()[2] + solution.getPoint()[4], 0.0000001);
    Assert.assertEquals(23.0, solution.getPoint()[1] + solution.getPoint()[3] + solution.getPoint()[5], 0.0000001);
    Assert.assertTrue(solution.getPoint()[0] >= 10.0 - 0.0000001);
    Assert.assertTrue(solution.getPoint()[2] >= 8.0 - 0.0000001);
    Assert.assertTrue(solution.getPoint()[4] >= 5.0 - 0.0000001);
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:21,代码来源:SimplexSolverTest.java


示例18: testMath434NegativeVariable

import org.apache.commons.math.optimization.GoalType; //导入依赖的package包/类
@Test
public void testMath434NegativeVariable() throws OptimizationException
{
    LinearObjectiveFunction f = new LinearObjectiveFunction(new double[] {0.0, 0.0, 1.0}, 0.0d);
    ArrayList<LinearConstraint> constraints = new ArrayList<LinearConstraint>();
    constraints.add(new LinearConstraint(new double[] {1, 1, 0}, Relationship.EQ, 5));
    constraints.add(new LinearConstraint(new double[] {0, 0, 1}, Relationship.GEQ, -10));

    double epsilon = 1e-6;
    SimplexSolver solver = new SimplexSolver();
    RealPointValuePair solution = solver.optimize(f, constraints, GoalType.MINIMIZE, false);

    Assert.assertEquals(5.0, solution.getPoint()[0] + solution.getPoint()[1], epsilon);
    Assert.assertEquals(-10.0, solution.getPoint()[2], epsilon);
    Assert.assertEquals(-10.0, solution.getValue(), epsilon);

}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:18,代码来源:SimplexSolverTest.java


示例19: search

import org.apache.commons.math.optimization.GoalType; //导入依赖的package包/类
/**
 * Find the minimum of the function {@code f(p + alpha * d)}.
 *
 * @param p Starting point.
 * @param d Search direction.
 * @return the optimum.
 * @throws org.apache.commons.math.exception.TooManyEvaluationsException
 * if the number of evaluations is exceeded.
 * @throws org.apache.commons.math.exception.MathUserException if the
 * objective function throws one.
 */
public UnivariateRealPointValuePair search(final double[] p, final double[] d) {
    final int n = p.length;
    final UnivariateRealFunction f = new UnivariateRealFunction() {
            public double value(double alpha) {
                final double[] x = new double[n];
                for (int i = 0; i < n; i++) {
                    x[i] = p[i] + alpha * d[i];
                }
                final double obj = PowellOptimizer.this.computeObjectiveValue(x);
                return obj;
            }
        };

    final GoalType goal = PowellOptimizer.this.getGoalType();
    bracket.search(f, goal, 0, 1);
    // Passing "MAX_VALUE" as a dummy value because it is the enclosing
    // class that counts the number of evaluations (and will eventually
    // generate the exception).
    return optimize(Integer.MAX_VALUE, f, goal,
                    bracket.getLo(), bracket.getHi(), bracket.getMid());
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:33,代码来源:PowellOptimizer.java


示例20: testMoreEstimatedParametersSimple

import org.apache.commons.math.optimization.GoalType; //导入依赖的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



注:本文中的org.apache.commons.math.optimization.GoalType类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ArrayIterator类代码示例发布时间:2022-05-23
下一篇:
Java SimplePointMarker类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap