Skip to main content

Optimization benchmarks, both synthetic and practical.

Project description

PyPI PyPI - License PyPI - Downloads codecov


Evobench is a collection of benchmark problems dedicated for optimization problems (both synthetic and practical). Please note that Python isn't still best tool for solving optimization problems, as loops are still slow. This might change in a next couple of years. Our main intention is to provide easily accessible package for PoC, research or teaching purposes.

Getting started

pip install evobench
import evobench

trap = evobench.discrete.Trap(blocks=[4, 4, 4])

population = trap.initialize_population(population_size=1e3)

Fitness evaluation produces side effect of defining solution's fitness.


You can also evaluate single solution.

fitness = trap.evaluate_solution([0])

Every time you evaluate undefined solution we increment ffe counter. Solution is not evaluated again, if it didn't change. You can access it through a benchmark instance.



This package exposes following problems.


  • TSP
  • cVRP


  • Trap
  • Step Trap
  • Bimodal
  • Step Bimodal
  • HIFF
  • Ising Spin Glass


  • Trap
  • Step Trap
  • Multimodal
  • Step Multimodal
  • Sawtooth

Compound Benchmark

Creating your own compound benchmarks is really easy. You just need to define your sub-benchmarks and pass them as a list. All other fuctions work just the same as with the normal Benchmark.

from evobench import CompoundBenchmark, continuous, discrete

benchmark = CompoundBenchmark(
        discrete.Trap(blocks=[5, 2, 4]),
        continuous.Trap(blocks=[3, 6, 4])

population = benchmark.initialize_population(population_size=1000)

Ising Spin Glass

To instantiate ISG you need to pass specific problem configuration.

from evobench.discrete import IsingSpinGlass

isg = IsingSpinGlass('IsingSpinGlass_pm_16_0')

You can find 5,000 instances at evobench\discrete\isg\data folder. Instances vary in length and complexity.

How to implement your own benchmark

Inherit Benchmark class from evobench.benchmark. Then implement:

  • def _evaluate_solution(self, solution: Solution) -> float
  • def random_solutions(self, population_size: int) -> List[Solution]

Partially separable

You need to inherit Separable class from evobench.separable. Then just implement:

  • def evaluate_block(self, block: np.ndarray) -> int.

Best follow evobench.discrete.trap implementation.

Linkage quality

Linkage quality metrics are located at evobench.linkage.metrics. Available metrics:

  • Mean Reciprocal Ranking @K
  • Mean Average Precision @K
  • NDCG @K $B
  • Fill Quality

Coming soon

We'll be adding more problems in the near future. If you're looking for any particular problem, please mail us or open an issue. We're working on linkage quality metrics. Once they're published, we'll be incorporating them to this package.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

evobench-0.5.2.tar.gz (21.9 kB view hashes)

Uploaded Source

Built Distribution

evobench-0.5.2-py3-none-any.whl (12.9 MB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page