Cultural Algorithm β
Evolutionary
Cultural Algorithm (CA) optimization algorithm.
Algorithm Overview β
This module provides an implementation of the Cultural Algorithm optimizer. The Cultural Algorithm is a population-based optimization algorithm that combines individual learning (exploitation) with social learning (exploration) to search for the best solution to a given optimization problem.
The CulturalAlgorithm class is the main class of this module. It inherits from the AbstractOptimizer class and implements the search method to perform the Cultural Algorithm search.
Example usage: optimizer = CulturalAlgorithm( func=shifted_ackley, dim=2, lower_bound=-2.768, upper_bound=+2.768 ) best_solution, best_fitness = optimizer.search() print(f"Best solution found: {best_solution}") print(f"Best fitness found: {best_fitness}")
Usage β
from opt.evolutionary.cultural_algorithm import CulturalAlgorithm
from opt.benchmark.functions import sphere
optimizer = CulturalAlgorithm(
func=sphere,
lower_bound=-5.12,
upper_bound=5.12,
dim=10,
max_iter=500,
population_size=50,
)
best_solution, best_fitness = optimizer.search()
print(f"Best solution: {best_solution}")
print(f"Best fitness: {best_fitness:.6e}")Parameters β
| Parameter | Type | Default | Description |
|---|---|---|---|
func | Callable | Required | Objective function to minimize. |
lower_bound | float | Required | Lower bound of search space. |
upper_bound | float | Required | Upper bound of search space. |
dim | int | Required | Problem dimensionality. |
population_size | int | 100 | Number of individuals. |
max_iter | int | 1000 | Maximum iterations. |
belief_space_size | int | 20 | Belief space size. |
scaling_factor | float | 0.5 | Influence strength. |
mutation_probability | float | 0.5 | Mutation probability. |
elitism | float | 0.1 | Elite preservation rate. |
seed | int | None | None | Random seed for reproducibility. |
Algorithm Metadata β
| Property | Value |
|---|---|
| Algorithm Name | Cultural Algorithm |
| Acronym | CA |
| Year Introduced | 1994 |
| Authors | Reynolds, Robert G. |
| Algorithm Class | Evolutionary |
| Complexity | O(NP * dim) per iteration |
| Properties | Population-based, Derivative-free, Stochastic |
| Implementation | Python 3.10+ |
| COCO Compatible | Yes |
Mathematical Formulation β
Cultural algorithms combine population-based search with a belief space storing collective knowledge. Two key spaces evolve:
Population Space (similar to GA):
- Selection, crossover, mutation on individuals
Belief Space (collective knowledge): Stores best solutions and their characteristics:
Influence Function: Belief space guides population evolution:
where:
is belief space (top-performing solutions) is acceptance threshold for belief space is best solution in belief space controls influence of belief space controls mutation strength- Population and belief space communicate bidirectionally
Constraint handling:
- Boundary conditions: Clamping to bounds
- Feasibility enforcement: Solutions clipped to valid range
Hyperparameters β
| Parameter | Default | BBOB Recommended | Description |
|---|---|---|---|
| population_size | 100 | 10*dim | Number of individuals |
| max_iter | 1000 | 10000 | Maximum iterations |
| belief_space_size | 20 | 0.2*pop_size | Number of solutions in belief space |
| scaling_factor | 0.5 | 0.3-0.7 | Influence strength |
| mutation_probability | 0.5 | 0.3-0.7 | Mutation probability |
| elitism | 0.1 | 0.05-0.2 | Elite preservation rate |
Sensitivity Analysis:
belief_space_size: High impact - controls knowledge retentionscaling_factor: Medium impact - balances exploration/exploitation- Recommended tuning ranges:
,
COCO/BBOB Benchmark Settings β
Search Space:
- Dimensions tested:
2, 3, 5, 10, 20, 40 - Bounds: Function-specific (typically
[-5, 5]or[-100, 100]) - Instances: 15 per function (BBOB standard)
Evaluation Budget:
- Budget:
function evaluations - Independent runs: 15 (for statistical significance)
- Seeds:
0-14(reproducibility requirement)
Performance Metrics:
- Target precision:
1e-8(BBOB default) - Success rate at precision thresholds:
[1e-8, 1e-6, 1e-4, 1e-2] - Expected Running Time (ERT) tracking
Raises β
ValueError: If search space is invalid or function evaluation fails.
Notes β
- Modifies self.history if track_history=True
- Uses self.seed for all random number generation
- BBOB: Returns final best solution after max_iter or convergence
Computational Complexity:
- Time per iteration:
- Space complexity:
with belief space - BBOB budget usage: Typically uses 50-85% of dim*10000 budget
BBOB Performance Characteristics:
- Best function classes: Moderately multimodal, Structured
- Weak function classes: Highly ill-conditioned
- Typical success rate at 1e-8 precision: 60-75% (dim=5)
Convergence Properties:
- Convergence rate: Linear with knowledge acceleration
- Local vs Global: Enhanced by belief space guidance
- Premature convergence risk: Medium
Reproducibility:
- Deterministic: Yes - Same seed guarantees same results
- BBOB compliance: seed parameter required
- Initialization: Uniform random sampling
- RNG usage:
numpy.random.default_rng(self.seed)
Implementation Details:
- Parallelization: Not supported
- Constraint handling: Clamping to bounds
- Numerical stability: Standard precision
Known Limitations:
- Belief space overhead for simple problems
- BBOB known issues: None specific
Version History:
- v0.1.0: Initial implementation
References β
[1] Reynolds, R. G. (1994). "An Introduction to Cultural Algorithms." Proceedings of 3rd Annual Conference on Evolutionary Programming, Vol. 24, 131-139.
[2] Hansen, N., Auger, A., Ros, R., Mersmann, O., TuΕ‘ar, T., Brockhoff, D. (2021). "COCO: A platform for comparing continuous optimizers in a black-box setting." Optimization Methods and Software, 36(1), 114-144. https://doi.org/10.1080/10556788.2020.1808977
COCO Data Archive:
- Benchmark results: https://coco-platform.org/testsuites/bbob/data-archive.html
- Code repository: https://github.com/Anselmoo/useful-optimizer
Implementation:
- This implementation: Dual inheritance model with belief space guidance
See Also β
GeneticAlgorithm: Classical evolutionary without belief space BBOB Comparison: CA adds knowledge retention for potentially faster convergence
AbstractOptimizer: Base class for all optimizers opt.benchmark.functions: BBOB-compatible test functions
Related BBOB Algorithm Classes:
- Evolutionary: GeneticAlgorithm, DifferentialEvolution
- Swarm: ParticleSwarm
- Gradient: AdamW, SGDMomentum
Benchmark Performance β
Results of the benchmark suite for this optimizer, on the same evaluation budget as every other optimizer and compared with a random search baseline. See the methodology for the protocol and statistics.
Related Pages β
Source Code
View the implementation: cultural_algorithm.py