D Optimality (Alphabetic) Criteria#

Bayesian D Optimality Criterion (Binary Design)#

Module providing implementations of the Bayesian D-optimality criterion (utility function) for Bayesian inverse problems.

class BayesianInversionDOptConfigs(*, debug=False, verbose=False, output_dir='./_PYOED_RESULTS_', oed_problem=None, lp_behavior=LP_Behavior.MAP, use_FIM=True, evaluation_method='exact', sample_size=50, optimize_sample_size=False, min_sample_size=10, max_sample_size=100, distribution='Rademacher', randomization_vectors=None, random_seed=None, accuracy=0.01, sigma_bounds=<factory>, n_deg=14)[source]#

Bases: BayesianInversionAOptConfigs

Configuration class for Bayesian D-optimality criterion (utility functions).

This mirrors the configurations in BayesianInversionAOptConfigs with two additional configurations used for estimating (when method is randomized) the log-determinant of the matrix. These configurations are passed to the utility function utility.math.matrix_logdet:

Parameters:
  • verbose (bool) – a boolean flag to control verbosity of the object.

  • debug (bool) – a boolean flag that enables adding extra functionlity in a debug mode

  • output_dir (str | Path) – the base directory where the output files will be saved.

  • oed_problem (InversionOED | None) – OED problem for which the utility function is defined. This must be an instance of InversionOED.

  • lp_behavior (LP_Behavior | str) – behavior of the linearization point (MAP, prior, manual). By default, it is set to MAP. However, if the oed problem is linear, the passed parameter is ignored and is changed to LINEAR instead. If you wish to forcefully choose the linearization point despite the linearity of the problem, set the field after instantiation.

  • use_FIM (bool) – if True, the trace of the FIM is used as the criterion. If False, the inverse of the FIM (the posterior covariance matrix) trace is used.

  • evaluation_method (str) –

    A string describing the method to use for computing the criterion and its gradients. Supported are:

    • "exact": Compute the exact value of the criterion. Potentially

      intractable if problem is too large.

    • "randomized": Use randomized algorithms to compute the

      criterion value. Potentially faster for large problems but may be inaccurate.

  • sample_size (int) – The number of samples to use for randomized algorithms. Default is 50.

  • optimize_sample_size (bool) – If True, the sample size is optimized based on the problem size. Default is False.

  • min_sample_size (int) – The minimum sample size to use for randomized algorithms. Default is 10.

  • max_sample_size (int) – The maximum sample size to use for randomized algorithms. Default is 100.

  • distribution (str) – The distribution to use for randomization. Default is “Rademacher”.

  • randomization_vectors (None | ndarray | Sequence) – The randomization vectors to use for randomized algorithms. Default is None. Note, if None, the randomization vectors are constructed and saved for future use during the first evaluation.

  • random_seed (None | int) – The random seed to use for randomized algorithms. Default is None.

  • accuracy (float) – The accuracy to use for randomized algorithms. Default is 1e-2.

  • sigma_bounds ([Optional[float], Optional[float]]) – bounds on the singular values of the matrix. Default is [None, None], which means that the singular values are estimated. THIS IS VERY COSTLY!

  • n_deg (int) – number of terms to use in Chebyshev expansion.

sigma_bounds: [Optional[float], Optional[float]]#
n_deg: int#
__init__(*, debug=False, verbose=False, output_dir='./_PYOED_RESULTS_', oed_problem=None, lp_behavior=LP_Behavior.MAP, use_FIM=True, evaluation_method='exact', sample_size=50, optimize_sample_size=False, min_sample_size=10, max_sample_size=100, distribution='Rademacher', randomization_vectors=None, random_seed=None, accuracy=0.01, sigma_bounds=<factory>, n_deg=14)#
class BayesianInversionDOpt(configs=None)[source]#

Bases: BayesianInversionAOpt

General class implementing common functionality for Bayesian D optimality criterion (utility functions).

Bayesian D-optimality is defined as the log-det of the Fisher information matrix (FIM) (the utility function to be maximized) or the posterior covariance (optimality criterion to be minimized) assuming a Gaussian posterior (or a Laplacian/Gaussian approximation of the posterior, usually obtained by linearization of the forward (simulation + observation) around an estimate of the ground truth).

\[\mathcal{\Phi}_{\rm A}(\xi) = \text{log det}(\mathbf{C}_\text{post}), \text{ or } \mathcal{\Phi}_{\rm A}(\xi) = \text{log det}(\mathbf{C}^{-1}_\text{post})\]

