sampling.mm.mmlhs

sampling.mm.mmlhs(X_start, population, iterations, q=2.0, plot=False)

Performs an evolutionary search (using perturbations) to find a Morris-Mitchell optimal Latin hypercube, starting from an initial plan X_start.

This function does the following

  1. Initializes a “best” Latin hypercube (X_best) from the provided X_start.
  2. Iteratively perturbs X_best to create offspring.
  3. Evaluates the space-fillingness of each offspring via the Morris-Mitchell metric (using mmphi).
  4. Updates the best plan whenever a better offspring is found.

Parameters

Name Type Description Default
X_start np.ndarray A 2D array of shape (n, k) providing the initial Latin hypercube (n points in k dimensions). required
population int Number of offspring to create in each generation. required
iterations int Total number of generations to run the evolutionary search. required
q float The exponent used by the Morris-Mitchell space-filling criterion. Defaults to 2.0. 2.0
plot bool If True, a simple scatter plot of the first two dimensions will be displayed at each iteration. Only if k >= 2. Defaults to False. False

Returns

Name Type Description
np.ndarray np.ndarray: A 2D array representing the most space-filling Latin hypercube found after all iterations, of the same shape as X_start.

Notes

Many thanks to the original author of this code, A Sobester, for providing the original Matlab code under the GNU Licence. Original Matlab Code: Copyright 2007 A Sobester: “This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU General Public License and GNU Lesser General Public License along with this program. If not, see http://www.gnu.org/licenses/.”

Examples

>>> import numpy as np
>>> from spotoptim.sampling.mm import mmlhs
>>> # Suppose we have an initial 4x2 plan
>>> X_start = np.array([
...     [0, 0],
...     [1, 3],
...     [2, 1],
...     [3, 2]
... ])
>>> # Search for a more space-filling plan
>>> X_opt = mmlhs(X_start, population=5, iterations=10, q=2)
>>> print("Optimized plan:")
>>> print(X_opt)