Skip to content

Commit a20cc30

Browse files
committed
VI -> Vector{Int}
1 parent 16a7d23 commit a20cc30

File tree

2 files changed

+42
-42
lines changed

2 files changed

+42
-42
lines changed

src/nlp/batch_api.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Abstract base type for batched nonlinear optimization models.
1919
Each model in the batch has the same number of variables and constraints,
2020
and the sparsity patterns of the Jacobian and the Hessian of the Lagrangian are identical across the batch.
2121
"""
22-
abstract type AbstractBatchNLPModel{T,S,VI} end
22+
abstract type AbstractBatchNLPModel{T, S} end
2323

2424
"""
2525
bf = batch_obj(bnlp, bx)
@@ -75,9 +75,9 @@ function batch_cons! end
7575
7676
This function is only available if `bnlp.meta.jac_available` is set to `true`.
7777
"""
78-
function batch_jac_structure(bnlp::AbstractBatchNLPModel{T, S, VI}) where {T, S, VI}
79-
jrows = VI(undef, bnlp.meta.nnzj)
80-
jcols = VI(undef, bnlp.meta.nnzj)
78+
function batch_jac_structure(bnlp::AbstractBatchNLPModel{T, S}) where {T, S}
79+
jrows = Vector{Int}(undef, bnlp.meta.nnzj)
80+
jcols = Vector{Int}(undef, bnlp.meta.nnzj)
8181
batch_jac_structure!(bnlp, jrows, jcols)
8282
return (jrows, jcols)
8383
end
@@ -152,9 +152,9 @@ function batch_jtprod! end
152152
153153
This function is only available if `bnlp.meta.hess_available` is set to `true`.
154154
"""
155-
function batch_hess_structure(bnlp::AbstractBatchNLPModel{T,S,VI}) where {T, S, VI}
156-
hrows = VI(undef, bnlp.meta.nnzh)
157-
hcols = VI(undef, bnlp.meta.nnzh)
155+
function batch_hess_structure(bnlp::AbstractBatchNLPModel{T,S}) where {T, S}
156+
hrows = Vector{Int}(undef, bnlp.meta.nnzh)
157+
hcols = Vector{Int}(undef, bnlp.meta.nnzh)
158158
batch_hess_structure!(bnlp, hrows, hcols)
159159
return hrows, hcols
160160
end

src/nlp/batch_meta.jl

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export AbstractBatchNLPModelMeta, BatchNLPModelMeta
55
66
Abstract base type for metadata related to batched nonlinear optimization models.
77
"""
8-
abstract type AbstractBatchNLPModelMeta{T, S, VI} end
8+
abstract type AbstractBatchNLPModelMeta{T, S} end
99

1010
"""
1111
BatchNLPModelMeta <: AbstractBatchNLPModelMeta
@@ -70,31 +70,31 @@ The following keyword arguments are accepted:
7070
- `jfree`: indices of "free" constraints (there shouldn't be any)
7171
- `jinf`: indices of the visibly infeasible constraints
7272
"""
73-
struct BatchNLPModelMeta{T, S, VI} <: AbstractBatchNLPModelMeta{T, S, VI}
73+
struct BatchNLPModelMeta{T, S} <: AbstractBatchNLPModelMeta{T, S}
7474
nbatch::Int
7575
nvar::Int
7676
x0::S
7777
lvar::S
7878
uvar::S
7979

80-
ifix::VI
81-
ilow::VI
82-
iupp::VI
83-
irng::VI
84-
ifree::VI
85-
iinf::VI
80+
ifix::Vector{Int}
81+
ilow::Vector{Int}
82+
iupp::Vector{Int}
83+
irng::Vector{Int}
84+
ifree::Vector{Int}
85+
iinf::Vector{Int}
8686

8787
ncon::Int
8888
y0::S
8989
lcon::S
9090
ucon::S
9191

92-
jfix::VI
93-
jlow::VI
94-
jupp::VI
95-
jrng::VI
96-
jfree::VI
97-
jinf::VI
92+
jfix::Vector{Int}
93+
jlow::Vector{Int}
94+
jupp::Vector{Int}
95+
jrng::Vector{Int}
96+
jfree::Vector{Int}
97+
jinf::Vector{Int}
9898

9999
nnzj::Int
100100
nnzh::Int
@@ -111,7 +111,7 @@ struct BatchNLPModelMeta{T, S, VI} <: AbstractBatchNLPModelMeta{T, S, VI}
111111
hprod_available::Bool
112112
end
113113

114-
function BatchNLPModelMeta{T, S, VI}(
114+
function BatchNLPModelMeta{T, S}(
115115
nbatch::Int,
116116
nvar::Int;
117117
x0::S = fill!(S(undef, nvar * nbatch), zero(T)),
@@ -132,35 +132,35 @@ function BatchNLPModelMeta{T, S, VI}(
132132
jprod_available::Bool = (ncon > 0),
133133
jtprod_available::Bool = (ncon > 0),
134134
hprod_available::Bool = true,
135-
) where {T, S, VI}
135+
) where {T, S}
136136
if (nvar < 1) || (ncon < 0) || (nnzj < 0) || (nnzh < 0)
137137
error("Nonsensical dimensions")
138138
end
139139

140-
ifix = convert(VI, findall(lvar .== uvar))
141-
ilow = convert(VI, findall((lvar .> T(-Inf)) .& (uvar .== T(Inf))))
142-
iupp = convert(VI, findall((lvar .== T(-Inf)) .& (uvar .< T(Inf))))
143-
irng = convert(VI, findall((lvar .> T(-Inf)) .& (uvar .< T(Inf)) .& (lvar .< uvar)))
144-
ifree = convert(VI, findall((lvar .== T(-Inf)) .& (uvar .== T(Inf))))
145-
iinf = convert(VI, findall(lvar .> uvar))
140+
ifix = findall(lvar .== uvar)
141+
ilow = findall((lvar .> T(-Inf)) .& (uvar .== T(Inf)))
142+
iupp = findall((lvar .== T(-Inf)) .& (uvar .< T(Inf)))
143+
irng = findall((lvar .> T(-Inf)) .& (uvar .< T(Inf)) .& (lvar .< uvar))
144+
ifree = findall((lvar .== T(-Inf)) .& (uvar .== T(Inf)))
145+
iinf = findall(lvar .> uvar)
146146

147147
if ncon > 0
148-
jfix = convert(VI, findall(lcon .== ucon))
149-
jlow = convert(VI, findall((lcon .> T(-Inf)) .& (ucon .== T(Inf))))
150-
jupp = convert(VI, findall((lcon .== T(-Inf)) .& (ucon .< T(Inf))))
151-
jrng = convert(VI, findall((lcon .> T(-Inf)) .& (ucon .< T(Inf)) .& (lcon .< ucon)))
152-
jfree = convert(VI, findall((lcon .== T(-Inf)) .& (ucon .== T(Inf))))
153-
jinf = convert(VI, findall(lcon .> ucon))
148+
jfix = findall(lcon .== ucon)
149+
jlow = findall((lcon .> T(-Inf)) .& (ucon .== T(Inf)))
150+
jupp = findall((lcon .== T(-Inf)) .& (ucon .< T(Inf)))
151+
jrng = findall((lcon .> T(-Inf)) .& (ucon .< T(Inf)) .& (lcon .< ucon))
152+
jfree = findall((lcon .== T(-Inf)) .& (ucon .== T(Inf)))
153+
jinf = findall(lcon .> ucon)
154154
else
155-
jfix = VI(undef, 0)
156-
jlow = VI(undef, 0)
157-
jupp = VI(undef, 0)
158-
jrng = VI(undef, 0)
159-
jfree = VI(undef, 0)
160-
jinf = VI(undef, 0)
155+
jfix = Int[]
156+
jlow = Int[]
157+
jupp = Int[]
158+
jrng = Int[]
159+
jfree = Int[]
160+
jinf = Int[]
161161
end
162162

163-
BatchNLPModelMeta{T, S, VI}(
163+
BatchNLPModelMeta{T, S}(
164164
nbatch,
165165
nvar,
166166
x0,

0 commit comments

Comments
 (0)