Skip to content

Missing attribute ConstraintDual for ZerosBridge #1831

Closed

Description

@guilhermebodin

This code gives the following error

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]] in SecondOrderCone())
@constraint(model, con2, [t[2], 2x[2] + p, x[2]] in SecondOrderCone())
@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.

Activity

  1. odow commented on May 4, 2022

    @odow
    Member

    The problem is p == 1. See the discussion here: #1767

    We can revisit if we get anyone encountering this issue in the wild.

    I guess this now applies.

  2. odow commented on May 23, 2022

    @odow
    Member

    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]] in SecondOrderCone())
    con1 : [t[1], x[1] + p, x[1]] ∈ MathOptInterface.SecondOrderCone(3)
    
    julia> @constraint(model, con2, [t[2], 2x[2] + p, x[2]] in SecondOrderCone())
    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+00  5e-01  1e-03  1e+00  3e+00    ---    ---    1  1  - |  -  - 
     1  +3.122e-01  +3.189e-01  +1e+00  9e-02  2e-04  1e-01  4e-01  0.8656  4e-03   2  2  2 |  0  0
     2  +1.126e+00  +1.136e+00  +7e-02  7e-03  9e-06  2e-02  3e-02  0.9623  4e-02   2  2  2 |  0  0
     3  +1.154e+00  +1.154e+00  +8e-04  8e-05  1e-07  2e-04  3e-04  0.9890  1e-04   1  1  1 |  0  0
     4  +1.154e+00  +1.154e+00  +8e-06  8e-07  1e-09  2e-06  4e-06  0.9890  1e-04   1  1  1 |  0  0
     5  +1.154e+00  +1.154e+00  +9e-08  9e-09  1e-11  3e-08  4e-08  0.9890  1e-04   2  1  1 |  0  0
     6  +1.154e+00  +1.154e+00  +1e-09  1e-10  1e-13  3e-10  4e-10  0.9890  1e-04   1  1  1 |  0  0
    
    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?

  3. guilhermebodin commented on May 24, 2022

    @guilhermebodin
    ContributorAuthor

    Hi @odow, in my opinion, the new error message is instructive enough to close the issue. 👍🏻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions