Skip to content

Commit cb3c1ba

Browse files
committed
🤖 Format .jl files
1 parent e3bf043 commit cb3c1ba

File tree

3 files changed

+48
-12
lines changed

3 files changed

+48
-12
lines changed

src/SolveModel/SolveModelNLSST_TR.jl

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
function solve_modelNLSST_TR(PData::PDataNLSST, Jx, Fx, norm_∇f, calls, max_calls, δ::T) where {T}
1+
function solve_modelNLSST_TR(
2+
PData::PDataNLSST,
3+
Jx,
4+
Fx,
5+
norm_∇f,
6+
calls,
7+
max_calls,
8+
δ::T,
9+
) where {T}
210
# cas particulier Steihaug-Toint
311
# ϵ = sqrt(eps(T)) # * 100.0 # old
412
# cgtol = max(ϵ, min(cgtol, 9 * cgtol / 10, 0.01 * norm(g)^(1.0 + PData.ζ))) # old

src/main.jl

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -72,27 +72,58 @@ function NLPModels.grad!(nls::AbstractNLSModel, x, workspace::TRARCWorkspace)
7272
return jtprod_residual!(nls, x, Fx, workspace.∇f)
7373
end
7474

75-
function preprocess(stp::NLPStopping, PData::TPData, workspace::TRARCWorkspace, ∇f, norm_∇f, α)
75+
function preprocess(
76+
stp::NLPStopping,
77+
PData::TPData,
78+
workspace::TRARCWorkspace,
79+
∇f,
80+
norm_∇f,
81+
α,
82+
)
7683
max_hprod = stp.meta.max_cntrs[:neval_hprod]
7784
Hx = stp.current_state.Hx
7885
PData = preprocess(PData, Hx, ∇f, norm_∇f, neval_hprod(stp.pb), max_hprod, α)
7986
return PData
8087
end
8188

82-
function compute_direction(stp::NLPStopping, PData::TPData, workspace::TRARCWorkspace, ∇f, norm_∇f, α, solve_model)
89+
function compute_direction(
90+
stp::NLPStopping,
91+
PData::TPData,
92+
workspace::TRARCWorkspace,
93+
∇f,
94+
norm_∇f,
95+
α,
96+
solve_model,
97+
)
8398
max_hprod = stp.meta.max_cntrs[:neval_hprod]
8499
Hx = stp.current_state.Hx
85100
return solve_model(PData, Hx, ∇f, norm_∇f, neval_hprod(stp.pb), max_hprod, α)
86101
end
87102

88-
function compute_direction(stp::NLPStopping, PData::PDataIterLS, workspace::TRARCWorkspace, ∇f, norm_∇f, α, solve_model)
103+
function compute_direction(
104+
stp::NLPStopping,
105+
PData::PDataIterLS,
106+
workspace::TRARCWorkspace,
107+
∇f,
108+
norm_∇f,
109+
α,
110+
solve_model,
111+
)
89112
max_prod = stp.meta.max_cntrs[:neval_jprod_residual]
90113
Jx = jac_op_residual(stp.pb, workspace.xt)
91114
Fx = workspace.Fx
92115
return solve_model(PData, Jx, Fx, norm_∇f, neval_jprod_residual(stp.pb), max_prod, α)
93116
end
94117

95-
function compute_direction(stp::NLPStopping, PData::PDataIterLS, workspace::TRARCWorkspace{T,S,Hess}, ∇f, norm_∇f, α, solve_model) where {T,S,Hess <: HessGaussNewtonOp}
118+
function compute_direction(
119+
stp::NLPStopping,
120+
PData::PDataIterLS,
121+
workspace::TRARCWorkspace{T,S,Hess},
122+
∇f,
123+
norm_∇f,
124+
α,
125+
solve_model,
126+
) where {T,S,Hess<:HessGaussNewtonOp}
96127
max_prod = stp.meta.max_cntrs[:neval_jprod_residual]
97128
Jx = jac_op_residual!(stp.pb, workspace.xt, workspace.Hstruct.Jv, workspace.Hstruct.Jtv)
98129
Fx = workspace.Fx
@@ -148,11 +179,7 @@ function TRARC(
148179
nlp_stop.meta.optimality0 = norm_∇f
149180

150181
OK = update_and_start!(nlp_stop, x = xt, fx = ft, gx = ∇f)
151-
!OK && Stopping.update!(
152-
nlp_at_x,
153-
Hx = hessian!(workspace, nlp, xt),
154-
convert = true,
155-
)
182+
!OK && Stopping.update!(nlp_at_x, Hx = hessian!(workspace, nlp, xt), convert = true)
156183

157184
iter = 0 # counter different than stop count
158185
succ, unsucc, verysucc, unsuccinarow = 0, 0, 0, 0
@@ -173,7 +200,8 @@ function TRARC(
173200

174201
success = false
175202
while !success & (unsuccinarow < max_unsuccinarow)
176-
d, λ = compute_direction(nlp_stop, PData, workspace, ∇f, norm_∇f, α, solve_model)
203+
d, λ =
204+
compute_direction(nlp_stop, PData, workspace, ∇f, norm_∇f, α, solve_model)
177205

178206
slope = ∇f d
179207
Δq = -(∇f + 0.5 * (nlp_at_x.Hx * d)) d

src/solvers.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,4 @@ const solvers_nls_const = Dict(
4141
:ST_TROpGN => (HessGaussNewtonOp, PDataST, solve_modelST_TR, ()),
4242
:ST_TROpGNLS => (HessGaussNewtonOp, PDataNLSST, solve_modelNLSST_TR, ()),
4343
:ST_TROpLS => (HessOp, PDataNLSST, solve_modelNLSST_TR, ()),
44-
)
44+
)

0 commit comments

Comments
 (0)