Python micro framework for building nature-inspired algorithms.
-
class niapy.Runner(dimension=10, max_evals=1000000, runs=1, algorithms='ArtificialBeeColonyAlgorithm', benchmarks='Ackley')[source]
Bases: object
Runner utility feature.
Feature which enables running multiple algorithms with multiple benchmarks.
It also support exporting results in various formats (e.g. Pandas DataFrame, JSON, Excel)
- Variables
dimension (int) – Dimension of problem
max_evals (int) – Number of function evaluations
runs (int) – Number of repetitions
algorithms (Union[List[str], List[Algorithm]]) – List of algorithms to run
benchmarks (Union[List[str], List[Benchmark]]) – List of benchmarks to run
Initialize Runner.
- Parameters
dimension (int) – Dimension of problem
max_evals (int) – Number of function evaluations
runs (int) – Number of repetitions
algorithms (List[Algorithm]) – List of algorithms to run
benchmarks (List[Benchmark]) – List of benchmarks to run
-
__init__(dimension=10, max_evals=1000000, runs=1, algorithms='ArtificialBeeColonyAlgorithm', benchmarks='Ackley')[source]
Initialize Runner.
- Parameters
dimension (int) – Dimension of problem
max_evals (int) – Number of function evaluations
runs (int) – Number of repetitions
algorithms (List[Algorithm]) – List of algorithms to run
benchmarks (List[Benchmark]) – List of benchmarks to run
-
run(export='dataframe', verbose=False)[source]
Execute runner.
- Parameters
export (str) – Takes export type (e.g. dataframe, json, xls, xlsx) (default: “dataframe”)
verbose (bool) – Switch for verbose logging (default: {False})
- Returns
Returns dictionary of results
- Return type
dict
- Raises
TypeError – Raises TypeError if export type is not supported
-
task_factory(name)[source]
Create optimization task.
- Parameters
name (str) – Benchmark name.
- Returns
Optimization task to use.
- Return type
Task