Skip to content

Commit 2550cfd

Browse files
Add hess_op for RegularizedNLPModels (#81)
* add hess_op for RegularizedNLPModels * add hess_op test * fix formatting for targets * fix test
1 parent 17cf948 commit 2550cfd

File tree

4 files changed

+20
-8
lines changed

4 files changed

+20
-8
lines changed

Project.toml

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,29 +18,35 @@ SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
1818
[compat]
1919
ADNLPModels = "^0.3, 0.4, 0.7"
2020
Distributions = "0.25"
21+
LinearOperators = "2.11.0"
2122
ManualNLPModels = "0.2"
2223
MLDatasets = "^0.7.4"
2324
NLPModels = "0.16, 0.17, 0.18, 0.19, 0.20, 0.21"
25+
NLPModelsModifiers = "0.7.3"
2426
Noise = "0.2"
2527
Requires = "1"
2628
julia = "^1.6.0"
2729

2830
[extras]
2931
ADNLPModels = "54578032-b7ea-4c30-94aa-7cbd1cce6c9a"
3032
DifferentialEquations = "0c46a032-eb83-5123-abaf-570d42b7fbaa"
33+
LinearOperators = "5c8ed15e-5a4c-59e4-a42b-c7e8811fb125"
3134
MLDatasets = "eb30cadb-4394-5ae3-aed4-317e484a6458"
35+
NLPModelsModifiers = "e01155f1-5c6f-4375-a9d8-616dd036575f"
3236
ProximalOperators = "a725b495-10eb-56fe-b38b-717eba820537"
3337
QuadraticModels = "f468eda6-eac5-11e8-05a5-ff9e497bcd19"
3438
ShiftedProximalOperators = "d4fd37fa-580c-4e43-9b30-361c21aae263"
3539
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
3640

3741
[targets]
3842
test = [
39-
"ADNLPModels",
40-
"DifferentialEquations",
41-
"MLDatasets",
42-
"ProximalOperators",
43-
"QuadraticModels",
44-
"ShiftedProximalOperators",
45-
"Test",
43+
"ADNLPModels",
44+
"DifferentialEquations",
45+
"LinearOperators",
46+
"MLDatasets",
47+
"NLPModelsModifiers",
48+
"ProximalOperators",
49+
"QuadraticModels",
50+
"ShiftedProximalOperators",
51+
"Test"
4652
]

src/types.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ function NLPModels.obj(rnlp::AbstractRegularizedNLPModel, x::AbstractVector)
6161
obj(rnlp.model, x) + rnlp.h(x)
6262
end
6363

64+
function NLPModels.hess_op(rnlp::AbstractRegularizedNLPModel, x::AbstractVector)
65+
return hess_op(rnlp.model, x)
66+
end
67+
6468
# Forward meta getters so they grab info from the smooth model
6569
for field fieldnames(NLPModels.NLPModelMeta)
6670
meth = Symbol("get_", field)

test/rmodel_tests.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ using ProximalOperators
1515
@test get_nequ(rlsmodel) == get_nequ(nls_model)
1616
obj(nls_model, nls_model.meta.x0)
1717
@test neval_obj(rlsmodel) == neval_obj(nls_model)
18+
rmodel_lbfgs = RegularizedNLPModel(LBFGSModel(model), h)
19+
@test typeof(hess_op(rmodel_lbfgs, model.meta.x0)) <: LBFGSOperator
1820
end
1921

2022
@testset "Problem combos" begin

test/runtests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using LinearAlgebra, Test
2-
using ADNLPModels, DifferentialEquations, ManualNLPModels, MLDatasets, NLPModels, QuadraticModels
2+
using ADNLPModels, DifferentialEquations, LinearOperators, ManualNLPModels, MLDatasets, NLPModels, NLPModelsModifiers, QuadraticModels
33
using RegularizedProblems
44

55
function test_well_defined(model, nls_model, sol)

0 commit comments

Comments
 (0)