For a linear/linearized problem, the FIM is equal to the inverse of the posterior covariance. The choise between the two formulation (FIM vs. posterior covariance) is decided based on the appropriate configurations parameter

For a nonlinear inverse problem (non-linear solution operator/model and/or observation operator) the Hessian (inverse of the covariance operator) needs to be evaluated based on a linearization (tangent linear model) of the solution and the observation operator at the truth (or an approximation thereof) where the MAP estimate is used. Thus, the MAP estimate must be be available for nonlinear inverse problem.

Parameters:

configs (dict | BayesianInversionDOptConfigs | None) – an object holding configurations.

__init__(configs=None)[source]#

Constructor for utility functions / optimality criteria.

Parameters:

configs (dict) – Object holding configurations for the criterion.

validate_configurations(configs, raise_for_invalid=True)[source]#

A method to check the passed configurations and make sure they are conformable with each other, and with current configurations (or default of not set)

Parameters:
  • configs (dict | BayesianInversionDOptConfigs) – an object holding key/value configurations

  • raise_for_invalid (bool) – if True raise TypeError for invalid configrations key

Returns:

True/False flag indicating whether passed configurations is valid or not

evaluate(design)[source]#

Evaluate the D-optimal criterion for the given OED problem at the given design.

Parameters:

design – an observational design vector conformable with the observation operator and the observation error covariance matrix operator.

Returns:

D-optimal design criterion value.

Return type:

float

property n_deg#

n_deg in configurations

property sigma_bounds#

sigma_bounds in configurations

Relaxed Bayesian D Optimality Criterion (Binary or Relaxed Design)#

class RelaxedBayesianInversionDOptConfigs(*, debug=False, verbose=False, output_dir='./_PYOED_RESULTS_', oed_problem=None, lp_behavior=LP_Behavior.MAP, use_FIM=True, evaluation_method='exact', sample_size=50, optimize_sample_size=False, min_sample_size=10, max_sample_size=100, distribution='Rademacher', randomization_vectors=None, random_seed=None, accuracy=0.01, sigma_bounds=<factory>, n_deg=14, formulation_approach=FORMULATION_APPROACH.POINTWISE_COVARIANCE_MULTIPLICATION, pcw_scheme='covariance-product')[source]#

Bases: BayesianInversionDOptConfigs

Configuration class for RelaxedBayesianInversionDOpt criterion. See RelaxedBayesianInversionDOpt for D-Opt specific configurations and

Parameters:
  • verbose (bool) – a boolean flag to control verbosity of the object.

  • debug (bool) – a boolean flag that enables adding extra functionlity in a debug mode

  • output_dir (str | Path) – the base directory where the output files will be saved.

  • oed_problem (InversionOED | None) – OED problem for which the utility function is defined. This must be an instance of InversionOED.

  • lp_behavior (LP_Behavior | str) – behavior of the linearization point (MAP, prior, manual). By default, it is set to MAP. However, if the oed problem is linear, the passed parameter is ignored and is changed to LINEAR instead. If you wish to forcefully choose the linearization point despite the linearity of the problem, set the field after instantiation.

  • use_FIM (bool) – if True, the trace of the FIM is used as the criterion. If False, the inverse of the FIM (the posterior covariance matrix) trace is used.

  • evaluation_method (str) –

    A string describing the method to use for computing the criterion and its gradients. Supported are:

    • "exact": Compute the exact value of the criterion. Potentially

      intractable if problem is too large.

    • "randomized": Use randomized algorithms to compute the

      criterion value. Potentially faster for large problems but may be inaccurate.

  • sample_size (int) – The number of samples to use for randomized algorithms. Default is 50.

  • optimize_sample_size (bool) – If True, the sample size is optimized based on the problem size. Default is False.

  • min_sample_size (int) – The minimum sample size to use for randomized algorithms. Default is 10.

  • max_sample_size (int) – The maximum sample size to use for randomized algorithms. Default is 100.

  • distribution (str) – The distribution to use for randomization. Default is “Rademacher”.

  • randomization_vectors (None | ndarray | Sequence) – The randomization vectors to use for randomized algorithms. Default is None. Note, if None, the randomization vectors are constructed and saved for future use during the first evaluation.

  • random_seed (None | int) – The random seed to use for randomized algorithms. Default is None.

  • accuracy (float) – The accuracy to use for randomized algorithms. Default is 1e-2.

  • sigma_bounds ([Optional[float], Optional[float]]) – bounds on the singular values of the matrix. Default is [None, None], which means that the singular values are estimated. THIS IS VERY COSTLY!

  • n_deg (int) – number of terms to use in Chebyshev expansion.

