davidanthoff / PyRhodium.jl
1
#
2
# Sensitivity analysis related types and functions
3
#
4

5
struct Sensitivity <: Wrapper
6
    pyo::PyObject
7

8
    function Sensitivity(pyo::PyObject)
9 0
        new(pyo)
10
    end
11
end
12

13
struct SAResult  <: Wrapper
14
    pyo::PyObject
15

16
    function SAResult(pyo::PyObject)
17 0
        new(pyo)
18
    end
19
end
20

21
function sa(m::Model, response; policy = Dict(), method = "sobol", nsamples = 1000, kwargs...)
22 0
    my_sa = py"my_sa"
23 0
    pyo = my_sa(m.pyo, response; policy = policy, method = method, nsamples = nsamples, kwargs...)
24 0
    return SAResult(pyo."sa_result")   # access without conversion
25
end
26

27
function plot(sar::SAResult; kwargs...)
28 0
    return rhodium.SAResult.plot(sar.pyo; kwargs...)
29
end
30

31
function plot_sobol(sar::SAResult;
32
                    radSc = 2.0, scaling = 1, widthSc = 0.5, STthick = 1, varNameMult = 1.3,
33
                    colors = nothing, groups = nothing, gpNameMult = 1.5, threshold = "conf")
34

35 0
    fig = rhodium.SAResult.plot_sobol(sar.pyo; radSc = radSc, scaling = scaling, widthSc = widthSc,
36
                               STthick = STthick, varNameMult = varNameMult,
37
                               colors = colors, groups = groups, gpNameMult = gpNameMult,
38
                               threshold = threshold)
39 0
    return fig
40
end
41

42
function oat(m::Model, response; policy = Dict(), nsamples::Int = 100, kwargs...)
43 0
    fig = rhodium.oat(m.pyo, response; policy = policy, nsamples = nsamples, kwargs...)
44 0
    return fig
45
end

Read our documentation on viewing source code .

Loading