First order reliability method
[1]:
# Import auxiliary libraries for demonstration
import matplotlib as mpl
import matplotlib.pyplot as plt
import numpy as np
from scipy import stats
plt.rcParams[ "figure.figsize" ] = [ 5, 4 ]
plt.rcParams[ "figure.dpi" ] = 80
plt.rcParams[ "font.family" ] = "Times New Roman"
plt.rcParams[ "font.size" ] = '14'
Hasofer-Lind-Rackwitz-Fiessler FORM
Hasofer-Lind-Rackwitz-Fiessler (HLRF) algorithm is an iterative method to find the reliability index. It is shown that the HLRF algorithm is very effective in many situations even if the convergence is not assured in all cases.
Function hlrfFORM
implements the FORM with Hasofer-Lind-Rackwitz-Fiessler algorithm. The Nataf transformation is used in the method to map the random variables from X space to U space.
Reference:
Wang, C., 2021. Structural reliability and time-dependent reliability. Cham, Switzerland: Springer.
Lemaire, M., 2013. Structural reliability. John Wiley & Sons.
Function help
[2]:
from ffpack.rrm import hlrfFORM
help( hlrfFORM )
Help on function hlrfFORM in module ffpack.rrm.firstOrderReliabilityMethod:
hlrfFORM(dim, g, dg, distObjs, corrMat, iter=1000, tol=1e-06, quadDeg=99, quadRange=8, dx=1e-06)
First order reliability method based on Hasofer-Lind-Rackwitz-Fiessler algorithm.
Parameters
----------
dim: integer
Space dimension ( number of random variables ).
g: function
Limit state function. It will be called like g( [ x1, x2, ... ] ).
dg: array_like of function
Gradient of the limit state function. It should be an array_like of function
like dg = [ dg_dx1, dg_dx2, ... ]. To get the derivative of i-th random
variable at ( x1*, x2*, ... ), dg[ i ]( x1*, x2*, ... ) will be called.
dg can be None, see the following Notes.
distObjs: array_like of distributions
Marginal distribution objects. It should be the freezed distribution
objects with pdf, cdf, ppf. We recommend to use scipy.stats functions.
corrMat: 2d matrix
Correlation matrix of the marginal distributions.
iter: integer
Maximum iteration steps.
tol: scalar
Tolerance to demtermine if the iteration converges.
quadDeg: integer
Quadrature degree for Nataf transformation
quadRange: scalar
Quadrature range for Nataf transformation. The integral will be performed
in the range [ -quadRange, quadRange ].
dx : scalar, optional
Spacing for auto differentiation. Not required if dg is provided.
Returns
-------
beta: scalar
Reliability index.
pf: scalar
Probability of failure.
uCoord: 1d array
Design point coordinate in U space.
xCoord: 1d array
Design point coordinate in X space.
Raises
------
ValueError
If the dim is less than 1.
If the dim does not match the disObjs and corrMat.
If corrMat is not 2d matrix.
If corrMat is not positive definite.
If corrMat is not symmetric.
If corrMat diagonal is not 1.
Notes
-----
If dg is None, the numerical differentiation will be used. The tolerance of the
numerical differentiation can be changed in globalConfig.
Examples
--------
>>> from ffpack.rrm import hlrfFORM
>>> dim = 2
>>> g = lambda X: -np.sum( X ) + 1
>>> dg = [ lambda X: -1, lambda X: -1 ]
>>> distObjs = [ stats.norm(), stats.norm() ]
>>> corrMat = np.eye( dim )
>>> beta, pf, uCoord, xCoord = hlrfFORM( dim, g, dg, distObjs, corrMat )
Example with explicit derivative of LSF
[3]:
# Define the dimension for the FORM problem
dim = 2
# Define the limit state function (LSF) g
g = lambda X: 1.0 - X[ 0 ] - X[ 1 ]
# Explicit derivative of LSF
# dg is a list in which each element is a partial derivative function of g w.r.t. X
# dg[0] = partial g / partial X[0]
# dg[1] = partial g / partial X[1]
dg = [ lambda X: -1, lambda X: -1 ]
# Marginal distributions and correlation Matrix of the random variables
distObjs = [ stats.norm(), stats.norm() ]
corrMat = np.eye( dim )
beta, pf, uCoord, xCoord = hlrfFORM( dim, g, dg, distObjs, corrMat )
[4]:
print( "Reliability index: " )
print( beta )
print()
print( "Failure probability: " )
print( pf )
print()
print( "Design point coordinate in U space: " )
print( uCoord )
print()
print( "Design point coordinate in X space: " )
print( xCoord )
Reliability index:
0.7071067811865477
Failure probability:
0.23975006109347669
Design point coordinate in U space:
[0.5000000000000001, 0.5000000000000001]
Design point coordinate in X space:
[0.5000000000000001, 0.5000000000000001]
Example with automatic differentiation of LSF
[5]:
# Define the dimension for the FORM problem
dim = 2
# Define the limit state function (LSF) g
g = lambda X: 1.0 - X[ 0 ] - X[ 1 ]
# If dg is None, the internal automatic differentiation algorithm will be used
dg = None
# Marginal distributions and correlation Matrix of the random variables
distObjs = [ stats.norm(), stats.norm() ]
corrMat = np.eye( dim )
beta, pf, uCoord, xCoord = hlrfFORM( dim, g, dg, distObjs, corrMat )
[6]:
print( "Reliability index: " )
print( beta )
print()
print( "Failure probability: " )
print( pf )
print()
print( "Design point coordinate in U space: " )
print( uCoord )
print()
print( "Design point coordinate in X space: " )
print( xCoord )
Reliability index:
0.7071053669729852
Failure probability:
0.23975050048498586
Design point coordinate in U space:
[0.4999990000000001, 0.4999990000000001]
Design point coordinate in X space:
[0.49999900000000025, 0.49999900000000025]
Constrained optimization FORM
Finding the design point or most probable point (MPP) for a given limit state function is basically a constrained optimization problem. It can be represented by the following equation,
where transformation \(\mathbf{T}\) is introduced to map the original random variables \(\mathbf{X}\) (in X-space) to the standard, uncorrelated normal variables \(\mathbf{U}\) with \(\mathbf{U} = \mathbf{T} ( \mathbf{X} )\).
Function coptFORM
implements the FORM with constrained optimization algorithm. The Nataf transformation is used in the method to map the random variables from X space to U space.
Function help
[7]:
from ffpack.rrm import coptFORM
help( coptFORM )
Help on function coptFORM in module ffpack.rrm.firstOrderReliabilityMethod:
coptFORM(dim, g, distObjs, corrMat, quadDeg=99, quadRange=8)
First order reliability method based on constrained optimization.
Parameters
----------
dim: integer
Space dimension ( number of random variables ).
g: function
Limit state function. It will be called like g( [ x1, x2, ... ] ).
distObjs: array_like of distributions
Marginal distribution objects. It should be the freezed distribution
objects with pdf, cdf, ppf. We recommend to use scipy.stats functions.
corrMat: 2d matrix
Correlation matrix of the marginal distributions.
quadDeg: integer
Quadrature degree for Nataf transformation
quadRange: scalar
Quadrature range for Nataf transformation. The integral will be performed
in the range [ -quadRange, quadRange ].
Returns
-------
beta: scalar
Reliability index.
pf: scalar
Probability of failure.
uCoord: 1d array
Design point coordinate in U space.
xCoord: 1d array
Design point coordinate in X space.
Raises
------
ValueError
If the dim is less than 1.
If the dim does not match the disObjs and corrMat.
If corrMat is not 2d matrix.
If corrMat is not positive definite.
If corrMat is not symmetric.
If corrMat diagonal is not 1.
Examples
--------
>>> from ffpack.rrm import coptFORM
>>> dim = 2
>>> g = lambda X: -np.sum( X ) + 1
>>> distObjs = [ stats.norm(), stats.norm() ]
>>> corrMat = np.eye( dim )
>>> beta, pf, uCoord, xCoord = coptFORM( dim, g, distObjs, corrMat )
Example with default values
[8]:
# Define the dimension for the FORM problem
dim = 2
# Define the limit state function (LSF) g
g = lambda X: 1.0 - X[ 0 ] - X[ 1 ]
# Marginal distributions and correlation Matrix of the random variables
distObjs = [ stats.norm(), stats.norm() ]
corrMat = np.eye( dim )
beta, pf, uCoord, xCoord = coptFORM( dim, g, distObjs, corrMat )
[9]:
print( "Reliability index: " )
print( beta )
print()
print( "Failure probability: " )
print( pf )
print()
print( "Design point coordinate in U space: " )
print( uCoord )
print()
print( "Design point coordinate in X space: " )
print( xCoord )
Reliability index:
0.7071067706498352
Failure probability:
0.23975006436719704
Design point coordinate in U space:
[0.4999999925494192, 0.4999999925494193]
Design point coordinate in X space:
[0.4999999925494192, 0.4999999925494192]