Skip to content

Method

sgptools.methods.Method

Base class for informative sensing / path-planning optimization methods.

All methods optimize a set of sensing locations or waypoints, typically under a task-specific objective defined over a Gaussian process model (e.g., mutual information, ELBO).

Attributes:

Name Type Description
num_sensing

Number of sensing locations (or waypoints) to optimize per robot.

num_dim

Dimensionality of each sensing location (e.g., 2 for (x, y), 3 for (x, y, θ)).

num_robots

Number of robots / agents whose paths or sensing locations are being optimized.

X_candidates

Optional discrete set of candidate sensing locations with shape (c, num_dim). If provided, continuous solutions may be snapped to the closest candidates via cont2disc.

Source code in sgptools/methods.py
class Method:
    """
    Base class for informative sensing / path-planning optimization methods.

    All methods optimize a set of sensing locations or waypoints,
    typically under a task-specific objective defined over a Gaussian process
    model (e.g., mutual information, ELBO).

    Attributes:
        num_sensing: Number of sensing locations (or waypoints) to optimize
            per robot.
        num_dim: Dimensionality of each sensing location (e.g., 2 for (x, y),
            3 for (x, y, θ)).
        num_robots: Number of robots / agents whose paths or sensing locations
            are being optimized.
        X_candidates: Optional discrete set of candidate sensing locations
            with shape `(c, num_dim)`. If provided, continuous solutions may be
            snapped to the closest candidates via `cont2disc`.
    """

    def __init__(self,
                 num_sensing: int,
                 X_objective: np.ndarray,
                 kernel: gpflow.kernels.Kernel,
                 noise_variance: float,
                 transform: Optional[Transform] = None,
                 num_robots: int = 1,
                 X_candidates: Optional[np.ndarray] = None,
                 num_dim: Optional[int] = None,
                 **kwargs: Any):
        """
        Base initializer for an optimization method.

        Parameters
        ----------
        num_sensing:
            Number of sensing locations (inducing points / waypoints) to be
            optimized per robot.
        X_objective:
            Array of shape `(n, d)` containing the inputs used to define the
            objective (e.g., training inputs or a spatial grid). The last
            dimension `d` is used as the default `num_dim` if `num_dim` is not
            provided explicitly.
        kernel:
            GPflow kernel used by the objective. Stored only indirectly through
            subclasses (via their objective models).
        noise_variance:
            Observation noise variance used in the objective.
        transform:
            Optional `Transform` object that maps inducing points to an
            expanded representation (e.g., IPP path expansion, sensor FoV).
            Also used for constraint evaluation. Not stored here, but passed
            through to subclasses as needed.
        num_robots:
            Number of robots / agents. The total number of optimized points
            is `num_sensing * num_robots`. Defaults to 1.
        X_candidates:
            Optional array of shape `(c, d)` representing a discrete set of
            feasible sensing locations. When provided, many methods map their
            continuous solution to this candidate set using `cont2disc`.
        num_dim:
            Dimensionality of each sensing location. If `None`, defaults to
            `X_objective.shape[-1]`.
        **kwargs:
            Additional keyword arguments are accepted for forward compatibility,
            but ignored by the base class.
        """
        self.num_sensing = num_sensing
        self.num_robots = num_robots
        self.X_candidates = X_candidates
        if num_dim is None:
            self.num_dim = X_objective.shape[-1]
        else:
            self.num_dim = num_dim

    def optimize(self) -> np.ndarray:
        """
        Run the optimization procedure and return the optimized sensing
        locations / waypoints.

        Returns
        -------
        np.ndarray
            Array with shape `(num_robots, num_sensing, num_dim)` containing
            the optimized sensing locations.

        Raises
        ------
        NotImplementedError
            Must be implemented in subclasses.
        """
        raise NotImplementedError

    def update(self, kernel: gpflow.kernels.Kernel,
               noise_variance: float) -> None:
        """
        Update the kernel and noise-variance hyperparameters used by the
        underlying objective or SGP model.

        Parameters
        ----------
        kernel:
            New GPflow kernel instance.
        noise_variance:
            New observation noise variance.

        Raises
        ------
        NotImplementedError
            Must be implemented in subclasses.
        """
        raise NotImplementedError

    def get_hyperparameters(self) -> Tuple[gpflow.kernels.Kernel, float]:
        """
        Return the current kernel and noise-variance hyperparameters used by
        the underlying objective or SGP model.

        Returns
        -------
        (gpflow.kernels.Kernel, float)
            A tuple `(kernel, noise_variance)` containing copies of the current
            hyperparameters.

        Raises
        ------
        NotImplementedError
            Must be implemented in subclasses.
        """
        raise NotImplementedError

__init__(num_sensing, X_objective, kernel, noise_variance, transform=None, num_robots=1, X_candidates=None, num_dim=None, **kwargs)

Base initializer for an optimization method.

Parameters

num_sensing: Number of sensing locations (inducing points / waypoints) to be optimized per robot. X_objective: Array of shape (n, d) containing the inputs used to define the objective (e.g., training inputs or a spatial grid). The last dimension d is used as the default num_dim if num_dim is not provided explicitly. kernel: GPflow kernel used by the objective. Stored only indirectly through subclasses (via their objective models). noise_variance: Observation noise variance used in the objective. transform: Optional Transform object that maps inducing points to an expanded representation (e.g., IPP path expansion, sensor FoV). Also used for constraint evaluation. Not stored here, but passed through to subclasses as needed. num_robots: Number of robots / agents. The total number of optimized points is num_sensing * num_robots. Defaults to 1. X_candidates: Optional array of shape (c, d) representing a discrete set of feasible sensing locations. When provided, many methods map their continuous solution to this candidate set using cont2disc. num_dim: Dimensionality of each sensing location. If None, defaults to X_objective.shape[-1]. **kwargs: Additional keyword arguments are accepted for forward compatibility, but ignored by the base class.

Source code in sgptools/methods.py
def __init__(self,
             num_sensing: int,
             X_objective: np.ndarray,
             kernel: gpflow.kernels.Kernel,
             noise_variance: float,
             transform: Optional[Transform] = None,
             num_robots: int = 1,
             X_candidates: Optional[np.ndarray] = None,
             num_dim: Optional[int] = None,
             **kwargs: Any):
    """
    Base initializer for an optimization method.

    Parameters
    ----------
    num_sensing:
        Number of sensing locations (inducing points / waypoints) to be
        optimized per robot.
    X_objective:
        Array of shape `(n, d)` containing the inputs used to define the
        objective (e.g., training inputs or a spatial grid). The last
        dimension `d` is used as the default `num_dim` if `num_dim` is not
        provided explicitly.
    kernel:
        GPflow kernel used by the objective. Stored only indirectly through
        subclasses (via their objective models).
    noise_variance:
        Observation noise variance used in the objective.
    transform:
        Optional `Transform` object that maps inducing points to an
        expanded representation (e.g., IPP path expansion, sensor FoV).
        Also used for constraint evaluation. Not stored here, but passed
        through to subclasses as needed.
    num_robots:
        Number of robots / agents. The total number of optimized points
        is `num_sensing * num_robots`. Defaults to 1.
    X_candidates:
        Optional array of shape `(c, d)` representing a discrete set of
        feasible sensing locations. When provided, many methods map their
        continuous solution to this candidate set using `cont2disc`.
    num_dim:
        Dimensionality of each sensing location. If `None`, defaults to
        `X_objective.shape[-1]`.
    **kwargs:
        Additional keyword arguments are accepted for forward compatibility,
        but ignored by the base class.
    """
    self.num_sensing = num_sensing
    self.num_robots = num_robots
    self.X_candidates = X_candidates
    if num_dim is None:
        self.num_dim = X_objective.shape[-1]
    else:
        self.num_dim = num_dim

get_hyperparameters()

Return the current kernel and noise-variance hyperparameters used by the underlying objective or SGP model.

Returns

(gpflow.kernels.Kernel, float) A tuple (kernel, noise_variance) containing copies of the current hyperparameters.

Raises

NotImplementedError Must be implemented in subclasses.

Source code in sgptools/methods.py
def get_hyperparameters(self) -> Tuple[gpflow.kernels.Kernel, float]:
    """
    Return the current kernel and noise-variance hyperparameters used by
    the underlying objective or SGP model.

    Returns
    -------
    (gpflow.kernels.Kernel, float)
        A tuple `(kernel, noise_variance)` containing copies of the current
        hyperparameters.

    Raises
    ------
    NotImplementedError
        Must be implemented in subclasses.
    """
    raise NotImplementedError

optimize()

Run the optimization procedure and return the optimized sensing locations / waypoints.

Returns

np.ndarray Array with shape (num_robots, num_sensing, num_dim) containing the optimized sensing locations.

Raises

NotImplementedError Must be implemented in subclasses.

Source code in sgptools/methods.py
def optimize(self) -> np.ndarray:
    """
    Run the optimization procedure and return the optimized sensing
    locations / waypoints.

    Returns
    -------
    np.ndarray
        Array with shape `(num_robots, num_sensing, num_dim)` containing
        the optimized sensing locations.

    Raises
    ------
    NotImplementedError
        Must be implemented in subclasses.
    """
    raise NotImplementedError

update(kernel, noise_variance)

Update the kernel and noise-variance hyperparameters used by the underlying objective or SGP model.

Parameters

kernel: New GPflow kernel instance. noise_variance: New observation noise variance.

Raises

NotImplementedError Must be implemented in subclasses.

Source code in sgptools/methods.py
def update(self, kernel: gpflow.kernels.Kernel,
           noise_variance: float) -> None:
    """
    Update the kernel and noise-variance hyperparameters used by the
    underlying objective or SGP model.

    Parameters
    ----------
    kernel:
        New GPflow kernel instance.
    noise_variance:
        New observation noise variance.

    Raises
    ------
    NotImplementedError
        Must be implemented in subclasses.
    """
    raise NotImplementedError