有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java ORTools/SCIP如何使用指标约束解决MIP问题?

Minizing站点(https://www.minizinc.org/doc-2.5.5/en/solvers.html#indicator-constraints)声明MIP SCIP解算器支持指标约束

我在http://google.github.io/or-tools/javadoc/com/google/ortools/linearsolver/MPIndicatorConstraint.html找到了MPIndicatorConstraint文档,但没有相关的示例

C++文档还通知了一个MPoServer接口,它有一个AddiaDeaCuffor方法,在java文档中(https://developers.google.com/optimization/reference/linear_solver/linear_solver/MPSolverInterface?hl=en

中没有发现并行的方法。

CP模型的一些示例可以在https://github.com/google/or-tools/blob/master/ortools/sat/doc/channeling.md#java-code上找到,但我找不到任何与MIP相关的类似应用程序

有没有记录过任何例子?如果没有,是否可以在此线程上共享一个


共 (1) 个答案

  1. # 1 楼答案

    根据这个test case应该可以通过使用proto接口构建模型来使用指标约束。是否有将其移植到MPSolver的路线图

        @Test
        public void shouldSolveLPWithIndicatorConstraint() {
            final MPModelProto.Builder mpModelProto = this.getLinearObjective();
    
            final MPVariableProto k = this.getIntVar("k").setUpperBound(1.0d).build();
            mpModelProto
                    .addVariable(2, k)
                    .removeConstraint(0);
    
            // x + 7y <= 17.5
            final MPConstraintProto c0_0 = this.getFirstConstraint(17.5d);
            // x + 7y <= 24.5
            final MPConstraintProto c0_1 = this.getFirstConstraint(24.5d);
    
            final MPIndicatorConstraint ic0 = MPIndicatorConstraint.newBuilder()
                    .setVarIndex(2)
                    .setVarValue(0)
                    .setConstraint(c0_0)
                    .build();
    
            final MPIndicatorConstraint ic1 = MPIndicatorConstraint.newBuilder()
                    .setVarIndex(2)
                    .setVarValue(1)
                    .setConstraint(c0_1)
                    .build();
    
            mpModelProto
                    .addGeneralConstraint(MPGeneralConstraintProto.newBuilder().setIndicatorConstraint(ic0).build())
                    .addGeneralConstraint(MPGeneralConstraintProto.newBuilder().setIndicatorConstraint(ic1).build());
    
            final MPSolutionResponse mpSolutionResponse = this.solve(mpModelProto);
    
            assertEquals(MPSOLVER_OPTIMAL, mpSolutionResponse.getStatus());
            assertEquals(33.0d, mpSolutionResponse.getObjectiveValue());
            assertEquals(3.0d, mpSolutionResponse.getVariableValue(0));
            assertEquals(3.0d, mpSolutionResponse.getVariableValue(1));
            assertEquals(1.0d, mpSolutionResponse.getVariableValue(2));
        }