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

Bump to NLPModels 0.21 #327

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ CUTEst_jll = "=2.0.6"
Combinatorics = "1.0"
DataStructures = "0.17, 0.18"
JSON = "0.8, 0.9, 0.10, 0.11, 0.12, 0.13, 0.14, 0.15, 0.16, 0.17, 0.18, 0.19, 0.20, 0.21"
NLPModels = "0.18, 0.19, 0.20"
NLPModels = "0.18, 0.19, 0.20, ^0.21.1"
julia = "^1.6.0"

[extras]
Expand Down
6 changes: 2 additions & 4 deletions src/julia_interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ function NLPModels.objcons!(
f,
c,
)
increment!(nlp, :neval_cons)
else
ccall(
dlsym(cutest_lib, :cutest_ufn_),
Expand All @@ -44,6 +43,7 @@ function NLPModels.objcons!(
)
end
increment!(nlp, :neval_obj)
increment!(nlp, :neval_cons)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, isn't this the source of the error? You're incrementing nevals_cons even on unconstrained problems.

More generally, this pull request is about bumping the NLPModels version, but it does other things. I suggest removing the other changes so we can isolate the problem (if any).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is part of the update to NLPModels 0.21. This was necessary to pass unit tests from NLPModelsTest that come along the new release.

Essentially, the idea is that we need to be consistent when calling cons! (and objcons!) on unconstrained problems.
I opened a new PR that updates link to better isolate the issue with the CI on macOS #328

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But what sense is there to incrementing neval_cons on an unconstrained problem?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the discussion goes back to this: https://github.com/JuliaSmoothOptimizers/NLPModels.jl/blob/bfd4ceafec9ad6f58cbf11a4a88f2e61767ce701/src/nlp/api.jl#L60
If a user is calling cons! on an unconstrained problem, should we increment or not? Currently, we do.

@cutest_error

return f[1], c
Expand Down Expand Up @@ -133,9 +133,7 @@ end
function NLPModels.obj(nlp::CUTEstModel, x::AbstractVector)
@lencheck nlp.meta.nvar x
f = objcons!(nlp, x, nlp.work)[1]
if nlp.meta.ncon > 0
decrement!(nlp, :neval_cons) # does not really count as a constraint eval
end
decrement!(nlp, :neval_cons) # does not really count as a constraint eval
return f
end

Expand Down
2 changes: 1 addition & 1 deletion test/test_julia.jl
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ function test_nlpinterface(nlp::CUTEstModel, comp_nlp::AbstractNLPModel)
else
@assert nlp.counters.neval_obj == 3
@assert nlp.counters.neval_grad == 3
@assert nlp.counters.neval_cons == 0
@assert nlp.counters.neval_cons == 1
@assert nlp.counters.neval_jac == 0
@assert nlp.counters.neval_jprod == 0
@assert nlp.counters.neval_jtprod == 0
Expand Down
Loading