Giter VIP home page Giter VIP logo

Comments (9)

baggepinnen avatar baggepinnen commented on August 17, 2024 1

similar on a sparse matrix returns a new sparse matrix with the same sparsity structure. The problem appears to be if the structure has structurally non-zero elements that are numerically zero, hence the y.nzval .= 1

from ipopt.jl.

odow avatar odow commented on August 17, 2024
import Ipopt
const MOI = Ipopt.MOI
for ls in ["ma97", "pardiso", "mumps"]
    model = Ipopt.Optimizer()
    MOI.set(model, MOI.RawOptimizerAttribute("linear_solver"), ls)
    x = MOI.add_variable(model)
    MOI.set(model, MOI.ObjectiveSense(), MOI.MIN_SENSE)
    f = 1.0 * x * x
    MOI.set(model, MOI.ObjectiveFunction{typeof(f)}(), f)
    MOI.optimize!(model)
end
GC.gc()
julia> import Ipopt

julia> const MOI = Ipopt.MOI
MathOptInterface

julia> for ls in ["ma97", "pardiso", "mumps"]
           model = Ipopt.Optimizer()
           MOI.set(model, MOI.RawOptimizerAttribute("linear_solver"), ls)
           x = MOI.add_variable(model)
           MOI.set(model, MOI.ObjectiveSense(), MOI.MIN_SENSE)
           f = 1.0 * x * x
           MOI.set(model, MOI.ObjectiveFunction{typeof(f)}(), f)
           MOI.optimize!(model)
       end
Exception of type: DYNAMIC_LIBRARY_FAILURE in file "Common/IpLibraryLoader.cpp" at line 67:
 Exception message: dlopen(libhsl.dylib, 2): image not found

EXIT: Library loading failure.
Exception of type: DYNAMIC_LIBRARY_FAILURE in file "Common/IpLibraryLoader.cpp" at line 67:
 Exception message: dlopen(libpardiso.dylib, 2): image not found

EXIT: Library loading failure.

******************************************************************************
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.14.4, running with linear solver MUMPS 5.4.1.

Number of nonzeros in equality constraint Jacobian...:        0
Number of nonzeros in inequality constraint Jacobian.:        0
Number of nonzeros in Lagrangian Hessian.............:        1

Total number of variables............................:        1
                     variables with only lower bounds:        0
                variables with lower and upper bounds:        0
                     variables with only upper bounds:        0
Total number of equality constraints.................:        0
Total number of inequality constraints...............:        0
        inequality constraints with only lower bounds:        0
   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  0.0000000e+00 0.00e+00 0.00e+00  -1.0 0.00e+00    -  0.00e+00 0.00e+00   0

Number of Iterations....: 0

                                   (scaled)                 (unscaled)
Objective...............:   0.0000000000000000e+00    0.0000000000000000e+00
Dual infeasibility......:   0.0000000000000000e+00    0.0000000000000000e+00
Constraint violation....:   0.0000000000000000e+00    0.0000000000000000e+00
Variable bound violation:   0.0000000000000000e+00    0.0000000000000000e+00
Complementarity.........:   0.0000000000000000e+00    0.0000000000000000e+00
Overall NLP error.......:   0.0000000000000000e+00    0.0000000000000000e+00


Number of objective function evaluations             = 1
Number of objective gradient evaluations             = 1
Number of equality constraint evaluations            = 0
Number of inequality constraint evaluations          = 0
Number of equality constraint Jacobian evaluations   = 0
Number of inequality constraint Jacobian evaluations = 0
Number of Lagrangian Hessian evaluations             = 0
Total seconds in IPOPT                               = 0.133

EXIT: Optimal Solution Found.

julia> GC.gc()

signal (11): Segmentation fault: 11
in expression starting at REPL[4]:1
unknown function (ip: 0x0)
Allocations: 9012305 (Pool: 9008649; Big: 3656); GC: 11
zsh: segmentation fault  ~/julia --project=ippt

Since it happens on GC, my guess it's a contention between multiple finalizers. Doesn't seem something easily fixable from Julia, so the ETA to get this fixed is long. Why would you want do this in the first place?

from ipopt.jl.

IlyaOrson avatar IlyaOrson commented on August 17, 2024

