Skip to content

Commit

Permalink
Example: how to list conflicting constraints (#2605)
Browse files Browse the repository at this point in the history
  • Loading branch information
jd-foster authored May 20, 2021
1 parent 1abc179 commit c27e4b9
Showing 1 changed file with 16 additions and 0 deletions.
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

0 comments on commit c27e4b9

Please sign in to comment.