Skip to content

Commit 2310312

Browse files
committed
replace message with ints
1 parent 921ca83 commit 2310312

1 file changed

Lines changed: 25 additions & 9 deletions

File tree

src/plans/stepsize.jl

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1862,12 +1862,15 @@ mutable struct WolfePowellLinesearchStepsize{
18621862
candidate_point::P
18631863
last_stepsize::R
18641864
max_stepsize::R
1865-
message::String
18661865
retraction_method::TRM
18671866
stop_when_stepsize_less::R
18681867
vector_transport_method::VTM
18691868
stop_increasing_at_step::Int
18701869
stop_decreasing_at_step::Int
1870+
1871+
stop_decreasing_at_step_activated_at::Int
1872+
stop_increasing_at_step_activated_at::Int
1873+
stop_when_stepsize_less_activated_at::Int
18711874
function WolfePowellLinesearchStepsize(
18721875
M::AbstractManifold;
18731876
p::P = allocate_result(M, rand),
@@ -1888,12 +1891,14 @@ mutable struct WolfePowellLinesearchStepsize{
18881891
p,
18891892
0.0,
18901893
max_stepsize,
1891-
"", # init empty message
18921894
retraction_method,
18931895
stop_when_stepsize_less,
18941896
vector_transport_method,
18951897
stop_increasing_at_step,
18961898
stop_decreasing_at_step,
1899+
-1,
1900+
-1,
1901+
-1,
18971902
)
18981903
end
18991904
end
@@ -1906,7 +1911,9 @@ function (a::WolfePowellLinesearchStepsize)(
19061911
)
19071912
# For readability extract a few variables
19081913
# maybe collect and warn
1909-
a.message = ""
1914+
a.stop_decreasing_at_step_activated_at = -1
1915+
a.stop_increasing_at_step_activated_at = -1
1916+
a.stop_when_stepsize_less_activated_at = -1
19101917
M = get_manifold(mp)
19111918
p = get_iterate(ams)
19121919
l = get_differential(mp, p, η)
@@ -1935,8 +1942,7 @@ function (a::WolfePowellLinesearchStepsize)(
19351942
fNew = get_cost(mp, a.candidate_point)
19361943
i += 1
19371944
if i == a.stop_decreasing_at_step
1938-
a.message = (length(a.message) > 0) ? a.message * "\n " : "Wolfe-Powell line search:\n"
1939-
a.message = "$(a.message) Max decrease steps for s_minus ($(a.stop_decreasing_at_step)) reached in iteration $k."
1945+
a.stop_decreasing_at_step_activated_at = k
19401946
break
19411947
end
19421948
end
@@ -1952,8 +1958,7 @@ function (a::WolfePowellLinesearchStepsize)(
19521958
ManifoldsBase.retract_fused!(M, a.candidate_point, p, η, step, a.retraction_method)
19531959
fNew = get_cost(mp, a.candidate_point)
19541960
if i == a.stop_increasing_at_step
1955-
a.message = (length(a.message) > 0) ? a.message * "\n " : "Wolfe-Powell line search:\n"
1956-
a.message = "$(a.message) Max increase steps for s_plus ($(a.stop_increasing_at_step)) reached in iteration $k."
1961+
a.stop_increasing_at_step_activated_at = k
19571962
break
19581963
end
19591964
end
@@ -1972,8 +1977,7 @@ function (a::WolfePowellLinesearchStepsize)(
19721977
s_plus = step
19731978
end
19741979
if abs(s_plus - s_minus) <= a.stop_when_stepsize_less
1975-
a.message = (length(a.message) > 0) ? a.message * "\n " : "Wolfe-Powell line search:\n"
1976-
a.message = "$(a.message) Minimum step size ($(a.stop_when_stepsize_less)) exceeded in iteration $k."
1980+
a.stop_when_stepsize_less_activated_at = k
19771981
break
19781982
end
19791983
ManifoldsBase.retract_fused!(M, a.candidate_point, p, η, s_minus, a.retraction_method)
@@ -2000,6 +2004,18 @@ function show(io::IO, a::WolfePowellLinesearchStepsize)
20002004
end
20012005
function status_summary(a::WolfePowellLinesearchStepsize)
20022006
s = (a.last_stepsize > 0) ? "\nand the last stepsize used was $(a.last_stepsize)." : ""
2007+
if a.stop_decreasing_at_step_activated_at >= 0
2008+
s = (length(s) > 0) ? s * "\n " : "Wolfe-Powell line search:\n"
2009+
s = s * " Max decrease steps for s_minus ($(a.stop_decreasing_at_step)) reached in iteration $(a.stop_decreasing_at_step_activated_at)."
2010+
end
2011+
if a.stop_increasing_at_step_activated_at >= 0
2012+
s = (length(s) > 0) ? s * "\n " : "Wolfe-Powell line search:\n"
2013+
s = s * " Max increase steps for s_plus ($(a.stop_increasing_at_step)) reached in iteration $(a.stop_increasing_at_step_activated_at)."
2014+
end
2015+
if a.stop_when_stepsize_less_activated_at >= 0
2016+
s = (length(s) > 0) ? s * "\n " : "Wolfe-Powell line search:\n"
2017+
s = s * " Minimum step size ($(a.stop_when_stepsize_less)) exceeded in iteration $(a.stop_when_stepsize_less_activated_at)."
2018+
end
20032019
return "$a$s"
20042020
end
20052021
"""

0 commit comments

Comments
 (0)