You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Accessing Linear and Nonlinear Constraints (Linear API)
8
+
9
+
This short tutorial illustrates how to inspect and operate on the constraint Jacobian using the "linear API" utilities available in the NLPModels ecosystem. The linear API is useful when a problem contains both linear and nonlinear constraints and you want to test or operate on the Jacobian and related linear operators without materializing dense matrices.
10
+
11
+
We demonstrate how to:
12
+
13
+
- evaluate the constraint vector;
14
+
- obtain the Jacobian sparsity and coordinates;
15
+
- build the `LinearOperator` representation of the Jacobian and use `mul!` to compute Jacobian-vector products; and
16
+
- compare direct `jprod!`/`jtprod!` evaluations with the operator-based `mul!`.
17
+
18
+
## Example using a test problem
19
+
20
+
We use a problem from `NLPModelsTest` which may contain both linear and nonlinear constraints. The `NLPModelsTest` package exposes a collection of example problems useful for experimenting with the APIs.
21
+
22
+
```julia
23
+
using NLPModelsTest, NLPModels, LinearOperators, LinearAlgebra
24
+
25
+
# Load a test problem (choose one that has constraints)
println("||J' * w (op) - J' * w (jtprod!)|| = ", norm(Jt_w_op - Jt_w_direct))
68
+
```
69
+
70
+
## Notes
71
+
72
+
- The `jac_op!`/`hess_op!` helpers produce `LinearOperator` objects (see `LinearOperators.jl`), which allow efficient `mul!` operations without assembling dense matrices.
73
+
- The testing utilities in this repository expose a `linear_api` option (for example in `test_allocs_nlpmodels`) that enables checking the linear-specific functions; see the `Test allocations of NLPModels` tutorial for details.
0 commit comments