Skip to content

Commit 468bea3

Browse files
ChrisRackauckas-ClaudeChrisRackauckasclaude
authored
Fix ensemble work-precision error storage (#4390)
Claude-Session: https://chatgpt.com/codex/tasks/01a03a17-ad6f-7131-82fc-d0fd57ea6512 Co-authored-by: ChrisRackauckas-Claude <[email protected]> Co-authored-by: Claude <[email protected]>
1 parent a27ee03 commit 468bea3

3 files changed

Lines changed: 29 additions & 3 deletions

File tree

‎lib/DiffEqDevTools/src/benchmark.jl‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1070,7 +1070,9 @@ function WorkPrecisionSet(
10701070
stats = nothing
10711071
wps = [
10721072
WorkPrecision(
1073-
prob, _abstols[i], _reltols[i], errors[i], times[:, i],
1073+
prob, _abstols[i], _reltols[i],
1074+
_dicts_to_structarray([Dict(error_estimate => err) for err in errors[i]]),
1075+
times[:, i],
10741076
_dts[i], stats, names[i], error_estimate, N,
10751077
_combined_tags(
10761078
setups[i][:alg], _setup_tags(setups[i]),

‎lib/DiffEqDevTools/test/analyticless_stochastic_wp.jl‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ wp2 = @time WorkPrecisionSet(
130130
trajectories = numtraj, error_estimate = :weak_final
131131
)
132132

133-
err1 = [wp1.wps[i].errors for i in 1:length(setups)]
134-
err2 = [wp2.wps[i].errors for i in 1:length(setups)]
133+
err1 = [wp1.wps[i].errors.weak_final for i in 1:length(setups)]
134+
err2 = [wp2.wps[i].errors.weak_final for i in 1:length(setups)]
135135

136136
@test isapprox(err1, err2, atol = 1.0e-3)

‎lib/DiffEqDevTools/test/plotrecipes_tests.jl‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,3 +171,27 @@ end
171171
@test plt[1][i][:label] == names[i]
172172
end
173173
end
174+
175+
@testset "Ensemble weak WorkPrecisionSet" begin
176+
f!(du, u, p, t) = (du[1] = -u[1]; nothing)
177+
g!(du, u, p, t) = (du[1] = u[1]; nothing)
178+
prob = SDEProblem(f!, g!, [1.0], (0.0, 0.1))
179+
seeds = rand(UInt, 4)
180+
ensemble_prob = EnsembleProblem(
181+
prob;
182+
output_func = (sol, ctx) -> (sol.u[end][1], false),
183+
prob_func = (prob, ctx) -> remake(prob; seed = seeds[ctx.sim_id])
184+
)
185+
tolerances = 1.0 ./ 4.0 .^ (1:2)
186+
setups = [Dict(:alg => EM(), :dts => [0.05, 0.025], :adaptive => false)]
187+
wp = WorkPrecisionSet(
188+
ensemble_prob, tolerances, tolerances, setups;
189+
numruns = 1, trajectories = 4, expected_value = exp(-0.1),
190+
save_everystep = false, save_start = false, error_estimate = :weak_final,
191+
ensemblealg = EnsembleSerial()
192+
)
193+
194+
@test propertynames(wp[1].errors) == (:weak_final,)
195+
plt = plot(wp)
196+
@test plt[1][1][:x] == wp[1].errors.weak_final
197+
end

0 commit comments

Comments
 (0)