# UndefVarError: with\_optimizer not defined with ProxSDP

**URL:** https://discourse.julialang.org/t/undefvarerror-with-optimizer-not-defined-with-proxsdp/94076
**Category:** Optimization (Mathematical)
**Created:** [February 5, 2023, 4:17am UTC](https://discourse.julialang.org/t/undefvarerror-with-optimizer-not-defined-with-proxsdp/94076 "2023-02-05T04:17:03Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![horvetz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/horvetz/32/31993_2.png) [@horvetz](https://discourse.julialang.org/u/horvetz)
#### Post date: [February 5, 2023, 4:17am UTC](https://discourse.julialang.org/t/undefvarerror-with-optimizer-not-defined-with-proxsdp/94076/1 "2023-02-05T04:17:03Z")

</div>

I just installed [ProxSDP](https://github.com/mariohsouto/ProxSDP.jl), but when I tried this test code,

```julia
# Load packages
using ProxSDP, JuMP, LinearAlgebra

# Number of vertices
n = 4
# Graph weights
W = [18.0 -5.0 -7.0 -6.0
     -5.0 6.0 0.0 -1.0
     -7.0 0.0 8.0 -1.0
     -6.0 -1.0 -1.0 8.0]

# Build Max-Cut SDP relaxation via JuMP
model = Model(with_optimizer(ProxSDP.Optimizer, log_verbose=true, tol_gap=1e-4, tol_feasibility=1e-4))
@variable(model, X[1:n, 1:n], PSD)
@objective(model, Max, 0.25 * dot(W, X))
@constraint(model, diag(X) .== 1)

# Solve optimization problem with ProxSDP
JuMP.optimize!(model)

# Retrieve solution
Xsol = JuMP.value.(X)

```

I get the following error

```julia
UndefVarError: with_optimizer not defined

Stacktrace:
 [1] top-level scope
   @ In[1]:13
 [2] eval
   @ ./boot.jl:373 [inlined]
 [3] include_string(mapexpr::typeof(REPL.softscope), mod::Module, code::String, filename::String)
   @ Base ./loading.jl:1196

```

---

<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: [February 5, 2023, 4:34am UTC](https://discourse.julialang.org/t/undefvarerror-with-optimizer-not-defined-with-proxsdp/94076/2 "2023-02-05T04:34:58Z")

</div>

The README example is out-of-date. Do instead:

```julia
model = Model(ProxSDP.Optimizer)
set_optimizer_attribute(model, "log_verbose", true)
set_optimizer_attribute(model, "tol_gap", 1e-4)
set_optimizer_attribute(model, "tol_feasibility", 1e-4)

```

I’ll update the README: [Update README example by odow · Pull Request #92 · mariohsouto/ProxSDP.jl · GitHub](https://github.com/mariohsouto/ProxSDP.jl/pull/92)

---

<div class="post-metadata">

### Author: ![horvetz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/horvetz/32/31993_2.png) [@horvetz](https://discourse.julialang.org/u/horvetz)
#### Post date: [February 5, 2023, 8:46am UTC](https://discourse.julialang.org/t/undefvarerror-with-optimizer-not-defined-with-proxsdp/94076/3 "2023-02-05T08:46:51Z")

</div>

> [@odow](#):
>
> ```julia
> model = Model(ProxSDP.Optimizer)
> set_optimizer_attribute(model, "log_verbose", true)
> set_optimizer_attribute(model, "tol_gap", 1e-4)
> set_optimizer_attribute(model, "tol_feasibility", 1e-4)
> 
> ```

Thank you!

I am not sure if this can be fixed, but why doesn’t the solver output results in more digits or in exponential forms (Rather than meaningless 0.00000). Here is the output

```julia
Constraints:
       13 linear equalities and 
    Cones:
       1 psd cone of size 4
       2 psd cones of size 2
---------------------------------------------------------------------------------------
    Initializing Primal-Dual Hybrid Gradient method
---------------------------------------------------------------------------------------
| iter | prim obj | rel. gap | feasb. | prim res | dual res | tg. rank | time(s) |
---------------------------------------------------------------------------------------
| 1000 | 0.000 | 0.00006 | 0.00008 | 0.00015 | 0.00026 | 6 | 0.0272 |
| 2000 | 0.000 | 0.00020 | 0.00001 | 0.00003 | 0.00007 | 6 | 0.0417 |
| 3000 | 0.000 | 0.00003 | 0.00000 | 0.00000 | 0.00001 | 6 | 0.0563 |
| 4000 | 0.000 | 0.00001 | 0.00000 | 0.00000 | 0.00001 | 6 | 0.0708 |
| 5000 | 0.000 | 0.00001 | 0.00000 | 0.00000 | 0.00001 | 6 | 0.0862 |
| 6000 | 0.000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 6 | 0.1015 |
| 7000 | 0.000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 6 | 0.1161 |
| 8000 | 0.000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 6 | 0.1311 |
| 9000 | 0.000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 6 | 0.1465 |
| 10000 | 0.000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 6 | 0.1620 |
| 11000 | 0.000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 6 | 0.1770 |
| 12000 | 0.000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 6 | 0.1918 |
| 13000 | 0.000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 6 | 0.2066 |
| 14000 | 0.000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 6 | 0.2219 |
| 15000 | 0.000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 6 | 0.2364 |
| 16000 | 0.000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 6 | 0.2508 |
| 17000 | 0.000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 6 | 0.2662 |
| 18000 | 0.000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 6 | 0.2818 |
| 19000 | 0.000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 6 | 0.2965 |

```

---

<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: [February 5, 2023, 12:11pm UTC](https://discourse.julialang.org/t/undefvarerror-with-optimizer-not-defined-with-proxsdp/94076/4 "2023-02-05T12:11:49Z")

</div>

> [@horvetz](#):
>
> I am not sure if this can be fixed, but why doesn’t the solver output results in more digits or in exponential forms (Rather than meaningless 0.00000)

This is a question for @joaquimg

---

<div class="post-metadata">

### Author: ![MarioSouto](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mariosouto/32/36673_2.png) [@MarioSouto](https://discourse.julialang.org/u/MarioSouto)
#### Post date: [February 7, 2023, 6:17am UTC](https://discourse.julialang.org/t/undefvarerror-with-optimizer-not-defined-with-proxsdp/94076/5 "2023-02-07T06:17:32Z")

</div>

Thanks for the feedback @horvetz. I modified the output of the solver on ProxSDP v1.8.2. You just need to upgrade your version.
