Skip to content

methods: Optimization Algorithms

This module provides various algorithms to optimize the sensor placements or paths. Use the get_methods method to retrieve an optimization method class by its string name.

  • ContinuousSGP: This method directly optimizes the inducing points of the AugmentedSGPR model to maximize the Evidence Lower Bound (ELBO). This is the main SGP-based optimization approach proposed in the papers associated with this library.

  • GreedySGP and GreedyObjective: These implement greedy algorithms for sensor placement. GreedySGP iteratively selects inducing points to maximize the SGP's ELBO, while GreedyObjective uses a more general objective function like Mutual Information.

  • BayesianOpt: This method uses Bayesian Optimization, a powerful black-box optimization algorithm, to find the best sensor locations by maximizing a general objective function.

  • CMA: This method uses Covariance Matrix Adaptation Evolution Strategy (CMA-ES), a powerful black-box optimization algorithm, to find the best sensor locations by maximizing a general objective function.

  • DifferentiableObjective: This method leverages TensorFlow's automatic differentiation to directly optimize the objective function with respect to the sensor locations. This can be more efficient than black-box methods for smooth objective functions. However, the method is also more prone to getting stuck in local minima.

sgptools.methods.get_method(method)

Retrieve an optimization method class by name.

Parameters

method: Name of the optimization method. Must be one of the keys in :data:METHODS, e.g. 'ContinuousSGP', 'CMA', 'BayesianOpt', 'GreedyObjective', etc.

Returns

Type[Method] The corresponding method class.

Raises

KeyError If method is not a valid key in :data:METHODS.

Usage

ContinuousSGPClass = get_method('ContinuousSGP')
csgp = ContinuousSGPClass(
    num_sensing=10,
    X_objective=X_train,
    kernel=kernel_opt,
    noise_variance=noise_var_opt,
)
Source code in sgptools/methods.py
def get_method(method: str) -> Type[Method]:
    """
    Retrieve an optimization method class by name.

    Parameters
    ----------
    method:
        Name of the optimization method. Must be one of the keys in
        :data:`METHODS`, e.g. `'ContinuousSGP'`, `'CMA'`, `'BayesianOpt'`,
        `'GreedyObjective'`, etc.

    Returns
    -------
    Type[Method]
        The corresponding method class.

    Raises
    ------
    KeyError
        If `method` is not a valid key in :data:`METHODS`.

    Usage
    --------
    ```python
    ContinuousSGPClass = get_method('ContinuousSGP')
    csgp = ContinuousSGPClass(
        num_sensing=10,
        X_objective=X_train,
        kernel=kernel_opt,
        noise_variance=noise_var_opt,
    )
    ```
    """
    if method not in METHODS:
        raise KeyError(f"Method '{method}' not found. Available methods: {', '.join(METHODS.keys())}")
    return METHODS[method]