Some solvers will indicate the constraints causing infeasibilities (e.g. Gurobi, Xpress, …) like this:
User MIP start violates constraint R33048 by 0.493000000
Is there a way to retrieve the JuMP constraint ref corresponding to “R33048”?
I know that I can use write_to_file and inspect the JSON, but in this case that file is quite large and I’m looking for a more direct way to debug.
I get the following output from the CPLEX log: Infeasibility row 'c47180': 0 = -1.
So, I did the following to find it (NOTE: since CPLEX is 0-indexed, I increase the index value by 1 from 47180 to 47181):
julia> cons=vcat([all_constraints(model, i...) for i in list_of_constraint_types(model)]...);
julia> con_dict=Dict(con => optimizer_index(con).value for con in cons);
julia> findall(i -> i==47181, con_dict)
1-element Vector{ConstraintRef{Model, MathOptInterface.ConstraintIndex{MathOptInterface.SingleVariable, MathOptInterface.EqualTo{Float64}}, ScalarShape}}:
OS[-19,5,20] = 0.0
I noticed this is a variable fixing constraint in my model (using fix), so I removed it from the model. I reran the problem and get the same CPLEX output Infeasibility row 'c47180': 0 = -1.
I see. All of my constraints are named (name(ConstraintRef) returns a valid string name), but these don’t seem to be passed to CPLEX. Is there something I need to do to pass these over?
Use direct_model(CPLEX.Optimizer()). Upcoming releases of JuMP and MOI will push more information to the solver. At present they sometimes aren’t if bridges and caches are used.