Skip to content

Commit

Permalink
solve extended problem with variable paras and solved vars
Browse files Browse the repository at this point in the history
  • Loading branch information
thorek1 committed Jan 26, 2024
1 parent 7f718a3 commit 61e01dc
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions src/MacroModelling.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3036,6 +3036,28 @@ function block_solver(parameters_and_solved_vars::Vector{Float64},
) # alternatively use .001)#, μ = μ, p = p)# catch e end

sol_minimum = isnan(sum(abs2,info[4])) ? Inf : sum(abs2,info[4])

if sol_minimum > tol
function ss_solve_blocks_incl_params(guesses)
guess = guesses[1:length(guess)]
parameters_and_solved_vars_guess = guesses[length(guess)+1:end]
res = ss_solve_blocks(parameters_and_solved_vars, guess)
return vcat(res, parameters_and_solved_vars .- parameters_and_solved_vars_guess)
end

sol_new, info = SS_optimizer(
ss_solve_blocks_incl_params,
vcat(previous_sol_init,parameters_and_solved_vars),
vcat(lbs,fill(-1e12,length(parameters_and_solved_vars))),
vcat(ubs,fill(1e12,length(parameters_and_solved_vars))),
parameters = parameters
) # alternatively use .001)#, μ = μ, p = p)# catch e end

sol_new = sol_new[1:length(guess)]

sol_minimum = isnan(sum(abs2,info[4])) ? Inf : sum(abs2,info[4])
end

sol_values = max.(lbs,min.(ubs, sol_new ))
iters = info[1]

Expand All @@ -3059,6 +3081,21 @@ function block_solver(parameters_and_solved_vars::Vector{Float64},
)# catch e end

sol_minimum = isnan(sum(abs2,info[4])) ? Inf : sum(abs2,info[4])

if sol_minimum > tol
sol_new, info = SS_optimizer(
ss_solve_blocks_incl_params,
vcat(standard_inits,parameters_and_solved_vars),
vcat(lbs,fill(-1e12,length(parameters_and_solved_vars))),
vcat(ubs,fill(1e12,length(parameters_and_solved_vars))),
parameters = parameters
) # alternatively use .001)#, μ = μ, p = p)# catch e end

sol_new = sol_new[1:length(guess)]

sol_minimum = isnan(sum(abs2,info[4])) ? Inf : sum(abs2,info[4])
end

sol_values = max.(lbs,min.(ubs, sol_new))
iters = info[1]

Expand Down

0 comments on commit 61e01dc

Please sign in to comment.