opytimark.core

A core package for all common opytimark modules.

class opytimark.core.Benchmark(name: Optional[str] = 'Benchmark', dims: Optional[int] = 1, continuous: Optional[bool] = False, convex: Optional[bool] = False, differentiable: Optional[bool] = False, multimodal: Optional[bool] = False, separable: Optional[bool] = False)

A Benchmark class is the root of any benchmarking function.

It is composed by several properties that defines the traits of a function, as well as a non-implemented __call__ method.

abstract __call__(self, x: numpy.array)

This method returns the function’s output when the class is called.

Note that it needs to be implemented in every child class as it is the one to hold the benchmarking function logic.

Parameters

x – An input array for calculating the function’s output.

Returns

The benchmarking function output f(x).

Return type

(float)

__init__(self, name: Optional[str] = 'Benchmark', dims: Optional[int] = 1, continuous: Optional[bool] = False, convex: Optional[bool] = False, differentiable: Optional[bool] = False, multimodal: Optional[bool] = False, separable: Optional[bool] = False)

Initialization method.

Parameters
  • name – Name of the function.

  • dims – Number of allowed dimensions.

  • continuous – Whether the function is continuous.

  • convex – Whether the function is convex.

  • differentiable – Whether the function is differentiable.

  • multimodal – Whether the function is multimodal.

  • separable – Whether the function is separable.

property continuous(self)

Whether function is continuous or not.

property convex(self)

Whether function is convex or not.

property differentiable(self)

Whether function is differentiable or not.

property dims(self)

Number of allowed dimensions.

property multimodal(self)

Whether function is multimodal or not.

property name(self)

Name of the function.

property separable(self)

Whether function is separable or not.

class opytimark.core.CECBenchmark(name: str, year: str, auxiliary_data: Optional[Tuple[str, Ellipsis]] = (), dims: Optional[int] = 1, continuous: Optional[bool] = False, convex: Optional[bool] = False, differentiable: Optional[bool] = False, multimodal: Optional[bool] = False, separable: Optional[bool] = False)

A CECBenchmark class is the root of CEC-based benchmarking function.

It is composed by several properties that defines the traits of a function, as well as a non-implemented __call__ method.

abstract __call__(self, x: numpy.array)

This method returns the function’s output when the class is called.

Note that it needs to be implemented in every child class as it is the one to hold the benchmarking function logic.

Parameters

x – An input array for calculating the function’s output.

Returns

The benchmarking function output f(x).

Return type

(float)

__init__(self, name: str, year: str, auxiliary_data: Optional[Tuple[str, Ellipsis]] = (), dims: Optional[int] = 1, continuous: Optional[bool] = False, convex: Optional[bool] = False, differentiable: Optional[bool] = False, multimodal: Optional[bool] = False, separable: Optional[bool] = False)

Initialization method.

Parameters
  • name – Name of the function.

  • year – Year of the function.

  • auxiliary_data – Auxiliary variables to be externally loaded.

  • dims – Number of allowed dimensions.

  • continuous – Whether the function is continuous.

  • convex – Whether the function is convex.

  • differentiable – Whether the function is differentiable.

  • multimodal – Whether the function is multimodal.

  • separable – Whether the function is separable.

_load_auxiliary_data(self, name: str, year: str, data: List[str])

Loads auxiliary data from a set of files.

Parameters
  • name – Name of the function.

  • year – Year of the function.

  • data – List holding the variables to be loaded.

property continuous(self)

Whether function is continuous or not.

property convex(self)

Whether function is convex or not.

property differentiable(self)

Whether function is differentiable or not.

property dims(self)

Number of allowed dimensions.

property multimodal(self)

Whether function is multimodal or not.

property name(self)

Name of the function.

property separable(self)

Whether function is separable or not.

property year(self)

Year of the function.

class opytimark.core.CECCompositeBenchmark(name: str, year: str, auxiliary_data: Optional[Tuple[str, Ellipsis]] = (), sigma: Optional[Tuple[float, Ellipsis]] = (), l: Optional[Tuple[float, Ellipsis]] = (), functions: Optional[Tuple[callable, Ellipsis]] = (), bias: Optional[int] = 1, dims: Optional[int] = 1, continuous: Optional[bool] = False, convex: Optional[bool] = False, differentiable: Optional[bool] = False, multimodal: Optional[bool] = False, separable: Optional[bool] = False)

Bases: CECBenchmark

A CECCompositeBenchmark class is the root of CEC-based composite benchmarking function.

It is composed by several properties that defines the traits of a function, as well as an implemented __call__ method.

__call__(self, x: numpy.array)

This method returns the function’s output when the class is called.

Parameters

x – An input array for calculating the function’s output.

Returns

The benchmarking function output f(x).

Return type

(float)

__init__(self, name: str, year: str, auxiliary_data: Optional[Tuple[str, Ellipsis]] = (), sigma: Optional[Tuple[float, Ellipsis]] = (), l: Optional[Tuple[float, Ellipsis]] = (), functions: Optional[Tuple[callable, Ellipsis]] = (), bias: Optional[int] = 1, dims: Optional[int] = 1, continuous: Optional[bool] = False, convex: Optional[bool] = False, differentiable: Optional[bool] = False, multimodal: Optional[bool] = False, separable: Optional[bool] = False)

Initialization method.

Parameters
  • name – Name of the function.

  • year – Year of the function.

  • auxiliary_data – Auxiliary variables to be externally loaded.

  • sigma – Controls the functions coverage range.

  • l – Streches or compresses the functions.

  • functions – Benchmarking functions to be composed.

  • bias – Composite function bias.

  • dims – Number of allowed dimensions.

  • continuous – Whether the function is continuous.

  • convex – Whether the function is convex.

  • differentiable – Whether the function is differentiable.

  • multimodal – Whether the function is multimodal.

  • separable – Whether the function is separable.