rapid_models.doe.utils

Module Contents

Functions

fullfact_with_bounds(LBs, UBs, N_xi)

Return a ND array of corresponding (x_0, ..., x_i) values that span out the

lhs_with_bounds(nDim, nSamples, LBs, UBs[, random_state])

Return a 2D array of corresponding (x, y) values that fill the input space

in_hull(p, hull)

Test if points in 'p' are in 'hull'

kmeans_sample(points, N[, values, mode, random_state])

Based on

rapid_models.doe.utils.fullfact_with_bounds(LBs, UBs, N_xi)

Return a ND array of corresponding (x_0, …, x_i) values that span out the inputspace between lowerbound and upperbound in a structured grid-like) way with n_x_i points in the i’th-dimension.

Parameters:
  • LBs (list-like, 1D) – lower bounds of the input space. len(LBs) must equal len(UBs)

  • UBs (list-like, 1D) – upper bounds of the input space. len(UBs) must equal len(LBs)

  • N_xi (list-like, 1D) – number of equidistant samples for each xi-dimension

Returns:

[[x_0,…,x_i],…,[x_0_n,…,x_i_n]]

Return type:

fullfact (ndarray)

rapid_models.doe.utils.lhs_with_bounds(nDim, nSamples, LBs, UBs, random_state=None)

Return a 2D array of corresponding (x, y) values that fill the input space between lowerbound and upperbound with n points using a Latin-hypercube design.

Parameters:
  • nDim (int) – Number of dimensions

  • nSamples (int) – Number of total samples

  • LBs (list-like) – 1D, lower bounds of the input space. len(LBs) must equal len(UBs)

  • UBs (list-like) – 1D, upper bounds of the input space. len(UBs) must equal len(LBs)

  • random_state (int, RandomState instance or None, default=None) – Determines random number generation used to initialize the samples. Pass an int for reproducible results across multiple function calls.

Returns:

Array of sample points with shape (nSamples, nDim)

[[x_0,…,x_i],…,[x_0_n,…,x_i_n]]

Return type:

lhs (ndarray)

rapid_models.doe.utils.in_hull(p, hull)

Test if points in ‘p’ are in ‘hull’

‘p’ should be a ‘NxK’ coordinates of ‘N’ points in ‘K’ dimensions ‘hull’ is either a scipy.spatial.Delaunay object or the ‘MxK’ array of the coordinates of ‘M’ points in ‘K’dimensions for which Delaunay triangulation will be computed.

Parameters:
  • p (array-like) – NxK array. Set of ‘N’ points in ‘K’ dimensions for which to check if is inside convex hull.

  • hull (array like / scipy.spatial.Delaunay) – MxK array. Set of ‘M’ points in ‘K’ dimensions to calculate the Delaunay tessellation using the [Qhull library](http://www.qhull.org/), or an existing scipy.spatial.Delaunay object.

Returns:

(N, ) boolean array of sample points where

’True’ indicate that the point of that index is inside the triangulation while ‘False’ indicate that the point of corresponding index is outside the triangulation.

Return type:

b_in_hull (boolean ndarray)

rapid_models.doe.utils.kmeans_sample(points, N, values=None, mode='center', random_state=42)

Based on https://stackoverflow.com/questions/69195903/

Parameters:
  • points (array-like) – PxK array, set of ‘P’ points in ‘K’ dimensions from which to calculate N k-means clusters to use as distance maximizing samples in K-dimensions

  • N (int) – Number of clusters

  • values (array-like, 1D) – Array of corresponding values at each point ‘P’ in ‘points’. These values can be used to select e.g. minimum or maximum values inside each cluster by specifying ‘mode’

  • mode (str, default="center") – default mode select center of k-means cluster. “center_closest_point” select the point which are closest to the cluster center, “min” select the point with the corresponding minimum value, “max” select the point with the corresponding maximum value

Returns:

NxK array of ‘N’ points in ‘K’ dimensions

representing the ‘mode’ (default “center”) in the N k-means clusters.

values (ndarray): optional array of ‘N’ values of the returned points.

Return type:

points (ndarray)