benchmarkfcns.Composition

class benchmarkfcns.Composition(constant_C=2000.0)[source]

Bases: Composition

A high-performance engine for creating hybrid/composition benchmark functions. This class allows blending multiple base functions using CEC-standard exponential weighting, shifting, and rotation.

__init__(constant_C=2000.0)[source]

Methods

__init__([constant_C])

add(function, shift[, rotation, sigma, ...])

Adds a base function component to the composition.

add_component(self, fcn, , ]], ...)

Adds a base function component to the composition.

evaluate(x)

Evaluates the composed function for a batch of points.

set_constant_C(self, C)

Sets the C constant for height normalization (default 2000.0).

add(function, shift, rotation=None, sigma=1.0, lambda_val=1.0, bias=0.0, f_max=1.0)[source]

Adds a base function component to the composition.

Parameters:
  • function (str | callable) – Name of the built-in function (e.g. ‘ackley’) or a pointer.

  • shift (np.ndarray) – 1D array of size N for shifting the optimum.

  • rotation (np.ndarray | None) – 2D array of size N-by-N for coordinate rotation. Defaults to Identity matrix.

  • sigma (float) – Convergence range / basin of attraction size.

  • lambda_val (float) – Scaling parameter for the landscape.

  • bias (float) – Internal bias for this component.

  • f_max (float) – Estimated maximum value for height normalization.

evaluate(x)[source]

Evaluates the composed function for a batch of points.

Parameters:

x (ndarray) – Matrix of size M-by-N (M points in N dimensions)

Return type:

ndarray

Returns:

1D array of size M containing the composed scores.