formulation_approach: str#
pcw_scheme: str | PCWFunction#
__init__(*, debug=False, verbose=False, output_dir='./_PYOED_RESULTS_', oed_problem=None, lp_behavior=LP_Behavior.MAP, use_FIM=True, evaluation_method='exact', sample_size=50, optimize_sample_size=False, min_sample_size=10, max_sample_size=100, distribution='Rademacher', randomization_vectors=None, random_seed=None, accuracy=0.01, sigma_bounds=<factory>, n_deg=14, formulation_approach=FORMULATION_APPROACH.POINTWISE_COVARIANCE_MULTIPLICATION, pcw_scheme='covariance-product')#
class RelaxedBayesianInversionDOpt(configs=None)[source]#

Bases: BayesianInversionDOpt

An implementation of the D-optimal design criterion for Bayesian Optimal Design of Experiments for Sensor Placement. This implementation extends the Bayesian D-optimality criterion functionality provided by pyoed.oed.utility_functions.alphabetic_criteria.BayesianInversionDOpt by providing specific implementations that depend on the way the design enters the enters the inverse problem. Specifically, here we assume the design is used for sensor placement.

Thus a design/control variable is a binary vector with each entry associated with a candidate sensor location with value 1 meaning on (activate the sensor) and zero meaning off (deactivate the sensor). In other words, in sensor placement, a binary (on/off) design is associated with the observation vector (or equivalently with the observation noise (error covariance) matrix).

In the OED literature, some (relaxed/approximate) formulations apply the design to the precision matrix. The exact form for of relaxation affects the way the utility function is evaluated and is potentially differentiated, Thus, this implementation supports multiple approaches for formulating the OED utility function for sensor placement based on how the design is applied to the inverse problem. The design (binary indexes associated with candidate sensors) constructs a diagonal design matrix \(\mathbf{D}\) which changes the inverse problem as follows based on the formulation approach dictated by the formulation_approach configuration parameter with acceptable values: ‘pre-post-covariance-multiplication’, ‘pre-post-precision-multiplication’, and ‘pointwise-covariance-multiplication’.

Parameters:

configs (dict | RelaxedBayesianInversionDOptConfigs | None) – an object containing configuarations for the criterion, see RelaxedBayesianInversionDOptConfigs for more details.

__init__(configs=None)[source]#

Constructor for utility functions / optimality criteria.

Parameters:

configs (dict) – Object holding configurations for the criterion.

validate_configurations(configs, raise_for_invalid=True)[source]#

A method to check the passed configurations and make sure they are conformable with each other, and with current configurations (or default of not set)

Parameters:
  • configs (dict | RelaxedBayesianInversionDOptConfigs) – an object holding key/value configurations

  • raise_for_invalid (bool) – if True raise TypeError for invalid configrations key

Returns:

True/False flag indicating whether passed configurations is valid or not

Return type:

bool

update_configurations(**kwargs)[source]#

Update the configurations of the object.

Parameters:

kwargs – configurations to be updated.

register_formulation_approach(approach)[source]#
grad_design(design)[source]#

Derivative of the A Optimal design criterion with respect to the design assuming a relaxed (non-binary) design, and based on the registered formulation apprach.

Parameters:

design – an observational design vector conformable with the observation operator and the observation error covariance matrix operator. For the purposes of this method, it is intended to be a relaxed design (over the interval [0, 1]),

Returns:

gradient w.r.t the relaxed design

property configurations: RelaxedBayesianInversionDOptConfigs#

Return the configurations object

property formulation_approach#

Return the formulation approach

property pcw_scheme: PCWFunction#

Return the PCW scheme

property pointwise_weighting_kernel#
property pointwise_weighting_kernel_grad#
property n_deg#

n_deg in configurations

property sigma_bounds#

sigma_bounds in configurations

Robust Bayesian D Optimality#

class RobustBayesianInversionDOptConfigs(*, debug=False, verbose=False, output_dir='./_PYOED_RESULTS_', oed_problem=None, lp_behavior=LP_Behavior.MAP, use_FIM=True, evaluation_method='exact', sample_size=50, optimize_sample_size=False, min_sample_size=10, max_sample_size=100, distribution='Rademacher', randomization_vectors=None, random_seed=None, accuracy=0.01, sigma_bounds=<factory>, n_deg=14)[source]#

Bases: BayesianInversionDOptConfigs

