Skip to content

Commit

Permalink
lwoer tol on find shocks
Browse files Browse the repository at this point in the history
  • Loading branch information
thorek1 committed Nov 6, 2024
1 parent fd925fe commit c04d8bf
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/filter/find_shocks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function find_shocks(::Val{:LagrangeNewton},
𝐒ⁱ²ᡉ::AbstractMatrix{Float64},
shock_independent::Vector{Float64};
max_iter::Int = 1000,
tol::Float64 = 1e-14) # will fail for higher or lower precision
tol::Float64 = 1e-13) # will fail for higher or lower precision
x = copy(initial_guess)

Ξ» = zeros(size(𝐒ⁱ, 1))
Expand Down Expand Up @@ -142,7 +142,7 @@ function rrule(::typeof(find_shocks),
𝐒ⁱ²ᡉ::AbstractMatrix{Float64},
shock_independent::Vector{Float64};
max_iter::Int = 1000,
tol::Float64 = 1e-14)
tol::Float64 = 1e-13)

x, matched = find_shocks(Val(:LagrangeNewton),
initial_guess,
Expand Down Expand Up @@ -208,7 +208,7 @@ function find_shocks(::Val{:LagrangeNewton},
𝐒ⁱ³ᡉ::AbstractMatrix{Float64},
shock_independent::Vector{Float64};
max_iter::Int = 1000,
tol::Float64 = 1e-14) # will fail for higher or lower precision
tol::Float64 = 1e-13) # will fail for higher or lower precision
x = copy(initial_guess)

Ξ» = zeros(size(𝐒ⁱ, 1))
Expand Down Expand Up @@ -368,7 +368,7 @@ function rrule(::typeof(find_shocks),
𝐒ⁱ³ᡉ::AbstractMatrix{Float64},
shock_independent::Vector{Float64};
max_iter::Int = 1000,
tol::Float64 = 1e-14)
tol::Float64 = 1e-13)

x, matched = find_shocks(Val(:LagrangeNewton),
initial_guess,
Expand Down Expand Up @@ -431,7 +431,7 @@ function find_shocks(::Val{:SLSQP},
𝐒ⁱ²ᡉ::AbstractMatrix{Float64},
shock_independent::Vector{Float64};
max_iter::Int = 500,
tol::Float64 = 1e-14) # will fail for higher or lower precision
tol::Float64 = 1e-13) # will fail for higher or lower precision
function objective_optim_fun(X::Vector{S}, grad::Vector{S}) where S
if length(grad) > 0
copy!(grad, X)
Expand Down Expand Up @@ -516,7 +516,7 @@ function find_shocks(::Val{:SLSQP},
𝐒ⁱ³ᡉ::AbstractMatrix{Float64},
shock_independent::Vector{Float64};
max_iter::Int = 500,
tol::Float64 = 1e-14) # will fail for higher or lower precision
tol::Float64 = 1e-13) # will fail for higher or lower precision
function objective_optim_fun(X::Vector{S}, grad::Vector{S}) where S
if length(grad) > 0
copy!(grad, X)
Expand Down Expand Up @@ -614,7 +614,7 @@ function find_shocks(::Val{:COBYLA},
𝐒ⁱ²ᡉ::AbstractMatrix{Float64},
shock_independent::Vector{Float64};
max_iter::Int = 10000,
tol::Float64 = 1e-14) # will fail for higher or lower precision
tol::Float64 = 1e-13) # will fail for higher or lower precision
function objective_optim_fun(X::Vector{S}, grad::Vector{S}) where S
sum(abs2, X)
end
Expand Down Expand Up @@ -682,7 +682,7 @@ function find_shocks(::Val{:COBYLA},
𝐒ⁱ³ᡉ::AbstractMatrix{Float64},
shock_independent::Vector{Float64};
max_iter::Int = 10000,
tol::Float64 = 1e-14) # will fail for higher or lower precision
tol::Float64 = 1e-13) # will fail for higher or lower precision
function objective_optim_fun(X::Vector{S}, grad::Vector{S}) where S
sum(abs2, X)
end
Expand Down Expand Up @@ -762,7 +762,7 @@ end
# 𝐒ⁱ³ᡉ::AbstractMatrix{Float64},
# shock_independent::Vector{Float64};
# max_iter::Int = 500,
# tol::Float64 = 1e-14) # will fail for higher or lower precision
# tol::Float64 = 1e-13) # will fail for higher or lower precision
# model = JuMP.Model(MadNLP.Optimizer)

# JuMP.set_silent(model)
Expand Down Expand Up @@ -811,7 +811,7 @@ end
# 𝐒ⁱ³ᡉ::AbstractMatrix{Float64},
# shock_independent::Vector{Float64};
# max_iter::Int = 500,
# tol::Float64 = 1e-14) # will fail for higher or lower precision
# tol::Float64 = 1e-13) # will fail for higher or lower precision
# model = JuMP.Model(Ipopt.Optimizer)

# JuMP.set_silent(model)
Expand Down Expand Up @@ -852,7 +852,7 @@ end
# 𝐒ⁱ::AbstractMatrix{Float64},
# 𝐒ⁱ²ᡉ::AbstractMatrix{Float64},
# shock_independent::Vector{Float64};
# tol::Float64 = 1e-14) # will fail for higher or lower precision
# tol::Float64 = 1e-13) # will fail for higher or lower precision

# nExo = Int(sqrt(length(kron_buffer)))

Expand Down Expand Up @@ -930,7 +930,7 @@ end
# 𝐒ⁱ²ᡉ::AbstractMatrix{Float64},
# 𝐒ⁱ³ᡉ::AbstractMatrix{Float64},
# shock_independent::Vector{Float64};
# tol::Float64 = 1e-14) # will fail for higher or lower precision
# tol::Float64 = 1e-13) # will fail for higher or lower precision

# nExo = Int(sqrt(length(kron_buffer)))

Expand Down

0 comments on commit c04d8bf

Please sign in to comment.