gemseo.post.core.robustness_quantifier module#

Quantification of robustness of the optimum to variables perturbations.

class RobustnessQuantifier(history, approximation_method=Approximation.SR1)[source]#

Bases: object

classdocs.

Parameters:
  • history -- An approximation history.

  • approximation_method (Approximation) --

    The approximation method for the Hessian.

    By default it is set to "SR1".

class Approximation(value)[source]#

Bases: StrEnum

The approximation types.

BFGS = 'BFGS'#
LEAST_SQUARES = 'LEAST_SQUARES'#
SR1 = 'SR1'#
compute_approximation(funcname, first_iter=0, last_iter=None, b0_mat=None, at_most_niter=None, func_index=None)[source]#

Build the BFGS approximation for the Hessian.

Parameters:
  • funcname (str) -- The name of the function.

  • first_iter (int) --

    The index of the first iteration.

    By default it is set to 0.

  • last_iter (int | None) -- The last iteration of the history to be considered. If None, consider all the iterations.

  • b0_mat -- The Hessian matrix at the first iteration.

  • at_most_niter (int | None) -- The maximum number of iterations to be considered. If None, consider all the iterations.

  • func_index -- The component of the function.

Returns:

An approximation of the Hessian matrix.

compute_expected_value(expect, cov)[source]#

Compute the expected value of the output.

Equal to \(0.5\mathbb{E}[e^TBe]\) where \(e\) is the expected values and \(B\) the covariance matrix.

Parameters:
  • expect (Sized) -- The expected value of the inputs.

  • cov -- The covariance matrix of the inputs.

Returns:

The expected value of the output.

Raises:

ValueError -- When expectation and covariance matrices have inconsistent shapes or when the Hessian approximation is missing.

compute_function_approximation(x_vars)[source]#

Compute a second order approximation of the function.

Parameters:

x_vars -- The point on which the approximation is evaluated.

Returns:

A second order approximation of the function.

Return type:

float

compute_gradient_approximation(x_vars)[source]#

Computes a first order approximation of the gradient based on the hessian.

Parameters:

x_vars -- The point on which the approximation is evaluated.

compute_variance(expect, cov)[source]#

Compute the variance of the output.

Equal to \(0.5\mathbb{E}[e^TBe]\) where \(e\) is the expected values and \(B\) the covariance matrix.

Parameters:
  • expect (Sized) -- The expected value of the inputs.

  • cov -- The covariance matrix of the inputs.

Returns:

The variance of the output.

Raises:

ValueError -- When expectation and covariance matrices have inconsistent shapes or when the Hessian approximation is missing.

montecarlo_average_var(mean, cov, n_samples=100000, func=None)[source]#

Computes the variance and expected value using Monte Carlo approach.

Parameters:
  • mean (Sized) -- The mean value.

  • cov -- The covariance matrix.

  • n_samples (int) --

    The number of samples for the distribution.

    By default it is set to 100000.

  • func -- If None, the compute_function_approximation function, otherwise a user function.