Skip to content

Commit 4b6d2bb

Browse files
committed
Add availability flags in NLPModelMeta
1 parent c83e702 commit 4b6d2bb

File tree

2 files changed

+74
-38
lines changed

2 files changed

+74
-38
lines changed

docs/src/index.md

Lines changed: 39 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -79,40 +79,45 @@ 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+
`jacobian_available` | `Bool` | true if the sparse Jacobian of the constraints is available
117+
`hessian_available` | `Bool` | true if the sparse Hessian of the Lagrangian is available
118+
`Jv_available` | `Bool` | true if the Jacobian-vector product `J * v` is available
119+
`Jtv_available` | `Bool` | true if the transpose Jacobian-vector product `J' * v` is available
120+
`Hv_available` | `Bool` | true if the Hessian-vector product of the objective or Lagrangian `H * v` is available
116121

117122
## License
118123

src/nlp/meta.jl

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ The following keyword arguments are accepted:
5151
- `minimize`: true if optimize == minimize
5252
- `islp`: true if the problem is a linear program
5353
- `name`: problem name
54+
- `jacobian_available`: indicates whether the sparse Jacobian of the constraints is available
55+
- `hessian_available`: indicates whether the sparse Hessian of the Lagrangian is available
56+
- `Jv_available`: indicates whether the Jacobian-vector product `J * v` is available
57+
- `Jtv_available`: indicates whether the transpose Jacobian-vector product `J' * v` is available
58+
- `Hv_available`: indicates whether the Hessian-vector product of the objective or Lagrangian `H * v` is available
5459
5560
`NLPModelMeta` also contains the following attributes, which are computed from the variables above:
5661
- `nvar`: number of variables
@@ -114,6 +119,12 @@ struct NLPModelMeta{T, S} <: AbstractNLPModelMeta{T, S}
114119
minimize::Bool
115120
islp::Bool
116121
name::String
122+
123+
jacobian_available::Bool
124+
hessian_available::Bool
125+
Jv_available::Bool
126+
Jtv_available::Bool
127+
Hv_available::Bool
117128
end
118129

119130
function NLPModelMeta{T, S}(
@@ -134,9 +145,14 @@ function NLPModelMeta{T, S}(
134145
nln_nnzj = nnzj - lin_nnzj,
135146
nnzh = nvar * (nvar + 1) / 2,
136147
lin = Int[],
137-
minimize = true,
138-
islp = false,
148+
minimize::Bool = true,
149+
islp::Bool = false,
139150
name = "Generic",
151+
jacobian_available::Bool = true,
152+
hessian_available::Bool = true,
153+
Jv_available::Bool = true,
154+
Jtv_available::Bool = true,
155+
Hv_available::Bool = true,
140156
) where {T, S}
141157
if (nvar < 1) || (ncon < 0)
142158
error("Nonsensical dimensions")
@@ -213,6 +229,11 @@ function NLPModelMeta{T, S}(
213229
minimize,
214230
islp,
215231
name,
232+
jacobian_available,
233+
hessian_available,
234+
Jv_available,
235+
Jtv_available,
236+
Hv_available,
216237
)
217238
end
218239

@@ -238,9 +259,14 @@ function NLPModelMeta(
238259
nln_nnzj = meta.nln_nnzj,
239260
nnzh = meta.nnzh,
240261
lin = meta.lin,
241-
minimize = meta.minimize,
242-
islp = meta.islp,
262+
minimize::Bool = meta.minimize,
263+
islp::Bool = meta.islp,
243264
name = meta.name,
265+
jacobian_available::Bool = meta.jacobian_available,
266+
hessian_available::Bool = meta.hessian_available,
267+
Jv_available::Bool = meta.Jv_available,
268+
Jtv_available::Bool = meta.Jtv_available,
269+
Hv_available::Bool = meta.Hv_available,
244270
) where {T, S}
245271
NLPModelMeta{T, S}(
246272
nvar,
@@ -263,6 +289,11 @@ function NLPModelMeta(
263289
minimize = minimize,
264290
islp = islp,
265291
name = name,
292+
jacobian_available = jacobian_available,
293+
hessian_available = hessian_available,
294+
Jv_available = Jv_available,
295+
Jtv_available = Jtv_available,
296+
Hv_available = Hv_available,
266297
)
267298
end
268299

0 commit comments

Comments
 (0)