HimmelblausFunction#
- class HimmelblausFunction(A=-11, B=-7, objective='minimize', modifiers: List[BaseModifier] | None = None, memory=False, collect_data=True, callbacks=None, catch_errors=None)[source]#
Himmelblau’s two-dimensional test function.
A multimodal function with four identical global minima.
The function is defined as:
\[f(x, y) = (x^2 + y + A)^2 + (x + y^2 + B)^2\]where \(A = -11\) and \(B = -7\) by default.
- The four global minima are:
\(f(3.0, 2.0) = 0\)
\(f(-2.805118, 3.131312) = 0\)
\(f(-3.779310, -3.283186) = 0\)
\(f(3.584428, -1.848126) = 0\)
- Parameters:
Examples
>>> from surfaces.test_functions import HimmelblausFunction >>> func = HimmelblausFunction() >>> result = func({"x0": 3.0, "x1": 2.0}) >>> 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 meta: MetaSpec[source]#
Instance display/identity metadata (a frozen MetaSpec).
Metadata is fully static today, so this returns the class-level
MetaSpecresolved at class-definition time.
- 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:
- Returns:
The true function value without modifiers, with direction applied.
- Return type:
float or np.ndarray
- property search_space: Dict[str, Any][source]#
Search space for this function (read-only public API).
- property spec: FunctionSpec[source]#
Instance-resolved function specification (a frozen FunctionSpec).
type(self)._specis the static class-level template. This property overlays the fields that genuinely vary per instance (n_dim,n_objectives,f_global,x_global) by lifting them off the instance, so thatfunc.spec.n_dimreflects this instance’s value. It is resolved on every access rather than cached, because some functions (e.g. BBOB) readspecduring__init__before the optimum has been computed, and a cached early value would go stale.