Configuration class for RobustBayesianInversionDOpt criterion. See BayesianInversionDOptConfigs for D-Opt specific configurations.

Parameters:
  • verbose (bool) – a boolean flag to control verbosity of the object.

  • debug (bool) – a boolean flag that enables adding extra functionlity in a debug mode

  • output_dir (str | Path) – the base directory where the output files will be saved.

  • oed_problem (InversionOED | None) – OED problem for which the utility function is defined. This must be an instance of InversionOED.

  • lp_behavior (LP_Behavior | str) – behavior of the linearization point (MAP, prior, manual). By default, it is set to MAP. However, if the oed problem is linear, the passed parameter is ignored and is changed to LINEAR instead. If you wish to forcefully choose the linearization point despite the linearity of the problem, set the field after instantiation.

  • use_FIM (bool) – if True, the trace of the FIM is used as the criterion. If False, the inverse of the FIM (the posterior covariance matrix) trace is used.

  • evaluation_method (str) –

    A string describing the method to use for computing the criterion and its gradients. Supported are:

    • "exact": Compute the exact value of the criterion. Potentially

      intractable if problem is too large.

    • "randomized": Use randomized algorithms to compute the

      criterion value. Potentially faster for large problems but may be inaccurate.

  • sample_size (int) – The number of samples to use for randomized algorithms. Default is 50.

  • optimize_sample_size (bool) – If True, the sample size is optimized based on the problem size. Default is False.

  • min_sample_size (int) – The minimum sample size to use for randomized algorithms. Default is 10.

  • max_sample_size (int) – The maximum sample size to use for randomized algorithms. Default is 100.

  • distribution (str) – The distribution to use for randomization. Default is “Rademacher”.

  • randomization_vectors (None | ndarray | Sequence) – The randomization vectors to use for randomized algorithms. Default is None. Note, if None, the randomization vectors are constructed and saved for future use during the first evaluation.

  • random_seed (None | int) – The random seed to use for randomized algorithms. Default is None.

  • accuracy (float) – The accuracy to use for randomized algorithms. Default is 1e-2.

  • sigma_bounds ([Optional[float], Optional[float]]) – bounds on the singular values of the matrix. Default is [None, None], which means that the singular values are estimated. THIS IS VERY COSTLY!

  • n_deg (int) – number of terms to use in Chebyshev expansion.

__init__(*, debug=False, verbose=False, output_dir='./_PYOED_RESULTS_', oed_problem=None, lp_behavior=LP_Behavior.MAP, use_FIM=True, evaluation_method='exact', sample_size=50, optimize_sample_size=False, min_sample_size=10, max_sample_size=100, distribution='Rademacher', randomization_vectors=None, random_seed=None, accuracy=0.01, sigma_bounds=<factory>, n_deg=14)#
class RobustBayesianInversionDOpt(configs=None)[source]#

Bases: BayesianInversionDOpt

This class introduces an uncertain parameter over BayesianInversionDOpt.

__init__(configs=None)[source]#

Constructor for utility functions / optimality criteria.

Parameters:

configs (dict) – Object holding configurations for the criterion.

validate_configurations(configs, raise_for_invalid=True)[source]#

Configuration validation for RobustBayesianInversionDOpt criterion.

Parameters:
  • configs (dict) – configurations to validate.

  • raise_for_invalid (bool) – if True raise an exception for invalid configurations.

evaluate(design, uncertain_parameter_val, reset_parameter_val=False)[source]#

Evaluate the optimality criterion (D-optimality for sensor placement with uncertain parameter).

The criterion is the D-optimality criterion (Trace of the FIM or the posterior covariance) with respect to the uncertainty hyperparamater. Which hyperparameter is used is set internally in the OED problem.

Parameters:
  • design – a design vector conformable with the oed problem.

  • uncertain_parameter_val – the value of the uncertain parameter.

  • reset_parameter_val (bool) – if True reset the uncertain parameter value to its original value

Returns:

D-optimal design criterion value.

Return type:

float

grad_uncertainty(design, uncertain_parameter_val, reset_parameter_val=False)[source]#

Evaluate the gradient of the D-optimality criterion (Trace of the FIM) with respect to the uncertainty hyperparamater. Which hyperparameter is used is set internally in the OED problem.

Parameters:
  • design – a design conformable with the underlying oed problem.

  • uncertain_parameter_val – the value of the uncertain parameter.

  • reset_parameter_val (bool) – if True reset the uncertain parameter value to its original value

Returns:

The gradient of the D-optimal criterion with respect to the uncertain parameter.

Return type:

ndarray