Error with couenne

Hi, please help me. I can’t see the problem. I am using this code:

using JuMP, AmplNLWriter, Couenne_jll
function run()
model = Model(() → AmplNLWriter.Optimizer(Couenne_jll.amplexe))
@variable(model, x)
@variable(model, y)
@NLobjective(model, Max, x + y)
@constraint(model, x + y <= 10)
@constraint(model, x <= 2)
@constraint(model, y <= 3)
optimize!(model)
println("Optimal objective value: ", objective_value(model))
println("Optimal value of x: ", value(x))
println("Optimal value of y: ", value(y))
end
run()

I have this error:
ERROR: LoadError: Result index of attribute MathOptInterface.ObjectiveValue(1) out of bounds. There are currently 0 solution(s) in the model.

Hi @medardo,

The error is because Couenne didn’t find a solution.

To help debug, can you please post the full output of running this code:

import Pkg
Pkg.status()
versioninfo()
using JuMP, AmplNLWriter, Couenne_jll
function run()
    model = Model(() -> AmplNLWriter.Optimizer(Couenne_jll.amplexe))
    @variable(model, x)
    @variable(model, y)
    @NLobjective(model, Max, x + y)
    @constraint(model, x + y <= 10)
    @constraint(model, x <= 2)
    @constraint(model, y <= 3)
    optimize!(model)
    println("Optimal objective value: ", objective_value(model))
    println("Optimal value of x: ", value(x))
    println("Optimal value of y: ", value(y))
end
run()

Here’s what it looks like for me:

julia> import Pkg

julia> Pkg.status()
Status `/private/tmp/ampl/Project.toml`
  [7c4d4715] AmplNLWriter v1.2.0
  [4076af6c] JuMP v1.19.0
  [f09e9e23] Couenne_jll v0.500.801+0

