# AmplNLWriter no longer works with JuMP

**URL:** <https://discourse.julialang.org/t/amplnlwriter-no-longer-works-with-jump/70740>\
**Category:** Optimization (Mathematical)\
**Tags:** jump, optimization\
**Created:** [November 1, 2021, 2:37pm UTC](https://discourse.julialang.org/t/amplnlwriter-no-longer-works-with-jump/70740 "2021-11-01T14:37:12Z")\
**Posts on this page:** 1\
**Showing post:** 2

<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:** [November 1, 2021, 7:11pm UTC](https://discourse.julialang.org/t/amplnlwriter-no-longer-works-with-jump/70740/2 "2021-11-01T19:11:30Z")

</div>

I can’t reproduce this on a clean install:

```nohighlight
(amplnl) pkg> st
      Status `/private/tmp/amplnl/Project.toml`
  [7c4d4715] AmplNLWriter v0.7.2
  [4076af6c] JuMP v0.21.10
  [9cc047cb] Ipopt_jll v3.13.4+2

julia> using JuMP, AmplNLWriter, Ipopt_jll
[Info: Precompiling AmplNLWriter [7c4d4715-977e-5154-bfe0-e096adeac482]

julia> function nlp_model(p, c1, c2,b, k, n)
           #model = Model(Ipopt.Optimizer)
           model = Model(() -> AmplNLWriter.Optimizer(Ipopt_jll.amplexe))
           @variable(model, 0 <= x[i = 1:n] <= 1)
           @variable(model, 0<=var1<=1)
           @variable(model, 0<=var2<=1)
           @variable(model, 0<=var3<=1)

           @objective(model,Max,var1-var2+var3)
           @NLconstraint(model,con3,sum(x[i]*p[i] for i in 1:n)-sum(b[j]/(1+var1)^j for j in 1:k) == 0)
           @NLconstraint(model,con5,sum(x[i]*p[i] for i in 1:n)-sum(c1[j,i] *x[i] / (1+var2)^j for i in 1:n, j in 1:k) == 0)
           @NLconstraint(model,con6,sum(x[i]*p[i] for i in 1:n)-sum(c2[j,i] *x[i] / (1+var3)^j for i in 1:n, j in 1:k) == 0)

           @constraint(model, con1, c1*x .>= b)
           JuMP.optimize!(model)
           println("")
           println("variable l = $(value(var1)) , variable 2 = $(value(var2)) , variable 3 = $(value(var3))")

       end
nlp_model (generic function with 1 method)

julia> function data()
           p = rand(400:700,5,1); c1= (rand(100:200,4,5))'; c2 = 0.9 .* c1
           b =rand(150:250,5,1); n= size(c1,2); k = size(c1,1)
           return p, c1, c2, b, n, k
       end
data (generic function with 1 method)

julia> p, c1, c2, b, n, k = data()
([496; 611; … ; 556; 538], [148 132 147 168; 143 103 151 131; … ; 187 107 165 168; 136 116 113 115], [133.20000000000002 118.8 132.3 151.20000000000002; 128.70000000000002 92.7 135.9 117.9; … ; 168.3 96.3 148.5 151.20000000000002; 122.4 104.4 101.7 103.5], [214; 236; … ; 245; 230], 4, 5)

julia> nlp_model(p, c1, c2,b, k, n)
Ipopt 3.13.4: 

******************************************************************************
This program contains Ipopt, a library for large-scale nonlinear optimization.
 Ipopt is released as open source code under the Eclipse Public License (EPL).
         For more information visit https://github.com/coin-or/Ipopt
******************************************************************************

This is Ipopt version 3.13.4, running with linear solver mumps.
NOTE: Other linear solvers might be more efficient (see Ipopt documentation).

Number of nonzeros in equality constraint Jacobian...: 15
Number of nonzeros in inequality constraint Jacobian.: 20
Number of nonzeros in Lagrangian Hessian.............: 11

Total number of variables............................: 7
                     variables with only lower bounds: 0
                variables with lower and upper bounds: 7
                     variables with only upper bounds: 0
Total number of equality constraints.................: 3
Total number of inequality constraints...............: 5
        inequality constraints with only lower bounds: 5
   inequality constraints with lower and upper bounds: 0
        inequality constraints with only upper bounds: 0

iter objective inf_pr inf_du lg(mu) ||d|| lg(rg) alpha_du alpha_pr ls
   0 -9.9999900e-03 1.03e+03 1.02e+00 -1.0 0.00e+00 - 0.00e+00 0.00e+00 0
   1 1.9579652e-02 1.01e+03 3.78e+00 -1.0 3.68e+01 - 7.24e-03 2.26e-02h 1
   2 2.4164720e-02 9.78e+02 2.83e+00 -1.0 2.61e+01 - 1.48e-02 3.26e-02h 1
   3 2.4885037e-02 9.37e+02 2.06e+00 -1.0 6.60e+01 - 3.19e-02 4.28e-02h 1
   4 2.0337198e-02 6.46e+02 2.13e+01 -1.0 6.64e+01 - 6.08e-02 3.10e-01f 1
   5 3.0496669e-02 4.64e+02 1.68e+01 -1.0 4.90e+01 - 2.80e-01 2.85e-01h 1
   6 2.1298312e-02 6.86e+01 5.29e+01 -1.0 3.09e+01 - 3.76e-01 1.00e+00f 1
   7 1.4099605e-02 2.21e+00 6.81e+00 -1.0 2.21e+00 - 9.51e-01 1.00e+00h 1
   8 1.0793746e-02 6.61e-01 2.75e+00 -1.0 1.87e+01 - 7.32e-01 1.00e+00f 1
   9 2.3359836e-02 1.03e+00 1.14e-01 -1.0 9.52e+00 - 1.00e+00 1.00e+00h 1
iter objective inf_pr inf_du lg(mu) ||d|| lg(rg) alpha_du alpha_pr ls
  10 2.1091011e-02 3.66e-02 3.98e-01 -2.5 9.58e-01 - 9.11e-01 1.00e+00h 1
  11 2.3162260e-03 8.23e-01 1.80e-01 -2.5 1.23e+01 - 9.61e-01 7.05e-01H 1
  12 -2.6152134e-03 1.72e-01 2.93e-03 -2.5 2.94e+00 - 1.00e+00 1.00e+00h 1
  13 -2.2378732e-03 8.36e-04 1.71e-05 -2.5 8.70e-01 - 1.00e+00 1.00e+00h 1
  14 -9.3178524e-03 3.22e-01 1.34e-03 -3.8 2.97e+00 - 8.88e-01 9.31e-01h 1
  15 -1.1340947e-02 3.13e-02 7.85e-05 -3.8 2.76e+00 - 1.00e+00 1.00e+00h 1
  16 -1.1274751e-02 2.70e-05 4.40e-08 -3.8 1.32e-01 - 1.00e+00 1.00e+00h 1
  17 -1.1872683e-02 2.31e-03 1.21e-05 -5.7 3.33e-01 - 9.87e-01 9.84e-01h 1
  18 -1.1880387e-02 4.04e-07 1.02e-09 -5.7 3.21e-03 - 1.00e+00 1.00e+00h 1
  19 -1.1887776e-02 3.52e-07 7.52e-10 -8.6 3.77e-03 - 1.00e+00 1.00e+00h 1
iter objective inf_pr inf_du lg(mu) ||d|| lg(rg) alpha_du alpha_pr ls
  20 -1.1887775e-02 3.10e-13 2.51e-14 -8.6 2.26e-06 - 1.00e+00 1.00e+00h 1

Number of Iterations....: 20

                                   (scaled) (unscaled)
Objective...............: -1.1887775027987380e-02 -1.1887775027987380e-02
Dual infeasibility......: 2.5059035596809423e-14 1.8425697038399239e-14
Constraint violation....: 1.5906112343410032e-13 3.1048731294336385e-13
Complementarity.........: 2.5059057582680507e-09 2.5059057582680507e-09
Overall NLP error.......: 2.5059057582680507e-09 2.5059057582680507e-09

Number of objective function evaluations = 22
Number of objective gradient evaluations = 21
Number of equality constraint evaluations = 22
Number of inequality constraint evaluations = 22
Number of equality constraint Jacobian evaluations = 21
Number of inequality constraint Jacobian evaluations = 21
Number of Lagrangian Hessian evaluations = 20
Total CPU secs in IPOPT (w/o function evaluations) = 0.054
Total CPU secs in NLP function evaluations = 0.002

EXIT: Optimal Solution Found.

variable l = 0.05424865812663058 , variable 2 = 0.13581364085638178 , variable 3 = 0.09345275775773859

```

What is

```julia
] st -m

```

And what’s a moderately sized problem? Ipopt.jl shouldn’t take hours if it can be solved with AmplNLWriter.

---

_[View the full topic](https://discourse.julialang.org/t/amplnlwriter-no-longer-works-with-jump/70740)._
