# Help needed with AmplNLWriter

**URL:** <https://discourse.julialang.org/t/help-needed-with-amplnlwriter/102088>\
**Category:** Optimization (Mathematical)\
**Tags:** question\
**Created:** [July 25, 2023, 6:36pm UTC](https://discourse.julialang.org/t/help-needed-with-amplnlwriter/102088 "2023-07-25T18:36:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![EmilyBrewer](https://avatars.discourse-cdn.com/v4/letter/e/9fc348/32.png) [@EmilyBrewer](https://discourse.julialang.org/u/EmilyBrewer)\
**Post date:** [July 25, 2023, 6:36pm UTC](https://discourse.julialang.org/t/help-needed-with-amplnlwriter/102088/1 "2023-07-25T18:36:51Z")

</div>

Hello,

I am trying to use “Bonmin” or “Couenne” from AmplNLWriter in Julia. My code is attached below.

```julia
using JuMP, AmplNLWriter, Couenne_jll

#model = Model(() -> AmplNLWriter.Optimizer("bonmin")) 

model = Model(() -> AmplNLWriter.Optimizer(Couenne_jll.amplexe))

v = [10, 20, 12, 23, 42]

w = [12, 45, 12, 22, 21]

@variable(model, x[1:5], Bin)

@objective(model, Max, v' * x)

@constraint(model, sum(w[i]*x[i]^2 for i in 1:5) <= 45)

optimize!(model)

println(termination_status(model))

println(objective_value(model))

println(value.(x))

```

I got the errors when running  
“ERROR: ERROR: The provided `optimizer_constructor` is invalid. It must be callable with zero arguments. For example, “Ipopt.Optimizer” or “() → ECOS.Optimizer()”. It should not be an instantiated optimizer like “Ipopt.Optimizer()” or “ECOS.Optimizer()”. (Note the difference in parentheses!)”

I am new to Julia so I was wondering maybe there is something simple that I missed in my codes. Thank you for taking the time to read my post and for any help you can provide.

Thanks,  
Emily

---

<div class="post-metadata">

**Author:** ![algunion](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/algunion/32/51630_2.png) [@algunion](https://discourse.julialang.org/u/algunion)\
**Post date:** [July 25, 2023, 7:40pm UTC](https://discourse.julialang.org/t/help-needed-with-amplnlwriter/102088/2 "2023-07-25T19:40:47Z")

</div>

The code you provided works perfectly on my end - do you have problems with specific versions of Julia/Packages?

Check my output below.

> **Ouput**
>
> ```julia
> A JuMP Model
> Feasibility problem with:
> Variables: 0
> Model mode: AUTOMATIC
> CachingOptimizer state: EMPTY_OPTIMIZER
> Solver name: AmplNLWriter
> 
> 5-element Vector{Int64}:
> 10
> 20
> 12
> 23
> 42
> 
> 5-element Vector{Int64}:
> 12
> 45
> 12
> 22
> 21
> 
> 5-element Vector{VariableRef}:
> x[1]
> x[2]
> x[3]
> x[4]
> x[5]
> 
> 10 x[1] + 20 x[2] + 12 x[3] + 23 x[4] + 42 x[5]
> 
> 12 x[1]² + 45 x[2]² + 12 x[3]² + 22 x[4]² + 21 x[5]² ≤ 45
> 
> Couenne 0.5.8 -- an Open-Source solver for Mixed Integer Nonlinear Optimization
> Mailing list: couenne@list.coin-or.org
> Instructions: http://www.coin-or.org/Couenne
> couenne: 
> ANALYSIS TEST: Couenne: new cutoff value 0.0000000000e+00 (0.075899 seconds)
> NLP0012I 
> Num Status Obj It time Location
> NLP0014I 1 OPT -77.755059 14 0.06618
> Couenne: new cutoff value -6.4000000000e+01 (0.18193 seconds)
> NLP0014I 2 OPT -64 0 0
> Loaded instance "/tmp/jl_blQ19y/model.nl"
> Constraints: 1
> Variables: 5 (5 integer)
> Auxiliaries: 7 (7 integer)
> 
> Coin0506I Presolve 17 (0) rows, 11 (-1) columns and 41 (-1) elements
> Clp0006I 0 Obj -107 Primal inf 2.547618 (1)
> Clp0006I 12 Obj -67
> Clp0000I Optimal - objective value -67
> Clp0032I Optimal objective -67 - 12 iterations time 0.002, Presolve 0.00
> Clp0000I Optimal - objective value -67
> NLP Heuristic: time limit reached.
> Clp0000I Optimal - objective value -67
> Optimality Based BT: Couenne: new cutoff value -6.5000000000e+01 (0.252534 seconds)
> 1 improved bounds
> Probing: 0 improved bounds
> NLP Heuristic: time limit reached.
> Cbc0013I At root node, 0 cuts changed objective from -67 to -65 in 1 passes
> Cbc0014I Cut generator 0 (Couenne convexifier cuts) - 0 row cuts average 0.0 elements, 5 column cuts (5 active)
> Cbc0004I Integer solution of -65 found after 0 iterations and 0 nodes (0.03 seconds)
> Cbc0001I Search completed - best objective -65, took 0 iterations and 0 nodes (0.03 seconds)
> Cbc0035I Maximum depth 0, 0 variables fixed on reduced cost
> 
> "Finished"
> 
> Linearization cuts added at root node: 17
> Linearization cuts added in total: 17 (separation time: 0.001672s)
> Total solve time: 0.039566s (0.039541s in branch-and-bound)
> Lower bound: -65
> Upper bound: -65 (gap: 0.00%)
> Branch-and-bound nodes: 0
> Performance of FBBT: 0.000828s, 4 runs. fix: 0 shrnk: 0 ubd: 0 2ubd: 0 infeas: 0
> Performance of OBBT: 0.004393s, 1 runs. fix: 9 shrnk: 0 ubd: 0 2ubd: 0 infeas: 0
> 
> LOCALLY_SOLVED
> 
> 65.0
> 
> [0.0, 0.0, 0.0, 1.0, 1.0]
> 
> ```

---

<div class="post-metadata">

**Author:** ![EmilyBrewer](https://avatars.discourse-cdn.com/v4/letter/e/9fc348/32.png) [@EmilyBrewer](https://discourse.julialang.org/u/EmilyBrewer)\
**Post date:** [July 26, 2023, 2:32pm UTC](https://discourse.julialang.org/t/help-needed-with-amplnlwriter/102088/3 "2023-07-26T14:32:36Z")

</div>

Hello,

Thanks for the reply!

I got the problems solved. It worked on VS codes when running without debugging.

-Emily
