Skip to content

Commit 1425571

Browse files
authored
Move ARTrustRegion to SolverTools (#116)
1 parent 94c3bc1 commit 1425571

File tree

8 files changed

+17
-125
lines changed

8 files changed

+17
-125
lines changed

Project.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
99
LinearOperators = "5c8ed15e-5a4c-59e4-a42b-c7e8811fb125"
1010
NLPModels = "a4795742-8479-5a88-8948-cc11e1c8c1a6"
1111
SolverCore = "ff4d7338-4cf1-434d-91df-b86cb86fb843"
12+
SolverTools = "b5612192-2639-5dc1-abfe-fbedd65fab29"
1213
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
1314
SparseMatricesCOO = "fa32481b-f100-4b48-8dc8-c62f61b13870"
1415
Stopping = "c4fe5a9e-e7fb-5c3d-89d5-7f405ab2214f"
@@ -19,6 +20,7 @@ Krylov = "^0.8.2, 0.9"
1920
LinearOperators = "1, 2"
2021
NLPModels = "0.18, 0.19, 0.20"
2122
SolverCore = "0.2, 0.3"
23+
SolverTools = "^0.8.8"
2224
SparseMatricesCOO = "0.1, 0.2"
2325
Stopping = "0.6.4"
2426
StoppingInterface = "0.3, 0.4, 0.5"

src/AdaptiveRegularization.jl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,13 @@ module AdaptiveRegularization
33
# stdlib
44
using LinearAlgebra, SparseArrays
55
# JSO
6-
using Krylov, LinearOperators, NLPModels, SparseMatricesCOO, SolverCore
6+
using Krylov, LinearOperators, NLPModels, SparseMatricesCOO, SolverCore, SolverTools
77
# Stopping
88
using Stopping, StoppingInterface
99

1010
# Selective includes.
1111
include("./utils/hessian_rep.jl")
1212
include("./utils/pdata_struct.jl")
13-
include("./utils/utils.jl")
1413
include("./utils/increase_decrease.jl")
1514

1615
path = joinpath(dirname(@__FILE__), "SolveModel")
@@ -48,7 +47,7 @@ Some variants of TRARC are already implemented and listed in `AdaptiveRegulariza
4847
- `nlp::AbstractNLPModel`: the model solved, see `NLPModels.jl`.
4948
5049
The keyword arguments include
51-
- `TR::TrustRegion`: structure with trust-region/ARC parameters, see [`TrustRegion`](@ref). Default: `TrustRegion(T(10.0))`.
50+
- `TR::ARTrustRegion`: structure with trust-region/ARC parameters, see [`SolverTools.jl`](https://github.com/JuliaSmoothOptimizers/SolverTools.jl). Default: `ARTrustRegion(T(10.0))`.
5251
- `hess_type::Type{Hess}`: Structure used to handle the hessian. The possible values are: `HessDense`, `HessSparse`, `HessSparseCOO`, `HessOp`. Default: `HessOp`.
5352
- `pdata_type::Type{ParamData}` Structure used for the preprocessing step. Default: `PDataKARC`.
5453
- `robust::Bool`: `true` implements a robust evaluation of the model. Default: `true`.

src/main.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ function SolverCore.solve!(
172172

173173
iter += 1
174174

175-
r, good_grad, ∇fnext = compute_r(nlp, ft, Δf, Δq, slope, d, xtnext, workspace, robust)
175+
r, good_grad, ∇fnext = SolverTools.compute_r(nlp, ft, Δf, Δq, slope, d, xtnext, workspace, robust)
176176

177177
if Δq < 0.0 # very unsucessful
178178
verbose > 0 &&

src/trarc_solver.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ The keyword arguments may include:
8888
- `stp::NLPStopping`: `Stopping` structure for this algorithm workflow;
8989
- `meta::ParamData`: see [`ParamData`](@ref);
9090
- `workspace::TRARCWorkspace`: allocated space for the solver itself;
91-
- `TR::TrustRegion`: trust-region parameters.
91+
- `TR::ARTrustRegion`: trust-region parameters.
9292
9393
"""
9494
mutable struct TRARCSolver{
@@ -106,7 +106,7 @@ mutable struct TRARCSolver{
106106
stp::NLPStopping{Pb, M, SRC, NLPAtX{Score, T, S}, MStp, LoS}
107107
meta::Data
108108
workspace::TRARCWorkspace{T, S, Hess}
109-
TR::TrustRegion{T}
109+
TR::ARTrustRegion{T}
110110
end
111111

112112
export TRARCSolver
@@ -118,7 +118,7 @@ end
118118

119119
function TRARCSolver(
120120
stp::NLPStopping{Pb, M, SRC, NLPAtX{Score, T, S}, MStp, LoS};
121-
TR::TrustRegion = TrustRegion(T(10.0)),
121+
TR::ARTrustRegion = ARTrustRegion(T(10.0)),
122122
hess_type::Type{Hess} = HessOp,
123123
pdata_type::Type{ParamData} = PDataKARC,
124124
kwargs...,

src/utils/increase_decrease.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
"""
2-
decrease(X::TPData, α::T, TR::TrustRegion)
2+
decrease(X::TPData, α::T, TR::ARTrustRegion)
33
44
Return a decreased `α`.
55
"""
6-
function decrease(X::TPData, α::T, TR::TrustRegion) where {T}
6+
function decrease(X::TPData, α::T, TR::ARTrustRegion) where {T}
77
return α * TR.decrease_factor
88
end
99

1010
"""
11-
increase(X::TPData, α::T, TR::TrustRegion)
11+
increase(X::TPData, α::T, TR::ARTrustRegion)
1212
1313
Return an increased `α`.
1414
"""
15-
function increase(::TPData, α::T, TR::TrustRegion) where {T}
15+
function increase(::TPData, α::T, TR::ARTrustRegion) where {T}
1616
return min* TR.increase_factor, TR.max_α)
1717
end
1818

1919
# X.indmin is between 1 and nshifts
20-
function decrease(X::PDataKARC, α::T, TR::TrustRegion) where {T}
20+
function decrease(X::PDataKARC, α::T, TR::ARTrustRegion) where {T}
2121
X.indmin += 1 # the step wasn't successful so we need to change something
2222
α2 = max(X.norm_dirs[X.indmin] / X.shifts[X.indmin], eps(T))
2323

@@ -41,7 +41,7 @@ function decrease(X::PDataKARC, α::T, TR::TrustRegion) where {T}
4141
return α2
4242
end
4343

44-
function decrease(X::PDataTRK, α::T, TR::TrustRegion) where {T}
44+
function decrease(X::PDataTRK, α::T, TR::ARTrustRegion) where {T}
4545
X.indmin += 1
4646
α2 = X.norm_dirs[X.indmin]
4747

src/utils/utils.jl

Lines changed: 0 additions & 110 deletions
This file was deleted.

test/allocation_test_utils.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ T = Float64
44
S = Vector{T}
55
n = 1000
66

7-
TR = TrustRegion(T(10))
7+
TR = ARTrustRegion(T(10))
88
α = T(100)
99

1010
# Test increase / decrease

test/runtests.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ using AdaptiveRegularization
33
# stdlib
44
using LinearAlgebra, SparseArrays, Test
55
# JSO
6-
using ADNLPModels, NLPModels, OptimizationProblems.ADNLPProblems, SolverCore, SolverTest
6+
using ADNLPModels, NLPModels, OptimizationProblems.ADNLPProblems
7+
using SolverCore, SolverTools, SolverTest
78
# Stopping
89
using Stopping
910

0 commit comments

Comments
 (0)