jump-dev / Ipopt.jl

A Julia interface to the Ipopt nonlinear solver
https://github.com/coin-or/ipopt
Other
153 stars 58 forks source link

Unconstrained Problem Crashes Julia #80

Closed mes9 closed 4 years ago

mes9 commented 7 years ago

I'm trying to reproduce a simple example of an unconstrained problem but it crashes Julia. The example comes from a previously solved issue: https://github.com/JuliaOpt/Ipopt.jl/issues/28

using Ipopt

const A = randn(10)
prob = createProblem(1, [-10.], [10.], 0, Float64[], Float64[], 0, 1,
           (x) -> sum(exp(x[1] .* A)),
           (x, g) -> println("shouldn't be called"),
           (x, grad_f) -> grad_f[1] = sum(exp(x[1] .* A) .* A),
           (x, mode, rows, cols, values) -> println("don't call me"),
           (x, mode, rows, cols, obj_factor, lambda, values) -> begin
               rows[1] = 1;
               cols[1] = 1;
               values[1]=sum(exp(x[1] .* A) .* A .* A)
           end)

status = solveProblem(prob)
GravityAssisted commented 7 years ago

I duplicated the above problem in Julia 0.6-rc2

tkelman commented 7 years ago

what's the error? what platform?

charlesll commented 7 years ago

Getting curious about the error, I tried the above code on JuliaBox, kernels 0.5.2 and 0.6 as well as on my local OSX platform kernel 0.5.2. Kernels actually die when trying to solve the problem, no error message...

tkelman commented 7 years ago

and outside of ijulia?

charlesll commented 7 years ago

Got a segmentation fault 11.

