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

non-informative error message for invalid constraints #129

Closed
tpapp opened this issue Apr 18, 2023 · 1 comment
Closed

non-informative error message for invalid constraints #129

tpapp opened this issue Apr 18, 2023 · 1 comment

Comments

@tpapp
Copy link

tpapp commented Apr 18, 2023

using ADNLPModels, Percival
nlp = ADNLPModel(
  x -> sum(abs2, x),            # objective
  [2.0, 2.0],                   # x0
  x -> [sum(x) - 1],            # constraint
  [-Inf],                       # lvar
  [Inf],                        # uvar
)
output = percival(nlp, verbose = 1)

results in

ERROR: DimensionError: Input lvar should have length 3 not 2
Stacktrace:
 [1] macro expansion
   @ ~/.julia/packages/NLPModels/XBcWL/src/nlp/utils.jl:37 [inlined]
 [2] NLPModels.NLPModelMeta{Float64, Vector{Float64}}(nvar::Int64; x0::Vector{Float64}, lvar::Vector{Float64}, uvar::Vector{Float64}, nlvb::Int64, nlvo::Int64, nlvc::Int64, ncon::Int64, y0::Vector{Float64}, lcon::Vector{Float64}, ucon::Vector{Float64}, nnzo::Int64, nnzj::Int64, lin_nnzj::Int64, nln_nnzj::Int64, nnzh::Int64, lin::Vector{Int64}, minimize::Bool, islp::Bool, name::String)
   @ NLPModels ~/.julia/packages/NLPModels/XBcWL/src/nlp/meta.jl:143
 [3] #NLPModelMeta#63
   @ ~/.julia/packages/NLPModels/XBcWL/src/nlp/meta.jl:216 [inlined]
 [4] slack_meta(meta::NLPModels.NLPModelMeta{Float64, Vector{Float64}}; name::String)
   @ NLPModelsModifiers ~/.julia/packages/NLPModelsModifiers/QR0za/src/slack-model.jl:134
 [5] #SlackModel#27
   @ ~/.julia/packages/NLPModelsModifiers/QR0za/src/slack-model.jl:159 [inlined]
 [6] NLPModelsModifiers.SlackModel(model::ADNLPModel{Float64, Vector{Float64}, Vector{Int64}})
   @ NLPModelsModifiers ~/.julia/packages/NLPModelsModifiers/QR0za/src/slack-model.jl:154
 [7] percival(::Val{:ineq}, nlp::ADNLPModel{Float64, Vector{Float64}, Vector{Int64}}; x::Vector{Float64}, kwargs::Base.Pairs{Symbol, Int64, Tuple{Symbol}, NamedTuple{(:verbose,), Tuple{Int64}}})
   @ Percival ~/.julia/packages/Percival/mlZ4N/src/method.jl:57
 [8] percival(nlp::ADNLPModel{Float64, Vector{Float64}, Vector{Int64}}; kwargs::Base.Pairs{Symbol, Int64, Tuple{Symbol}, NamedTuple{(:verbose,), Tuple{Int64}}})
   @ Percival ~/.julia/packages/Percival/mlZ4N/src/method.jl:14
 [9] top-level scope
   @ REPL[6]:1

This is of course user error (meaningless constraints), lcon = ucon = [0.0] works. But the error message is misleading.

version information

julia> VERSION
v"1.8.5"

(jl_0RwdKo) pkg> st
Status `/tmp/jl_0RwdKo/Project.toml`
  [54578032] ADNLPModels v0.6.1
  [01435c0c] Percival v0.6.5
@tmigot
Copy link
Member

tmigot commented Sep 5, 2024

After this PR
JuliaSmoothOptimizers/NLPModelsModifiers.jl#125
we get

julia> output = percival(nlp, verbose = 1)
ERROR: NLPModels with constraints of the form -∞ ≤ cᵢ(x) ≤ ∞ are not supported by slack models.

@tmigot tmigot closed this as completed Sep 5, 2024
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