Skip to content

Add model reformulation to get infeasible constraints to the recipes #855

Closed
@Joao-Dionisio

Description

@Joao-Dionisio

More than once we've had an inquiry on whether PySCIPOpt had something like Gurobi's IIS, to which the answer is, not really. However, it's possible to add slack variables to the constraints and change the model's objective to be the minimization of these slack variables. I think we should add this reformulation to the recipes, it shouldn't be too hard and it seems quite helpful.

A rough sketch of what's needed:

from pyscipopt import Model

def get_infeasible_constraints(Model model):

    for c in model.getConss():
        slack[c.name] = model.addVar(c.name) 
        model.addConsCoeff(c, slack[c.name], 1) # need to think about the difference <=, >= and == constraints

    model.setObjective(quicksum(slack_var for slack_var in slack.values())

    model.setPresolve(0) # just to be safe, maybe we can use presolving
    model.optimize()

    for v in slack:
        if model.isGT(model.getVal(slack[v]), 0):
            print("Constraint %s is causing an infeasibility." % v)

    print("If the constraint names are unhelpful, consider giving them \
    a suitable name when creating the model with model.addCons(...., name="the_name_you_want").

Creating the issue as a reminder. It's important that we also add a bunch of tests. This seems pretty important, so I think we should discuss whether this belongs to the recipes or to scip.pxi.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions