Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example: how to list conflicting constraints #2605

Merged
merged 1 commit into from
May 20, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions docs/src/manual/solutions.md
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,7 @@ For instance, this is how you can use this functionality:
using JuMP
model = Model() # You must use a solver that supports conflict refining/IIS
# computation, like CPLEX or Gurobi
# e.g. using Gurobi; model = Model(Gurobi.Optimizer)
@variable(model, x >= 0)
@constraint(model, c1, x >= 2)
@constraint(model, c2, x <= 1)
Expand All @@ -450,6 +451,21 @@ MOI.get(model, MOI.ConstraintConflictStatus(), c2)
new_model, reference_map = copy_conflict(model)
```

Conflicting constraints can be collected in a list and printed
as follows:

```julia
conflict_constraint_list = ConstraintRef[]
for (F, S) in list_of_constraint_types(model)
for con in all_constraints(model, F, S)
if MOI.get(model, MOI.ConstraintConflictStatus(), con) == MOI.IN_CONFLICT
push!(conflict_constraint_list, con)
println(con)
end
end
end
```

## Multiple solutions

Some solvers support returning multiple solutions. You can check how many
Expand Down