`UnoSolver.uno` seems stuck, doesn't terminate
Issue
This code outputs the first few steps of the solver and hangs consuming CPU with no further output:
x0 = [0.5, 0.5, -0.1,0.1, 1.,2.]
model = ADNLPModels.ADNLPModel(
objective,
x0,
[0,0, -Inf,-Inf, 0,0],
[Inf,Inf, Inf,Inf, Inf,Inf],
sparse([1. 1 0 0 0 0]), [1.], [1.]
)
display(model)
@info "Now optimizing..."
result = UnoSolver.uno(model, preset="filtersqp", print_solution=true, logger="INFO")
The call to UnoSolver.uno was taken from the README: https://github.com/cvanaret/Uno/blob/81262ccb4fe5a16e6c536eecba49067cfe42dbe1/interfaces/Julia/README.md?plain=1#L33
Reproducible example
import Pkg
Pkg.activate(temp=true)
Pkg.add([
Pkg.PackageSpec("SpecialFunctions"),
Pkg.PackageSpec(name="ADNLPModels", version="0.8.13"),
Pkg.PackageSpec(name="UnoSolver", version="0.1.2"),
])
Pkg.status()
using SparseArrays
import ADNLPModels, UnoSolver
import SpecialFunctions: erf
struct MyMix{T<:Real, V<:AbstractVector{T}}
ps::V
ms::V
vs::V
end
function cdf(d::MyMix, x::Real)
ncdf(z::Real) = (1 + erf(z / sqrt(2)))/2
sum(
p * ncdf((x - m) / sqrt(v))
for (p, m, v) in zip(d.ps, d.ms, d.vs)
)
end
function loss_CramerMises(d::MyMix, xs::AbstractVector{<:Real}, sorted::Bool=false)
xs = sorted ? xs : sort(xs)
N = length(xs)
1/(12N) + sum(
((2n - 1)/N - cdf(d, x))^2
for (n, x) in enumerate(xs)
)
end
function mytest()
sample = sort(randn(100))
objective(par) = @views loss_CramerMises(
MyMix(par[1:2], par[3:4], par[5:6]), sample, true
)
x0 = [0.5, 0.5, -0.1,0.1, 1.,2.]
@show objective(x0)
model = ADNLPModels.ADNLPModel(
objective,
x0,
[0,0, -Inf,-Inf, 0,0],
[Inf,Inf, Inf,Inf, Inf,Inf],
sparse([1. 1 0 0 0 0]), [1.], [1.]
)
display(model)
@info "Now optimizing..."
# Taken from https://github.com/cvanaret/Uno/blob/81262ccb4fe5a16e6c536eecba49067cfe42dbe1/interfaces/Julia/README.md?plain=1#L33
result = UnoSolver.uno(model, preset="filtersqp", print_solution=true, logger="INFO")
@show result
end
mytest()
Output
~/test> julia uno-loop.jl
Activating new project at `/var/folders/61/p7f15sln0gxd7lwbr58cy6f00000gn/T/jl_4UrenI`
Resolving package versions...
Updating `/private/var/folders/61/p7f15sln0gxd7lwbr58cy6f00000gn/T/jl_4UrenI/Project.toml`
[54578032] + ADNLPModels v0.8.13
[276daf66] + SpecialFunctions v2.6.1
[1baa60ac] + UnoSolver v0.1.2
Updating `/private/var/folders/61/p7f15sln0gxd7lwbr58cy6f00000gn/T/jl_4UrenI/Manifest.toml`
[...snip...]
Status `/private/var/folders/61/p7f15sln0gxd7lwbr58cy6f00000gn/T/jl_4UrenI/Project.toml`
[54578032] ADNLPModels v0.8.13
[276daf66] SpecialFunctions v2.6.1
[1baa60ac] UnoSolver v0.1.2
objective(x0) = 33.25062127850325
ADNLPModel - Model with automatic differentiation backend ADModelBackend{
ForwardDiffADGradient,
ForwardDiffADHvprod,
ForwardDiffADJprod,
ForwardDiffADJtprod,
SparseADJacobian,
SparseADHessian,
ForwardDiffADGHjvprod,
}
Problem name: Generic
All variables: ████████████████████ 6 All constraints: ████████████████████ 1
free: ███████⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 2 free: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0
lower: ██████████████⋅⋅⋅⋅⋅⋅ 4 lower: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0
upper: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0 upper: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0
low/upp: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0 low/upp: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0
fixed: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0 fixed: ████████████████████ 1
infeas: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0 infeas: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0
nnzh: ( 0.00% sparsity) 21 linear: ████████████████████ 1
nonlinear: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0
nnzj: ( 66.67% sparsity) 2
Counters:
obj: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0 grad: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0 cons: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0
cons_lin: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0 cons_nln: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0 jcon: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0
jgrad: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0 jac: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0 jac_lin: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0
jac_nln: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0 jprod: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0 jprod_lin: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0
jprod_nln: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0 jtprod: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0 jtprod_lin: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0
jtprod_nln: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0 hess: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0 hprod: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0
jhess: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0 jhprod: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0
[ Info: Now optimizing...
Original model C model
6 variables, 1 constraints (1 equality, 0 inequality)
Used overwritten options:
- QP_solver = BQPD
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
iter TR iter TR radius phase step norm objective primal feas stationarity complementarity status
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
0 - 1.0000e+01 OPT - 3.3251e+01 0.0000e+00 9.5224e+01 0.0000e+00 initial point
1 1 1.0000e+01 OPT 1.0000e+01 3.3331e+01 0.0000e+00 - - ✘ (current)
- 2 5.0000e+00 OPT 5.0000e+00 3.3331e+01 0.0000e+00 - - ✘ (current)
- 3 2.5000e+00 OPT 2.5000e+00 3.3331e+01 0.0000e+00 - - ✘ (current)
- 4 1.2500e+00 OPT 1.2500e+00 2.7311e+01 0.0000e+00 nan 0.0000e+00 ✔ (f-type)
This doesn't terminate. I've set a separate instance running, it consumes one CPU core and has been stuck like this for 2000 seconds now.
When I terminate this, it crashes Julia:
^C
[7515] signal 2: Interrupt: 2
in expression starting at /Users/forcebru/test/uno-loop.jl:59
_foldl_impl at ./reduce.jl:62 [inlined]
foldl_impl at ./reduce.jl:48 [inlined]
mapfoldl_impl at ./reduce.jl:44 [inlined]
#mapfoldl#337 at ./reduce.jl:175 [inlined]
mapfoldl at ./reduce.jl:175 [inlined]
#mapreduce#341 at ./reduce.jl:307 [inlined]
mapreduce at ./reduce.jl:307 [inlined]
#sum#344 at ./reduce.jl:532 [inlined]
sum at ./reduce.jl:532 [inlined]
#sum#345 at ./reduce.jl:561 [inlined]
sum at ./reduce.jl:561 [inlined]
loss_CramerMises at /Users/forcebru/test/uno-loop.jl:31
objective at /Users/forcebru/test/uno-loop.jl:39 [inlined]
lag#158 at /Users/forcebru/.julia/packages/ADNLPModels/N6grE/src/forward.jl:204
lag at /Users/forcebru/.julia/packages/ADNLPModels/N6grE/src/forward.jl:195 [inlined]
vector_mode_dual_eval! at /Users/forcebru/.julia/packages/ForwardDiff/kQBw9/src/apiutils.jl:24 [inlined]
vector_mode_gradient! at /Users/forcebru/.julia/packages/ForwardDiff/kQBw9/src/gradient.jl:105
gradient! at /Users/forcebru/.julia/packages/ForwardDiff/kQBw9/src/gradient.jl:39 [inlined]
gradient! at /Users/forcebru/.julia/packages/ForwardDiff/kQBw9/src/gradient.jl:36
unknown function (ip: 0x110fe01f6)
∇φ!#159 at /Users/forcebru/.julia/packages/ADNLPModels/N6grE/src/forward.jl:215
unknown function (ip: 0x110fdb17a)
∇φ! at /Users/forcebru/.julia/packages/ADNLPModels/N6grE/src/forward.jl:214
Hvprod! at /Users/forcebru/.julia/packages/ADNLPModels/N6grE/src/forward.jl:252
unknown function (ip: 0x110fda4a7)
#hprod!#413 at /Users/forcebru/.julia/packages/ADNLPModels/N6grE/src/nlp.jl:745
hprod! at /Users/forcebru/.julia/packages/ADNLPModels/N6grE/src/nlp.jl:731 [inlined]
nlpmodels_lagrangian_hessian_operator at /Users/forcebru/.julia/packages/UnoSolver/ZtQWN/ext/UnoSolverNLPModelsExt/UnoSolverNLPModelsExt.jl:48
unknown function (ip: 0x110fd712d)
uno_lagrangian_hessian_operator at /Users/forcebru/.julia/packages/UnoSolver/ZtQWN/src/C_wrapper.jl:110
unknown function (ip: 0x110fcae87)
_ZNK8UnoModel30compute_hessian_vector_productEPKdS1_dRKN3uno6VectorIdEEPd at /Users/forcebru/.julia/artifacts/dca16cc81d328775c716c4c630b8145b0278f216/lib/libuno.dylib (unknown line)
_ZN3uno12ExactHessian30compute_hessian_vector_productERKNS_5ModelEPKdS5_dRKNS_6VectorIdEEPd at /Users/forcebru/.julia/artifacts/dca16cc81d328775c716c4c630b8145b0278f216/lib/libuno.dylib (unknown line)
_ZNK3uno10Subproblem30compute_hessian_vector_productEPKdS2_Pd at /Users/forcebru/.julia/artifacts/dca16cc81d328775c716c4c630b8145b0278f216/lib/libuno.dylib (unknown line)
bqpd_ at /Users/forcebru/.julia/artifacts/dca16cc81d328775c716c4c630b8145b0278f216/lib/libuno.dylib (unknown line)
_ZN3uno10BQPDSolver16solve_subproblemERKNS_10SubproblemERKNS_6VectorIdEERNS_9DirectionERKNS_20WarmstartInformationE at /Users/forcebru/.julia/artifacts/dca16cc81d328775c716c4c630b8145b0278f216/lib/libuno.dylib (unknown line)
_ZN3uno27InequalityConstrainedMethod5solveERNS_10StatisticsERNS_7IterateERNS_9DirectionERNS_12HessianModelERNS_25InertiaCorrectionStrategyIdEEdRNS_20WarmstartInformationE at /Users/forcebru/.julia/artifacts/dca16cc81d328775c716c4c630b8145b0278f216/lib/libuno.dylib (unknown line)
_ZN3uno22FeasibilityRestoration16solve_subproblemERNS_10StatisticsERNS_24InequalityHandlingMethodERKNS_19OptimizationProblemERNS_7IterateERNS_9DirectionERNS_12HessianModelERNS_25InertiaCorrectionStrategyIdEEdRNS_20WarmstartInformationE at /Users/forcebru/.julia/artifacts/dca16cc81d328775c716c4c630b8145b0278f216/lib/libuno.dylib (unknown line)
_ZN3uno22FeasibilityRestoration26compute_feasible_directionERNS_10StatisticsERNS_21GlobalizationStrategyERKNS_5ModelERNS_7IterateERNS_9DirectionEdRNS_20WarmstartInformationE at /Users/forcebru/.julia/artifacts/dca16cc81d328775c716c4c630b8145b0278f216/lib/libuno.dylib (unknown line)
_ZN3uno19TrustRegionStrategy20compute_next_iterateERNS_10StatisticsERNS_28ConstraintRelaxationStrategyERNS_21GlobalizationStrategyERKNS_5ModelERNS_7IterateESB_RNS_9DirectionERNS_20WarmstartInformationERNS_13UserCallbacksE at /Users/forcebru/.julia/artifacts/dca16cc81d328775c716c4c630b8145b0278f216/lib/libuno.dylib (unknown line)
_ZN3uno3Uno9uno_solveERKNS_5ModelERKNS_7OptionsERNS_13UserCallbacksE at /Users/forcebru/.julia/artifacts/dca16cc81d328775c716c4c630b8145b0278f216/lib/libuno.dylib (unknown line)
_ZN3uno3Uno5solveERKNS_5ModelERKNS_7OptionsERNS_13UserCallbacksE at /Users/forcebru/.julia/artifacts/dca16cc81d328775c716c4c630b8145b0278f216/lib/libuno.dylib (unknown line)
uno_optimize at /Users/forcebru/.julia/artifacts/dca16cc81d328775c716c4c630b8145b0278f216/lib/libuno.dylib (unknown line)
uno_optimize at /Users/forcebru/.julia/packages/UnoSolver/ZtQWN/src/libuno.jl:180 [inlined]
uno_optimize at /Users/forcebru/.julia/packages/UnoSolver/ZtQWN/src/C_wrapper.jl:336 [inlined]
#uno#1 at /Users/forcebru/.julia/packages/UnoSolver/ZtQWN/ext/UnoSolverNLPModelsExt/UnoSolverNLPModelsExt.jl:91 [inlined]
uno at /Users/forcebru/.julia/packages/UnoSolver/ZtQWN/ext/UnoSolverNLPModelsExt/UnoSolverNLPModelsExt.jl:88 [inlined]
uno at /Users/forcebru/.julia/packages/UnoSolver/ZtQWN/ext/UnoSolverNLPModelsExt/UnoSolverNLPModelsExt.jl:88 [inlined]
mytest at /Users/forcebru/test/uno-loop.jl:55
unknown function (ip: 0x110f7a45b)
jl_apply at /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-macmini-x64-4.0/build/default-macmini-x64-4-0/julialang/julia-release-1-dot-11/src/./julia.h:2157 [inlined]
do_call at /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-macmini-x64-4.0/build/default-macmini-x64-4-0/julialang/julia-release-1-dot-11/src/interpreter.c:126
eval_stmt_value at /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-macmini-x64-4.0/build/default-macmini-x64-4-0/julialang/julia-release-1-dot-11/src/interpreter.c:174
eval_body at /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-macmini-x64-4.0/build/default-macmini-x64-4-0/julialang/julia-release-1-dot-11/src/interpreter.c:666
jl_interpret_toplevel_thunk at /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-macmini-x64-4.0/build/default-macmini-x64-4-0/julialang/julia-release-1-dot-11/src/interpreter.c:824
jl_toplevel_eval_flex at /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-macmini-x64-4.0/build/default-macmini-x64-4-0/julialang/julia-release-1-dot-11/src/toplevel.c:943
jl_toplevel_eval_flex at /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-macmini-x64-4.0/build/default-macmini-x64-4-0/julialang/julia-release-1-dot-11/src/toplevel.c:886
ijl_toplevel_eval at /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-macmini-x64-4.0/build/default-macmini-x64-4-0/julialang/julia-release-1-dot-11/src/toplevel.c:952 [inlined]
ijl_toplevel_eval_in at /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-macmini-x64-4.0/build/default-macmini-x64-4-0/julialang/julia-release-1-dot-11/src/toplevel.c:994
eval at ./boot.jl:430 [inlined]
include_string at ./loading.jl:2734
_include at ./loading.jl:2794
include at ./Base.jl:562
jfptr_include_47091.1 at /Users/forcebru/.julia/juliaup/julia-1.11.7+0.x64.apple.darwin14/lib/julia/sys.dylib (unknown line)
exec_options at ./client.jl:323
_start at ./client.jl:531
jfptr__start_73934.1 at /Users/forcebru/.julia/juliaup/julia-1.11.7+0.x64.apple.darwin14/lib/julia/sys.dylib (unknown line)
jl_apply at /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-macmini-x64-4.0/build/default-macmini-x64-4-0/julialang/julia-release-1-dot-11/src/./julia.h:2157 [inlined]
true_main at /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-macmini-x64-4.0/build/default-macmini-x64-4-0/julialang/julia-release-1-dot-11/src/jlapi.c:900
jl_repl_entrypoint at /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-macmini-x64-4.0/build/default-macmini-x64-4-0/julialang/julia-release-1-dot-11/src/jlapi.c:1059
unknown function (ip: 0x0)
Allocations: 607360147 (Pool: 607357442; Big: 2705); GC: 2736
~/test [SIGINT]>
Versions
- UnoSolver v0.1.2
- ADNLPModels v0.8.13
julia> versioninfo()
Julia Version 1.11.7
Commit f2b3dbda30a (2025-09-08 12:10 UTC)
Build Info:
Official https://julialang.org/ release
Platform Info:
OS: macOS (x86_64-apple-darwin24.0.0)
CPU: 4 × Intel(R) Core(TM) i5-3330S CPU @ 2.70GHz
WORD_SIZE: 64
LLVM: libLLVM-16.0.6 (ORCJIT, ivybridge)
Threads: 1 default, 0 interactive, 1 GC (on 4 virtual cores)
Thanks for your feedback @ForceBru, I'll have a look!
First remark: in UnoSolver.jl, Bool options are not parsed properly... This is fixed in https://github.com/cvanaret/Uno/pull/434 and in UnoSolver.jl v0.1.3.
@ForceBru at iteration 2, the current primal iterate is x = 1 0 -8.28897 10.1 0 12 and for some reason the gradient of the objective is nan nan nan nan nan nan. That's why the QP solver (BQPD) is caught in an endless loop.
Any idea why that would happen?
Note for myself: Uno should detect NaNs and fail with a clear error message, see https://github.com/cvanaret/Uno/issues/442.
The second-to-last value is the variance of a Normal distribution, it should never be exactly zero, so that's an infeasible point. Not sure how it got there. I guess the gradient just went haywire at this point.
Worse, the first two values are weights of two Normal cumulative distribution functions. They must be positive and sum to one (the sparse matrix is supposed to convey the "sum-to-one" constraint). The first weight is exactly one (thus the second weight is zero), so this means the full weight corresponds to the Normal distribution with zero variance. That shouldn't happen...
IMO it would be most helpful if Uno tried to restore feasibility here instead of erroring out. I guess I should try solving this with other solvers to see if they have issues too.
I think there's two issues here, one on the modeling side and one on the solver side:
- modeling: if you only set the bound constraints and the constraints $x_1 + x_2 = 1$ (all of which are satisfied at the iterate), you do not explicitly prevent the error cases from happening (you just let the function evaluations crash);
- solver: I should use NaN as an indication that the trial iterate should be rejected. I'm working on it.
you do not explicitly prevent the error cases from happening
Is there something I could do about this on the modeling side? I've always been doing it like here: set up non-negativity constraints and let the objective return NaN when the solver evaluates it at zero or something slightly negative. Is there a better way?
Actually, it would be much easier for the solver if you returned NaN in the objective instead of in the gradients:
### Outer iteration 2
Current iterate
Primal variables: 1 0 -4.68501 7.1405 0 12
┌ Constraint: -220.325
Multipliers │ Lower bound: 0 324.601 0 0 25.53 0
└ Upper bound: 0 0 0 0 0 0
Objective value: 33.3308
Primal feasibility: 0
┌ Stationarity: nan
Residuals │ Complementarity: 0
└ Lagrangian gradient: nan nan nan nan nan nan
┌ Infeasibility: 0
Progress measures │ Optimality: 33.3308
└ Auxiliary terms: 0
Here the gradients (therefore the Lagrangian gradient) contain NaN, while the objective is well defined. In Uno, we monitor the objective value and the constraint violation to determine whether the new point is accepted or rejected. At the moment, we're not looking at the derivatives at the new point. Can you try adapting your callbacks?
You could of course add a small positive lower bound on the quantity that shouldn't be 0.
An alternative is to use an interior-point method, because it stays away from the bounds (at least to some extent). If I pass preset="ipopt" instead of preset="filtersqp", I get:
Original model C model
6 variables, 1 constraints (1 equality, 0 inequality)
Reformulated model C model -> no fixed bounds -> equality constrained -> bounds relaxed
6 variables, 1 constraints (1 equality, 0 inequality)
Used overwritten options:
- linear_solver = MUMPS
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
iter LS iter penalty barrier step length phase regulariz step norm objective primal feas stationarity complementarity status
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
0 - - - - OPT - - 3.505e+01 0.000e+00 7.175e+01 2.000e+00 initial point
1 1 - 1.000e-01 1.000e+00 OPT 1.000e+02 1.315e-01 3.174e+01 2.220e-16 1.291e+01 1.329e-01 ✔ (f-type)
2 1 - 1.000e-01 1.000e+00 OPT 3.333e+01 4.102e-01 2.266e+01 2.220e-16 1.066e+01 1.067e-01 ✔ (f-type)
3 1 - 1.000e-01 1.000e+00 OPT 1.111e+01 2.775e-01 1.915e+01 2.220e-16 1.237e+01 1.289e-01 ✔ (f-type)
4 1 - 1.000e-01 1.000e+00 OPT 3.704e+00 7.029e-01 1.956e+01 1.110e-16 - - ✘ (f-type)
- 2 - - 5.000e-01 - - 3.514e-01 1.755e+01 2.220e-16 4.239e+00 2.612e-01 ✔ (f-type)
5 1 - 1.000e-01 1.000e+00 OPT 1.235e+00 9.970e-02 1.708e+01 0.000e+00 5.285e-01 1.206e-01 ✔ (f-type)
6 1 - 2.000e-02 1.000e+00 OPT 4.115e-01 5.467e-02 1.699e+01 0.000e+00 2.495e-02 2.816e-02 ✔ (f-type)
7 1 - 1.504e-04 1.000e+00 OPT 1.372e-01 2.440e-03 1.696e+01 0.000e+00 4.353e-04 2.827e-04 ✔ (f-type)
8 1 - 1.845e-06 1.000e+00 OPT 4.572e-02 3.668e-05 1.696e+01 2.220e-16 1.559e-06 1.878e-06 ✔ (f-type)
9 1 - 2.506e-09 1.000e+00 OPT 1.524e-02 6.478e-06 1.696e+01 1.110e-16 9.874e-08 2.509e-09 ✔ (f-type)
10 1 - 2.506e-09 1.000e+00 OPT 5.081e-03 1.943e-05 1.696e+01 1.110e-16 9.873e-08 2.506e-09 ✔ (f-type)
11 1 - 2.506e-09 1.000e+00 OPT 1.694e-03 5.830e-05 1.696e+01 0.000e+00 9.873e-08 2.506e-09 ✔ (f-type)
12 1 - 2.506e-09 1.000e+00 OPT 5.645e-04 1.749e-04 1.696e+01 2.220e-16 9.874e-08 2.506e-09 ✔ (f-type)
13 1 - 2.506e-09 1.000e+00 OPT 1.882e-04 5.249e-04 1.696e+01 0.000e+00 5.294e-07 2.506e-09 ✔ (f-type)
14 1 - 2.506e-09 1.000e+00 OPT 6.272e-05 1.576e-03 1.696e+01 0.000e+00 4.768e-06 2.506e-09 ✔ (f-type)
15 1 - 2.506e-09 1.000e+00 OPT 2.091e-05 4.737e-03 1.696e+01 0.000e+00 4.301e-05 2.506e-09 ✔ (f-type)
16 1 - 2.506e-09 1.000e+00 OPT 6.969e-06 1.430e-02 1.696e+01 0.000e+00 3.897e-04 2.506e-09 ✔ (f-type)
17 1 - 2.506e-09 1.000e+00 OPT 2.323e-06 4.368e-02 1.696e+01 0.000e+00 3.577e-03 2.506e-09 ✔ (f-type)
18 1 - 2.506e-09 1.000e+00 OPT 7.744e-07 1.383e-01 1.696e+01 0.000e+00 3.392e-02 2.506e-09 ✔ (f-type)
19 1 - 2.506e-09 1.000e+00 OPT 2.581e-07 4.836e-01 1.696e+01 0.000e+00 3.296e-01 2.506e-09 ✔ (f-type)
20 1 - 2.506e-09 1.000e+00 OPT 8.604e-08 1.817e+00 1.696e+01 1.110e-16 1.477e+00 2.506e-09 ✔ (f-type)
21 1 - 2.506e-09 1.000e+00 OPT 2.868e-08 1.410e+00 1.696e+01 0.000e+00 4.149e+00 3.154e-09 ✔ (f-type)
22 1 - 2.506e-09 1.000e+00 OPT 0.000e+00 8.313e-01 1.696e+01 1.110e-16 4.951e-01 2.907e-09 ✔ (f-type)
23 1 - 2.506e-09 1.000e+00 OPT 0.000e+00 8.188e-01 1.696e+01 0.000e+00 6.017e-02 2.507e-09 ✔ (f-type)
24 1 - 2.506e-09 1.000e+00 OPT 9.560e-09 1.521e-01 1.696e+01 0.000e+00 3.304e-04 2.764e-09 ✔ (f-type)
25 1 - 2.506e-09 1.000e+00 OPT 0.000e+00 1.488e+00 1.696e+01 0.000e+00 4.169e-03 2.506e-09 ✔ (f-type)
26 1 - 2.506e-09 1.000e+00 OPT 3.187e-09 1.998e-01 1.696e+01 0.000e+00 1.492e-04 2.726e-09 ✔ (f-type)
27 1 - 2.506e-09 1.000e+00 OPT 0.000e+00 2.598e+00 1.696e+01 0.000e+00 6.146e-04 2.506e-09 ✔ (f-type)
28 1 - 2.506e-09 1.000e+00 OPT 1.062e-09 3.491e-01 1.696e+01 2.220e-16 2.076e-05 2.679e-09 ✔ (f-type)
29 1 - 2.506e-09 1.000e+00 OPT 0.000e+00 5.568e+00 1.696e+01 1.110e-16 1.421e-03 2.506e-09 ✔ (f-type)
30 1 - 2.506e-09 1.000e+00 OPT 3.541e-10 5.659e-01 1.696e+01 0.000e+00 3.160e-05 2.635e-09 ✔ (f-type)
31 1 - 2.506e-09 1.000e+00 OPT 0.000e+00 1.157e+01 1.696e+01 0.000e+00 8.111e-04 2.506e-09 ✔ (f-type)
32 1 - 2.506e-09 1.000e+00 OPT 1.180e-10 8.723e-01 1.696e+01 0.000e+00 2.030e-05 2.600e-09 ✔ (f-type)
33 1 - 2.506e-09 1.000e+00 OPT 0.000e+00 2.364e+01 1.696e+01 0.000e+00 3.414e-04 2.506e-09 ✔ (f-type)
34 1 - 2.506e-09 1.000e+00 OPT 3.934e-11 1.313e+00 1.696e+01 0.000e+00 7.112e-06 2.575e-09 ✔ (f-type)
35 1 - 2.506e-09 1.000e+00 OPT 0.000e+00 4.800e+01 1.696e+01 0.000e+00 1.214e-04 2.506e-09 ✔ (f-type)
36 1 - 2.506e-09 1.000e+00 OPT 1.311e-11 1.959e+00 1.696e+01 1.110e-16 1.741e-06 2.557e-09 ✔ (f-type)
37 1 - 2.506e-09 1.000e+00 OPT 0.000e+00 9.708e+01 1.696e+01 0.000e+00 3.610e-05 2.506e-09 ✔ (f-type)
38 1 - 2.506e-09 1.000e+00 OPT 4.371e-12 2.916e+00 1.696e+01 0.000e+00 3.148e-07 2.543e-09 ✔ (f-type)
39 1 - 2.506e-09 1.000e+00 OPT 0.000e+00 1.957e+02 1.696e+01 0.000e+00 8.745e-06 2.506e-09 ✔ (f-type)
40 1 - 2.506e-09 1.000e+00 OPT 0.000e+00 1.521e+05 1.696e+01 1.110e-16 6.132e-05 2.506e-09 ✔ (f-type)
41 1 - 2.506e-09 1.000e+00 OPT 1.457e-12 5.918e-03 1.696e+01 0.000e+00 4.974e-14 2.506e-09 ✔ (f-type)
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
iter LS iter penalty barrier step length phase regulariz step norm objective primal feas stationarity complementarity status
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Uno 2.3.1 (LS Waechter-filter restoration primal-dual interior-point method with exact Hessian and primal-dual regularization)
Fri Nov 21 15:02:43 2025
────────────────────────────────────────
Optimization status: Success
Solution status: Feasible KKT point
Objective value: 16.96191
Primal feasibility: 0
┌ Stationarity residual: 4.973799e-14
│ Primal feasibility: 0
└ Complementarity residual: 2.505904e-09
Primal solution: 1 -9.949541e-09 -0.8449225 19422.25 0.2707083 152464.4
┌ Constraint multipliers: 49.66217
│ Lower bound multipliers: -2.505904e-09 -49.66217 -0 -0 -9.256839e-09 -1.6436e-14
└ Upper bound multipliers: -0 -0 -0 -0 -0 -0
CPU time: 2.125633s
Iterations: 41
Objective evaluations: 43
Constraints evaluations: 43
Objective gradient evaluations: 43
Jacobian evaluations: 42
Hessian evaluations: 41
Number of subproblems solved: 41
Note: some runs fail because p * ncdf((x - m) / sqrt(v)) is called on a negative v.
I did a change of variables v = exp(l/2) and tried to optimize over -Inf < l < Inf, but getting segmentation faults all over the place: https://github.com/cvanaret/Uno/issues/443#issuecomment-3570700641.
Yeah we have a severe bug with the NLPModels interface. Trying to figure that out...
The segfaults are fixed in UnoSolver.jl v0.1.6. Could you try again?
The segfaults are fixed in UnoSolver.jl v0.1.6. Could you try again?
Yes, I don't encounter any segfaults anymore
@ForceBru did you have any success with your change of variables?