Skip to content

Commit 2e70916

Browse files
geoffroylecontedpo
authored andcommitted
increase coverage
1 parent 736e4fd commit 2e70916

File tree

2 files changed

+43
-1
lines changed

2 files changed

+43
-1
lines changed

src/qpmodel.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ function NLPModels.jac_coord!(
398398
vals::AbstractVector
399399
) where {T, S, M1, M2 <: SparseMatrixCSC}
400400
NLPModels.increment!(qp, :neval_jac)
401-
fill_coord!(qp.data.H, vals, one(T))
401+
fill_coord!(qp.data.A, vals, one(T))
402402
return vals
403403
end
404404

test/runtests.jl

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,4 +205,46 @@ end
205205
@test objgrad(SMLO, x)[2] objgrad(SM, x)[2]
206206
end
207207

208+
@testset "struct and coord CSC" begin
209+
H = [
210+
6.0 2.0 1.0
211+
2.0 5.0 2.0
212+
1.0 2.0 4.0
213+
]
214+
c = [-8.0; -3; -3]
215+
A = [
216+
1.0 0.0 1.0
217+
0.0 2.0 1.0
218+
]
219+
b = [0.0; 3]
220+
l = [0.0; 0; 0]
221+
u = [Inf; Inf; Inf]
222+
T = eltype(c)
223+
qp = QuadraticModel(
224+
c,
225+
tril(sparse(H)),
226+
A = sparse(A),
227+
lcon = b,
228+
ucon = b,
229+
lvar = l,
230+
uvar = u,
231+
c0 = 0.0,
232+
name = "QM",
233+
)
234+
235+
x = zeros(3)
236+
rowsH, colsH = hess_structure(qp)
237+
valsH = hess_coord(qp, x)
238+
rowsHtrue, colsHtrue, valsHtrue = findnz(tril(sparse(H)))
239+
@test rowsH == rowsHtrue
240+
@test colsH == colsHtrue
241+
@test valsH == valsHtrue
242+
rowsA, colsA = jac_structure(qp)
243+
valsA = jac_coord(qp, x)
244+
rowsAtrue, colsAtrue, valsAtrue = findnz(sparse(A))
245+
@test rowsA == rowsAtrue
246+
@test colsA == colsAtrue
247+
@test valsA == valsAtrue
248+
end
249+
208250
include("test_presolve.jl")

0 commit comments

Comments
 (0)