2
$\begingroup$

Is there any systematic way to retrieve some information on the constraint that caused infeasibility in Or.Tools CP-SAT?

using System;
using Google.OrTools.Sat;

public class InfeasibleCpModel
{
  static void Main()
  {
    CpModel _cpModel = new CpModel();

    IntVar x = _cpModel.NewIntVar(0, 10, "x");
    IntVar y = _cpModel.NewIntVar(0, 10, "y");
    
    _cpModel.AddAllDifferent(new IntVar[]{x, y})
    _cpModel.Add(x == y);
    
    CpSolver solver = new CpSolver();
    CpSolverStatus status = solver.Solve(_cpModel);
    
    if (status == CpSolverStatus.Infeasible)
    {
        // Catch the constraint that did not meet the feasibility gap
    }
  }
}
$\endgroup$
  • $\begingroup$ Note that, in general, one cannot identify a single constraint that causes infeasibility. What you can try to do is find an "irreducible infeasible subset" of constraints -- a set of constraints that cannot be simultaneously satisfied, such that omitting any one of them lets the solver satisfy the rest. $\endgroup$ – prubin Oct 18 at 18:43
  • $\begingroup$ That is correct. This question is more about how a particular solver reports on those constraints that could not meet the feasibility gap. $\endgroup$ – Mahmoud Oct 18 at 18:57
4
$\begingroup$

Not yet, see https://github.com/google/or-tools/issues/973

For debugging I would recommend you to divide your constraints into groups so you can activate/deactivate some of them to pin down the infeasibility

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.