diff --git a/docs/src/apireference.md b/docs/src/apireference.md index 76976f8f4e..e48e2e1e6d 100644 --- a/docs/src/apireference.md +++ b/docs/src/apireference.md @@ -169,6 +169,19 @@ The value of the attribute is of type `TerminationStatusCode`. TerminationStatusCode ``` +### Conflict Status + +The `ConflictStatus` attribute indicates why the conflict finder stopped executing. +The value of the attribute is of type `ConflictStatusCode`. + +```@docs +compute_conflict! +ConflictStatus +ConflictStatusCode +ConstraintConflictStatus +ConflictParticipationStatusCode +``` + ### Result Status The `PrimalStatus` and `DualStatus` attributes indicate how to interpret the result returned by the solver. diff --git a/src/MathOptInterface.jl b/src/MathOptInterface.jl index 925bad590c..ffec6100c9 100644 --- a/src/MathOptInterface.jl +++ b/src/MathOptInterface.jl @@ -32,6 +32,26 @@ Start the solution procedure. """ function optimize! end +""" + compute_conflict!(optimizer::AbstractOptimizer) + +Computes a minimal subset of constraints such that the model with the other +constraint removed is still infeasible. + +Some solvers call a set of conflicting constraints an Irreducible Inconsistent +Subsystem (IIS). + +See also [`ConflictStatus`](@ref) and [`ConstraintConflictStatus`](@ref). + +### Note + +If the model is modified after a call to `compute_conflict!`, the implementor +is not obliged to purge the conflict. Any calls to the above attributes may +return values for the original conflict without a warning. Similarly, when +modifying the model, the conflict can be discarded. +""" +function compute_conflict! end + """ write_to_file(model::ModelLike, filename::String) diff --git a/src/attributes.jl b/src/attributes.jl index 7604eb1446..94b0bf2022 100644 --- a/src/attributes.jl +++ b/src/attributes.jl @@ -910,6 +910,35 @@ A model attribute for the number of results available. """ struct ResultCount <: AbstractModelAttribute end +""" + ConflictStatusCode + +An Enum of possible values for the `ConflictStatus` attribute. This attribute +is meant to explain the reason why the conflict finder stopped executing in the +most recent call to [`compute_conflict!`](@ref). + +Possible values are: +* `COMPUTE_CONFLICT_NOT_CALLED`: the function [`compute_conflict!`](@ref) has + not yet been called +* `NO_CONFLICT_EXISTS`: there is no conflict because the problem is feasible +* `NO_CONFLICT_FOUND`: the solver could not find a conflict +* `CONFLICT_FOUND`: at least one conflict could be found +""" +@enum ConflictStatusCode begin + COMPUTE_CONFLICT_NOT_CALLED + NO_CONFLICT_EXISTS + NO_CONFLICT_FOUND + CONFLICT_FOUND +end + +""" + ConflictStatus() + +A model attribute for the [`ConflictStatusCode`](@ref) explaining why the conflict +refiner stopped when computing the conflict. +""" +struct ConflictStatus <: AbstractModelAttribute end + ## Variable attributes """ @@ -1117,6 +1146,30 @@ function throw_set_error_fallback(::ModelLike, ::ConstraintSet, type $(typeof(set)). Use `transform` instead.""")) end +""" + ConflictParticipationStatusCode + +An Enum of possible values for the [`ConstraintConflictStatus`](@ref) attribute. +This attribute is meant to indicate whether a given constraint participates +or not in the last computed conflict. + +Possible values are: +* `NOT_IN_CONFLICT`: the constraint does not participate in the conflict +* `IN_CONFLICT`: the constraint participates in the conflict +* `MAYBE_IN_CONFLICT`: the constraint may participate in the conflict, + the solver was not able to prove that the constraint can be excluded from + the conflict +""" +@enum(ConflictParticipationStatusCode, NOT_IN_CONFLICT, IN_CONFLICT, MAYBE_IN_CONFLICT) + +""" + ConstraintConflictStatus() + +A constraint attribute indicating whether the constraint participates +in the conflict. Its type is [`ConflictParticipationStatusCode`](@ref). +""" +struct ConstraintConflictStatus <: AbstractConstraintAttribute end + ## Termination status """ TerminationStatus() @@ -1318,6 +1371,8 @@ function is_set_by_optimize(::Union{ObjectiveValue, NodeCount, RawSolver, ResultCount, + ConflictStatus, + ConstraintConflictStatus, TerminationStatus, RawStatusString, PrimalStatus,