Skip to content

Commit 4fc4fff

Browse files
authored
Merge pull request #9 from slimgroup/ls-e
Linesearch fix
2 parents b9c4cec + 4163eb5 commit 4fc4fff

File tree

4 files changed

+21
-6
lines changed

4 files changed

+21
-6
lines changed

.github/workflows/CI.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
fail-fast: false
2424

2525
matrix:
26-
version: ['1.6', '1.7', '1.8', '1.9', '1']
26+
version: ['1.6', '1.7', '1.8', '1.9', '1.10', '1']
2727
os: [ubuntu-latest]
2828
arch: [x64]
2929

Project.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "SlimOptim"
22
uuid = "e4c7bc62-5b23-4522-a1b9-71c2be45f1df"
33
authors = ["Mathias Louboutin <[email protected]>"]
4-
version = "0.2.3"
4+
version = "0.2.5"
55

66
[deps]
77
LineSearches = "d3d80556-e9d4-5f37-9878-2ab0fcc64255"

src/linesearches.jl

+6-2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,11 @@ function linesearch(ls, sol::result, d::AbstractArray{T}, f::Function, g!::Funct
4444
try
4545
return ls(ϕ, dϕ, ϕdϕ, t, funRef, gtd)
4646
catch e
47-
@info "Line search failed"
48-
return 0, funRef
47+
if isa(e, LineSearchException)
48+
@info "Line search failed"
49+
return 0, funRef
50+
else
51+
throw(e)
52+
end
4953
end
5054
end

test/runtests.jl

+13-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Author: Mathias Louboutin, [email protected]
22
# Date: December 2020
33

4-
using SlimOptim, Test
4+
using SlimOptim, Test, LineSearches
55

66
@testset "SPG" begin
77
include("test_spg.jl")
@@ -17,4 +17,15 @@ end
1717

1818
@testset "Rosenbrock accuracy" begin
1919
include("test_rosen.jl")
20-
end
20+
end
21+
22+
23+
# Test linesearch error
24+
25+
sol = result([1])
26+
ls = BackTracking(;iterations=5)
27+
28+
f(x) = x[]
29+
@test linesearch(ls, sol, [1.0], f, x->-x, x->-x, 1.0, 1.0, 1.0, [1.0])[1] == 0.0
30+
fs(x) = sqrt(-1)
31+
@test_throws DomainError linesearch(ls, sol, [1.0], fs, x->x, x->x, 1.0, 1.0, 1.0, [1.0])

0 commit comments

Comments
 (0)