Skip to content

Commit df4e872

Browse files
authored
Merge branch 'main' into separate-api-defaults
2 parents c54b329 + 776723a commit df4e872

File tree

17 files changed

+896
-615
lines changed

17 files changed

+896
-615
lines changed

.github/workflows/breakage.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,14 @@ jobs:
159159
fi
160160
done >> summary.md
161161
162+
- name: Display summary in CI logs
163+
run: |
164+
echo "### Breakage Summary" >> $GITHUB_STEP_SUMMARY
165+
cat breakage/summary.md >> $GITHUB_STEP_SUMMARY
166+
162167
- name: PR comment with file
163-
uses: actions/github-script@v6
168+
if: github.event.pull_request.head.repo.fork == false
169+
uses: actions/github-script@main
164170
with:
165171
github-token: ${{ secrets.GITHUB_TOKEN }}
166172
script: |

LICENSE

Lines changed: 373 additions & 0 deletions
Large diffs are not rendered by default.

LICENSE.md

Lines changed: 0 additions & 379 deletions
This file was deleted.

Project.toml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "NLPModels"
22
uuid = "a4795742-8479-5a88-8948-cc11e1c8c1a6"
3-
version = "0.21.5"
3+
version = "0.21.6"
44

55
[deps]
66
FastClosures = "9aa1b823-49e4-5ca5-8b0f-3971ec8bab6a"
@@ -11,8 +11,12 @@ SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
1111

1212
[compat]
1313
FastClosures = "0.3.0"
14+
LinearAlgebra = "1.10"
1415
LinearOperators = "2"
15-
julia = "1.6.0"
16+
Printf = "1.10"
17+
SparseArrays = "1.10"
18+
Test = "1.10"
19+
julia = "1.10"
1620

1721
[extras]
1822
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

README.md

Lines changed: 40 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -84,40 +84,46 @@ The complete list of methods that an interface may implement can be found in the
8484

8585
`NLPModelMeta` objects have the following attributes (with `S <: AbstractVector`):
8686

