# Accessing backend of Model

**URL:** <https://discourse.julialang.org/t/accessing-backend-of-model/91689>\
**Category:** Optimization (Mathematical)\
**Created:** [December 15, 2022, 9:51am UTC](https://discourse.julialang.org/t/accessing-backend-of-model/91689 "2022-12-15T09:51:06Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Maxime](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/maxime/32/45122_2.png) [@Maxime](https://discourse.julialang.org/u/Maxime)\
**Post date:** [December 15, 2022, 9:51am UTC](https://discourse.julialang.org/t/accessing-backend-of-model/91689/1 "2022-12-15T09:51:06Z")

</div>

Hi,

I have a usecase where I have to copy models. I also need to access the solver backend. However it seems that I can either use direct\_model(), so I have access to the backend, but can’t copy the model, or i can use Model(), but I can’t find the way to access the backend in this mode.

Minimum examples:

```julia
using JuMP
using HiGHS

backend = HiGHS.Optimizer()
m = direct_model(backend)
@variable(m, a)

Highs_writeOptions(backend, "options.txt") # this works
copy_model(m) # this does not

```

```julia
using JuMP
using HiGHS

m = Model(HiGHS.Optimizer)
@variable(m, a)

copy_model(m) # this works
Highs_writeOptions(m.moi_backend, "options.txt") # this does not

```

---

<div class="post-metadata">

**Author:** ![Maxime](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/maxime/32/45122_2.png) [@Maxime](https://discourse.julialang.org/u/Maxime)\
**Post date:** [December 15, 2022, 10:36am UTC](https://discourse.julialang.org/t/accessing-backend-of-model/91689/2 "2022-12-15T10:36:16Z")

</div>

After a bit more research I found the solution.  
If anyone comes accross the same issue, this seems to work so far

```julia
using JuMP
using HiGHS

m = Model(HiGHS.Optimizer)
@variable(m, a)
optimize!(m)

Highs_writeOptions(m.moi_backend.optimizer.model, "options.txt") # this does not

```

---

<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:** [December 15, 2022, 5:55pm UTC](https://discourse.julialang.org/t/accessing-backend-of-model/91689/3 "2022-12-15T17:55:46Z")

</div>

Hi Maxime, welcome to the forum.

You’re pretty close. You can use `unsafe_backend` instead, which essentially is your last option in a nice function call.

Here is the part of the documentation to read

[https://jump.dev/JuMP.jl/stable/manual/models/#Unsafe-backend](https://jump.dev/JuMP.jl/stable/manual/models/#Unsafe-backend)

---

<div class="post-metadata">

**Author:** ![Maxime](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/maxime/32/45122_2.png) [@Maxime](https://discourse.julialang.org/u/Maxime)\
**Post date:** [December 20, 2022, 3:08pm UTC](https://discourse.julialang.org/t/accessing-backend-of-model/91689/4 "2022-12-20T15:08:44Z")

</div>

Hi odow,

Thank you for your answer
