Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MethodError: no method matching percival(::Val{:tron}, ...) when trying basic box-constrained optimization #7

Closed
ForceBru opened this issue Sep 26, 2022 · 1 comment

Comments

@ForceBru
Copy link

Code

import Pkg
Pkg.activate(temp=true, io=devnull)
Pkg.add([
    (name="Percival", version="0.5.2"),
    (name="Nonconvex", version="2.1.1"),
    (name="NonconvexPercival", version="0.1.3"),
], io=devnull)
Pkg.status()


import Nonconvex as NC; using NonconvexPercival

component_pdf(x::Real, mu::Real, tau::Real) =
    tau * exp(-tau^2 * (x - mu)^2 / 2) / sqrt(2π)

data = randn(300)

loss(params::AbstractVector) = -sum(log,
    (1 - params[1]) * component_pdf(x, 0, 1)
    +    params[1]  * component_pdf(x, params[2], params[3])
    for x in data
)

model = NC.Model(loss)
NC.addvar!(model, [0, -Inf, 0], [1, Inf, Inf], init=[0.1, 0, 1])

@info "Begin optimization..."
res = optimize(
    model, AugLag(), [0.1, -3, 1],
    options=AugLagOptions(), convcriteria=NC.KKTCriteria()
)
@info "End optimization" res.minimizer

Error message

$ julia-1.8 bug_nonconvex.jl
Status `/private/var/folders/ys/3h0gnqns4b98zb66_vl_m35m0000gn/T/jl_4nXQJl/Project.toml`
  [01bcebdf] Nonconvex v2.1.1
  [4296f080] NonconvexPercival v0.1.3
  [01435c0c] Percival v0.5.2
[ Info: Begin optimization...
ERROR: LoadError: MethodError: no method matching percival(::Val{:tron}, ::ADNLPModels.ADNLPModel{Float64, Vector{Float64}, Vector{Int64}}; max_iter=1000, max_time=Inf, max_eval=100000, atol=1.0e-6, rtol=1.0e-6, subsolver_logger=Base.CoreLogging.NullLogger(), subproblem_modifier=NonconvexPercival.var"#4#5"{DataType, Int64}(Float64, 5), subsolver_max_eval=200, subsolver_kwargs=Dict(:max_cgiter => 100))
Closest candidates are:
  percival(::Val{:tron}, ::NLPModels.AbstractNLPModel; max_iter, max_time, max_eval, atol, rtol, subproblem_modifier, subsolver_logger, subsolver_kwargs) at ~/.julia/packages/Percival/RpJYY/src/method.jl:17 got unsupported keyword argument "subsolver_max_eval"
  percival(::Val{:ineq}, ::NLPModels.AbstractNLPModel; kwargs...) at ~/.julia/packages/Percival/RpJYY/src/method.jl:46
  percival(::Val{:equ}, ::NLPModels.AbstractNLPModel{T, V}; μ, max_iter, max_time, max_eval, atol, rtol, ctol, subsolver_logger, inity, subproblem_modifier, subsolver_max_eval, subsolver_kwargs) where {T, V} at ~/.julia/packages/Percival/RpJYY/src/method.jl:73
Stacktrace:
 [1] kwerr(::NamedTuple{(:max_iter, :max_time, :max_eval, :atol, :rtol, :subsolver_logger, :subproblem_modifier, :subsolver_max_eval, :subsolver_kwargs), Tuple{Int64, Float64, Int64, Float64, Float64, Base.CoreLogging.NullLogger, NonconvexPercival.var"#4#5"{DataType, Int64}, Int64, Dict{Symbol, Int64}}}, ::Function, ::Val{:tron}, ::ADNLPModels.ADNLPModel{Float64, Vector{Float64}, Vector{Int64}})
   @ Base ./error.jl:165
 [2] _percival(nlp::ADNLPModels.ADNLPModel{Float64, Vector{Float64}, Vector{Int64}}; T::Type, μ::Float64, max_iter::Int64, max_time::Float64, max_eval::Int64, atol::Float64, rtol::Float64, ctol::Float64, first_order::Bool, memory::Int64, subsolver_logger::Base.CoreLogging.NullLogger, inity::Vector{Float64}, max_cgiter::Int64, subsolver_max_eval::Int64, kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
   @ NonconvexPercival ~/.julia/packages/NonconvexPercival/Y32FW/src/NonconvexPercival.jl:86
 [3] optimize!(workspace::NonconvexPercival.PercivalWorkspace{NonconvexCore.VecModel{NonconvexCore.Objective{NonconvexCore.var"#147#149"{typeof(loss), NonconvexCore.Unflatten{Tuple{Vector{Float64}}, NonconvexCore.var"#unflatten_to_Tuple#71"{Tuple{Int64}, Tuple{Int64}, Tuple{typeof(identity)}}}}, Base.RefValue{Float64}, Set{Symbol}}, NonconvexCore.VectorOfFunctions{Vector{NonconvexCore.EqConstraint}}, NonconvexCore.VectorOfFunctions{Vector{NonconvexCore.IneqConstraint}}, NonconvexCore.VectorOfFunctions{Vector{NonconvexCore.SDConstraint}}, Vector{Float64}, Vector{Float64}, Vector{Float64}}, ADNLPModels.ADNLPModel{Float64, Vector{Float64}, Vector{Int64}}, Vector{Float64}, PercivalOptions{NamedTuple{(:first_order, :memory, :inity), Tuple{Bool, Int64, typeof(ones)}}}, Base.RefValue{Int64}})
   @ NonconvexPercival ~/.julia/packages/NonconvexPercival/Y32FW/src/NonconvexPercival.jl:55
 [4] #optimize#144
   @ ~/.julia/packages/NonconvexCore/IPKCF/src/models/vec_model.jl:63 [inlined]
 [5] optimize(::Model{Vector{Any}}, ::PercivalAlg, ::Vector{Float64}; kwargs::Base.Pairs{Symbol, Any, Tuple{Symbol, Symbol}, NamedTuple{(:options, :convcriteria), Tuple{PercivalOptions{NamedTuple{(:first_order, :memory, :inity), Tuple{Bool, Int64, typeof(ones)}}}, KKTCriteria}}})
   @ NonconvexCore ~/.julia/packages/NonconvexCore/IPKCF/src/common.jl:233
 [6] top-level scope
   @ ~/test/bug_nonconvex.jl:28
in expression starting at /Users/forcebru/test/bug_nonconvex.jl:28
$

Apparently, percival(::Val{:tron}, ...) "got unsupported keyword argument subsolver_max_eval".

Versions

  • Julia 1.8.1
  • Percival 0.5.2
  • Nonconvex 2.1.1
  • NonconvexPercival 0.1.3
@mohamed82008
Copy link
Member

Hi, sorry for the late reply. Just saw this. The issue is now fixed and tested in master. I will make a new release shortly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants