tricands.tricands

tricands.tricands

Functions

Name Description
tricands Generate Triangulation Candidates for Bayesian Optimization.
tricands_fringe Generate fringe candidates outside the convex hull.
tricands_interior Generate interior candidates using Delaunay triangulation.

tricands

tricands.tricands.tricands(
    X,
    p=0.5,
    fringe=True,
    nmax=None,
    best=None,
    ordering=None,
    vis=False,
    imgname='tricands.pdf',
    lower=0,
    upper=1,
)

Generate Triangulation Candidates for Bayesian Optimization. Assumes a bounding box of [lower, upper]^m.

Parameters

Name Type Description Default
X np.ndarray Design matrix of shape (n_samples, n_features). Each row gives a design point and each column a feature. required
p float Distance to the boundary for fringe candidates (0 = on hull, 1 = on boundary). Defaults to 0.5. 0.5
fringe bool Whether to include fringe points to allow exploration outside the convex hull. Defaults to True. True
nmax int Maximum size of candidate set. If output exceeds this, strategic subsetting is employed. Defaults to 100 * n_features. None
best int Index of the best (lowest) currently observed point. Used for strategic subsetting in Bayesian optimization. Defaults to None. None
ordering np.ndarray Order of closeness of rows of X to a contour level. Used for contour location subsetting. Defaults to None. None
vis bool Whether to visualize the triangulation. Only applicable to 2D designs. Defaults to False. False
imgname str File name for saved plot if vis=True. Defaults to ‘tricands.pdf’. 'tricands.pdf'
lower float Lower bound of bounding box for all dimensions. Defaults to 0. 0
upper float Upper bound of bounding box for all dimensions. Defaults to 1. 1

Returns

Name Type Description
np.ndarray np.ndarray: Array of candidate points, shape (n_candidates, n_features).

Raises

Name Type Description
Exception If visualization is requested for non-2D data.
Exception If number of points is less than n_features + 1.
Exception If both ‘best’ and ‘ordering’ are provided.
Exception If X contains values outside [lower, upper].

Examples

>>> import numpy as np
>>> from spotoptim.tricands import tricands
>>> X = np.array([[0.1, 0.1], [0.9, 0.1], [0.5, 0.9], [0.2, 0.5]])
>>> candidates = tricands(X, fringe=True, p=0.5)
>>> print(candidates.shape)
(7, 2)

tricands_fringe

tricands.tricands.tricands_fringe(X, p=0.5, lower=0, upper=1)

Generate fringe candidates outside the convex hull.

Subroutine used by tricands wrapper. Assumes a bounding box of [lower, upper]^m.

Parameters

Name Type Description Default
X np.ndarray Input design matrix of shape (n_samples, n_features). required
p float Distance to the boundary (0 = on hull, 1 = on boundary). Defaults to 0.5. 0.5
lower float Lower bound of bounding box for all dimensions. Defaults to 0. 0
upper float Upper bound of bounding box for all dimensions. Defaults to 1. 1

Returns

Name Type Description
dict dict A dictionary containing: - ‘XF’ (np.ndarray): Fringe candidate points. - ‘XB’ (np.ndarray): Boundary points (means of external facets). - ‘qhull’ (scipy.spatial.ConvexHull): The computed convex hull object.

Raises

Name Type Description
Exception If the number of points is less than n_features + 1.

tricands_interior

tricands.tricands.tricands_interior(X)

Generate interior candidates using Delaunay triangulation.

Subroutine used by tricands wrapper.

Parameters

Name Type Description Default
X np.ndarray Input design matrix of shape (n_samples, n_features). required

Returns

Name Type Description
dict dict A dictionary containing: - ‘cand’ (np.ndarray): Candidate points (midpoints of triangles). - ‘tri’ (np.ndarray): Simplicies of the Delaunay triangulation.

Raises

Name Type Description
Exception If the number of points is less than n_features + 1.