Skip to content

Commit

Permalink
Updating increment! function to avoid further PR
Browse files Browse the repository at this point in the history
  • Loading branch information
AntoninKns authored and dpo committed Jun 3, 2022
1 parent 5e7f03f commit 3353d26
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/nlp/counters.jl
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,12 @@ end
Increment counter `s` of problem `nlp`.
"""
@inline function increment!(nlp::AbstractNLPModel, s::Symbol)
setproperty!(nlp.counters, s, getproperty(nlp.counters, s) + 1)
function increment!(nlp::AbstractNLPModel, s::Symbol)
NLPModels.increment!(nlp, Val(s))
end

for fun in fieldnames(Counters)
@eval $NLPModels.increment!(nlp::AbstractNLPModel, ::Val{$(Meta.quot(fun))}) = nlp.counters.$fun += 1
end

"""
Expand Down
19 changes: 19 additions & 0 deletions src/nls/counters.jl
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,25 @@ for counter in fieldnames(Counters)
end
end

"""
increment!(nls, s)
Increment counter `s` of problem `nls`.
"""
function increment!(nls::AbstractNLSModel, s::Symbol)
NLPModels.increment!(nls, Val(s))
end

for fun in fieldnames(NLSCounters)
fun == :counters && continue
@eval $NLPModels.increment!(nls::AbstractNLSModel, ::Val{$(Meta.quot(fun))}) = nls.counters.$fun += 1
end


for fun in fieldnames(Counters)
@eval $NLPModels.increment!(nls::AbstractNLSModel, ::Val{$(Meta.quot(fun))}) = nls.counters.counters.$fun += 1
end

function LinearOperators.reset!(nls::AbstractNLSModel)
reset!(nls.counters)
return nls
Expand Down

0 comments on commit 3353d26

Please sign in to comment.