Skip to content

Support dense Jacobians and Hessians#537

Merged
amontoison merged 11 commits into
mainfrom
am/sparse
Feb 14, 2026
Merged

Support dense Jacobians and Hessians#537
amontoison merged 11 commits into
mainfrom
am/sparse

Conversation

@amontoison

Copy link
Copy Markdown
Member

close #458
cc @klamike @frapac @sshin23

Reference: #376

It can replace the PRs #378 and #512

Comment thread src/nlp/meta.jl Outdated
Comment thread src/nlp/api.jl Outdated
@amontoison amontoison mentioned this pull request Feb 3, 2026
6 tasks
Comment thread src/nlp/api.jl
Comment on lines 310 to +313
Jx = jac(nlp, x)

Evaluate ``J(x)``, the constraints Jacobian at `x` as a sparse matrix.
This function is only available if `nlp.meta.jac_available` is set to `true`.
This function is only available when both `nlp.meta.jac_available` and `nlp.meta.sparse_jacobian` are set to `true`.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

why not have this return a dense matrix when sparse_jacobian is false?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Because we don't know the format of the dense matrix.
S is the storage type of the vectors in the model, not the matrix format for the Jacobian / Hessian.

@github-actions

github-actions Bot commented Feb 3, 2026

Copy link
Copy Markdown
Contributor
Package name latest stable
ADNLPModels
AdaptiveRegularization
AmplNLReader
BundleAdjustmentModels
CUTEst
CaNNOLeS
DCISolver
FletcherPenaltySolver
FluxNLPModels
JSOSolvers
JSOSuite
LLSModels
ManualNLPModels
NLPModelsIpopt
NLPModelsJuMP
NLPModelsKnitro
NLPModelsModifiers
NLPModelsTest
NLSProblems
PDENLPModels
PartiallySeparableNLPModels
PartiallySeparableSolvers
Percival
QuadraticModels
RegularizedOptimization
RegularizedProblems
SolverBenchmark
SolverTest
SolverTools

Comment thread docs/src/index.md
Comment thread src/nlp/api.jl Outdated
Evaluate ``J(x)``, the constraints Jacobian at `x` in sparse coordinate format, rewriting `vals`.
Evaluate ``J(x)``, the constraints Jacobian at `x`, overwriting `vals`.
It uses a sparse coordinate format when `nlp.meta.sparse_jacobian` is set to `true`.
Otherwise, `vals` is expected to be a dense matrix.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I think it's slightly misleading, as the name _coord implies that the Jacobian is returned as a COO matrix, not a dense matrix

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Hum, you are right.
Maybe we go back to the original issue and we need to add a jac_dense! and hess_dense! for consistency with the sparse API.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I updated the API for jac_dense! and hess_dense!.

Comment thread docs/src/guidelines.md Outdated
@amontoison amontoison requested a review from frapac February 9, 2026 03:44
@amontoison

Copy link
Copy Markdown
Member Author

@frapac May I ask you another review?

Comment thread docs/src/guidelines.md Outdated
@amontoison amontoison merged commit 75ee805 into main Feb 14, 2026
13 of 14 checks passed
@amontoison amontoison deleted the am/sparse branch February 14, 2026 05:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement AbstractDenseNLPModel

3 participants