# Getter that returns all optimizer attributes

**URL:** <https://discourse.julialang.org/t/getter-that-returns-all-optimizer-attributes/99113>\
**Category:** Optimization (Mathematical)\
**Created:** [May 19, 2023, 1:01pm UTC](https://discourse.julialang.org/t/getter-that-returns-all-optimizer-attributes/99113 "2023-05-19T13:01:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![raphaelsaavedra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/raphaelsaavedra/32/27631_2.png) [@raphaelsaavedra](https://discourse.julialang.org/u/raphaelsaavedra)\
**Post date:** [May 19, 2023, 1:01pm UTC](https://discourse.julialang.org/t/getter-that-returns-all-optimizer-attributes/99113/1 "2023-05-19T13:01:20Z")

</div>

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:

```julia
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
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).

---

<div class="post-metadata">

**Author:** ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)\
**Post date:** [May 19, 2023, 9:56pm UTC](https://discourse.julialang.org/t/getter-that-returns-all-optimizer-attributes/99113/2 "2023-05-19T21:56:48Z")

</div>

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 😄

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.

---

<div class="post-metadata">

**Author:** ![raphaelsaavedra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/raphaelsaavedra/32/27631_2.png) [@raphaelsaavedra](https://discourse.julialang.org/u/raphaelsaavedra)\
**Post date:** [May 23, 2023, 12:28pm UTC](https://discourse.julialang.org/t/getter-that-returns-all-optimizer-attributes/99113/3 "2023-05-23T12:28:05Z")

</div>

Sorry for the late response.

> [@odow](#):
>
> In what context do you need this?

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.

> [@odow](#):
>
> There’s also the issue of whether you want all the attributes supported by the solver, or just the ones modified by the user.

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`.
