EasomFunction#

class EasomFunction(A=-1, B=1, angle=1, objective='minimize', modifiers: List[BaseModifier] | None = None, memory=False, collect_data=True, callbacks=None, catch_errors=None)[source]#

Easom two-dimensional test function.

A unimodal function with a very small area relative to the search space where the function has a significant gradient. The global minimum has a small basin of attraction.

The function is defined as:

\[f(x, y) = A \cos(\omega x) \cos(\omega y) \exp\left[-(x - \pi/B)^2 - (y - \pi/B)^2\right]\]

where \(A = -1\), \(B = 1\), and \(\omega = 1\) by default.

The global minimum is \(f(\pi, \pi) = -1\).

Parameters:
  • A (float, default=-1) – Amplitude parameter.

  • B (float, default=1) – Scaling parameter for the optimum location.

  • angle (float, default=1) – Angular frequency parameter.

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

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

n_dim[source]#

Number of dimensions (always 2).

Type:

int

Examples

>>> from surfaces.test_functions import EasomFunction
>>> import numpy as np
>>> func = EasomFunction()
>>> result = func({"x0": np.pi, "x1": np.pi})
>>> abs(result + 1.0) < 1e-10
True
__call__(params: Dict[str, Any] | ndarray | list | tuple | None = None, **kwargs)[source]#

Evaluate the objective function.

Args:

params: Parameter values as dict, array, list, or tuple **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, **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.

  • **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).