diff --git a/PRASCore.jl/Project.toml b/PRASCore.jl/Project.toml index 1af73c1c..7edaec3f 100644 --- a/PRASCore.jl/Project.toml +++ b/PRASCore.jl/Project.toml @@ -6,7 +6,7 @@ authors = [ "Srihari Sundar ", "Julian Florez 0 + div(MeanEstimate(x[]..., x.nsamples), demand/1e6) + else + MeanEstimate(0.) + end + + return NEUE(estimate) + end function NEUE(x::ShortfallResult, r::AbstractString) + i_r = findfirstunique(x.regions.names, r) - return NEUE(div(MeanEstimate(x[r]..., x.nsamples),(sum(x.regions.load[i_r,:])/1e6))) + + demand = sum(x.regions.load[i_r, :]) + + estimate = if demand > 0 + div(MeanEstimate(x[r]..., x.nsamples), demand/1e6) + else + MeanEstimate(0.) + end + + return NEUE(estimate) + end function finalize( diff --git a/PRASCore.jl/src/Results/ShortfallSamples.jl b/PRASCore.jl/src/Results/ShortfallSamples.jl index bddca0f6..99106433 100644 --- a/PRASCore.jl/src/Results/ShortfallSamples.jl +++ b/PRASCore.jl/src/Results/ShortfallSamples.jl @@ -155,13 +155,34 @@ EUE(x::ShortfallSamplesResult{N,L,T,P,E}, t::ZonedDateTime) where {N,L,T,P,E} = EUE(x::ShortfallSamplesResult{N,L,T,P,E}, r::AbstractString, t::ZonedDateTime) where {N,L,T,P,E} = EUE{1,L,T,E}(MeanEstimate(x[r, t])) -function NEUE(x::ShortfallSamplesResult{N,L,T,P,E}) where {N,L,T,P,E} - return NEUE(div(MeanEstimate(x[]),(sum(x.regions.load)/1e6))) +function NEUE(x::ShortfallSamplesResult) + + demand = sum(x.regions.load) + + estimate = if demand > 0 + div(MeanEstimate(x[]), demand/1e6) + else + MeanEstimate(0.) + end + + return NEUE(estimate) + end -function NEUE(x::ShortfallSamplesResult{N,L,T,P,E}, r::AbstractString) where {N,L,T,P,E} +function NEUE(x::ShortfallSamplesResult, r::AbstractString) + i_r = findfirstunique(x.regions.names, r) - return NEUE(div(MeanEstimate(x[r]),(sum(x.regions.load[i_r,:])/1e6))) + + demand = sum(x.regions.load[i_r, :]) + + estimate = if demand > 0 + div(MeanEstimate(x[r]), demand/1e6) + else + MeanEstimate(0.) + end + + return NEUE(estimate) + end function finalize(