Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Schedulers no longer break when particle failures occur #295

Merged
merged 1 commit into from
Jun 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/LearningRateSchedulers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -137,15 +137,17 @@ end
"""
$(TYPEDSIGNATURES)
Calculates next timestep by pushing to ekp.Δt,
Calculates next timestep by pushing to ekp.Δt,
`!isnothing(return_value)` implies termination condition has been met
"""
function calculate_timestep!(
ekp::EnsembleKalmanProcess,
g::M,
Δt_new::NFT,
) where {M <: AbstractMatrix, NFT <: Union{Nothing, AbstractFloat}}
terminate = calculate_timestep!(ekp, g, Δt_new, get_scheduler(ekp))
# when using g to calculate Δt, pass only successful particles through
successful_ens, _ = split_indices_by_success(g)
terminate = calculate_timestep!(ekp, g[:, successful_ens], Δt_new, get_scheduler(ekp))
return terminate
end

Expand Down Expand Up @@ -247,7 +249,6 @@ function calculate_timestep!(
@info "Cannot override DataMisfitController-type timestep selection, ignoring Δt_new = $(Δt_new)"
end


M, J = size(g)
T = scheduler.terminate_at

Expand Down Expand Up @@ -285,7 +286,6 @@ function calculate_timestep!(
end
end

M, J = size(g)
y_mean = ekp.obs_mean

Φ = [0.5 * norm(inv_sqrt_Γ * (g[:, j] - reshape(y_mean, :, 1)))^2 for j in 1:J]
Expand Down
7 changes: 7 additions & 0 deletions test/EnsembleKalmanProcess/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,11 @@ end

# Get inverse problem
y_obs, G, Γy, A = inv_problem
if i_prob == 1
scheduler = DataMisfitController(on_terminate = "continue")
else
scheduler = DefaultScheduler()
end

ekiobj = EKP.EnsembleKalmanProcess(
initial_ensemble,
Expand All @@ -293,6 +298,7 @@ end
rng = rng,
failure_handler_method = SampleSuccGauss(),
localization_method = loc_method,
scheduler = scheduler,
)
ekiobj_unsafe = EKP.EnsembleKalmanProcess(
initial_ensemble,
Expand All @@ -302,6 +308,7 @@ end
rng = rng,
failure_handler_method = IgnoreFailures(),
localization_method = loc_method,
scheduler = scheduler,
)

g_ens = G(get_ϕ_final(prior, ekiobj))
Expand Down
Loading