# Sensitivity Problems

## Types of Sensitivity Problems in Fortuna.jl

Fortuna.jl districts two types of sensitivity problems:

ItemDescription
Type IUsed to find sensitivities w.r.t. to the parameters $\vec{\Theta}_{g}$ of the limit state function $g(\vec{X}, \vec{\Theta}_{g})$
Type IIUsed to find sensitivities w.r.t. to the parameters and/or moments $\vec{\Theta}_{f}$ of the random vector $\vec{X}(\vec{\Theta}_{f})$

## Defining and Solving Sensitivity Problems of Type I

In general, 4 main "items" are always needed to fully define a sensitivity problem of type I and successfully solve it to find the associated sensitivity vectors of probability of failure $\vec{\nabla}_{\vec{\Theta}_{g}} P_{f}$ and reliability index $\vec{\nabla}_{\vec{\Theta}_{g}} \beta$ w.r.t. to the parameters of the limit state function $\vec{\Theta}_{g}$:

ItemDescription
$\vec{X}$Random vector
$\rho^{X}$Correlation matrix
$g(\vec{X}, \vec{\Theta}_{g})$Limit state function parametrized in terms of its parameters
$\vec{\Theta}_{g}$Parameters of the limit state function

Fortuna.jl package uses these 4 "items" to fully define sensitivity problems of type I using SensitivityProblem() type as shown in the example below.

# Define the random vector:
M₁ = randomvariable("Normal",  "M", [250,   250   * 0.3])
M₂ = randomvariable("Normal",  "M", [125,   125   * 0.3])
P  = randomvariable("Gumbel",  "M", [2500,  2500  * 0.2])
Y  = randomvariable("Weibull", "M", [40000, 40000 * 0.1])
X  = [M₁, M₂, P, Y]

# Define the correlation matrix:
ρˣ = [
1.0 0.5 0.3 0.0
0.5 1.0 0.3 0.0
0.3 0.3 1.0 0.0
0.0 0.0 0.0 1.0]

# Define the limit state function:
g(x::Vector, θ::Vector) = 1 - x[1] / (θ[1] * x[4]) - x[2] / (θ[2] * x[4]) - (x[3] / (θ[3] * x[4])) ^ 2

# Define parameters of the limit state function:
s₁ = 0.030
s₂ = 0.015
a  = 0.190
Θ  = [s₁, s₂, a]

# Define a sensitivity problem:
Problem = SensitivityProblemTypeI(X, ρˣ, g, Θ)

After defining a sensitivity problem of type I, Fortuna.jl allows to easily perform sensitivity analysis using a single solve() function as shown in the example below.

# Perform the sensitivity analysis:
Solution = solve(Problem)
println("∇β   = $(Solution.∇β) ") println("∇PoF =$(Solution.∇PoF)")
∇β   = [36.772641319792505, 73.54528263958501, 9.257373675763706]
∇PoF = [-0.7013033794746208, -1.4026067589492417, -0.17655047912965946]

## Defining and Solving Sensitivity Problems of Type II

Similar to sensitivity problem of type I, 4 main "items" are needed to fully define a sensitivity problem of type II and successfully solve it to find the associated sensitivity vectors of probability of failure $\vec{\nabla}_{\vec{\Theta}_{f}} P_{f}$ and reliability index $\vec{\nabla}_{\vec{\Theta}_{f}} \beta$ w.r.t. to the parameters and/or moments of the random vector $\vec{\Theta}_{f}$:

ItemDescription
$\vec{X}(\vec{\Theta}_{f})$Random vector with correlated non-normal marginals parameterized in terms of its parameters and/or moments
$\rho^{X}$Correlation matrix
$g(\vec{X})$Limit state function
$\vec{\Theta}_{f}$Parameters and/or moments of the random vector

Fortuna.jl package uses these 4 "items" to fully define sensitivity problems of type I using SensitivityProblem() type as shown in the example below.

# Define the random vector as a function of its parameters and moments:
function XFunction(Θ::Vector)
M₁ = randomvariable("Normal",  "M", [Θ[1], Θ[2]])
M₂ = randomvariable("Normal",  "M", [Θ[3], Θ[4]])
P  = randomvariable("Gumbel",  "M", [Θ[5], Θ[6]])
Y  = randomvariable("Weibull", "M", [Θ[7], Θ[8]])

