Skip to content

Commit 64b0810

Browse files
Revert JuliaFormatter changes
1 parent 8debcd6 commit 64b0810

File tree

18 files changed

+155
-142
lines changed

18 files changed

+155
-142
lines changed

.JuliaFormatter.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
annotate_untyped_fields_with_any = false
12
indent = 2
23
margin = 92
34
normalize_line_endings = "unix"
5+
remove_extra_newlines = true
6+
whitespace_ops_in_indices = true
7+
whitespace_typedefs = true

benchmarks/tables/fh-table.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ if display_sol
178178
data = zeros(length(subset) + 1, 5)
179179
data[1, :] .= x0
180180
for i = 1:length(subset)
181-
data[i+1, :] .= stats[i].solution
181+
data[i + 1, :] .= stats[i].solution
182182
end
183183
pretty_table(
184184
data;

benchmarks/tables/regulopt-tables.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ function benchmark_table(
6262
pb_name::String,
6363
random_seed::Int;
6464
tex::Bool = false,
65-
nls_train::Union{Nothing,AbstractNLSModel} = nothing, # for SVM
66-
nls_test::Union{Nothing,AbstractNLSModel} = nothing, # for SVM
65+
nls_train::Union{Nothing, AbstractNLSModel} = nothing, # for SVM
66+
nls_test::Union{Nothing, AbstractNLSModel} = nothing, # for SVM
6767
)
6868
solver_names = [
6969
"$(solver)$(subsolvername(subsolver))$(options_str(opt, solver, subsolver_opt, subsolver))"

examples/plot-utils-fh.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ using PGFPlots
33
function plot_fh(outstruct, F, data, name = "tr-qr")
44
Comp_pg = outstruct.solver_specific[:SubsolverCounter]
55
objdec = outstruct.solver_specific[:Fhist] + outstruct.solver_specific[:Hhist]
6-
F1 = @view F[1:2:(end-1)]
6+
F1 = @view F[1:2:(end - 1)]
77
F2 = @view F[2:2:end]
8-
data1 = @view data[1:2:(end-1)]
8+
data1 = @view data[1:2:(end - 1)]
99
data2 = @view data[2:2:end]
1010
a = Axis(
1111
[

examples/plot-utils-nnmf.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ function plot_nnmf(outstruct, Avec, m, n, k, name = "tr-qr")
55
objdec = outstruct.solver_specific[:Fhist] + outstruct.solver_specific[:Hhist]
66
x = outstruct.solution
77
A = reshape(Avec, m, n)
8-
W = reshape(x[1:(m*k)], m, k)
9-
H = reshape(x[(m*k+1):end], k, n)
8+
W = reshape(x[1:(m * k)], m, k)
9+
H = reshape(x[(m * k + 1):end], k, n)
1010
WH = W * H
1111

1212
a = GroupPlot(2, 2, groupStyle = "horizontal sep = 2.5cm")

src/AL_alg.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -140,17 +140,17 @@ Notably, you can access, and modify, the following:
140140
- `stats.solver_specific[:smooth_obj]`: current value of the smooth part of the objective function;
141141
- `stats.solver_specific[:nonsmooth_obj]`: current value of the nonsmooth part of the objective function.
142142
"""
143-
mutable struct ALSolver{T,V,M,Pb,ST} <: AbstractOptimizationSolver
143+
mutable struct ALSolver{T, V, M, Pb, ST} <: AbstractOptimizationSolver
144144
x::V
145145
cx::V
146146
y::V
147147
has_bnds::Bool
148148
sub_problem::Pb
149149
sub_solver::ST
150-
sub_stats::GenericExecutionStats{T,V,V,T}
150+
sub_stats::GenericExecutionStats{T, V, V, T}
151151
end
152152

153-
function ALSolver(reg_nlp::AbstractRegularizedNLPModel{T,V}; kwargs...) where {T,V}
153+
function ALSolver(reg_nlp::AbstractRegularizedNLPModel{T, V}; kwargs...) where {T, V}
154154
nlp = reg_nlp.model
155155
nvar, ncon = nlp.meta.nvar, nlp.meta.ncon
156156
x = V(undef, nvar)
@@ -163,7 +163,7 @@ function ALSolver(reg_nlp::AbstractRegularizedNLPModel{T,V}; kwargs...) where {T
163163
sub_stats = RegularizedExecutionStats(sub_problem)
164164
M = typeof(nlp)
165165
ST = typeof(sub_solver)
166-
return ALSolver{T,V,M,typeof(sub_problem),ST}(
166+
return ALSolver{T, V, M, typeof(sub_problem), ST}(
167167
x,
168168
cx,
169169
y,
@@ -202,9 +202,9 @@ function SolverCore.solve!(
202202
end
203203

204204
function SolverCore.solve!(
205-
solver::ALSolver{T,V},
206-
reg_nlp::AbstractRegularizedNLPModel{T,V},
207-
stats::GenericExecutionStats{T,V};
205+
solver::ALSolver{T, V},
206+
reg_nlp::AbstractRegularizedNLPModel{T, V},
207+
stats::GenericExecutionStats{T, V};
208208
callback = (args...) -> nothing,
209209
x::V = reg_nlp.model.meta.x0,
210210
y::V = reg_nlp.model.meta.y0,
@@ -223,7 +223,7 @@ function SolverCore.solve!(
223223
factor_primal_linear_improvement::T = T(3 // 4),
224224
factor_decrease_subtol::T = T(1 // 4),
225225
dual_safeguard = project_y!,
226-
) where {T,V}
226+
) where {T, V}
227227
reset!(stats)
228228

229229
# Retrieve workspace

src/LMModel.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,20 @@ where `J` is the Jacobian of `F` at `xk`, represented via matrix-free operations
1717
`σ > 0` is a regularization parameter and `v` is a vector of the same size as `F(xk)` used for intermediary computations.
1818
"""
1919
mutable struct LMModel{
20-
T<:Real,
21-
V<:AbstractVector{T},
22-
Jac<:Union{AbstractMatrix,AbstractLinearOperator},
23-
} <: AbstractNLPModel{T,V}
20+
T <: Real,
21+
V <: AbstractVector{T},
22+
Jac <: Union{AbstractMatrix, AbstractLinearOperator},
23+
} <: AbstractNLPModel{T, V}
2424
J::Jac
2525
F::V
2626
v::V
2727
xk::V
2828
σ::T
29-
meta::NLPModelMeta{T,V}
29+
meta::NLPModelMeta{T, V}
3030
counters::Counters
3131
end
3232

33-
function LMModel(J::Jac, F::V, σ::T, xk::V) where {T,V,Jac}
33+
function LMModel(J::Jac, F::V, σ::T, xk::V) where {T, V, Jac}
3434
meta = NLPModelMeta(
3535
length(xk),
3636
x0 = xk, # Perhaps we should add lvar and uvar as well here.

src/LMTR_alg.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ function LMTR(
4949
subsolver = R2,
5050
subsolver_options = ROSolverOptions(ϵa = options.ϵa),
5151
selected::AbstractVector{<:Integer} = 1:(nls.meta.nvar),
52-
) where {H,X}
52+
) where {H, X}
5353
start_time = time()
5454
elapsed_time = 0.0
5555
# initialize passed options

src/LM_alg.jl

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ export LM, LMSolver, solve!
33
import SolverCore.solve!
44

55
mutable struct LMSolver{
6-
T<:Real,
7-
G<:ShiftedProximableFunction,
8-
V<:AbstractVector{T},
9-
ST<:AbstractOptimizationSolver,
10-
PB<:AbstractRegularizedNLPModel,
6+
T <: Real,
7+
G <: ShiftedProximableFunction,
8+
V <: AbstractVector{T},
9+
ST <: AbstractOptimizationSolver,
10+
PB <: AbstractRegularizedNLPModel,
1111
} <: AbstractOptimizationSolver
1212
xk::V
1313
∇fk::V
@@ -26,13 +26,13 @@ mutable struct LMSolver{
2626
u_bound_m_x::V
2727
subsolver::ST
2828
subpb::PB
29-
substats::GenericExecutionStats{T,V,V,T}
29+
substats::GenericExecutionStats{T, V, V, T}
3030
end
3131

3232
function LMSolver(
33-
reg_nls::AbstractRegularizedNLPModel{T,V};
33+
reg_nls::AbstractRegularizedNLPModel{T, V};
3434
subsolver = R2Solver,
35-
) where {T,V}
35+
) where {T, V}
3636
x0 = reg_nls.model.meta.x0
3737
l_bound = reg_nls.model.meta.lvar
3838
u_bound = reg_nls.model.meta.uvar
@@ -67,7 +67,7 @@ function LMSolver(
6767
substats = RegularizedExecutionStats(subpb)
6868
subsolver = subsolver(subpb)
6969

70-
return LMSolver{T,typeof(ψ),V,typeof(subsolver),typeof(subpb)}(
70+
return LMSolver{T, typeof(ψ), V, typeof(subsolver), typeof(subpb)}(
7171
xk,
7272
∇fk,
7373
mν∇fk,
@@ -176,9 +176,9 @@ function LM(reg_nls::AbstractRegularizedNLPModel; kwargs...)
176176
end
177177

178178
function SolverCore.solve!(
179-
solver::LMSolver{T,G,V},
180-
reg_nls::AbstractRegularizedNLPModel{T,V},
181-
stats::GenericExecutionStats{T,V};
179+
solver::LMSolver{T, G, V},
180+
reg_nls::AbstractRegularizedNLPModel{T, V},
181+
stats::GenericExecutionStats{T, V};
182182
callback = (args...) -> nothing,
183183
x::V = reg_nls.model.meta.x0,
184184
nonlinear::Bool = true,
@@ -195,7 +195,7 @@ function SolverCore.solve!(
195195
η2::T = T(0.9),
196196
γ::T = T(3),
197197
θ::T = 1/(1 + eps(T)^(1 / 5)),
198-
) where {T,V,G}
198+
) where {T, V, G}
199199
reset!(stats)
200200

201201
# Retrieve workspace
@@ -243,7 +243,7 @@ function SolverCore.solve!(
243243
@info log_header(
244244
[:outer, :inner, :fx, :hx, :xi, , , :normx, :norms, :normJ, :arrow],
245245
[Int, Int, T, T, T, T, T, T, T, T, Char],
246-
hdr_override = Dict{Symbol,String}(
246+
hdr_override = Dict{Symbol, String}(
247247
:fx => "f(x)",
248248
:hx => "h(x)",
249249
:xi => "√(ξ1/ν)",
@@ -364,7 +364,7 @@ function SolverCore.solve!(
364364
σk,
365365
norm(xk),
366366
norm(s),
367-
1/ν,
367+
1 / ν,
368368
(η2 ρk < Inf) ? '' : (ρk < η1 ? '' : '='),
369369
],
370370
colsep = 1,
@@ -445,7 +445,7 @@ function SolverCore.solve!(
445445

446446
if verbose > 0 && stats.status == :first_order
447447
@info log_row(
448-
Any[stats.iter, 0, fk, hk, sqrt_ξ1_νInv, ρk, σk, norm(xk), norm(s), 1/ν, ""],
448+
Any[stats.iter, 0, fk, hk, sqrt_ξ1_νInv, ρk, σk, norm(xk), norm(s), 1 / ν, ""],
449449
colsep = 1,
450450
)
451451
@info "LM: terminating with √(ξ1/ν) = $(sqrt_ξ1_νInv)"

src/R2DH.jl

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ export R2DH, R2DHSolver, solve!
33
import SolverCore.solve!
44

55
mutable struct R2DHSolver{
6-
T<:Real,
7-
G<:ShiftedProximableFunction,
8-
V<:AbstractVector{T},
9-
QN<:AbstractDiagonalQuasiNewtonOperator{T},
6+
T <: Real,
7+
G <: ShiftedProximableFunction,
8+
V <: AbstractVector{T},
9+
QN <: AbstractDiagonalQuasiNewtonOperator{T},
1010
} <: AbstractOptimizationSolver
1111
xk::V
1212
∇fk::V
@@ -26,10 +26,10 @@ mutable struct R2DHSolver{
2626
end
2727

2828
function R2DHSolver(
29-
reg_nlp::AbstractRegularizedNLPModel{T,V};
29+
reg_nlp::AbstractRegularizedNLPModel{T, V};
3030
m_monotone::Int = 6,
31-
D::Union{Nothing,AbstractDiagonalQuasiNewtonOperator} = nothing,
32-
) where {T,V}
31+
D::Union{Nothing, AbstractDiagonalQuasiNewtonOperator} = nothing,
32+
) where {T, V}
3333
x0 = reg_nlp.model.meta.x0
3434
l_bound = reg_nlp.model.meta.lvar
3535
u_bound = reg_nlp.model.meta.uvar
@@ -151,11 +151,11 @@ Notably, you can access, and modify, the following:
151151
- `stats.elapsed_time`: elapsed time in seconds.
152152
"""
153153
function R2DH(
154-
nlp::AbstractDiagonalQNModel{T,V},
154+
nlp::AbstractDiagonalQNModel{T, V},
155155
h,
156156
options::ROSolverOptions{T};
157157
kwargs...,
158-
) where {T,V}
158+
) where {T, V}
159159
kwargs_dict = Dict(kwargs...)
160160
selected = pop!(kwargs_dict, :selected, 1:(nlp.meta.nvar))
161161
x0 = pop!(kwargs_dict, :x0, nlp.meta.x0)
@@ -188,7 +188,13 @@ function R2DH(
188188
x0::AbstractVector{R};
189189
selected::AbstractVector{<:Integer} = 1:length(x0),
190190
kwargs...,
191-
) where {F<:Function,G<:Function,H,R<:Real,DQN<:AbstractDiagonalQuasiNewtonOperator}
191+
) where {
192+
F <: Function,
193+
G <: Function,
194+
H,
195+
R <: Real,
196+
DQN <: AbstractDiagonalQuasiNewtonOperator,
197+
}
192198
nlp = FirstOrderModel(f, ∇f!, x0)
193199
reg_nlp = RegularizedNLPModel(nlp, h, selected)
194200
stats = R2DH(
@@ -213,7 +219,7 @@ function R2DH(
213219
return stats.solution, stats.iter, nothing
214220
end
215221

216-
function R2DH(reg_nlp::AbstractRegularizedNLPModel{T,V}; kwargs...) where {T,V}
222+
function R2DH(reg_nlp::AbstractRegularizedNLPModel{T, V}; kwargs...) where {T, V}
217223
kwargs_dict = Dict(kwargs...)
218224
m_monotone = pop!(kwargs_dict, :m_monotone, 6)
219225
D = pop!(kwargs_dict, :D, nothing)
@@ -225,8 +231,8 @@ end
225231

226232
function SolverCore.solve!(
227233
solver::R2DHSolver{T},
228-
reg_nlp::AbstractRegularizedNLPModel{T,V},
229-
stats::GenericExecutionStats{T,V};
234+
reg_nlp::AbstractRegularizedNLPModel{T, V},
235+
stats::GenericExecutionStats{T, V};
230236
callback = (args...) -> nothing,
231237
x::V = reg_nlp.model.meta.x0,
232238
atol::T = eps(T),
@@ -242,7 +248,7 @@ function SolverCore.solve!(
242248
η2::T = T(0.9),
243249
γ::T = T(3),
244250
θ::T = 1/(1 + eps(T)^(1 / 5)),
245-
) where {T,V}
251+
) where {T, V}
246252
reset!(stats)
247253

248254
# Retrieve workspace
@@ -292,7 +298,7 @@ function SolverCore.solve!(
292298
@info log_header(
293299
[:iter, :fx, :hx, :xi, , , :normx, :norms, :arrow],
294300
[Int, T, T, T, T, T, T, T, Char],
295-
hdr_override = Dict{Symbol,String}( # TODO: Add this as constant dict elsewhere
301+
hdr_override = Dict{Symbol, String}( # TODO: Add this as constant dict elsewhere
296302
:fx => "f(x)",
297303
:hx => "h(x)",
298304
:xi => "√(ξ/ν)",
@@ -328,7 +334,7 @@ function SolverCore.solve!(
328334
set_solver_specific!(stats, :nonsmooth_obj, hk)
329335
set_solver_specific!(stats, :sigma, σk)
330336
set_solver_specific!(stats, :sigma_cauchy, 1/ν₁)
331-
m_monotone > 1 && (m_fh_hist[(stats.iter)%(m_monotone-1)+1] = fk + hk)
337+
m_monotone > 1 && (m_fh_hist[(stats.iter) % (m_monotone - 1) + 1] = fk + hk)
332338

333339
φ(d) = begin
334340
result = zero(T)
@@ -437,7 +443,7 @@ function SolverCore.solve!(
437443
ν₁ = θ / (DNorm + σk)
438444

439445
@. mν∇fk = -ν₁ * ∇fk
440-
m_monotone > 1 && (m_fh_hist[stats.iter%(m_monotone-1)+1] = fk + hk)
446+
m_monotone > 1 && (m_fh_hist[stats.iter % (m_monotone - 1) + 1] = fk + hk)
441447

442448
spectral_test ? prox!(s, ψ, mν∇fk, ν₁) : iprox!(s, ψ, ∇fk, dkσk)
443449
mks = mk(s)

0 commit comments

Comments
 (0)