qpots.acquisition

class qpots.acquisition.Acquisition(func: Function, gps: ModelListGP, cons: Callable | None = None, device: device | str | None = None, dtype: dtype | None = None, q: int = 1, NUM_RESTARTS: int = 10, RAW_SAMPLES: int = 512)[source]

Bases: object

A class providing various acquisition functions and methods for multi-objective optimization.

__init__(func: Function, gps: ModelListGP, cons: Callable | None = None, device: device | str | None = None, dtype: dtype | None = None, q: int = 1, NUM_RESTARTS: int = 10, RAW_SAMPLES: int = 512) None[source]

Initialize the multi-objective acquisition class.

This class provides various acquisition functions for multi-objective Bayesian optimization. It supports Gaussian Process models and handles inequality constraints if provided.

Parameters:
  • func (Function) – The test function being optimized.

  • gps (ModelListGP) – A list of Gaussian Process models used for Bayesian optimization.

  • cons (Optional[Callable], optional) – A vector-valued function representing inequality constraints. If provided, the acquisition function will account for feasibility constraints.

  • device (torch.device or str, optional) – The computational device to use. If omitted, qPOTS uses CUDA when available and falls back to CPU.

  • dtype (torch.dtype, optional) – Floating-point precision. If omitted, qPOTS uses the dtype attached to gps when present, otherwise qpots.config.DEFAULT_DTYPE.

  • q (int, optional) – The number of candidate points to sample per iteration. Defaults to 1.

  • NUM_RESTARTS (int, optional) – The number of restarts for optimizing the acquisition function. A higher value can improve optimization quality. Defaults to 10.

  • RAW_SAMPLES (int, optional) – The number of raw samples used in acquisition optimization. Higher values increase exploration but may slow computation. Defaults to 512.

_gp_posterior(x: Tensor, gps: ModelListGP, seed_iter: int = 1) Tensor[source]

Compute posterior samples for PyMoo optimization.

Parameters:
  • x (Tensor) – A tensor of input points for which posterior samples are computed.

  • gps (ModelListGP) – A list of Gaussian Process models used to estimate the posterior distribution.

  • seed_iter (int, optional) – An iteration index for seeding randomness in sampling. Defaults to 1.

Returns:

A tensor containing posterior samples from the GP models, with infeasible points penalized if constraints exist.

Return type:

Tensor

_mt_gp_posterior(x: Tensor, gps: MultiTaskGP, seed_iter: int = 1) Tensor[source]

Compute posterior samples for PyMoo optimization for MultiTaskGP.

Parameters:
  • x (Tensor) – A tensor of input points for which posterior samples are computed.

  • gps (MultiTaskGP) – A multi-task Gaussian Process model used to estimate the posterior distribution.

  • seed_iter (int, optional) – An iteration index for seeding randomness in sampling. Defaults to 1.

Returns:

A tensor containing posterior samples from the GP models, with infeasible points penalized if constraints exist.

Return type:

Tensor

_nystrom_approx(x: Tensor, gps: ModelListGP, m: int, pareto_set: Tensor | None = None, col_choice: str = 'pareto', seed_iter: int = 1, reg: float = 1e-06) Tensor[source]

Perform Thompson sampling using the Nyström approximation for Gaussian Process (GP) models.

The Nyström approximation is a method for approximating large covariance matrices in Gaussian Process inference, improving computational efficiency while preserving accuracy. This function selects a subset of columns to approximate the full covariance matrix and then performs posterior sampling.

Parameters:
  • x (Tensor) – A tensor of input points for which posterior samples are computed.

  • gps (ModelListGP) – A list of Gaussian Process models used to estimate the posterior distribution.

  • m (int) – The number of landmarks (subset size) used in the Nyström approximation.

  • pareto_set (Optional[Tensor], optional) – A tensor containing Pareto optimal points. Required if col_choice is ‘pareto’. Defaults to None.

  • col_choice (str, optional) – The column selection strategy for the Nyström approximation. Options: - ‘pareto’ (default): Select columns based on proximity to Pareto optimal points. - ‘random’: Select a random subset of columns.

  • seed_iter (int, optional) – An iteration index for seeding randomness in sampling. Defaults to 1.

  • reg (float, optional) – A small regularization constant added to the covariance matrix for numerical stability during matrix inversion. Defaults to 1e-6.