I was just testing if other line solvers where available and noticed the consistent segfault with a note to report the issue.
Not sure if this is the correct place to report this though. Is this related to BinaryBuilder somehow?

I forgot to copy the error message before:

Please submit a bug report with steps to reproduce this fault, and any error messages that follow (in their entirety). Thanks.
Exception: EXCEPTION_ACCESS_VIOLATION at 0x0 -- unknown function (ip: 0000000000000000)
in expression starting at REPL[10]:1
unknown function (ip: 0000000000000000)
_ZN5Ipopt19Ma97SolverInterfaceD1Ev at C:\Users\ilyao\.julia\artifacts\cd6b53ce70415659f3a97c3b0b79a7cbb197b835\bin\libipopt-3.dll (unknown line)
_ZN5Ipopt19Ma97SolverInterfaceD0Ev at C:\Users\ilyao\.julia\artifacts\cd6b53ce70415659f3a97c3b0b79a7cbb197b835\bin\libipopt-3.dll (unknown line)
_ZN5Ipopt16TSymLinearSolverD1Ev at C:\Users\ilyao\.julia\artifacts\cd6b53ce70415659f3a97c3b0b79a7cbb197b835\bin\libipopt-3.dll (unknown line)
_ZN5Ipopt16TSymLinearSolverD0Ev at C:\Users\ilyao\.julia\artifacts\cd6b53ce70415659f3a97c3b0b79a7cbb197b835\bin\libipopt-3.dll (unknown line)
_ZN5Ipopt18StdAugSystemSolverD1Ev at C:\Users\ilyao\.julia\artifacts\cd6b53ce70415659f3a97c3b0b79a7cbb197b835\bin\libipopt-3.dll (unknown line)
_ZN5Ipopt18StdAugSystemSolverD0Ev at C:\Users\ilyao\.julia\artifacts\cd6b53ce70415659f3a97c3b0b79a7cbb197b835\bin\libipopt-3.dll (unknown line)
_ZN5Ipopt17PDFullSpaceSolverD1Ev at C:\Users\ilyao\.julia\artifacts\cd6b53ce70415659f3a97c3b0b79a7cbb197b835\bin\libipopt-3.dll (unknown line)
_ZN5Ipopt17PDFullSpaceSolverD0Ev at C:\Users\ilyao\.julia\artifacts\cd6b53ce70415659f3a97c3b0b79a7cbb197b835\bin\libipopt-3.dll (unknown line)
.text at C:\Users\ilyao\.julia\artifacts\cd6b53ce70415659f3a97c3b0b79a7cbb197b835\bin\libipopt-3.dll (unknown line)
_ZN5Ipopt21PDSearchDirCalculatorD0Ev at C:\Users\ilyao\.julia\artifacts\cd6b53ce70415659f3a97c3b0b79a7cbb197b835\bin\libipopt-3.dll (unknown line)
_ZN5Ipopt14IpoptAlgorithmD1Ev at C:\Users\ilyao\.julia\artifacts\cd6b53ce70415659f3a97c3b0b79a7cbb197b835\bin\libipopt-3.dll (unknown line)
_ZN5Ipopt14IpoptAlgorithmD0Ev at C:\Users\ilyao\.julia\artifacts\cd6b53ce70415659f3a97c3b0b79a7cbb197b835\bin\libipopt-3.dll (unknown line)
_ZN5Ipopt16IpoptApplicationD1Ev at C:\Users\ilyao\.julia\artifacts\cd6b53ce70415659f3a97c3b0b79a7cbb197b835\bin\libipopt-3.dll (unknown line)
_ZN5Ipopt16IpoptApplicationD0Ev at C:\Users\ilyao\.julia\artifacts\cd6b53ce70415659f3a97c3b0b79a7cbb197b835\bin\libipopt-3.dll (unknown line)
FreeIpoptProblem at C:\Users\ilyao\.julia\artifacts\cd6b53ce70415659f3a97c3b0b79a7cbb197b835\bin\libipopt-3.dll (unknown line)
FreeIpoptProblem at C:\Users\ilyao\.julia\packages\Ipopt\M2QE8\src\C_wrapper.jl:292
jl_apply at /cygdrive/c/buildbot/worker/package_win64/build/src\julia.h:1788 [inlined]
run_finalizer at /cygdrive/c/buildbot/worker/package_win64/build/src\gc.c:278
jl_gc_run_finalizers_in_list at /cygdrive/c/buildbot/worker/package_win64/build/src\gc.c:365
run_finalizers at /cygdrive/c/buildbot/worker/package_win64/build/src\gc.c:394 [inlined]
run_finalizers at /cygdrive/c/buildbot/worker/package_win64/build/src\gc.c:372
jl_gc_run_pending_finalizers at /cygdrive/c/buildbot/worker/package_win64/build/src\gc.c:405
jl_mutex_unlock at /cygdrive/c/buildbot/worker/package_win64/build/src\julia_locks.h:131 [inlined]
jl_generate_fptr at /cygdrive/c/buildbot/worker/package_win64/build/src\jitlayers.cpp:359
jl_compile_method_internal at /cygdrive/c/buildbot/worker/package_win64/build/src\gf.c:1980
jl_compile_method_internal at /cygdrive/c/buildbot/worker/package_win64/build/src\gf.c:1934 [inlined]
_jl_invoke at /cygdrive/c/buildbot/worker/package_win64/build/src\gf.c:2239 [inlined]
jl_apply_generic at /cygdrive/c/buildbot/worker/package_win64/build/src\gf.c:2429
_eval_objective_gradient at C:\Users\ilyao\.julia\packages\Ipopt\M2QE8\src\MOI_wrapper.jl:865
eval_grad_f_cb at C:\Users\ilyao\.julia\packages\Ipopt\M2QE8\src\MOI_wrapper.jl:1087
unknown function (ip: 000000006436b76e)
_Eval_Grad_F_CB at C:\Users\ilyao\.julia\packages\Ipopt\M2QE8\src\C_wrapper.jl:49
unknown function (ip: 0000000064365d55)
_ZN5Ipopt11TNLPAdapter11Eval_grad_fERKNS_6VectorERS1_ at C:\Users\ilyao\.julia\artifacts\cd6b53ce70415659f3a97c3b0b79a7cbb197b835\bin\libipopt-3.dll (unknown line)
_ZN5Ipopt15GradientScaling30DetermineScalingParametersImplENS_8SmartPtrIKNS_11VectorSpaceEEES4_S4_NS1_IKNS_11MatrixSpaceEEES7_NS1_IKNS_14SymMatrixSpaceEEERKNS_6MatrixERKNS_6VectorESD_SG_RdRNS1_ISE_EESJ_SJ_ at C:\Users\ilyao\.julia\artifacts\cd6b53ce70415659f3a97c3b0b79a7cbb197b835\bin\libipopt-3.dll (unknown line)
_ZN5Ipopt19StandardScalingBase16DetermineScalingENS_8SmartPtrIKNS_11VectorSpaceEEES4_S4_NS1_IKNS_11MatrixSpaceEEES7_NS1_IKNS_14SymMatrixSpaceEEERS7_SB_RSA_RKNS_6MatrixERKNS_6VectorESF_SI_ at C:\Users\ilyao\.julia\artifacts\cd6b53ce70415659f3a97c3b0b79a7cbb197b835\bin\libipopt-3.dll (unknown line)
_ZN5Ipopt12OrigIpoptNLP20InitializeStructuresERNS_8SmartPtrINS_6VectorEEEbS4_bS4_bS4_bS4_bS4_S4_ at C:\Users\ilyao\.julia\artifacts\cd6b53ce70415659f3a97c3b0b79a7cbb197b835\bin\libipopt-3.dll (unknown line)
_ZN5Ipopt9IpoptData24InitializeDataStructuresERNS_8IpoptNLPEbbbbb at C:\Users\ilyao\.julia\artifacts\cd6b53ce70415659f3a97c3b0b79a7cbb197b835\bin\libipopt-3.dll (unknown line)
_ZN5Ipopt25DefaultIterateInitializer18SetInitialIteratesEv at C:\Users\ilyao\.julia\artifacts\cd6b53ce70415659f3a97c3b0b79a7cbb197b835\bin\libipopt-3.dll (unknown line)
_ZN5Ipopt14IpoptAlgorithm18InitializeIteratesEv at C:\Users\ilyao\.julia\artifacts\cd6b53ce70415659f3a97c3b0b79a7cbb197b835\bin\libipopt-3.dll (unknown line)
_ZN5Ipopt14IpoptAlgorithm8OptimizeEb at C:\Users\ilyao\.julia\artifacts\cd6b53ce70415659f3a97c3b0b79a7cbb197b835\bin\libipopt-3.dll (unknown line)
_ZN5Ipopt16IpoptApplication13call_optimizeEv at C:\Users\ilyao\.julia\artifacts\cd6b53ce70415659f3a97c3b0b79a7cbb197b835\bin\libipopt-3.dll (unknown line)
_ZN5Ipopt16IpoptApplication11OptimizeNLPERKNS_8SmartPtrINS_3NLPEEERNS1_INS_16AlgorithmBuilderEEE at C:\Users\ilyao\.julia\artifacts\cd6b53ce70415659f3a97c3b0b79a7cbb197b835\bin\libipopt-3.dll (unknown line)
_ZN5Ipopt16IpoptApplication11OptimizeNLPERKNS_8SmartPtrINS_3NLPEEE at C:\Users\ilyao\.julia\artifacts\cd6b53ce70415659f3a97c3b0b79a7cbb197b835\bin\libipopt-3.dll (unknown line)
_ZN5Ipopt16IpoptApplication12OptimizeTNLPERKNS_8SmartPtrINS_4TNLPEEE at C:\Users\ilyao\.julia\artifacts\cd6b53ce70415659f3a97c3b0b79a7cbb197b835\bin\libipopt-3.dll (unknown line)
IpoptSolve at C:\Users\ilyao\.julia\artifacts\cd6b53ce70415659f3a97c3b0b79a7cbb197b835\bin\libipopt-3.dll (unknown line)
IpoptSolve at C:\Users\ilyao\.julia\packages\Ipopt\M2QE8\src\C_wrapper.jl:433
optimize! at C:\Users\ilyao\.julia\packages\Ipopt\M2QE8\src\MOI_wrapper.jl:1225
#__solve#149 at C:\Users\ilyao\.julia\packages\GalacticOptim\fow0r\src\solve\moi.jl:215
__solve at C:\Users\ilyao\.julia\packages\GalacticOptim\fow0r\src\solve\moi.jl:163 [inlined]
#solve#480 at C:\Users\ilyao\.julia\packages\SciMLBase\GW7GW\src\solve.jl:3 [inlined]
solve at C:\Users\ilyao\.julia\packages\SciMLBase\GW7GW\src\solve.jl:3
unknown function (ip: 000000006435fb5d)
top-level scope at .\REPL[10]:4
jl_toplevel_eval_flex at /cygdrive/c/buildbot/worker/package_win64/build/src\toplevel.c:876
jl_toplevel_eval_flex at /cygdrive/c/buildbot/worker/package_win64/build/src\toplevel.c:830
eval_body at /cygdrive/c/buildbot/worker/package_win64/build/src\interpreter.c:550
jl_interpret_toplevel_thunk at /cygdrive/c/buildbot/worker/package_win64/build/src\interpreter.c:731
jl_toplevel_eval_flex at /cygdrive/c/buildbot/worker/package_win64/build/src\toplevel.c:885
jl_toplevel_eval_flex at /cygdrive/c/buildbot/worker/package_win64/build/src\toplevel.c:830
eval_body at /cygdrive/c/buildbot/worker/package_win64/build/src\interpreter.c:550
eval_body at /cygdrive/c/buildbot/worker/package_win64/build/src\interpreter.c:516
jl_interpret_toplevel_thunk at /cygdrive/c/buildbot/worker/package_win64/build/src\interpreter.c:731
jl_toplevel_eval_flex at /cygdrive/c/buildbot/worker/package_win64/build/src\toplevel.c:885
jl_toplevel_eval at /cygdrive/c/buildbot/worker/package_win64/build/src\toplevel.c:894 [inlined]
jl_toplevel_eval_in at /cygdrive/c/buildbot/worker/package_win64/build/src\toplevel.c:944
eval at .\boot.jl:373 [inlined]
eval_user_input at C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.7\REPL\src\REPL.jl:150
repl_backend_loop at C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.7\REPL\src\REPL.jl:246
start_repl_backend at C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.7\REPL\src\REPL.jl:231
#run_repl#47 at C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.7\REPL\src\REPL.jl:364
run_repl at C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.7\REPL\src\REPL.jl:351
#930 at .\client.jl:394
jfptr_YY.930_36349.clone_1 at C:\Users\ilyao\.julia\juliaup\julia-1.7.2+0~x64\lib\julia\sys.dll (unknown line)
jl_apply at /cygdrive/c/buildbot/worker/package_win64/build/src\julia.h:1788 [inlined]
jl_f__call_latest at /cygdrive/c/buildbot/worker/package_win64/build/src\builtins.c:757
#invokelatest#2 at .\essentials.jl:716 [inlined]
invokelatest at .\essentials.jl:714 [inlined]
run_main_repl at .\client.jl:379
exec_options at .\client.jl:309
_start at .\client.jl:495
jfptr__start_21275.clone_1 at C:\Users\ilyao\.julia\juliaup\julia-1.7.2+0~x64\lib\julia\sys.dll (unknown line)
jl_apply at /cygdrive/c/buildbot/worker/package_win64/build/src\julia.h:1788 [inlined]
true_main at /cygdrive/c/buildbot/worker/package_win64/build/src\jlapi.c:559
jl_repl_entrypoint at /cygdrive/c/buildbot/worker/package_win64/build/src\jlapi.c:701
mainCRTStartup at /cygdrive/c/buildbot/worker/package_win64/build/cli\loader_exe.c:42
BaseThreadInitThunk at C:\WINDOWS\System32\KERNEL32.DLL (unknown line)
RtlUserThreadStart at C:\WINDOWS\SYSTEM32\ntdll.dll (unknown line)
Allocations: 241302832 (Pool: 241255979; Big: 46853); GC: 92

