Java apache commons LinearObjectiveFunction算法

Java apache commons LinearObjectiveFunction算法,java,math,apache-commons,Java,Math,Apache Commons,apache commons数学库如何计算给定不等式约束的目标函数的最小值和最大值 e、 g apache commons库应用了什么算法。apache commons数学中有一个解算器 使用此库,您可以像这样解决问题: @Test public void testMathStackOverflow() { // maximize 3x1+5x2 // subject to // 2x1+8x2<=13 //

apache commons数学库如何计算给定不等式约束的目标函数的最小值和最大值

e、 g

apache commons库应用了什么算法。

apache commons数学中有一个解算器

使用此库,您可以像这样解决问题:

@Test
public void testMathStackOverflow() {
    //      maximize 3x1+5x2
    //      subject to
    //          2x1+8x2<=13
    //          5x1-x2<=11
    //              x1>=0
    // x2>=0

    LinearObjectiveFunction f = new LinearObjectiveFunction(new double[] { 3, 5}, 0);

    ArrayList<LinearConstraint> constraints = new ArrayList<>();

    constraints.add(new LinearConstraint(new double[] {2, 8}, Relationship.LEQ, 13));
    constraints.add(new LinearConstraint(new double[] {5, -1}, Relationship.LEQ, 11));

    double epsilon = 1e-6;
    SimplexSolver solver = new SimplexSolver();
    PointValuePair solution = solver.optimize(f, new LinearConstraintSet(constraints),
            GoalType.MAXIMIZE,
            new NonNegativeConstraint(true),
            PivotSelectionRule.BLAND);
    System.out.printf("x1: %f; x2: %f; max: %f", solution.getPoint()[0], solution.getPoint()[1], solution.getValue());
}
我使用了这些依赖项:

<groupId>org.apache.commons</groupId>
<artifactId>commons-math4</artifactId>
<version>4.0-SNAPSHOT</version>

你能就我对你问题的回答给我一些反馈吗?消极或积极的反馈非常受欢迎,总比完全没有反馈要好。
x1: 2.404762; x2: 1.023810; max: 12.333333
<groupId>org.apache.commons</groupId>
<artifactId>commons-math4</artifactId>
<version>4.0-SNAPSHOT</version>
org.apache.commons.math4.optim.linear