The MiniZinc site (https://www.minizinc.org/doc-2.5.5/en/solvers.html#indicator-constraints) states that the MIP SCIP solver supports indicator constraints.
I have found the MPIndicatorConstraint documentation at http://google.github.io/or-tools/javadoc/com/google/ortools/linearsolver/MPIndicatorConstraint.html, but with no examples associated with it.
The C++ documentation also informs of a MPSolverInterface which has an AddIndicatorConstraint method, for which I have found no parallel in the Java documentation (https://developers.google.com/optimization/reference/linear_solver/linear_solver/MPSolverInterface?hl=en)
Some examples for CP models are available at https://github.com/google/or-tools/blob/master/ortools/sat/doc/channeling.md#java-code but I could not find any analogous application associated with MIP.
Have any examples been documented? If not, would it be possible to share one on this thread?
As per this test case it should be possible to use indicator constraints by building the model with the proto interface. Is there a roadmap to port it to 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));
}