Skip to content

Commit db5e8b7

Browse files
committed
more comments/docstrings and add random seed in tests
1 parent aed8cff commit db5e8b7

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/linesearches.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ Constructs a Hager-Zhang line search object with the specified parameters.
4949
- `θ::Real`: Parameter regulating the bisection step. Default is `1//2` (should probably not be changed).
5050
- `γ::Real`: Parameter triggering the bisection step, namely if bracket reduction rate is slower than `γ`. Default is `2//3`.
5151
- `ρ::Real`: Parameter controlling the initial bracket expansion rate. Default is `5//1`.
52+
- `maxiter::Int`: Hard limit on the number of iterations. Default is `OptimKit.LS_MAXITER[]` (set to 50).
53+
- `maxfg::Int`: Soft limit on the number of function evaluations. Default is `OptimKit.LS_MAXFG[]` (set to 100).
54+
- `verbosity::Int`: The verbosity level (see below). Default is `OptimKit.LS_VERBOSITY[]` (set to 0).
5255
5356
## Returns:
5457
This method returns a `HagerZhangLineSearch` object `ls`, that can then be can be applied as `ls(fg, x₀, η₀; kwargs...)`
@@ -333,7 +336,7 @@ function bisect(iter::HagerZhangLineSearchIterator, a::LineSearchPoint, b::LineS
333336
fmax = p₀.f + ϵ
334337
numfg = 0
335338
while true
336-
if (b.α - a.α) <= eps(one(a.α)) || numfg >= iter.parameters.maxfg
339+
if (b.α - a.α) <= eps(one(a.α))^(3 // 4) || numfg >= iter.parameters.maxfg
337340
if verbosity >= 1
338341
@warn @sprintf(" Linesearch bisection failure: [a, b] = [%.2e, %.2e], b-a = %.2e, dϕᵃ = %.2e, dϕᵇ = %.2e, (ϕᵇ - ϕᵃ)/(b-a) = %.2e",
339342
a.α, b.α, b.α - a.α, a.dϕ, b.dϕ, (b.ϕ - a.ϕ) / (b.α - a.α))

test/runtests.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
using Test
22
using OptimKit
33
using LinearAlgebra
4+
using Random: Random
5+
Random.seed!(1234)
46

57
# Test linesearches
68
@testset "Linesearch" for (fg, x₀) in [(x -> (sin(x) + x^4, cos(x) + 4 * x^3), 0.0),

0 commit comments

Comments
 (0)