In JuMP I’m having problems getting conflicting equality constraints when using small values
using JuMP
using Gurobi
model = Model(Gurobi.Optimizer)
@variable(model, x)
a = 5e-5
b = 3e-3
@constraint(model, c1, x == 0)
@constraint(model, c2, 1 == (a * x^2 +b*x))
@objective(model, Min, x)
optimize!(model)
compute_conflict!(model)
MOI.get.(model, MOI.ConstraintConflictStatus(), c1)
MOI.get.(model, MOI.ConstraintConflictStatus(), c2)
# Without broadcasting
MOI.get.(model, MOI.ConstraintConflictStatus(), c2)
However, this gives (sorry for long traceback)
julia> MOI.get.(model, MOI.ConstraintConflictStatus(), c1)
IN_CONFLICT::ConflictParticipationStatusCode = 1
julia> MOI.get.(model, MOI.ConstraintConflictStatus(), c2)
ERROR: ArgumentError: Gurobi.Optimizer does not support getting the attribute MathOptInterface.ConstraintConflictStatus().
Stacktrace:
[1] get_fallback(model::Gurobi.Optimizer, attr::MathOptInterface.ConstraintConflictStatus, #unused#::MathOptInterface.ConstraintIndex{MathOptInterface.ScalarQuadraticFunction{Float64}, MathOptInterface.EqualTo{Float64}})
@ MathOptInterface ~/.julia/packages/MathOptInterface/IIN1o/src/attributes.jl:361
[2] get(model::Gurobi.Optimizer, attr::MathOptInterface.ConstraintConflictStatus, args::MathOptInterface.ConstraintIndex{MathOptInterface.ScalarQuadraticFunction{Float64}, MathOptInterface.EqualTo{Float64}})
@ MathOptInterface ~/.julia/packages/MathOptInterface/IIN1o/src/attributes.jl:330
[3] get(b::MathOptInterface.Bridges.LazyBridgeOptimizer{Gurobi.Optimizer}, attr::MathOptInterface.ConstraintConflictStatus, ci::MathOptInterface.ConstraintIndex{MathOptInterface.ScalarQuadraticFunction{Float64}, MathOptInterface.EqualTo{Float64}})
@ MathOptInterface.Bridges ~/.julia/packages/MathOptInterface/IIN1o/src/Bridges/bridge_optimizer.jl:1239
[4] get(model::MathOptInterface.Utilities.CachingOptimizer{MathOptInterface.Bridges.LazyBridgeOptimizer{Gurobi.Optimizer}, MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.Model{Float64}}}, attr::MathOptInterface.ConstraintConflictStatus, index::MathOptInterface.ConstraintIndex{MathOptInterface.ScalarQuadraticFunction{Float64}, MathOptInterface.EqualTo{Float64}})
@ MathOptInterface.Utilities ~/.julia/packages/MathOptInterface/IIN1o/src/Utilities/cachingoptimizer.jl:862
[5] _moi_get_result(::MathOptInterface.Utilities.CachingOptimizer{MathOptInterface.Bridges.LazyBridgeOptimizer{Gurobi.Optimizer}, MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.Model{Float64}}}, ::MathOptInterface.ConstraintConflictStatus, ::Vararg{Any})
@ JuMP ~/.julia/packages/JuMP/lnUbA/src/JuMP.jl:1226
[6] get(model::Model, attr::MathOptInterface.ConstraintConflictStatus, cr::ConstraintRef{Model, MathOptInterface.ConstraintIndex{MathOptInterface.ScalarQuadraticFunction{Float64}, MathOptInterface.EqualTo{Float64}}, ScalarShape})
@ JuMP ~/.julia/packages/JuMP/lnUbA/src/JuMP.jl:1289
[7] _broadcast_getindex_evalf
@ ./broadcast.jl:670 [inlined]
[8] _broadcast_getindex
@ ./broadcast.jl:643 [inlined]
[9] getindex
@ ./broadcast.jl:597 [inlined]
[10] copy
@ ./broadcast.jl:875 [inlined]
[11] materialize(bc::Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{0}, Nothing, typeof(MathOptInterface.get), Tuple{Base.RefValue{Model}, Base.RefValue{MathOptInterface.ConstraintConflictStatus}, Base.RefValue{ConstraintRef{Model, MathOptInterface.ConstraintIndex{MathOptInterface.ScalarQuadraticFunction{Float64}, MathOptInterface.EqualTo{Float64}}, ScalarShape}}}})
@ Base.Broadcast ./broadcast.jl:860
[12] top-level scope
@ REPL[16]:1
julia> # Without broadcasting
MOI.get(model, MOI.ConstraintConflictStatus(), c2)
ERROR: ArgumentError: Gurobi.Optimizer does not support getting the attribute MathOptInterface.ConstraintConflictStatus().
Stacktrace:
[1] get_fallback(model::Gurobi.Optimizer, attr::MathOptInterface.ConstraintConflictStatus, #unused#::MathOptInterface.ConstraintIndex{MathOptInterface.ScalarQuadraticFunction{Float64}, MathOptInterface.EqualTo{Float64}})
@ MathOptInterface ~/.julia/packages/MathOptInterface/IIN1o/src/attributes.jl:361
[2] get(model::Gurobi.Optimizer, attr::MathOptInterface.ConstraintConflictStatus, args::MathOptInterface.ConstraintIndex{MathOptInterface.ScalarQuadraticFunction{Float64}, MathOptInterface.EqualTo{Float64}})
@ MathOptInterface ~/.julia/packages/MathOptInterface/IIN1o/src/attributes.jl:330
[3] get(b::MathOptInterface.Bridges.LazyBridgeOptimizer{Gurobi.Optimizer}, attr::MathOptInterface.ConstraintConflictStatus, ci::MathOptInterface.ConstraintIndex{MathOptInterface.ScalarQuadraticFunction{Float64}, MathOptInterface.EqualTo{Float64}})
@ MathOptInterface.Bridges ~/.julia/packages/MathOptInterface/IIN1o/src/Bridges/bridge_optimizer.jl:1239
[4] get(model::MathOptInterface.Utilities.CachingOptimizer{MathOptInterface.Bridges.LazyBridgeOptimizer{Gurobi.Optimizer}, MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.Model{Float64}}}, attr::MathOptInterface.ConstraintConflictStatus, index::MathOptInterface.ConstraintIndex{MathOptInterface.ScalarQuadraticFunction{Float64}, MathOptInterface.EqualTo{Float64}})
@ MathOptInterface.Utilities ~/.julia/packages/MathOptInterface/IIN1o/src/Utilities/cachingoptimizer.jl:862
[5] _moi_get_result(::MathOptInterface.Utilities.CachingOptimizer{MathOptInterface.Bridges.LazyBridgeOptimizer{Gurobi.Optimizer}, MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.Model{Float64}}}, ::MathOptInterface.ConstraintConflictStatus, ::Vararg{Any})
@ JuMP ~/.julia/packages/JuMP/lnUbA/src/JuMP.jl:1226
[6] get(model::Model, attr::MathOptInterface.ConstraintConflictStatus, cr::ConstraintRef{Model, MathOptInterface.ConstraintIndex{MathOptInterface.ScalarQuadraticFunction{Float64}, MathOptInterface.EqualTo{Float64}}, ScalarShape})
@ JuMP ~/.julia/packages/JuMP/lnUbA/src/JuMP.jl:1289
[7] top-level scope
@ REPL[17]:2
As you can see c1
is fine, but c2
encounters an error, I’ve also tried this with Ipopt.
Versions tried:
Julia 1.7.2 (2022-02-06)
[2e9cd046] Gurobi v0.10.1
[4076af6c] JuMP v0.22.2
Julia 1.8.0-beta3 (2022-03-29)
[2e9cd046] Gurobi v0.11.1
[4076af6c] JuMP v1.0.0