Skip to content

perform QN updates in callback#358

Merged
dpo merged 6 commits into
mainfrom
callback-qn
Feb 20, 2026
Merged

perform QN updates in callback#358
dpo merged 6 commits into
mainfrom
callback-qn

Conversation

@dpo

@dpo dpo commented Feb 13, 2026

Copy link
Copy Markdown
Member

Performing QN updates in a callback allows for customized updates instead of generic updates.
A default callback with the expected update is provided.

Performing QN updates in a callback allows for customized updates
instead of generic updates.
A default callback with the expected update is provided.
@dpo dpo requested review from Copilot and tmigot and removed request for Copilot February 13, 2026 20:08
@dpo

dpo commented Feb 13, 2026

Copy link
Copy Markdown
Member Author

This PR is related to

@MaxenceGollier

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR moves quasi-Newton Hessian-approximation updates out of the TRUNK/TRON solver loops and into a dedicated per-iteration callback, enabling users to customize the update logic while providing a default implementation.

Changes:

  • Added a default callback_quasi_newton(model, solver, stats) implementation to perform quasi-Newton updates.
  • Updated trunk and tron to accept and invoke callback_quasi_newton, and to set step acceptance/rejection status in stats.
  • Updated documentation to describe the new callback and renamed the callback section to “Callbacks”.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 8 comments.

File Description
src/trunk.jl Adds callback_quasi_newton plumbing, introduces solver.s, and sets step status for accepted/rejected steps.
src/tron.jl Adds callback_quasi_newton plumbing and sets step status for accepted/rejected steps.
src/JSOSolvers.jl Introduces the default callback_quasi_newton implementation for quasi-Newton models.
docs/src/index.md Documents the new callback and updates callback-related wording/section naming.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/trunk.jl Outdated
Comment thread src/tron.jl Outdated
Comment thread src/tron.jl
Comment thread src/JSOSolvers.jl Outdated
Comment thread src/JSOSolvers.jl
Comment thread docs/src/index.md Outdated
Comment thread src/trunk.jl Outdated
Comment thread src/trunk.jl
@github-actions

Copy link
Copy Markdown
Contributor
Package name latest stable
FletcherPenaltySolver
JSOSuite
PartiallySeparableNLPModels
Percival

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Comment thread src/tron.jl Outdated
Comment thread src/trunk.jl
Comment thread src/trunk.jl

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread docs/src/index.md Outdated
Comment thread test/callback.jl Outdated
@github-actions

Copy link
Copy Markdown
Contributor
Package name latest stable
FletcherPenaltySolver
JSOSuite
PartiallySeparableNLPModels
Percival

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/JSOSolvers.jl Outdated
Comment thread docs/src/index.md Outdated
Comment thread test/callback.jl Outdated

@testset "Test quasi-Newton callback" begin
f(x) = (x[1] - 1)^2 + 4 * (x[2] - x[1]^2)^2
nlp = LBFGSModel(ADNLPModel(f, [-1.2; 1.0]))

Copilot AI Feb 18, 2026

Copy link

Choose a reason for hiding this comment

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

The test uses LBFGSModel which is not imported in this file. While it works when included from runtests.jl, the test would fail if run independently. Consider adding using NLPModelsModifiers to make the test file self-contained.

Copilot uses AI. Check for mistakes.
Comment thread test/callback.jl
Comment on lines +61 to +76
@testset "Test quasi-Newton callback" begin
f(x) = (x[1] - 1)^2 + 4 * (x[2] - x[1]^2)^2
nlp = LBFGSModel(ADNLPModel(f, [-1.2; 1.0]))
B0 = Matrix(hess_op(nlp, nlp.meta.x0))
nb_callback_calls = 0
function qn_cb(nlp, solver, stats)
nb_callback_calls += 1
default_callback_quasi_newton(nlp, solver, stats)
end
stats = with_logger(NullLogger()) do
trunk(nlp, callback_quasi_newton = qn_cb)
end
@test nb_callback_calls > 0
Bn = Matrix(hess_op(nlp, stats.solution))
@test !(all(B0 .== Bn))
end

Copilot AI Feb 18, 2026

Copy link

Choose a reason for hiding this comment

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

The quasi-Newton callback test only covers the trunk solver, but according to the documentation (line 119 in docs/src/index.md) and the code changes, tron also supports callback_quasi_newton. Consider adding a test for tron with a quasi-Newton model to ensure the callback works correctly for both solvers.

Copilot uses AI. Check for mistakes.

@MaxenceGollier MaxenceGollier left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Very nice @dpo, I only have one suggestion/comment.

Comment thread src/trunk.jl Outdated
Comment thread src/trunk.jl Outdated
@github-actions

Copy link
Copy Markdown
Contributor
Package name latest stable
FletcherPenaltySolver
JSOSuite
PartiallySeparableNLPModels
Percival

@tmigot tmigot left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good, thanks. I created a version 0.3.10 for SolverCore, so hopefully the tests should pass.

dpo and others added 2 commits February 20, 2026 09:36
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Maxence Gollier <134112149+MaxenceGollier@users.noreply.github.com>
@dpo

dpo commented Feb 20, 2026

Copy link
Copy Markdown
Member Author

Thank you both. I applied more comments from Copilot's review and submitted a release of NLPModelsModifiers. It should be green lights soon.

@github-actions

Copy link
Copy Markdown
Contributor
Package name latest stable
FletcherPenaltySolver
JSOSuite
PartiallySeparableNLPModels
Percival

@github-actions

Copy link
Copy Markdown
Contributor
Package name latest stable
FletcherPenaltySolver
JSOSuite
PartiallySeparableNLPModels
Percival

@dpo dpo closed this Feb 20, 2026
@dpo dpo reopened this Feb 20, 2026
@github-actions

Copy link
Copy Markdown
Contributor
Package name latest stable
FletcherPenaltySolver
JSOSuite
PartiallySeparableNLPModels
Percival

@dpo dpo merged commit 0bfa77f into main Feb 20, 2026
31 of 46 checks passed
@dpo dpo deleted the callback-qn branch February 20, 2026 17:43
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

Successfully merging this pull request may close these issues.

4 participants