87-
Attribute | Type | Notes
88-
------------|--------------------|------------------------------------
89-
`nvar` | `Int ` | number of variables
90-
`x0 ` | `S` | initial guess
91-
`lvar` | `S` | vector of lower bounds
92-
`uvar` | `S` | vector of upper bounds
93-
`ifix` | `Vector{Int}` | indices of fixed variables
94-
`ilow` | `Vector{Int}` | indices of variables with lower bound only
95-
`iupp` | `Vector{Int}` | indices of variables with upper bound only
96-
`irng` | `Vector{Int}` | indices of variables with lower and upper bound (range)
97-
`ifree` | `Vector{Int}` | indices of free variables
98-
`iinf` | `Vector{Int}` | indices of visibly infeasible bounds
99-
`ncon` | `Int ` | total number of general constraints
100-
`nlin ` | `Int ` | number of linear constraints
101-
`nnln` | `Int ` | number of nonlinear general constraints
102-
`y0 ` | `S` | initial Lagrange multipliers
103-
`lcon` | `S` | vector of constraint lower bounds
104-
`ucon` | `S` | vector of constraint upper bounds
105-
`lin ` | `Vector{Int}` | indices of linear constraints
106-
`nln` | `Vector{Int}` | indices of nonlinear constraints
107-
`jfix` | `Vector{Int}` | indices of equality constraints
108-
`jlow` | `Vector{Int}` | indices of constraints of the form c(x) ≥ cl
109-
`jupp` | `Vector{Int}` | indices of constraints of the form c(x) ≤ cu
110-
`jrng` | `Vector{Int}` | indices of constraints of the form cl ≤ c(x) ≤ cu
111-
`jfree` | `Vector{Int}` | indices of "free" constraints (there shouldn't be any)
112-
`jinf` | `Vector{Int}` | indices of the visibly infeasible constraints
113-
`nnzo` | `Int ` | number of nonzeros in the gradient
114-
`nnzh` | `Int ` | number of nonzeros in the sparse Hessian
115-
`nnzj` | `Int ` | number of nonzeros in the sparse Jacobian
116-
`lin_nnzj` | `Int ` | number of nonzeros in the linear part of sparse Jacobian
117-
`nln_nnzj` | `Int ` | number of nonzeros in the nonlinear part of sparse Jacobian
118-
`minimize` | `Bool ` | true if `optimize == minimize`
119-
`islp` | `Bool ` | true if the problem is a linear program
120-
`name` | `String` | problem name
87+
Attribute | Type | Notes
88+
-------------------|---------------|------------------------------------
89+
`nvar` | `Int` | number of variables
90+
`x0 ` | `S` | initial guess
91+
`lvar` | `S` | vector of lower bounds
92+
`uvar` | `S` | vector of upper bounds
93+
`ifix` | `Vector{Int}` | indices of fixed variables
94+
`ilow` | `Vector{Int}` | indices of variables with lower bound only
95+
`iupp` | `Vector{Int}` | indices of variables with upper bound only
96+
`irng` | `Vector{Int}` | indices of variables with lower and upper bound (range)
97+
`ifree` | `Vector{Int}` | indices of free variables
98+
`iinf` | `Vector{Int}` | indices of visibly infeasible bounds
99+
`ncon` | `Int` | total number of general constraints
100+
`nlin ` | `Int` | number of linear constraints
101+
`nnln` | `Int` | number of nonlinear general constraints
102+
`y0 ` | `S` | initial Lagrange multipliers
103+
`lcon` | `S` | vector of constraint lower bounds
104+
`ucon` | `S` | vector of constraint upper bounds
105+
`lin ` | `Vector{Int}` | indices of linear constraints
106+
`nln` | `Vector{Int}` | indices of nonlinear constraints
107+
`jfix` | `Vector{Int}` | indices of equality constraints
108+
`jlow` | `Vector{Int}` | indices of constraints of the form c(x) ≥ cl
109+
`jupp` | `Vector{Int}` | indices of constraints of the form c(x) ≤ cu
110+
`jrng` | `Vector{Int}` | indices of constraints of the form cl ≤ c(x) ≤ cu
111+
`jfree` | `Vector{Int}` | indices of "free" constraints (there shouldn't be any)
112+
`jinf` | `Vector{Int}` | indices of the visibly infeasible constraints
113+
`nnzo` | `Int` | number of nonzeros in the gradient
114+
`nnzj` | `Int` | number of nonzeros in the sparse Jacobian
115+
`lin_nnzj` | `Int` | number of nonzeros in the sparse linear constraints Jacobian
116+
`nln_nnzj` | `Int` | number of nonzeros in the sparse nonlinear constraints Jacobian
117+
`nnzh` | `Int` | number of nonzeros in the lower triangular part of the sparse Hessian of the Lagrangian
118+
`minimize` | `Bool` | true if `optimize == minimize`
119+
`islp` | `Bool` | true if the problem is a linear program
120+
`name` | `String` | problem name
121+
`grad_available` | `Bool` | true if the gradient of the objective is available
122+
`jac_available` | `Bool` | true if the sparse Jacobian of the constraints is available
123+
`hess_available` | `Bool` | true if the sparse Hessian of the Lagrangian is available
124+
`jprod_available` | `Bool` | true if the Jacobian-vector product `J * v` is available
125+
`jtprod_available` | `Bool` | true if the transpose Jacobian-vector product `J' * v` is available
126+
`hprod_available` | `Bool` | true if the Hessian-vector product of the Lagrangian `H * v` is available
121127

122128
# Bug reports and discussions
123129

docs/Project.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
[deps]
2-
ADNLPModels = "54578032-b7ea-4c30-94aa-7cbd1cce6c9a"
32
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
43
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
54
NLPModels = "a4795742-8479-5a88-8948-cc11e1c8c1a6"
65

76
[compat]
8-
ADNLPModels = "0.8"
97
Documenter = "1.0"

docs/src/api.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ NLPModels instances.
4545
| ``J(x)`` | [`jac_lin`](@ref), [`jac_nln`](@ref), [`jac`](@ref), [`jac_lin_op`](@ref), [`jac_lin_op!`](@ref), [`jac_nln_op`](@ref), [`jac_nln_op!`](@ref),[`jac_op`](@ref), [`jac_op!`](@ref), [`jac_lin_coord`](@ref), [`jac_lin_coord!`](@ref), [`jac_nln_coord`](@ref), [`jac_nln_coord!`](@ref), [`jac_coord`](@ref), [`jac_coord!`](@ref), [`jac_lin_structure`](@ref), [`jac_lin_structure!`](@ref), [`jac_nln_structure`](@ref), [`jac_nln_structure!`](@ref), [`jac_structure`](@ref), [`jprod_lin`](@ref), [`jprod_lin!`](@ref), [`jprod_nln`](@ref), [`jprod_nln!`](@ref), [`jprod`](@ref), [`jprod!`](@ref), [`jtprod_lin`](@ref), [`jtprod_lin!`](@ref), [`jtprod_nln`](@ref), [`jtprod_nln!`](@ref), [`jtprod`](@ref), [`jtprod!`](@ref) |
4646
| ``\nabla^2 L(x,y)`` | [`hess`](@ref), [`hess_op`](@ref), [`hess_coord`](@ref), [`hess_coord!`](@ref), [`hess_structure`](@ref), [`hess_structure!`](@ref), [`hprod`](@ref), [`hprod!`](@ref), [`jth_hprod`](@ref), [`jth_hprod!`](@ref), [`jth_hess`](@ref), [`jth_hess_coord`](@ref), [`jth_hess_coord!`](@ref), [`ghjvprod`](@ref), [`ghjvprod!`](@ref) |
4747

48+
If only a subset of the functions listed above is implemented, you can indicate which ones are not available when creating the [`NLPModelMeta`](@ref), using the keyword arguments
49+
`grad_available`, `jac_available`, `hess_available`, `jprod_available`, `jtprod_available`, and `hprod_available`.
50+
4851
## [API for NLSModels](@id nls-api)
4952

5053
For the Nonlinear Least Squares models, ``f(x) = \tfrac{1}{2} \Vert F(x)\Vert^2``,
@@ -59,3 +62,5 @@ and its derivatives. Namely,
5962
| ``F(x)`` | [`residual`](@ref), [`residual!`](@ref) |
6063
| ``J_F(x)`` | [`jac_residual`](@ref), [`jac_coord_residual`](@ref), [`jac_coord_residual!`](@ref), [`jac_structure_residual`](@ref), [`jac_structure_residual!`](@ref), [`jprod_residual`](@ref), [`jprod_residual!`](@ref), [`jtprod_residual`](@ref), [`jtprod_residual!`](@ref), [`jac_op_residual`](@ref), [`jac_op_residual!`](@ref) |
6164
| ``\nabla^2 F_i(x)`` | [`hess_residual`](@ref), [`hess_coord_residual`](@ref), [`hess_coord_residual!`](@ref), [`hess_structure_residual`](@ref), [`hess_structure_residual!`](@ref), [`jth_hess_residual`](@ref), [`jth_hess_residual_coord`](@ref), [`jth_hess_residual_coord!`](@ref), [`hprod_residual`](@ref), [`hprod_residual!`](@ref), [`hess_op_residual`](@ref), [`hess_op_residual!`](@ref) |
65+
66+
If only a subset of the functions listed above is implemented, you can indicate which ones are not available when creating the [`NLSMeta`](@ref), using the keyword arguments `jac_residual_available`, `hess_residual_available`, `jprod_residual_available`, `jtprod_residual_available`, and `hprod_residual_available`.

docs/src/guidelines.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,11 @@ The following functions should be defined:
6868
- `cons_nln!(nlp, x, c)`
6969
- `jac_lin_structure!(nlp, jrows, jcols)`
7070
- `jac_nln_structure!(nlp, jrows, jcols)`
71-
- `jac_lin_coord!(nlp, jvals)`
71+
- `jac_lin_coord!(nlp, x, jvals)`
7272
- `jac_nln_coord!(nlp, x, jvals)`
73-
- `jprod_lin!(nlp, v, Jv)`
73+
- `jprod_lin!(nlp, x, v, Jv)`
7474
- `jprod_nln!(nlp, x, v, Jv)`
75-
- `jtprod_lin!(nlp, v, Jtv)`
75+
- `jtprod_lin!(nlp, x, v, Jtv)`
7676
- `jtprod_nln!(nlp, x, v, Jtv)`
7777
- `hess_coord!(nlp, x, y, hvals; obj_weight=1)`
7878
- `hprod!(nlp, x, y, v, Hv; obj_weight=1)`
@@ -82,6 +82,15 @@ The indices of linear and nonlinear constraints are respectively available in `n
8282
If your model uses only linear (resp. nonlinear) constraints, then it suffices to implement the `*_lin` (resp. `*_nln`) functions.
8383
Alternatively, one could implement only the functions without the suffixes `_nln!` (e.g., only `cons!`), but this might run into errors with tools differentiating linear and nonlinear constraints.
8484

85+
## [Availability of the API](@id availability-api)
86+
87+
If only a subset of the functions listed above is implemented, you can indicate which ones are not available when creating the [`NLPModelMeta`](@ref), using the keyword arguments
88+
`grad_available`, `jac_available`, `hess_available`, `jprod_available`, `jtprod_available`, and `hprod_available`.
89+
90+
By default, `grad_available`, `hess_available`, and `hprod_available` are set to `true`.
91+
For constrained problems (`ncon > 0`), the fields `jac_available`, `jprod_available`, and `jtprod_available` are also set to `true`.
92+
For unconstrained problems (`ncon == 0`), they default to `false`.
93+
8594
## [Expected behaviour](@id expected-behaviour)
8695

8796
The following is a non-exhaustive list of expected behaviour for methods.

docs/src/index.md

Lines changed: 40 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -79,40 +79,46 @@ See the [Models](@ref), the [Tools](@ref tools-section), or the [API](@ref).
7979

8080
`NLPModelMeta` objects have the following attributes (with `S <: AbstractVector`):
8181

82-
Attribute | Type | Notes
83-
------------|--------------------|------------------------------------
84-
`nvar` | `Int ` | number of variables
85-
`x0 ` | `S` | initial guess
86-
`lvar` | `S` | vector of lower bounds
87-
`uvar` | `S` | vector of upper bounds
88-
`ifix` | `Vector{Int}` | indices of fixed variables
89-
`ilow` | `Vector{Int}` | indices of variables with lower bound only
90-
`iupp` | `Vector{Int}` | indices of variables with upper bound only
91-
`irng` | `Vector{Int}` | indices of variables with lower and upper bound (range)
92-
`ifree` | `Vector{Int}` | indices of free variables
93-
`iinf` | `Vector{Int}` | indices of visibly infeasible bounds
94-
`ncon` | `Int ` | total number of general constraints
95-
`nlin ` | `Int ` | number of linear constraints
96-
`nnln` | `Int ` | number of nonlinear general constraints
97-
`y0 ` | `S` | initial Lagrange multipliers
98-
`lcon` | `S` | vector of constraint lower bounds
99-
`ucon` | `S` | vector of constraint upper bounds
100-
`lin ` | `Vector{Int}` | indices of linear constraints
101-
`nln` | `Vector{Int}` | indices of nonlinear constraints
102-
`jfix` | `Vector{Int}` | indices of equality constraints
103-
`jlow` | `Vector{Int}` | indices of constraints of the form c(x) ≥ cl
104-
`jupp` | `Vector{Int}` | indices of constraints of the form c(x) ≤ cu
105-
`jrng` | `Vector{Int}` | indices of constraints of the form cl ≤ c(x) ≤ cu
106-
`jfree` | `Vector{Int}` | indices of "free" constraints (there shouldn't be any)
107-
`jinf` | `Vector{Int}` | indices of the visibly infeasible constraints
108-
`nnzo` | `Int ` | number of nonzeros in the gradient
109-
`nnzj` | `Int ` | number of nonzeros in the sparse Jacobian
110-
`lin_nnzj` | `Int ` | number of nonzeros in the sparse linear constraints Jacobian
111-
`nln_nnzj` | `Int ` | number of nonzeros in the sparse nonlinear constraints Jacobian
112-
`nnzh` | `Int ` | number of nonzeros in the lower triangular part of the sparse Hessian of the Lagrangian
113-
`minimize` | `Bool ` | true if `optimize == minimize`
114-
`islp` | `Bool ` | true if the problem is a linear program
115-
`name` | `String` | problem name
82+
Attribute | Type | Notes
83+
-------------------|---------------|------------------------------------
84+
`nvar` | `Int` | number of variables
85+
`x0 ` | `S` | initial guess
86+
`lvar` | `S` | vector of lower bounds
87+
`uvar` | `S` | vector of upper bounds
88+
`ifix` | `Vector{Int}` | indices of fixed variables
89+
`ilow` | `Vector{Int}` | indices of variables with lower bound only
90+
`iupp` | `Vector{Int}` | indices of variables with upper bound only
91+
`irng` | `Vector{Int}` | indices of variables with lower and upper bound (range)
92+
`ifree` | `Vector{Int}` | indices of free variables
93+
`iinf` | `Vector{Int}` | indices of visibly infeasible bounds
94+
`ncon` | `Int` | total number of general constraints
95+
`nlin ` | `Int` | number of linear constraints
96+
`nnln` | `Int` | number of nonlinear general constraints
97+
`y0 ` | `S` | initial Lagrange multipliers
98+
`lcon` | `S` | vector of constraint lower bounds
99+
`ucon` | `S` | vector of constraint upper bounds
100+
`lin ` | `Vector{Int}` | indices of linear constraints
101+
`nln` | `Vector{Int}` | indices of nonlinear constraints
102+
`jfix` | `Vector{Int}` | indices of equality constraints
103+
`jlow` | `Vector{Int}` | indices of constraints of the form c(x) ≥ cl
104+
`jupp` | `Vector{Int}` | indices of constraints of the form c(x) ≤ cu
105+
`jrng` | `Vector{Int}` | indices of constraints of the form cl ≤ c(x) ≤ cu
106+
`jfree` | `Vector{Int}` | indices of "free" constraints (there shouldn't be any)
107+
`jinf` | `Vector{Int}` | indices of the visibly infeasible constraints
108+
`nnzo` | `Int` | number of nonzeros in the gradient
109+
`nnzj` | `Int` | number of nonzeros in the sparse Jacobian
110+
`lin_nnzj` | `Int` | number of nonzeros in the sparse linear constraints Jacobian
111+
`nln_nnzj` | `Int` | number of nonzeros in the sparse nonlinear constraints Jacobian
112+
`nnzh` | `Int` | number of nonzeros in the lower triangular part of the sparse Hessian of the Lagrangian
113+
`minimize` | `Bool` | true if `optimize == minimize`
114+
`islp` | `Bool` | true if the problem is a linear program
115+
`name` | `String` | problem name
116+
`grad_available` | `Bool` | true if the gradient of the objective is available
117+
`jac_available` | `Bool` | true if the sparse Jacobian of the constraints is available
118+
`hess_available` | `Bool` | true if the sparse Hessian of the Lagrangian is available
119+
`jprod_available` | `Bool` | true if the Jacobian-vector product `J * v` is available
120+
`jtprod_available` | `Bool` | true if the transpose Jacobian-vector product `J' * v` is available
121+
`hprod_available` | `Bool` | true if the Hessian-vector product of the Lagrangian `H * v` is available
116122

117123
## License
118124

docs/src/tools.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ After calling one the [API](@ref) functions to get a function value, the
66
number of times that function was called is stored inside the
77
`NLPModel`. For instance
88

9-
```@example
9+
```julia
1010
using ADNLPModels, LinearAlgebra, NLPModels
1111
nlp = ADNLPModel(x -> dot(x, x), zeros(2))
1212
for i = 1:100
@@ -52,7 +52,7 @@ least squares models (the ones with `residual` below).
5252
To get the sum of all counters except `cons`, `jac`, `jprod` and `jtprod` called for a problem, use
5353
[`sum_counters`](@ref).
5454

55-
```@example
55+
```julia
5656
using ADNLPModels, LinearAlgebra, NLPModels
5757
nlp = ADNLPModel(x -> dot(x, x), zeros(2))
5858
obj(nlp, rand(2))

0 commit comments

Comments
 (0)