@@ -35,3 +35,22 @@ function EnsembleProblem(; prob,
3535 safetycopy = prob_func != = DEFAULT_PROB_FUNC)
3636 EnsembleProblem (prob, prob_func, output_func, reduction, u_init, safetycopy)
3737end
38+
39+ struct WeightedEnsembleProblem{T, T2, T3, T4, T5, T6} <: AbstractEnsembleProblem
40+ ensembleprob:: EnsembleProblem{T, T2, T3, T4, T5}
41+ weights:: T6
42+ end
43+ Base. propertynames (e:: WeightedEnsembleProblem ) = (Base. propertynames (getfield (e, :ensembleprob ))... , :weights )
44+ function Base. getproperty (e:: WeightedEnsembleProblem , f:: Symbol )
45+ f === :weights && return getfield (e, :weights )
46+ f === :ensembleprob && return getfield (e, :ensembleprob )
47+ return getproperty (getfield (e, :ensembleprob ), f)
48+ end
49+ function WeightedEnsembleProblem (args... ; weights, kwargs... )
50+ # TODO : allow skipping checks?
51+ @assert sum (weights) ≈ 1
52+ ep = EnsembleProblem (args... ; kwargs... )
53+ @assert length (ep. prob) == length (weights)
54+ WeightedEnsembleProblem (ep, weights)
55+ end
56+
0 commit comments