using JuMP
using Gurobi
function get_irreducible_inconsistent_subsystem(m::JuMP.Model)
grb_model = m.internalModel.inner
num_constrs = Gurobi.num_constrs(grb_model)
Gurobi.computeIIS(grb_model)
iis_constrs = Gurobi.get_intattrarray(grb_model, "IISConstr", 1, num_constrs)
m.linconstr[find(iis_constrs)]
end
m=Model(solver=GurobiSolver())
@defVar(m,x, Int)
@defVar(m,y, Int)
@addConstraint(m,y<=1000) #This one won't cause problems
@addConstraint(m,x>=6) #This will
@addConstraint(m,y>=6) #This will
@addConstraint(m,x+y<=11) #This will
status = solve(m)
@assert status==:Infeasible
get_irreducible_inconsistent_subsystem(m)
3-element Array{JuMP.GenericRangeConstraint{JuMP.GenericAffExpr{Float64,JuMP.Variable}},1}:
x ≥ 6,
y ≥ 6,
x + y ≤ 11
Note that the first constraint is not listed, as that caused no problems.
I'm not certain this code works all the time.
(I'm not 100% sure this isn't in Gurobi.jl either)
Copyright (c) 2016 Lyndon White (AKA oxinabox)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.