Skip to content

Commit 7b54d4f

Browse files
add skip_sigma kwarg
1 parent 539b228 commit 7b54d4f

File tree

4 files changed

+6
-4
lines changed

4 files changed

+6
-4
lines changed

src/LMModel.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,12 @@ function LMModel(J::Jac, F::V, σ::T, xk::V) where {T, V, Jac}
3939
return LMModel(J, F, v, xk, σ, meta, Counters())
4040
end
4141

42-
function NLPModels.obj(nlp::LMModel, x::AbstractVector{T}) where {T}
42+
function NLPModels.obj(nlp::LMModel, x::AbstractVector{T}; skip_sigma = false) where {T}
4343
@lencheck nlp.meta.nvar x
4444
increment!(nlp, :neval_obj)
4545
mul!(nlp.v, nlp.J, x)
4646
nlp.v .+= nlp.F
47+
skip_sigma && return dot(nlp.v, nlp.v)/2
4748
return (dot(nlp.v, nlp.v) + nlp.σ * dot(x, x)) / 2
4849
end
4950

src/LM_alg.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ function SolverCore.solve!(
300300
end
301301

302302
mk = let ψ = ψ, solver = solver
303-
d -> obj(solver.subpb.model, d) + ψ(d)
303+
d -> obj(solver.subpb.model, d, skip_sigma = true) + ψ(d)
304304
end
305305

306306
prox!(s, ψ, mν∇fk, ν)

src/R2N.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ function SolverCore.solve!(
327327
end
328328

329329
mk = let ψ = ψ, solver = solver
330-
d -> obj(solver.subpb.model, d) + ψ(d)::T
330+
d -> obj(solver.subpb.model, d, skip_sigma = true) + ψ(d)::T
331331
end
332332

333333
prox!(s1, ψ, mν∇fk, ν₁)

src/R2NModel.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,11 @@ function R2NModel(B::G, ∇f::V, σ::T, x0::V) where {T, V, G}
3434
return R2NModel(B::G, ∇f::V, v::V, σ::T, meta, Counters())
3535
end
3636

37-
function NLPModels.obj(nlp::R2NModel, x::AbstractVector)
37+
function NLPModels.obj(nlp::R2NModel, x::AbstractVector; skip_sigma = false)
3838
@lencheck nlp.meta.nvar x
3939
increment!(nlp, :neval_obj)
4040
mul!(nlp.v, nlp.B, x)
41+
skip_sigma && return dot(nlp.v, x)/2 + dot(nlp.∇f, x)
4142
return dot(nlp.v, x)/2 + dot(nlp.∇f, x) + nlp.σ * dot(x, x) / 2
4243
end
4344

0 commit comments

Comments
 (0)