You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Missing attribute ConstraintDual for ZerosBridge #1831
using JuMP
using ECOS
model =Model(() -> ECOS.Optimizer())
@variable(model, x[1:2])
@variable(model, t[1:2])
@variable(model, p ==1)
@constraint(model, con1, [t[1], x[1] + p, x[1]] inSecondOrderCone())
@constraint(model, con2, [t[2], 2x[2] + p, x[2]] inSecondOrderCone())
@objective(model, Min, sum(t))
optimize!(model)
dual(FixRef(p))
julia>dual(FixRef(p))
ERROR: ArgumentError: Bridge of type `MathOptInterface.Bridges.Variable.ZerosBridge{Float64}` does not support
accessing the attribute `MathOptInterface.ConstraintDual(1)`. If you encountered this error unexpectedly, it probably means your model has been reformulated using the bridge, and you are attempting to query an attribute that we haven't implemented yet for this bridge. Please open an issue at https://github.com/jump-dev/MathOptInterface.jl/issues/new and provide a reproducible example explaining what you were trying to do.
I was testing querying duals of parameters in some conic sets.
There's another work-around that would require adding methods to JuMP:
julia>using JuMP
julia>using ECOS
julia>remove_bridge(model::Model, B) =remove_bridge(backend(model), B)
remove_bridge (generic function with 3 methods)
julia>remove_bridge(model::MOI.Utilities.CachingOptimizer, B) =remove_bridge(model.optimizer, B)
remove_bridge (generic function with 3 methods)
julia>remove_bridge(model::MOI.Bridges.AbstractBridgeOptimizer, B) = MOI.Bridges.remove_bridge(model, B)
remove_bridge (generic function with 3 methods)
julia> model =Model(ECOS.Optimizer)
A JuMP Model
Feasibility problem with:
Variables:0
Model mode: AUTOMATIC
CachingOptimizer state: EMPTY_OPTIMIZER
Solver name: ECOS
julia>remove_bridge(model, MOI.Bridges.Variable.ZerosBridge{Float64})
julia>@variable(model, x[1:2])
2-element Vector{VariableRef}:
x[1]
x[2]
julia>@variable(model, t[1:2])
2-element Vector{VariableRef}:
t[1]
t[2]
julia>@variable(model, p ==1)
p
julia>@constraint(model, con1, [t[1], x[1] + p, x[1]] inSecondOrderCone())
con1 : [t[1], x[1] + p, x[1]] ∈ MathOptInterface.SecondOrderCone(3)
julia>@constraint(model, con2, [t[2], 2x[2] + p, x[2]] inSecondOrderCone())
con2 : [t[2], 2 x[2] + p, x[2]] ∈ MathOptInterface.SecondOrderCone(3)
julia>@objective(model, Min, sum(t))
t[1] + t[2]
julia>optimize!(model)
ECOS 2.0.8- (C) embotech GmbH, Zurich Switzerland, 2012-15. Web: www.embotech.com/ECOS
It pcost dcost gap pres dres k/t mu step sigma IR | BT
0+0.000e+00-0.000e+00+8e+005e-011e-031e+003e+00------11-|--1+3.122e-01+3.189e-01+1e+009e-022e-041e-014e-010.86564e-03222|002+1.126e+00+1.136e+00+7e-027e-039e-062e-023e-020.96234e-02222|003+1.154e+00+1.154e+00+8e-048e-051e-072e-043e-040.98901e-04111|004+1.154e+00+1.154e+00+8e-068e-071e-092e-064e-060.98901e-04111|005+1.154e+00+1.154e+00+9e-089e-091e-113e-084e-080.98901e-04211|006+1.154e+00+1.154e+00+1e-091e-101e-133e-104e-100.98901e-04111|00
OPTIMAL (within feastol=1.0e-10, reltol=8.9e-10, abstol=1.0e-09).
Runtime:0.000114 seconds.
julia>dual(FixRef(p))
1.1543203763939147
But that requires the user to have some pretty deep understanding of bridges, and they could do it by calling on backend(model).optimizer, so I'm hesitant to add that to JuMP.
@guilhermebodin does the error improve things enough to close this issue?
Activity
odow commentedon May 4, 2022
The problem is
p == 1. See the discussion here: #1767I guess this now applies.
odow commentedon May 23, 2022
There's another work-around that would require adding methods to JuMP:
But that requires the user to have some pretty deep understanding of bridges, and they could do it by calling on
backend(model).optimizer, so I'm hesitant to add that to JuMP.@guilhermebodin does the error improve things enough to close this issue?
guilhermebodin commentedon May 24, 2022
Hi @odow, in my opinion, the new error message is instructive enough to close the issue. 👍🏻