julia> versioninfo()
Julia Version 1.10.0
Commit 3120989f39b (2023-12-25 18:01 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: macOS (x86_64-apple-darwin22.4.0)
  CPU: 8 × Intel(R) Core(TM) i5-8259U CPU @ 2.30GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-15.0.7 (ORCJIT, skylake)
  Threads: 1 on 8 virtual cores

julia> using JuMP, AmplNLWriter, Couenne_jll

julia> function run()
           model = Model(() -> AmplNLWriter.Optimizer(Couenne_jll.amplexe))
           @variable(model, x)
           @variable(model, y)
           @NLobjective(model, Max, x + y)
           @constraint(model, x + y <= 10)
           @constraint(model, x <= 2)
           @constraint(model, y <= 3)
           optimize!(model)
           println("Optimal objective value: ", objective_value(model))
           println("Optimal value of x: ", value(x))
           println("Optimal value of y: ", value(y))
       end
run (generic function with 1 method)

julia> run()
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 -3.0000000000e+00 (0.03067 seconds)
NLP0012I 
              Num      Status      Obj             It       time                 Location
NLP0014I             1         OPT -5        6 0.003479
Couenne: new cutoff value -5.0000000000e+00 (0.034612 seconds)
Loaded instance "/var/folders/bg/dzq_hhvx1dxgy6gb5510pxj80000gn/T/jl_Ik78sB/model.nl"
Constraints:            3
Variables:              2 (0 integer)
Auxiliaries:            2 (0 integer)

Coin0506I Presolve 1 (-1) rows, 1 (-3) columns and 1 (-4) elements
Clp0000I Optimal - objective value -5
Clp0032I Optimal objective -5 - 0 iterations time 0.002, Presolve 0.00
Cbc3007W No integer variables - nothing to do
Clp0000I Optimal - objective value -5

 	"Finished"

Linearization cuts added at root node:          2
Linearization cuts added in total:              2  (separation time: 5.5e-05s)
Total solve time:                        0.000486s (0.000487s in branch-and-bound)
Lower bound:                                   -5
Upper bound:                                   -5  (gap: 0.00%)
Branch-and-bound nodes:                         0
Performance of                           FBBT:	      5e-05s,        3 runs. fix:          0 shrnk:    7.80203 ubd:          1 2ubd:          1 infeas:          0
Optimal objective value: 5.0
Optimal value of x: 2.0
Optimal value of y: 3.0
1 Like

Status C:\Users\LENOVO\.julia\environments\v1.10\Project.toml
⌃ [7c4d4715] AmplNLWriter v1.0.1
⌃ [a076750e] CPLEX v1.0.2
[9961bab8] Cbc v1.2.0
[e2554f3b] Clp v1.0.3
[a93c6f00] DataFrames v1.6.1
[60bf3e95] GLPK v1.1.3
[2e9cd046] Gurobi v1.2.1
[87dc4568] HiGHS v1.8.1
[b6b21f68] Ipopt v1.6.1
[4076af6c] JuMP v1.19.0
[2ddba703] Juniper v0.9.2
[f6097e2c] MultiJuMP v0.6.1
[0327d340] MultiObjectiveAlgorithms v1.3.2
[7c640890] MultiobjectiveProximalBundle v0.0.1
[ccf2f8ad] PlotThemes v3.1.0
[91a5bcdd] Plots v1.40.1
[6fc51010] Surrogates v6.9.0
[fdbf4ff8] XLSX v0.10.1
[29cba6d7] Bonmin_jll v100.800.901+0
[f09e9e23] Couenne_jll v0.500.801+0
[de0858da] Printf
[9a3f8284] Random
[10745b16] Statistics v1.10.0
Info Packages marked with ⌃ have new versions available and may be upgradable.
ERROR: LoadError: UndefVarError: versioninfo not defined
Stacktrace:
[1] top-level scope
@ C:\Users\LENOVO\Documents\Cursos\Optimization Julia Udemy\MINLP\prueba.jl:3
in expression starting at C:\Users\LENOVO\Documents\Cursos\Optimization Julia Udemy\MINLP\prueba.jl:3

Try

import Pkg
Pkg.update("AmplNLWriter")

then restart Julia.

You have an older version of AmplNLWriter (v1.0.1). I fixed a bug in v1.0.2; Work-around bug in recent Ipopt_jll releases by odow · Pull Request #162 · jump-dev/AmplNLWriter.jl · GitHub

Also: why did versioninfo() fail? Did you run it from the REPL? If you ran from a script, you need using InteractiveUtils; versioninfo(). But it’s not that important anymore. I can see you’re using Windows.

1 Like

Thank you very much! Now it’s working.

1 Like

Hi! I have similar problem but the solution didn’t work to me.

using InteractiveUtils
import Pkg
Pkg.status()
versioninfo()
using JuMP, AmplNLWriter, Couenne_jll

function run()
  model = Model(() -> AmplNLWriter.Optimizer(Couenne_jll.amplexe))
  @variable(model, x)
  @variable(model, y)
  @NLobjective(model, Max, x + y)
  @constraint(model, x + y <= 10)
  @constraint(model, x <= 2)
  @constraint(model, y <= 3)
  optimize!(model)
  println("Optimal objective value: ", objective_value(model))
  println("Optimal value of x: ", value(x))
  println("Optimal value of y: ", value(y))
  end
  run()

and the error found is:

Status `~/.julia/environments/v1.10/Project.toml`
  [7c4d4715] AmplNLWriter v1.2.0
  [60bf3e95] GLPK v1.1.3
  [2e9cd046] Gurobi v1.2.1
  [b6b21f68] Ipopt v1.6.1
  [4076af6c] JuMP v1.19.0
  [82193955] SCIP v0.11.14
  [f09e9e23] Couenne_jll v0.500.801+0
  [de0858da] Printf
Julia Version 1.10.0
Commit 3120989f39b (2023-12-25 18:01 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: macOS (arm64-apple-darwin22.4.0)
  CPU: 11 × Apple M3 Pro
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-15.0.7 (ORCJIT, apple-m1)
  Threads: 1 on 5 virtual cores
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 -3.0000000000e+00 (0.012156 seconds)
NLP0012I 
              Num      Status      Obj             It       time                 Location
NLP0014I             1         OPT -5        6 0.001367
Couenne: new cutoff value -5.0000000000e+00 (0.013751 seconds)
Loaded instance "/var/folders/wc/rq60t16j47x5hcb0slbkr5lw0000gn/T/jl_CZ57XL/model.nl"
Constraints:            3
Variables:              2 (0 integer)
Auxiliaries:            2 (0 integer)

Coin0506I Presolve 1 (-1) rows, 1 (-3) columns and 1 (-4) elements
Clp0000I Optimal - objective value -5
couenne(82030,0x1de381000) malloc: *** error for object 0xe00000000000000: pointer being freed was not allocated
couenne(82030,0x1de381000) malloc: *** set a breakpoint in malloc_error_break to debug
ERROR: LoadError: Result index of attribute MathOptInterface.ObjectiveValue(1) out of bounds. There are currently 0 solution(s) in the model.
Stacktrace:
  [1] check_result_index_bounds
    @ ~/.julia/packages/MathOptInterface/DDWnF/src/attributes.jl:207 [inlined]
  [2] get
    @ ~/.julia/packages/MathOptInterface/DDWnF/src/FileFormats/NL/sol.jl:92 [inlined]
  [3] get
    @ ~/.julia/packages/AmplNLWriter/KiUQ5/src/AmplNLWriter.jl:299 [inlined]
  [4] _get_model_attribute(model::MathOptInterface.Utilities.CachingOptimizer{AmplNLWriter.Optimizer, MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.Model{Float64}}}, attr::MathOptInterface.ObjectiveValue)
    @ MathOptInterface.Utilities ~/.julia/packages/MathOptInterface/DDWnF/src/Utilities/cachingoptimizer.jl:828
  [5] get
    @ ~/.julia/packages/MathOptInterface/DDWnF/src/Utilities/cachingoptimizer.jl:895 [inlined]
  [6] get(b::MathOptInterface.Bridges.LazyBridgeOptimizer{MathOptInterface.Utilities.CachingOptimizer{AmplNLWriter.Optimizer, MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.Model{Float64}}}}, attr::MathOptInterface.ObjectiveValue)
    @ MathOptInterface.Bridges ~/.julia/packages/MathOptInterface/DDWnF/src/Bridges/bridge_optimizer.jl:1111
  [7] _get_model_attribute(model::MathOptInterface.Utilities.CachingOptimizer{MathOptInterface.Bridges.LazyBridgeOptimizer{MathOptInterface.Utilities.CachingOptimizer{AmplNLWriter.Optimizer, MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.Model{Float64}}}}, MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.Model{Float64}}}, attr::MathOptInterface.ObjectiveValue)
    @ MathOptInterface.Utilities ~/.julia/packages/MathOptInterface/DDWnF/src/Utilities/cachingoptimizer.jl:828
  [8] get
    @ MathOptInterface.Utilities ~/.julia/packages/MathOptInterface/DDWnF/src/Utilities/cachingoptimizer.jl:895 [inlined]
  [9] _moi_get_result(model::MathOptInterface.Utilities.CachingOptimizer{MathOptInterface.Bridges.LazyBridgeOptimizer{MathOptInterface.Utilities.CachingOptimizer{AmplNLWriter.Optimizer, MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.Model{Float64}}}}, MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.Model{Float64}}}, args::MathOptInterface.ObjectiveValue)
    @ JuMP ~/.julia/packages/JuMP/HjlGr/src/optimizer_interface.jl:663
 [10] get(model::Model, attr::MathOptInterface.ObjectiveValue)
    @ JuMP ~/.julia/packages/JuMP/HjlGr/src/optimizer_interface.jl:683
 [11] objective_value(model::Model; result::Int64)
    @ JuMP ~/.julia/packages/JuMP/HjlGr/src/objective.jl:54
 [12] objective_value
    @ ~/.julia/packages/JuMP/HjlGr/src/objective.jl:50 [inlined]
 [13] run()
    @ Main ~/Desktop/Mycode/MINLP/minlp.jl:16
 [14] top-level scope
    @ ~/Desktop/Mycode/MINLP/minlp.jl:20

Maybe the error is because of MacOS?

Thanks in advance for your help!

Yes it may not work because of M3. Use the Rosetta build of Julia.