Returns:

A tensor containing posterior samples from the GP models. Infeasible points are penalized if constraints exist.

Return type:

Tensor

jesmo() Tensor[source]

Perform Joint Entropy Search for Multi-Objective optimization (JESMO).

JESMO is an acquisition function that uses joint entropy search to efficiently explore the Pareto frontier in multi-objective Bayesian optimization.

Returns:

A tensor containing the candidate points generated by JESMO.

Return type:

Tensor

mesmo() Tensor[source]

Perform Multi-Objective Max-Value Entropy Search (MESMO).

Returns:

A tensor containing the candidate points selected by MESMO.

Return type:

Tensor

parego() Tensor[source]

Perform qParEGO optimization using random weights for scalarization.

Returns:

A tensor containing the new candidate points selected based on qParEGO optimization.

Return type:

Tensor

pesmo() Tensor[source]

Perform Predictive Entropy Search for Multi-Objective optimization (PESMO).

Returns:

A tensor containing the candidate points selected by PESMO.

Return type:

Tensor

qlogei(ref_point: Tensor | None = None) Tensor[source]

Optimize the qLogEI acquisition function and return new candidate points.

Parameters:

ref_point (Tensor, optional) – The reference point for hypervolume calculation, typically representing a baseline for performance. Defaults to [0.0, 0.0].

Returns:

A tensor containing the new candidate points selected based on qLogEI optimization.

Return type:

Tensor

qlogparego() Tensor[source]

Perform qParEGO optimization using qNParEGO from BoTorch.

Returns:

A tensor containing the candidate points selected based on qParEGO optimization.

Return type:

Tensor

qpots(bounds: Tensor, iteration: int, **kwargs) Tensor[source]

Perform Pareto Optimal Thompson Sampling (qPOTS).

Parameters:
  • bounds (Tensor) – A tensor representing the lower and upper bounds for the optimization problem.

  • iteration (int) – The current iteration index, used for seeding randomness.

  • **kwargs (dict) –

    Additional arguments for customization, including:

    • nystrom (int): Whether to use the Nystrom approximation (1 for yes, 0 for no).

    • iters (int): Number of iterations used in the Nystrom approximation.

    • nychoice (str): Column selection method for the Nystrom approximation.

    • dim (int): Dimensionality of the input space.

    • ngen (int): Number of generations for the NSGA-II optimization.

    • q (int): Number of candidates to select.

    • mt (int): Whether to use MultiTaskGP for posterior sampling (1 for yes, 0 for no).

    • partial_info (int): Whether to perform candidate selection using partial information (1 for yes, 0 for no).

    • variance_threshold (float, optional): Variance threshold used during partial-information selection.

Returns:

If partial_info == 0, returns a normalized tensor of selected candidate points. If partial_info == 1, returns (candidates, task_ids), where task_ids records which objectives or constraints should be evaluated at each candidate.

Return type:

Tensor or Tuple[Tensor, Tensor]

sobol() Tensor[source]

Generate random Sobol sequence samples.

Returns:

A tensor of randomly generated candidate points using the Sobol sequence.

Return type:

Tensor

tsemo(save_dir: str, iters: int, ref_point: Tensor, train_shape: int, rep: int = 0)[source]

Perform Thompson Sampling Efficient Multiobjective Optimization (TS-EMO).

Parameters:
  • save_dir (str) – The directory to save the TS-EMO results.

  • iters (int) – How many iterations TS-EMO should run for.

  • ref_point (Tensor) – The reference point for the hypervolume calculation.

  • train_shape (int) – The shape for determining the size of bounds.

  • rep (int, optional) – The repetition of the experiment. Defaults to 0.

Returns:

  • x (np.ndarray) – The inputs of the function chosen by TS-EMO.

  • y (np.ndarray) – The outputs of the function for each input.

  • times (np.ndarray) – The time that each iteration takes.

  • hv (list) – The list of the hypervolume at each iteration.

  • pf (Tensor) – The Pareto frontier determined by TS-EMO.