BealeFunction#

class BealeFunction(A: float = 1.5, B: float = 2.25, C: float = 2.625, objective: str = 'minimize', modifiers: List[BaseModifier] | None = None, memory: bool = False, collect_data: bool = True, callbacks: Callable | List[Callable] | None = None, catch_errors: Dict[type, float] | None = None)[source]#

Beale two-dimensional test function.

A multimodal function with sharp peaks at the corners of the input domain. It is commonly used for testing optimization algorithms.

The function is defined as:

\[f(x, y) = (A - x + xy)^2 + (B - x + xy^2)^2 + (C - x + xy^3)^2\]

where \(A = 1.5\), \(B = 2.25\), and \(C = 2.625\) by default.

The global minimum is \(f(3, 0.5) = 0\).

Parameters:
  • A (float, default=1.5) – First coefficient.

  • B (float, default=2.25) – Second coefficient.

  • C (float, default=2.625) – Third coefficient.

  • objective (str, default="minimize") – Either “minimize” or “maximize”.

  • modifiers (list of BaseModifier, optional) – List of modifiers to apply to function evaluations.

n_dim[source]#

Number of dimensions (always 2).

Type:

int

References

Examples

>>> from surfaces.test_functions import BealeFunction
>>> func = BealeFunction()
>>> result = func({"x0": 3.0, "x1": 0.5})
>>> abs(result) < 1e-10
True
__call__(params: Dict[str, Any] | ndarray | list | tuple | None = None, *, fidelity: float | None = None, **kwargs)[source]#

Evaluate the objective function.

Args:

params: Parameter values as dict, array, list, or tuple fidelity: Optional fidelity level in (0, 1]. Controls evaluation

cost vs accuracy trade-off for multi-fidelity optimization (e.g. Hyperband, BOHB). None means full-fidelity evaluation. Only supported by ML test functions; ignored by algebraic functions.

**kwargs: Parameters as keyword arguments (only with dict input)

Returns:

The objective function value

batch(X: ArrayLike) ArrayLike[source]#

Evaluate multiple parameter sets in a single call.

Parameters:

X (ArrayLike) – 2D array of shape (n_points, n_dim) where each row is a parameter set.

Returns:

1D array of shape (n_points,) with evaluation results.

Return type:

ArrayLike

Raises:
  • NotImplementedError – If the function does not implement _batch_objective.

  • ValueError – If X has wrong number of dimensions or wrong n_dim.

property callbacks[source]#

Callback management (CallbackAccessor).

property data[source]#

Evaluation data (DataAccessor).

property errors[source]#

Error handler management (ErrorAccessor).

property memory[source]#

Memory cache management (MemoryAccessor).

property meta[source]#

Function metadata (MetaAccessor).

property modifiers[source]#

Modifier management (ModifierAccessor).

property plot[source]#

Access plotting methods for this function.

pure(params: Dict[str, Any] | ndarray | list | tuple | None = None, *, fidelity: float | None = None, **kwargs)[source]#

Evaluate the function without modifiers.

Returns the true (deterministic) function value, bypassing any configured modifiers. Does not update search_data, n_evaluations, or callbacks. Ignores memory caching.

Parameters:
  • params (dict, array, list, or tuple) – Parameter values to evaluate.

  • fidelity (float or None) – Fidelity level in (0, 1] for multi-fidelity evaluation.

  • **kwargs (dict) – Parameters as keyword arguments.

Returns:

The true function value without modifiers, with direction applied.

Return type:

float or np.ndarray

reset() None[source]#

Reset all state including collected data and memory cache.

property search_space: Dict[str, Any][source]#

Search space for this function (read-only public API).

property spec[source]#

Function characteristics (SpecAccessor).