Skip to content

Commit

Permalink
less allocations for SS solver cache comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
thorek1 committed Dec 3, 2024
1 parent 9cf1959 commit 406664a
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/MacroModelling.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3191,14 +3191,20 @@ function solve_steady_state!(𝓂::β„³, symbolic_SS, Symbolics::symbolics; verbo
solver_parameters::Vector{solver_parameters})
initial_parameters = typeof(initial_parameters) == Vector{Float64} ? initial_parameters : β„±.value.(initial_parameters)

initial_parameters_tmp = copy(initial_parameters)

parameters = copy(initial_parameters)
params_flt = copy(initial_parameters)

current_best = sum(abs2,𝓂.NSSS_solver_cache[end][end] - initial_parameters)
closest_solution_init = 𝓂.NSSS_solver_cache[end]

for pars in 𝓂.NSSS_solver_cache
latest = sum(abs2,pars[end] - initial_parameters)
copy!(initial_parameters_tmp, pars[end])

β„’.axpy!(-1,initial_parameters,initial_parameters_tmp)

latest = sum(abs2,initial_parameters_tmp)
if latest <= current_best
current_best = latest
closest_solution_init = pars
Expand Down Expand Up @@ -3233,7 +3239,12 @@ function solve_steady_state!(𝓂::β„³, symbolic_SS, Symbolics::symbolics; verbo
closest_solution = 𝓂.NSSS_solver_cache[end]

for pars in 𝓂.NSSS_solver_cache
latest = sum(abs2,pars[end] - initial_parameters)
copy!(initial_parameters_tmp, pars[end])

β„’.axpy!(-1,initial_parameters,initial_parameters_tmp)

latest = sum(abs2,initial_parameters_tmp)

if latest <= current_best
current_best = latest
closest_solution = pars
Expand Down

0 comments on commit 406664a

Please sign in to comment.