pystra.model.LimitState#
- class LimitState(expression=None)[source]#
Bases:
objectThe Limit State function definition class.
The limit state function can be defined in two main ways:
1. Numerical differentiation (FFD): the limit state function need only return its value at a set of evaluation points, X. In this form, the function can be either:
A python lambda object;
A python function object.
2. Using the Direct Differentiation Method (DDM): the limit state function is a python function object return both its value and gradient vector at each of the evaluation points.
Note in both cases that each parameter (i.e. function argument) may be passed as a vector, depending on the algorithm being called.
Where a function returns a gradient vector, it is only utilized when DDM is specified.
Argument matching: the function is called as
expression(**kwargs)where each keyword argument is a variable name from theStochasticModel. Arguments may therefore be declared explicitly (def lsf(X1, X2, X3): ...) or collected with**kwargsfor a dimension-agnostic definition:def lsf(**kwargs): return sum(v**2 for v in kwargs.values())
Methods
Call the user-defined limit state function.
Evaluate the LSF using direct differentiation (user-supplied gradient).
Evaluate the LSF and approximate the gradient by forward finite difference.
Evaluate the limit state function and (optionally) its gradient.
Evaluate the LSF without computing gradients (used for MCS).
getExpressionsetExpression- expression#
Expression of the limit-state function
- evaluate_lsf(x, stochastic_model, analysis_options, diff_mode=None)[source]#
Evaluate the limit state function and (optionally) its gradient.
Dispatches to the appropriate evaluation strategy based on the differentiation mode: no gradient (
"no"), forward finite difference ("ffd"), or direct differentiation ("ddm").- Parameters:
x (ndarray) – Evaluation points, shape
(nrv, nx)where nrv is the number of random variables and nx the number of points.stochastic_model (StochasticModel) – The probabilistic model.
analysis_options (AnalysisOptions) – Algorithm settings (differentiation mode, block size, etc.).
diff_mode (str or None, optional) – Override the differentiation mode. If a string is passed (any value), gradient computation is suppressed (
"no").
- Returns:
G (ndarray) – Limit state function values, shape
(1, nx).grad_G (ndarray) – Gradient matrix, shape
(nrv, nx). Zero when no gradient is computed.
- evaluate_ffd(x)[source]#
Evaluate the LSF and approximate the gradient by forward finite difference.
- compute_lsf(x, ddm=False)[source]#
Call the user-defined limit state function.
Builds a keyword-argument dictionary mapping variable names to their column vectors in
x, then callsself.expression(**kwargs).- Parameters:
x (ndarray) – Evaluation points, shape
(nrv, nc).ddm (bool, optional) – If
True, expects the expression to return both the function value and a gradient vector.
- Returns:
G (ndarray) – Function value(s).
gradient (ndarray or int) – Gradient vector (if ddm) or
0.