return [M₁, M₂, P, Y]
end

# Define the correlation matrix:
ρˣ = [
1.0 0.5 0.3 0.0
0.5 1.0 0.3 0.0
0.3 0.3 1.0 0.0
0.0 0.0 0.0 1.0]

# Define the parameters and moments of the random vector:
Θ = [
250,   250 * 0.30,
125,   125 * 0.30,
2500,  2500 * 0.20,
40000, 40000 * 0.10]

# Define the limit state function:
a            = 0.190
s₁           = 0.030
s₂           = 0.015
g(x::Vector) = 1 - x[1] / (s₁ * x[4]) - x[2] / (s₂ * x[4]) - (x[3] / (a * x[4])) ^ 2

# Define a sensitivity problem:
Problem  = SensitivityProblemTypeII(XFunction, ρˣ, g, Θ)

Similar to sensitivity problems of type I, sensitivity problems of type II are solved using the same solve() function as shown in the example below.

# Perform the sensitivity analysis:
Solution = solve(Problem)
println("∇β   = $(Solution.∇β) ") println("∇PoF =$(Solution.∇PoF)")
∇β   = [-0.0032377356438926144, -0.003916604381608311, -0.006475471287785204, -0.007833208763216592, -0.0005458335376913401, -0.0007886343083335104, 0.00012366075495612834, -0.00024529268016562015]
∇PoF = [6.174794269361286e-5, 7.469487614447258e-5, 0.00012349588538722523, 0.0001493897522889446, 1.0409774519174644e-5, 1.504030947339743e-5, -2.3583757447534128e-6, 4.678058996755998e-6]

## API

Fortuna.solveMethod
solve(Problem::SensitivityProblemTypeI; Differentiation::Symbol = :Automatic)

Function used to solve sensitivity problems of type I (sensitivities w.r.t. the parameters of the limit state function).
If Differentiation is:

• :Automatic, then the function will use automatic differentiation to compute gradients, jacobians, etc.
• :Numeric, then the function will use numeric differentiation to compute gradients, jacobians, etc.
Fortuna.solveMethod
solve(Problem::SensitivityProblemTypeII; Differentiation::Symbol = :Automatic)

Function used to solve sensitivity problems of type II (sensitivities w.r.t. the parameters of the random vector).
If Differentiation is:

• :Automatic, then the function will use automatic differentiation to compute gradients, jacobians, etc.
• :Numeric, then the function will use numeric differentiation to compute gradients, jacobians, etc.
Fortuna.SensitivityProblemTypeIType

SensitivityProblemTypeI <: AbstractReliabilityProblem

Type used to define sensitivity problems of type I (sensitivities w.r.t. the parameters of the limit state function).

• X::AbstractVector{<:UnivariateDistribution}: Random vector $\vec{X}$

• ρˣ::AbstractMatrix{<:Real}: Correlation matrix $\rho^{X}$

• g::Function: Limit state function $g(\vec{X}, \vec{\Theta})$

• Θ::AbstractVector{<:Real}: Parameters of limit state function $\vec{\Theta}$

Fortuna.SensitivityProblemTypeIIType

SensitivityProblemTypeII <: AbstractReliabilityProblem

Type used to define sensitivity problems of type II (sensitivities w.r.t. the parameters of the random vector).

• X::Function: Random vector $\vec{X}(\vec{\Theta})$

• ρˣ::AbstractMatrix{<:Real}: Correlation matrix $\rho^{X}$

• g::Function: Limit state function $g(\vec{X})$

• Θ::AbstractVector{<:Real}: Parameters of limit state function $\vec{\Theta}$

Fortuna.SensitivityProblemCacheType
SensitivityProblemCache

Type used to store results of sensitivity analysis for problems of type I (sensitivities w.r.t. the parameters of the limit state function).

• FORMSolution::iHLRFCache: Results of reliability analysis performed using First-Order Reliability Method (FORM)

• ∇β::Vector{Float64}: Sensivity vector of reliability index $\vec{\nabla}_{\vec{\Theta}} \beta$

• ∇PoF::Vector{Float64}: Sensivity vector of probability of failure $\vec{\nabla}_{\vec{\Theta}} P_{f}$