Skip to content

Internals of the incomplete gamma function does not work with ForwardDiff.jl's Dual() type due to enforced floating point precision  #465

Open
@akchurinda

Description

@akchurinda

I'm trying to run sensitivity analysis using Fortuna.jl in the example shown here:

using Fortuna

# Define the random vector:
XR      = generaterv("Lognormal", "M", [1.10, 0.10 * 1.10])
XD      = generaterv("Normal",    "M", [1.05, 0.10 * 1.05])
XLApt   = generaterv("Gamma",     "M", [0.22, 0.54 * 0.22])
XLMax   = generaterv("Gumbel",    "M", [1.10, 0.19 * 1.10])
XWMax   = generaterv("Gumbel",    "M", [0.47, 0.35 * 0.47])
X       = [XR, XD, XLApt, XLMax, XWMax]
ρˣ      = Matrix(1.0 * I, 5, 5)

# Define the limit state function:
function g(x, θ)
    R2D = (1 / θ[1]) * max(
        1.4, 
        1.2 + 1.6 * θ[2],
        1.2 + 0.5 * θ[2] + 1.0 * θ[3])

    Q2D = max(
        x[2] + θ[2] * x[3],
        x[2] + θ[2] * x[4],
        x[2] + θ[2] * x[3] + θ[3] * x[5])

    return R2D * x[1] - Q2D
end

# Define the parameters of the limit state function:
θ       = [0.90, 2, 1000] 

# Define and solve the sensitivity problem:
Problem     = SensitivityProblem(X, ρˣ, g, θ)
Solution    = analyze(Problem)

The example fails to run due to the fact that internals of the incomplete gamma function, such as __gamma_inc_inv(), enforce Float64 type and, as the result, errors on ForwardDiff.jl's Dual() type. Here a truncated error message:

ERROR: MethodError: no method matching __gamma_inc_inv(::ForwardDiff.Dual{…}, ::ForwardDiff.Dual{…}, ::Bool)

Closest candidates are:
  __gamma_inc_inv(::Float64, ::Float64, ::Bool)
   @ SpecialFunctions ~/.julia/packages/SpecialFunctions/QH8rV/src/gamma_inc.jl:1012
  __gamma_inc_inv(::T, ::T, ::Bool) where T<:Union{Float16, Float32}
   @ SpecialFunctions ~/.julia/packages/SpecialFunctions/QH8rV/src/gamma_inc.jl:1089

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions