Skip to content

Commit 5b8cd1f

Browse files
committed
complete API
1 parent 174a0bb commit 5b8cd1f

File tree

4 files changed

+24
-8
lines changed

4 files changed

+24
-8
lines changed

src/qpmodel.jl

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ function NLPModels.jac_lin_structure!(
385385
return rows, cols
386386
end
387387

388-
function NLPModels.jac_structure!(
388+
function NLPModels.jac_lin_structure!(
389389
qp::QuadraticModel{T, S, M1, M2},
390390
rows::AbstractVector{<:Integer},
391391
cols::AbstractVector{<:Integer},
@@ -503,6 +503,19 @@ function NLPModels.jtprod!(
503503
x::AbstractVector,
504504
v::AbstractVector,
505505
Atv::AbstractVector,
506+
)
507+
@lencheck qp.meta.nvar x Atv
508+
@lencheck qp.meta.ncon v
509+
NLPModels.increment!(qp, :neval_jtprod)
510+
mul!(Atv, transpose(qp.data.A), v)
511+
return Atv
512+
end
513+
514+
function NLPModels.jtprod_lin!(
515+
qp::AbstractQuadraticModel,
516+
x::AbstractVector,
517+
v::AbstractVector,
518+
Atv::AbstractVector,
506519
)
507520
@lencheck qp.meta.nvar x Atv
508521
@lencheck qp.meta.nlin v

test/problems/eqconqp.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ function eqconqp_autodiff()
33
n = 50
44
x0 = zeros(n)
55
f(x) = sum(i * x[i]^2 for i = 1:n) / 2 + x[1] * x[n]
6-
c(x) = [sum(x) - 1.0]
7-
lcon = [0.0]
8-
ucon = [0.0]
6+
lcon = [1.0]
7+
ucon = [1.0]
8+
A = ones(1, n)
99

10-
return ADNLPModel(f, x0, c, lcon, ucon, name = "eqconqp_autodiff")
10+
return ADNLPModel(f, x0, sparse(A), lcon, ucon, name = "eqconqp_autodiff")
1111
end
1212

1313
function eqconqp_QP_dense()

test/problems/ineqconqp.jl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@
22
function ineqconqp_autodiff()
33
x0 = ones(2)
44
f(x) = (x[1] - 1)^2 / 2 + (x[2] - 1)^2 / 2
5-
c(x) = [x[1] - x[2]; x[2] - x[1]; x[1] + x[2]]
65
lcon = [0.0; -Inf; -1.0]
76
ucon = [Inf; 0.0; 1.0]
87

9-
return ADNLPModel(f, x0, c, lcon, ucon, name = "ineqconqp_autodiff")
8+
Arows = [1, 1, 2, 2, 3, 3]
9+
Acols = [1, 2, 1, 2, 1, 2]
10+
Avals = [1.0; -1.0; -1.0; 1.0; 1.0; 1.0]
11+
12+
return ADNLPModel(f, x0, Arows, Acols, Avals, lcon, ucon, name = "ineqconqp_autodiff")
1013
end
1114

1215
function ineqconqp_QP()

test/test_consistency.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ for problem in NLPModelsTest.nlp_problems
6565
zeros(nlp.meta.nvar),
6666
nlp.meta.lvar - x,
6767
nlp.meta.uvar - x,
68-
s -> Ax * s,
68+
Ax,
6969
nlp.meta.lcon - cx,
7070
nlp.meta.ucon - cx,
7171
)

0 commit comments

Comments
 (0)