diff --git a/examples/plot-utils-nnmf.jl b/examples/plot-utils-nnmf.jl index 81137387..ed36381e 100644 --- a/examples/plot-utils-nnmf.jl +++ b/examples/plot-utils-nnmf.jl @@ -8,12 +8,30 @@ function plot_nnmf(outstruct, Avec, m, n, k, name = "tr-qr") W = reshape(x[1:(m * k)], m, k) H = reshape(x[(m * k + 1):end], k, n) WH = W * H - + a = GroupPlot(2, 2, groupStyle = "horizontal sep = 2.5cm") - push!(a, Axis(Plots.Image(A, (1, m), (1, n), colormap=ColorMaps.Named("Jet")), xlabel = "A matrix (reference)")) - push!(a, Axis(Plots.Image(WH, (1, m), (1, n), colormap=ColorMaps.Named("Jet")), xlabel = "WH matrix")) - push!(a, Axis(Plots.Image(H, (1, k), (1, n), colormap=ColorMaps.Named("Jet")), xlabel = "H matrix")) - push!(a, Axis(Plots.Image(abs.(A - WH), (1, m), (1, n), colormap=ColorMaps.Named("Jet")), xlabel = "|A-WH| matrix")) + push!( + a, + Axis( + Plots.Image(A, (1, m), (1, n), colormap = ColorMaps.Named("Jet")), + xlabel = "A matrix (reference)", + ), + ) + push!( + a, + Axis(Plots.Image(WH, (1, m), (1, n), colormap = ColorMaps.Named("Jet")), xlabel = "WH matrix"), + ) + push!( + a, + Axis(Plots.Image(H, (1, k), (1, n), colormap = ColorMaps.Named("Jet")), xlabel = "H matrix"), + ) + push!( + a, + Axis( + Plots.Image(abs.(A - WH), (1, m), (1, n), colormap = ColorMaps.Named("Jet")), + xlabel = "|A-WH| matrix", + ), + ) save("nnmf-$(name).pdf", a) b = Axis( diff --git a/src/R2_alg.jl b/src/R2_alg.jl index 55aa7a41..9c955214 100644 --- a/src/R2_alg.jl +++ b/src/R2_alg.jl @@ -50,7 +50,7 @@ function R2(nlp::AbstractNLPModel, args...; kwargs...) xk, k, outdict = R2( x -> obj(nlp, x), (g, x) -> grad!(nlp, x, g), - args..., + args..., x0; l_bound = nlp.meta.lvar, u_bound = nlp.meta.uvar, diff --git a/src/TR_alg.jl b/src/TR_alg.jl index 3c0f68dc..0a2e3f9a 100644 --- a/src/TR_alg.jl +++ b/src/TR_alg.jl @@ -53,7 +53,7 @@ function TR( subsolver_logger::Logging.AbstractLogger = Logging.NullLogger(), subsolver = R2, subsolver_options = ROSolverOptions(), - selected::AbstractVector{<:Integer} = 1:f.meta.nvar, + selected::AbstractVector{<:Integer} = 1:(f.meta.nvar), ) where {H, X} start_time = time() elapsed_time = 0.0 @@ -101,7 +101,8 @@ function TR( xkn = similar(xk) s = zero(xk) - ψ = has_bounds(f) ? shifted(h, xk, max.(-Δk, l_bound - xk), min.(Δk, u_bound - xk), selected) : + ψ = + has_bounds(f) ? shifted(h, xk, max.(-Δk, l_bound - xk), min.(Δk, u_bound - xk), selected) : shifted(h, xk, Δk, χ) Fobj_hist = zeros(maxIter) @@ -169,8 +170,9 @@ function TR( subsolver_options.ϵa = k == 1 ? 1.0e-5 : max(ϵ, min(1e-2, sqrt(ξ1)) * ξ1) ∆_effective = min(β * χ(s), Δk) - has_bounds(f) ? set_bounds!(ψ, max.(-∆_effective, l_bound - xk), min.(∆_effective, u_bound - xk)) : - set_radius!(ψ, ∆_effective) + has_bounds(f) ? + set_bounds!(ψ, max.(-∆_effective, l_bound - xk), min.(∆_effective, u_bound - xk)) : + set_radius!(ψ, ∆_effective) s, iter, _ = with_logger(subsolver_logger) do subsolver(φ, ∇φ!, ψ, subsolver_options, s) end @@ -225,7 +227,8 @@ function TR( if ρk < η1 || ρk == Inf Δk = Δk / 2 - has_bounds(f) ? set_bounds!(ψ, max.(-Δk, l_bound - xk), min.(Δk, u_bound - xk)) : set_radius!(ψ, Δk) + has_bounds(f) ? set_bounds!(ψ, max.(-Δk, l_bound - xk), min.(Δk, u_bound - xk)) : + set_radius!(ψ, Δk) end tired = k ≥ maxIter || elapsed_time > maxTime end