from ipopt.jl.

baggepinnen avatar baggepinnen commented on August 17, 2024

I'm not sure if related, but I keep running into a similar problem as well, the code below works sometimes and sometimes segfaults julia on julia v1.8.0-rc4

using Optimization, Symbolics, OptimizationMOI, Ipopt, SparseArrays

N = 10
x0 = randn(N)
x = Symbolics.variables(:x, 1:N)
p = Symbolics.variable(:p)

cost = sum(abs2, x)
hess = Symbolics.sparsehessian(cost, x)
hessfun = build_function(hess, x, p)[2]
hessfun = eval(hessfun)
hess_prototype = similar(hess, Float64)


costfun = (x,p)->sum(abs2, x)
grad = (g, x, p) -> g .= 2x
optfun = OptimizationFunction{false}(costfun; hess = hessfun, grad, hess_prototype);
prob = OptimizationProblem(optfun, x0);
sol = solve(prob, Ipopt.Optimizer());

from ipopt.jl.

odow avatar odow commented on August 17, 2024

This is unrelated. It's probably a bug in OptimizationMOI.jl. Do you have a stack trace of the segfault?

from ipopt.jl.

baggepinnen avatar baggepinnen commented on August 17, 2024

I narrowed this down to that it's not enough to have the correct sparsity structure in hess_prototype, if any of the structurally non-zero values are zero, I get the segfault. I created the sparsity structures like this

hess_prototype = similar(hess, Float64)

so they would sometimes contain zeros by chance, using

function safe_similar(x, ::Type{T}) where T
    y = similar(x, T)
    y.nzval .= 1
    y
end

instead works better

from ipopt.jl.

odow avatar odow commented on August 17, 2024

I don't know what the return type of hess_prototype = similar(hess, Float64) is, but yes, you need to use a sparsity structure that is valid for all x, including values which can sometimes be zero.

from ipopt.jl.

odow avatar odow commented on August 17, 2024

I don't know what we can or should do here. Calling into C is dangerous, especially calling symbols which don't exist.

from ipopt.jl.

odow avatar odow commented on August 17, 2024

Closing because I don't think there's much we can do here.

The solution is to ask the user for the linear solver and path, rather than testing to see if any are installed.

from ipopt.jl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.