Skip to content

Commit 5a84114

Browse files
🤖 Format .jl files
1 parent 6d2d8ec commit 5a84114

File tree

2 files changed

+31
-10
lines changed

2 files changed

+31
-10
lines changed

examples/plot-utils-nnmf.jl

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,30 @@ function plot_nnmf(outstruct, Avec, m, n, k, name = "tr-qr")
88
W = reshape(x[1:(m * k)], m, k)
99
H = reshape(x[(m * k + 1):end], k, n)
1010
WH = W * H
11-
11+
1212
a = GroupPlot(2, 2, groupStyle = "horizontal sep = 2.5cm")
13-
push!(a, Axis(Plots.Image(A, (1, m), (1, n), colormap=ColorMaps.Named("Jet")), xlabel = "A matrix (reference)"))
14-
push!(a, Axis(Plots.Image(WH, (1, m), (1, n), colormap=ColorMaps.Named("Jet")), xlabel = "WH matrix"))
15-
push!(a, Axis(Plots.Image(H, (1, k), (1, n), colormap=ColorMaps.Named("Jet")), xlabel = "H matrix"))
16-
push!(a, Axis(Plots.Image(abs.(A - WH), (1, m), (1, n), colormap=ColorMaps.Named("Jet")), xlabel = "|A-WH| matrix"))
13+
push!(
14+
a,
15+
Axis(
16+
Plots.Image(A, (1, m), (1, n), colormap = ColorMaps.Named("Jet")),
17+
xlabel = "A matrix (reference)",
18+
),
19+
)
20+
push!(
21+
a,
22+
Axis(Plots.Image(WH, (1, m), (1, n), colormap = ColorMaps.Named("Jet")), xlabel = "WH matrix"),
23+
)
24+
push!(
25+
a,
26+
Axis(Plots.Image(H, (1, k), (1, n), colormap = ColorMaps.Named("Jet")), xlabel = "H matrix"),
27+
)
28+
push!(
29+
a,
30+
Axis(
31+
Plots.Image(abs.(A - WH), (1, m), (1, n), colormap = ColorMaps.Named("Jet")),
32+
xlabel = "|A-WH| matrix",
33+
),
34+
)
1735
save("nnmf-$(name).pdf", a)
1836

1937
b = Axis(

src/TR_alg.jl

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ function TR(
5353
subsolver_logger::Logging.AbstractLogger = Logging.NullLogger(),
5454
subsolver = R2,
5555
subsolver_options = ROSolverOptions(),
56-
selected::AbstractVector{<:Integer} = 1:f.meta.nvar,
56+
selected::AbstractVector{<:Integer} = 1:(f.meta.nvar),
5757
) where {H, X}
5858
start_time = time()
5959
elapsed_time = 0.0
@@ -101,7 +101,8 @@ function TR(
101101

102102
xkn = similar(xk)
103103
s = zero(xk)
104-
ψ = has_bounds(f) ? shifted(h, xk, max.(-Δk, l_bound - xk), min.(Δk, u_bound - xk), selected) :
104+
ψ =
105+
has_bounds(f) ? shifted(h, xk, max.(-Δk, l_bound - xk), min.(Δk, u_bound - xk), selected) :
105106
shifted(h, xk, Δk, χ)
106107

107108
Fobj_hist = zeros(maxIter)
@@ -169,8 +170,9 @@ function TR(
169170

170171
subsolver_options.ϵa = k == 1 ? 1.0e-5 : max(ϵ, min(1e-2, sqrt(ξ1)) * ξ1)
171172
∆_effective = min* χ(s), Δk)
172-
has_bounds(f) ? set_bounds!(ψ, max.(-∆_effective, l_bound - xk), min.(∆_effective, u_bound - xk)) :
173-
set_radius!(ψ, ∆_effective)
173+
has_bounds(f) ?
174+
set_bounds!(ψ, max.(-∆_effective, l_bound - xk), min.(∆_effective, u_bound - xk)) :
175+
set_radius!(ψ, ∆_effective)
174176
s, iter, _ = with_logger(subsolver_logger) do
175177
subsolver(φ, ∇φ!, ψ, subsolver_options, s)
176178
end
@@ -225,7 +227,8 @@ function TR(
225227

226228
if ρk < η1 || ρk == Inf
227229
Δk = Δk / 2
228-
has_bounds(f) ? set_bounds!(ψ, max.(-Δk, l_bound - xk), min.(Δk, u_bound - xk)) : set_radius!(ψ, Δk)
230+
has_bounds(f) ? set_bounds!(ψ, max.(-Δk, l_bound - xk), min.(Δk, u_bound - xk)) :
231+
set_radius!(ψ, Δk)
229232
end
230233
tired = k maxIter || elapsed_time > maxTime
231234
end

0 commit comments

Comments
 (0)