Skip to content

Improve error message of print_active_bridges #2756

@blegat

Description

@blegat

What do you think if the fix for this ?

julia> model = Model(SDPLR.Optimizer)

julia> print_active_bridges(model)
ERROR: MathOptInterface.GetAttributeNotAllowed{MathOptInterface.ObjectiveFunctionType}: Getting attribute MathOptInterface.ObjectiveFunctionType() cannot be performed: SDPLR.Optimizer does not support getting the attribute MathOptInterface.ObjectiveFunctionType(). You may want to use a `CachingOptimizer` in `AUTOMATIC` mode or you may need to call `reset_optimizer` before doing this operation if the `CachingOptimizer` is in `MANUAL` mode.
Stacktrace:
  [1] get_fallback(model::SDPLR.Optimizer, attr::MathOptInterface.ObjectiveFunctionType)
    @ MathOptInterface ~/.julia/packages/MathOptInterface/JdLrc/src/attributes.jl:409
  [2] get(::SDPLR.Optimizer, ::MathOptInterface.ObjectiveFunctionType)
    @ MathOptInterface ~/.julia/packages/MathOptInterface/JdLrc/src/attributes.jl:390
  [3] get
    @ ~/.julia/packages/MathOptInterface/JdLrc/src/Bridges/bridge_optimizer.jl:1177 [inlined]
  [4] print_active_bridges(io::Base.TTY, b::MathOptInterface.Bridges.LazyBridgeOptimizer{SDPLR.Optimizer})
    @ MathOptInterface.Bridges ~/.julia/packages/MathOptInterface/JdLrc/src/Bridges/debug.jl:544
  [5] (::JuMP.var"#6#7"{Base.TTY})(m::MathOptInterface.Bridges.LazyBridgeOptimizer{SDPLR.Optimizer})
    @ JuMP ~/.julia/dev/JuMP/src/JuMP.jl:832
  [6] _moi_call_bridge_function(::Function, ::MathOptInterface.Bridges.LazyBridgeOptimizer{SDPLR.Optimizer})
    @ JuMP ~/.julia/dev/JuMP/src/JuMP.jl:691
  [7] _moi_call_bridge_function(::Function, ::MathOptInterface.Utilities.CachingOptimizer{…})
    @ JuMP ~/.julia/dev/JuMP/src/JuMP.jl:699
  [8] print_active_bridges(io::Base.TTY, model::Model)
    @ JuMP ~/.julia/dev/JuMP/src/JuMP.jl:831
  [9] print_active_bridges(::Model)
    @ JuMP ~/.julia/dev/JuMP/src/JuMP.jl:888
 [10] top-level scope
    @ REPL[4]:1
Some type information was truncated. Use `show(err)` to see complete types.

It turns out that it can easily be fixed now thanks to jump-dev/JuMP.jl#3979 by using Model(SDPLR.Optimizer, with_cache_type = Float64) but it's very hard to guess from the error message.
I think it could be worth adding a try catch that adds this tip in the error

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions