mo.mo_mm.mo_mm_desirability_function

mo.mo_mm.mo_mm_desirability_function(
    x,
    models,
    X_base,
    J_base,
    d_base,
    phi_base,
    D_overall,
    mm_objective=True,
    verbose=False,
)

Calculates the negative combined desirability for a candidate point x. Can be used by the mo_mm_desirability_optimizer. For each objective, a model is used to predict the objective value at x. If mm_objective is True, the Morris-Mitchell improvement is also calculated and included as an additional objective. The combined desirability, which uses the predictions from the models and optionally the Morris-Mitchell improvement, is then computed using the provided DOverall object.

Parameters

Name Type Description Default
x np.ndarray Candidate point (1D array). required
models list List of trained models. One model per objective. required
X_base np.ndarray Existing design points. Used for computing Morris-Mitchell improvement. required
J_base np.ndarray Multiplicities of distances for X_base. Used for Morris-Mitchell improvement. required
d_base np.ndarray Unique distances for X_base. Used for Morris-Mitchell improvement. required
phi_base float Base Morris-Mitchell metric for X_base. Used for Morris-Mitchell improvement. required
D_overall DOverall The overall desirability function. Must include desirability functions for each objective and optionally for Morris-Mitchell. required
mm_objective bool Whether to include space-filling improvement as an objective. Defaults to True. True
verbose bool Whether to print Morris-Mitchell improvement values. Defaults to False. False

Returns

Name Type Description
Tuple[float, List[float]] Tuple[float, List[float]]: A tuple containing: - Negative geometric mean of desirabilities (for minimization). - List of individual objective values.

Examples

>>> from spotoptim.mo import mo_mm_desirability_function
>>> from spotdesirability import DOverall, DMax
>>> import numpy as np
>>> from spotoptim.function.mo import mo_conv2_max
>>> from sklearn.ensemble import RandomForestRegressor
>>> from spotoptim.sampling.mm import mmphi_intensive
>>> # X_base in the range [0,1]
>>> X_base = np.random.rand(500, 2)
>>> y = mo_conv2_max(X_base)
>>> models = []
>>> for i in range(y.shape[1]):
...     model = RandomForestRegressor(n_estimators=100, random_state=42)
...     model.fit(X_base, y[:, i])
...     models.append(model)
>>> # calculate base Morris-Mitchell stats
>>> phi_base, J_base, d_base = mmphi_intensive(X_base, q=2, p=2)
>>> d_funcs = []
>>> for i in range(y.shape[1]):
...     d_func = DMax(low=np.min(y[:, i]), high=np.max(y[:, i]))
...     d_funcs.append(d_func)
>>> D_overall = DOverall(*d_funcs)
>>> x_test = np.random.rand(2)  # Example test point
>>> neg_D, objectives = mo_mm_desirability_function(x_test, models, X_base, J_base, d_base, phi_base, D_overall, mm_objective=False)
>>> print(f"Negative Desirability: {neg_D}")
Negative Desirability: ...
>>> print(f"Objectives: {objectives}")
Objectives: ...