A Joint Python/C++ Library for Efficient yet Accessible Black-Box and Gray-Box Optimization with GOMEA

Anton Bouter, Peter A. N. BosmanGECCO Companion 2023

Abstract

Evolutionary Algorithms (EAs) often face a trade-off between usability and computational efficiency. This paper presents the gomea library, a Python wrapper for the high-performance C++ implementation of the Gene-pool Optimal Mixing Evolutionary Algorithm (GOMEA). By leveraging Gray-Box Optimization (GBO) through partial evaluations, the library achieves significant speedups on structured problems while maintaining the accessibility of the Python ecosystem. Benchmark evaluations demonstrate that Python-based GBO can outperform pure C++ Black-Box Optimization (BBO) methods, effectively democratizing high-performance model-based EAs.

Introduction

Evolutionary Algorithms (EAs) are powerful tools for optimization, but high-performance variants like GOMEA are typically written in complex C++ code, making them difficult for non-experts to modify or integrate into modern data science workflows. Furthermore, most EAs treat objective functions as "Black-Boxes" (BBO), ignoring internal structure. This paper introduces a library that bridges the gap between Python's ease of use and C++'s efficiency, specifically supporting "Gray-Box Optimization" (GBO). GBO exploits problem structure by performing "partial evaluations"—updating only affected sub-components of a score when a variable changes—resulting in massive speedups for large-scale problems.

Methods

The core of the library is the Gene-pool Optimal Mixing Evolutionary Algorithm (GOMEA). Unlike standard genetic algorithms, GOMEA uses a linkage model (such as a Linkage Tree) to learn variable dependencies and applies the Gene-pool Optimal Mixing (GOM) operator to modify dependent sets together. Changes are only accepted if they do not degrade the solution's fitness.

Key technical features include:

  • Cython Integration: Bridges Python and C++, allowing the optimization engine to run at C++ speeds while calling user-defined Python fitness functions.
  • Zero-Copy Data Passing: Uses NumPy ndarray wrappers around C++ pointers to ensure efficient data transfer during partial evaluations.
  • Automated Population Sizing: Implements an Interleaved Multi-start Scheme (IMS) that automatically manages population sizes, removing the need for manual tuning.
  • Multi-Domain Support: Handles both discrete and real-valued optimization problems.

Results and Discussion

The library was evaluated using three benchmark functions: Concatenated Deceptive Trap, MaxCut, and Rosenbrock.

Performance and Language Overhead

A critical insight is that the algorithmic gains from GBO far outweigh the overhead of the Python/C++ bridge. As shown in Figure 1, for a 1,000-variable MaxCut problem, the Python GBO implementation is significantly faster than the Python BBO approach and remains highly competitive with pure C++ implementations. This proves that the architectural overhead is negligible compared to the benefits of partial evaluation.

Figure 1: Evaluation time (s) vs. Dimensionality across benchmark functions. GBO approaches, even in Python, show superior scaling compared to BBO counterparts.

Scalability and Efficiency

GBO-GOMEA demonstrates superior scalability in terms of the number of evaluations required to reach target fitness. For the Rosenbrock and MaxCut functions, GBO variants (using Linkage Trees or Static Linkage Trees) require orders of magnitude fewer evaluations as dimensionality increases compared to their BBO counterparts (Figure 5). In the Concatenated Deceptive Trap tests, GBO-GOMEA scaled linearly with problem size, while BBO approaches showed much steeper growth.

Figure 5: Number of evaluations vs. Dimensionality for MaxCut (b) and Rosenbrock (c). GBO variants require significantly fewer evaluations than BBO variants to reach target fitness.

Conclusion

The gomea library successfully democratizes high-performance optimization by making advanced GBO techniques accessible via a simple Python interface. While the current version is limited to single-objective optimization and lacks Genetic Programming variants, it provides a robust foundation for the GOMEA community. Future work will focus on multi-objective support and expanded customization options.

Summary updated

BibTeX
@inproceedings{bouter2023joint,
  author = {Anton Bouter and Peter A. N. Bosman},
  title = {{A Joint Python/C++ Library for Efficient yet Accessible Black-Box and Gray-Box Optimization with GOMEA}},
  booktitle = {GECCO Companion},
  year = {2023},
}
Figure