Getter that returns all optimizer attributes

I couldn’t find in the JuMP docs how to get all optimizer attributes from a solver. There’s the following, which allows you to get one particular attribute:

get_attribute(model::Model, attr::MOI.AbstractModelAttribute)
get_attribute(x::VariableRef, attr::MOI.AbstractVariableAttribute)
get_attribute(cr::ConstraintRef, attr::MOI.AbstractConstraintAttribute)

however I don’t see anything such as get_optimizer_attributes that would return everything. Doing this seems to work:

julia> model.moi_backend.optimizer.model.options
Dict{String, Any} with 5 entries:
  "mip_heuristic_effort" => 0.5
  "time_limit"           => 300.0
  "mip_abs_gap"          => 0.005
  "mip_rel_gap"          => 0.005
  "mip_report_level"     => 2

but it’s ugly and I’m wondering if there’s a reason this isn’t supported by the API (or it is and I missed it).

In what context do you need this?

We nominally have MOI.ListOfOptimizerAttributesSet() at the MOI level, but I don’t think many solvers support this attribute. We haven’t enforced this as part of the test suite, because no one has come asking for it before :smile:

So. the answer is not really, mainly because optimizer attributes cannot be copied between solvers, so there shouldn’t really be a need to look them up. There’s also the issue of whether you want all the attributes supported by the solver, or just the ones modified by the user.

Sorry for the late response.

I’m modelling a class of problems and I have a struct that contains several kinds of information around the problem, one of them being the underlying jump problem. I’d like to be able to seamlessly fetch the solver parameters and play with them to understand how this affects the solution, including performance. If I don’t know which parameters were specified by the user when the problem was created, then it’s hard for me to know what parameters to look out for. So I’d like to get all specified solver parameters.

That’s a good point. I think my preferred use case here is which parameters were set by the user (i.e., all parameters specified in optimizer_with_attributes(...) when the problem was created, plus any parameters set later). That seems to be returned by model.moi_backend.optimizer.model.options.