Here is the full error message: `** 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 http://projects.coin-or.org/Ipopt


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

don't call me

signal (11): Segmentation fault: 11 while loading /Users/charles/Desktop/test.jl, in expression starting on line 14

5 at /Users/charles/Desktop/test.jl:12

unknown function (ip: 0x10e0149d7) jl_call_method_internal at /Users/osx/buildbot/slave/package_osx10_9-x64/build/src/./julia_internal.h:211 [inlined] jl_apply_generic at /Users/osx/buildbot/slave/package_osx10_9-x64/build/src/gf.c:1950 eval_h_wrapper at /Users/charles/.julia/v0.5/Ipopt/src/Ipopt.jl:149 unknown function (ip: 0x10e012f42) _ZN5Ipopt16StdInterfaceTNLP6eval_hEiPKdbdiS2_biPiS3_Pd at /Users/charles/.julia/v0.5/Homebrew/deps/usr/lib/libipopt.dylib (unknown line) _ZN5Ipopt11TNLPAdapter9GetSpacesERNS_8SmartPtrIKNS_11VectorSpaceEEES5_S5_S5_RNS1_IKNS_11MatrixSpaceEEES5_S9_S5_S9_S5_S9_S9_S9_RNS1_IKNS_14SymMatrixSpaceEEE at /Users/charles/.julia/v0.5/Homebrew/deps/usr/lib/libipopt.dylib (unknown line) _ZN5Ipopt12OrigIpoptNLP20InitializeStructuresERNS_8SmartPtrINS_6VectorEEEbS4_bS4_bS4_bS4_bS4S4 at /Users/charles/.julia/v0.5/Homebrew/deps/usr/lib/libipopt.dylib (unknown line) _ZN5Ipopt9IpoptData24InitializeDataStructuresERNS_8IpoptNLPEbbbbb at /Users/charles/.julia/v0.5/Homebrew/deps/usr/lib/libipopt.dylib (unknown line) _ZN5Ipopt25DefaultIterateInitializer18SetInitialIteratesEv at /Users/charles/.julia/v0.5/Homebrew/deps/usr/lib/libipopt.dylib (unknown line) _ZN5Ipopt14IpoptAlgorithm18InitializeIteratesEv at /Users/charles/.julia/v0.5/Homebrew/deps/usr/lib/libipopt.dylib (unknown line) _ZN5Ipopt14IpoptAlgorithm8OptimizeEb at /Users/charles/.julia/v0.5/Homebrew/deps/usr/lib/libipopt.dylib (unknown line) _ZN5Ipopt16IpoptApplication13call_optimizeEv at /Users/charles/.julia/v0.5/Homebrew/deps/usr/lib/libipopt.dylib (unknown line) _ZN5Ipopt16IpoptApplication11OptimizeNLPERKNS_8SmartPtrINS_3NLPEEERNS1_INS_16AlgorithmBuilderEEE at /Users/charles/.julia/v0.5/Homebrew/deps/usr/lib/libipopt.dylib (unknown line) _ZN5Ipopt16IpoptApplication11OptimizeNLPERKNS_8SmartPtrINS_3NLPEEE at /Users/charles/.julia/v0.5/Homebrew/deps/usr/lib/libipopt.dylib (unknown line) _ZN5Ipopt16IpoptApplication12OptimizeTNLPERKNS_8SmartPtrINS_4TNLPEEE at /Users/charles/.julia/v0.5/Homebrew/deps/usr/lib/libipopt.dylib (unknown line) IpoptSolve at /Users/charles/.julia/v0.5/Homebrew/deps/usr/lib/libipopt.dylib (unknown line) solveProblem at /Users/charles/.julia/v0.5/Ipopt/src/Ipopt.jl:304 unknown function (ip: 0x10e0138c2) jl_call_method_internal at /Users/osx/buildbot/slave/package_osx10_9-x64/build/src/./julia_internal.h:211 [inlined] jl_apply_generic at /Users/osx/buildbot/slave/package_osx10_9-x64/build/src/gf.c:1950 do_call at /Users/osx/buildbot/slave/package_osx10_9-x64/build/src/interpreter.c:66 eval at /Users/osx/buildbot/slave/package_osx10_9-x64/build/src/interpreter.c:190 eval_body at /Users/osx/buildbot/slave/package_osx10_9-x64/build/src/interpreter.c:469 jl_interpret_call at /Users/osx/buildbot/slave/package_osx10_9-x64/build/src/interpreter.c:573 jl_toplevel_eval_flex at /Users/osx/buildbot/slave/package_osx10_9-x64/build/src/toplevel.c:572 jl_parse_eval_all at /Users/osx/buildbot/slave/package_osx10_9-x64/build/src/ast.c:717 jl_load at /Users/osx/buildbot/slave/package_osx10_9-x64/build/src/toplevel.c:596 [inlined] jlload at /Users/osx/buildbot/slave/package_osx10_9-x64/build/src/toplevel.c:605 include_from_node1 at ./loading.jl:488 jlcall_include_from_node1_20232 at /Applications/Julia-0.5.app/Contents/Resources/julia/lib/julia/sys.dylib (unknown line) jl_call_method_internal at /Users/osx/buildbot/slave/package_osx10_9-x64/build/src/./julia_internal.h:211 [inlined] jl_apply_generic at /Users/osx/buildbot/slave/package_osx10_9-x64/build/src/gf.c:1950 process_options at ./client.jl:265 _start at ./client.jl:321 jlcall__start_21574 at /Applications/Julia-0.5.app/Contents/Resources/julia/lib/julia/sys.dylib (unknown line) jl_call_method_internal at /Users/osx/buildbot/slave/package_osx10_9-x64/build/src/./julia_internal.h:211 [inlined] jl_apply_generic at /Users/osx/buildbot/slave/package_osx10_9-x64/build/src/gf.c:1950 true_main at /Applications/Julia-0.5.app/Contents/Resources/julia/bin/julia (unknown line) main at /Applications/Julia-0.5.app/Contents/Resources/julia/bin/julia (unknown line) `

nicrummel commented 5 years ago

I am dealing with a similar issue on another NL unconstrained problem. Has there any work being done to address this? Has anyone found a work around?

odow commented 4 years ago

This is not a bug in Ipopt.jl.

The hessian function needs to check the mode argument.

    (x, mode, rows, cols, obj_factor, lambda, values) -> begin
        if mode == :Structure
            rows[1] = 1;
            cols[1] = 1;
        else
            values[1] = sum(exp.(x[1] .* A) .* A .* A)
        end
    end,