# I use Solver of AmplNLWriter with some errors

**URL:** <https://discourse.julialang.org/t/i-use-solver-of-amplnlwriter-with-some-errors/119585>\
**Category:** Optimization (Mathematical)\
**Created:** [September 19, 2024, 6:12am UTC](https://discourse.julialang.org/t/i-use-solver-of-amplnlwriter-with-some-errors/119585 "2024-09-19T06:12:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![wjulia](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wjulia/32/45921_2.png) [@wjulia](https://discourse.julialang.org/u/wjulia)\
**Post date:** [September 19, 2024, 6:12am UTC](https://discourse.julialang.org/t/i-use-solver-of-amplnlwriter-with-some-errors/119585/1 "2024-09-19T06:12:53Z")

</div>

The following is my code :

```julia
using JuMP, AmplNLWriter
 m = Model(() -> AmplNLWriter.Optimizer("Your_Path\\lindoapi\\bin\\win64\\runlindo.exe"))

@variable(m, -2 <= x1 <= 2,Int)
@variable(m, -2 <= x2 <= 2)

@constraint(m, -2*x1 - x2 <= 2)
@constraint(m, -x1 - 2*x2 <= 2)
@constraint(m, x1^2 + x2^2 <= 1)

@objective(m, Min, (x1+x2)/(2+x1^2+x2^2))
write_to_file(m,"type4CONF.nl")

println(m)
 
optimize!(m)

value(x1)
value(x2)

objective_value(m)

solution_summary(m)

```

Firstly, lindoapi can solve this model, but it can not output the solutions. Some errors:

```julia
julia> value(x1)
ERROR: Result index of attribute MathOptInterface.VariablePrimal(1) out of bounds. There are currently 0 solution(s) in the model.

```

and

```julia
julia> solution_summary(m)
* Solver : AmplNLWriter

* Status
  Result count : 0
  Termination status : OTHER_ERROR
  Message from the solver:
  "Error calling the solver. Failed with: SystemError("opening file \"D:\\\\Temp\\\\jl_ugJoB7\\\\model.sol\"", 2, nothing)"

* Candidate solution (result #1)
  Primal status : NO_SOLUTION
  Dual status : NO_SOLUTION

* Work counters
  Solve time (sec) : 4.54000e-01

```

But, if i revised it with

```julia
m = Model(() -> AmplNLWriter.Optimizer("Your_Path\\lindoapi\\bin\\win64\\runlindo.exe",["-sol"]))

```

Every things is OK.

So, what is wrong with this errors? Thanks very much.

Sincerely,  
J. Wang.

---

<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:** [September 19, 2024, 7:34am UTC](https://discourse.julialang.org/t/i-use-solver-of-amplnlwriter-with-some-errors/119585/2 "2024-09-19T07:34:35Z")

</div>

We pass `-AMPL` to executables, but it seems like LINDO requires the non-standard additional argument of `-sol`.

Your revision seems correct.

---

<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:** [September 19, 2024, 8:38pm UTC](https://discourse.julialang.org/t/i-use-solver-of-amplnlwriter-with-some-errors/119585/3 "2024-09-19T20:38:55Z")

</div>

Just following up on this, I took a look: [Add -sol as a command line argument to solvers by odow · Pull Request #188 · jump-dev/AmplNLWriter.jl · GitHub](https://github.com/jump-dev/AmplNLWriter.jl/pull/188)

Lindo’s requirement to add `-sol` is non-standard, so you’ll need to do this yourself like you have done. We won’t be adding it by default to AmplNLWriter.

---

<div class="post-metadata">

**Author:** ![wjulia](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wjulia/32/45921_2.png) [@wjulia](https://discourse.julialang.org/u/wjulia)\
**Post date:** [October 15, 2024, 9:52am UTC](https://discourse.julialang.org/t/i-use-solver-of-amplnlwriter-with-some-errors/119585/4 "2024-10-15T09:52:10Z")

</div>

OK, i known.

THanks
