To determine the set of model constraints that cause infeasibility, there are two questions that you can ask the solver:
- What subset of model constraints is responsible for making the model infeasible?
- What changes do I need to make to the model to recover feasibility?
To answer the first question, you can compute an Irreducible Infeasible Subsystem (IIS). This is a minimal subset of constraints and variable bounds that, if isolated from the rest of the model, is still infeasible. However, if any single constraint or bound from this subsystem is removed, the resulting subsystem is feasible. In Python, you can compute an IIS using the Model.computeIIS() method.
Note that an infeasible model may have multiple IISs. The one returned by Gurobi is not necessarily the one with minimum cardinality; there may exist others with fewer constraints or bounds.
To answer the second question, you can compute the smallest (with respect to some specified metric) perturbation that would need to be made to the model in order to recover feasibility. In Python, you can do this with the Model.feasRelax() and Model.feasRelaxS() methods. The latter is a simplified version of the former, hence the "S" suffix.
- Diagnose and cope with infeasibility section in the documentation
- How does Gurobi compute the IIS for infeasible models?
- How do I change variable and/or constraint bounds to make an infeasible model feasible using feasRelax?
- Why does Gurobi sometimes return non-integral values for integer variables?
- Feasibility relaxations of multi-objective models in Gurobi v9.0.x