jump-dev / ParametricOptInterface.jl

Extension for dealing with parameters
MIT License
37 stars 7 forks source link

Support for `get_attribute(...)` #134

Closed sstroemer closed 1 year ago

sstroemer commented 1 year ago

The following currently fails

using JuMP, HiGHS
import ParametricOptInterface as POI

model = Model(() -> POI.Optimizer(HiGHS.Optimizer()))
get_attribute(model, MOI.RawOptimizerAttribute("presolve"))

with this error:

ERROR: MathOptInterface.GetAttributeNotAllowed{MathOptInterface.RawOptimizerAttribute}: Getting attribute MathOptInterface.RawOptimizerAttribute("presolve") cannot be performed: ParametricOptInterface.Optimizer{Float64, HiGHS.Optimizer} does not support getting the attribute MathOptInterface.RawOptimizerAttribute("presolve"). 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::ParametricOptInterface.Optimizer{Float64, HiGHS.Optimizer}, attr::MathOptInterface.RawOptimizerAttribute)
   @ MathOptInterface ~/.julia/packages/MathOptInterface/pgWRA/src/attributes.jl:406
 [2] get(::ParametricOptInterface.Optimizer{Float64, HiGHS.Optimizer}, ::MathOptInterface.RawOptimizerAttribute)
   @ MathOptInterface ~/.julia/packages/MathOptInterface/pgWRA/src/attributes.jl:390
 [3] get(b::MathOptInterface.Bridges.LazyBridgeOptimizer{ParametricOptInterface.Optimizer{Float64, HiGHS.Optimizer}}, attr::MathOptInterface.RawOptimizerAttribute)
   @ MathOptInterface.Bridges ~/.julia/packages/MathOptInterface/pgWRA/src/Bridges/bridge_optimizer.jl:893
 [4] get(model::MathOptInterface.Utilities.CachingOptimizer{MathOptInterface.Bridges.LazyBridgeOptimizer{ParametricOptInterface.Optimizer{Float64, HiGHS.Optimizer}}, MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.Model{Float64}}}, attr::MathOptInterface.RawOptimizerAttribute)
   @ MathOptInterface.Utilities ~/.julia/packages/MathOptInterface/pgWRA/src/Utilities/cachingoptimizer.jl:1068
 [5] get(model::Model, attr::MathOptInterface.RawOptimizerAttribute)
   @ JuMP ~/.julia/packages/JuMP/ToPd2/src/optimizer_interface.jl:630
 [6] top-level scope
   @ ~/path/to/julia/file.jl:85

which also makes the pre-2.0 get_optimizer_attribute(model, "presolve") fail, and - as far as I understand - comes from a missing implementation for something like this:

MOI.get(model::ParametricOptInterface.Optimizer, attr::Union{MOI.AbstractModelAttribute,MOI.AbstractOptimizerAttribute})

Unfortunately I don't really understand the specifics good enough to open a PR :disappointed: