Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/CUTEst.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ using JSON
import Libdl.dlsym
import REPL.TerminalMenus
import Base.format_bytes
import Base.RefValue
import Printf.@sprintf
import DataStructures: OrderedDict

Expand Down
15 changes: 9 additions & 6 deletions src/julia_interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -324,10 +324,14 @@ function NLPModels.jac_nln_structure!(
) where {T}
@lencheck nlp.meta.nln_nnzj rows cols
k = 1
for i in findall(j -> j in nlp.meta.nln, nlp.jrows)
rows[k] = nlp.jrows[i] - count(x < nlp.jrows[i] for x in nlp.meta.lin)
cols[k] = nlp.jcols[i]
k += 1
for index in eachindex(nlp.jrows)
jr = nlp.jrows[index]
if jr in nlp.meta.nln
offset = count(x < nlp.jrows[index] for x in nlp.meta.lin)
rows[k] = jr - offset
cols[k] = nlp.jcols[index]
k += 1
end
end
return rows, cols
end
Expand Down Expand Up @@ -759,15 +763,14 @@ function NLPModels.jth_hess_coord!(
@rangecheck 1 nlp.meta.ncon j
ref_j = nlp.index
ref_j[] = j
nnzh_output = Ref{Cint}()
cish(
T,
nlp.libsif,
nlp.status,
nlp.nvar,
x,
ref_j,
nnzh_output,
nlp.nnzh_jth,
nlp.nnzh,
vals,
nlp.hcols,
Expand Down
18 changes: 10 additions & 8 deletions src/model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@ mutable struct CUTEstModel{T} <: AbstractNLPModel{T, Vector{T}}
Jvar::Vector{Cint}

libsif::Ptr{Cvoid}
funit::Ref{Cint}
index::Ref{Cint}
nvar::Ref{Cint}
ncon::Ref{Cint}
nnzj::Ref{Cint}
nnzh::Ref{Cint}
f::Ref{T}
status::Ref{Cint}
funit::RefValue{Cint}
index::RefValue{Cint}
nvar::RefValue{Cint}
ncon::RefValue{Cint}
nnzj::RefValue{Cint}
nnzh::RefValue{Cint}
nnzh_jth::RefValue{Cint}
f::RefValue{T}
status::RefValue{Cint}
end

"""
Expand Down Expand Up @@ -326,6 +327,7 @@ function CUTEstModel{T}(
Ref{Cint}(ncon),
Ref{Cint}(nnzj),
Ref{Cint}(nnzh),
Ref{Cint}(),
Ref{T}(),
status,
)
Expand Down
1 change: 1 addition & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ include("test_core.jl")
include("test_julia.jl")
include("coverage.jl")
include("multiple_precision.jl")
include("test_allocations.jl")

for problem in problems
for T in (Float32, Float64, Float128)
Expand Down
12 changes: 12 additions & 0 deletions test/test_allocations.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# using CUTEst, NLPModelsTest, NLPModels, Quadmath

@testset "allocations -- $pb" for pb in ("BROWNDEN", "HS5", "HS6", "HS10", "HS11", "HS13", "HS14")
@testset "precision -- $T" for T in (Float32, Float64, Float128)
(T == Float128) && (Sys.ARCH == :aarch64) && Sys.islinux() && continue
nlp = CUTEstModel{T}(pb)
NLPModelsTest.test_zero_allocations(nlp; linear_api=true, exclude=[jac_op])
# mems = NLPModelsTest.test_allocs_nlpmodels(nlp; linear_api=true, exclude=[jac_op])
# display(mems)
finalize(nlp)
end
end
Loading