Skip to content

Commit 739c747

Browse files
authored
Merge pull request #742 from mimiframework/sobol
GlobalSA and Sobol Fixes
2 parents add61f6 + eb893e3 commit 739c747

File tree

4 files changed

+7
-6
lines changed

4 files changed

+7
-6
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Distributions = "0.21, 0.22, 0.23"
4343
Electron = "1.1, 2.0, 3.0"
4444
FileIO = "1"
4545
FilePaths = "0.8"
46-
GlobalSensitivityAnalysis = "0.0.9, 0.0.10"
46+
GlobalSensitivityAnalysis = "1.0"
4747
GraphPlot = "0.3, 0.4"
4848
IterTools = "1.3"
4949
IteratorInterfaceExtensions = "0.1.1, 1"

docs/src/tutorials/tutorial_5.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ sd = @defsim begin
205205
# Exclude the sampling() call, or use the following for simple random sampling:
206206
# sampling(MCSData)
207207
208-
# For Sobol sampling, specify N, and calc_second_order, which defaults to false.
208+
# For Sobol sampling, specify N, and calc_second_order, which defaults to true.
209209
# sampling(SobolData, N=10000, calc_second_order=true)
210210
211211
# assign RVs to model Parameters

src/mcs/sobol.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import GlobalSensitivityAnalysis
44
mutable struct SobolData <: AbstractSimulationData
55
calc_second_order::Bool
66

7-
function SobolData(;calc_second_order = false)
7+
function SobolData(;calc_second_order = true)
88
return new(calc_second_order)
99
end
1010
end
@@ -50,15 +50,15 @@ function sample!(sim_inst::SobolSimulationInstance, samplesize::Int)
5050
end
5151
end
5252

53-
function analyze(sim_inst::SobolSimulationInstance, model_output::AbstractArray{<:Number, N}; num_resamples::Union{Nothing, Int} = 10_000, conf_level::Union{Nothing, Number} = 0.95) where N
53+
function analyze(sim_inst::SobolSimulationInstance, model_output::AbstractArray{<:Number, N}; num_resamples::Union{Nothing, Int} = 10_000, conf_level::Union{Nothing, Number} = 0.95, N_override::Union{Nothing, Int}=nothing, progress_meter::Bool = true) where N
5454

5555
if sim_inst.trials == 0
5656
error("Cannot analyze simulation with 0 trials.")
5757
end
5858

5959
payload = create_GSA_payload(sim_inst)
6060

61-
return GlobalSensitivityAnalysis.analyze(payload, model_output; num_resamples = num_resamples, conf_level = conf_level)
61+
return GlobalSensitivityAnalysis.analyze(payload, model_output; num_resamples = num_resamples, conf_level = conf_level, N_override = N_override, progress_meter = progress_meter)
6262
end
6363

6464
function create_GSA_payload(sim_inst::SobolSimulationInstance)

test/mcs/test_defmcs_sobol.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ results_disk[!,2] = Symbol.(results_disk[!,2])
6868

6969
# do some analysis
7070
E = CSVFiles.load(joinpath(output_dir, "emissions_E.csv")) |> DataFrame
71-
results = analyze(si, E[1:60:end, 3]; num_resamples = 10_000, conf_level = 0.95)
71+
results = analyze(si, E[1:60:end, 3]; progress_meter = false, N_override = 100)
72+
results = analyze(si, E[1:60:end, 3]; progress_meter = false, num_resamples = 10_000, conf_level = 0.95)
7273

7374
function show_E_Region(year::Int; region = "Region1", bins=40)
7475
df = @from i in E begin

0 commit comments

Comments
 (0)