|
| 1 | +--- |
| 2 | +author: Yoshihiko Ozaki |
| 3 | +title: Multi-objective CMA-ES (MO-CMA-ES) Sampler |
| 4 | +description: A sampler based on a strong variant of CMA-ES for multi-objective optimization (s-MO-CMA). |
| 5 | +tags: [sampler, Multi-Objective Optimization, Evolutionary Algorithm (EA), CMA-ES] |
| 6 | +optuna_versions: [4.0.0] |
| 7 | +license: MIT License |
| 8 | +--- |
| 9 | + |
| 10 | +## Abstract |
| 11 | + |
| 12 | +MoCmaSampler provides the implementation of the s-MO-CMA-ES algorithm. This algorithm extends (1+1)-CMA-ES to multi-objective optimization by introducing a selection strategy based on non-domination sorting and contributing hypervolume (S-metric). It inherits important properties of CMA-ES, invariance against order-preserving transformations of the fitness function value and rotation and translation of the search space. |
| 13 | + |
| 14 | +## Class or Function Names |
| 15 | + |
| 16 | +- `MoCmaSampler(*, search_space: dict[str, BaseDistribution] | None = None, popsize: int | None = None, seed: int | None = None)` |
| 17 | + - `search_space`: A dictionary containing the search space that defines the parameter space. The keys are the parameter names and the values are [the parameter's distribution](https://optuna.readthedocs.io/en/stable/reference/distributions.html). If the search space is not provided, the sampler will infer the search space dynamically. |
| 18 | + Example: |
| 19 | + ```python |
| 20 | + search_space = { |
| 21 | + "x": optuna.distributions.FloatDistribution(-5, 5), |
| 22 | + "y": optuna.distributions.FloatDistribution(-5, 5), |
| 23 | + } |
| 24 | + MoCmaSampler(search_space=search_space) |
| 25 | + ``` |
| 26 | + - `popsize`: Population size of the CMA-ES algorithm. If not provided, the population size will be set based on the search space dimensionality. If you have a sufficient evaluation budget, it is recommended to increase the popsize. |
| 27 | + - `seed`: Seed for random number generator. |
| 28 | + |
| 29 | +Note that because of the limitation of the algorithm, only non-conditional numerical parameters are sampled by the MO-CMA-ES algorithm, and categorical parameters and conditional parameters are handled by random sampling. |
| 30 | + |
| 31 | +## Example |
| 32 | + |
| 33 | +```python |
| 34 | +import optuna |
| 35 | +import optunahub |
| 36 | + |
| 37 | + |
| 38 | +def objective(trial: optuna.Trial) -> tuple[float, float]: |
| 39 | + x = trial.suggest_float("x", 0, 5) |
| 40 | + y = trial.suggest_float("y", 0, 3) |
| 41 | + v0 = 4 * x**2 + 4 * y**2 |
| 42 | + v1 = (x - 5) ** 2 + (y - 5) ** 2 |
| 43 | + return v0, v1 |
| 44 | + |
| 45 | +samplers = [ |
| 46 | + optunahub.load_local_module("samplers/mocma", registry_root="package").MoCmaSampler(popsize=100, seed=42), |
| 47 | + optuna.samplers.NSGAIISampler(population_size=100, seed=42), |
| 48 | +] |
| 49 | +studies = [] |
| 50 | +for sampler in samplers: |
| 51 | + study = optuna.create_study( |
| 52 | + directions=["minimize", "minimize"], |
| 53 | + sampler=sampler, |
| 54 | + study_name=f"{sampler.__class__.__name__}", |
| 55 | + ) |
| 56 | + study.optimize(objective, n_trials=1000) |
| 57 | + studies.append(study) |
| 58 | + |
| 59 | +optunahub.load_module("visualization/plot_pareto_front_multi").plot_pareto_front( |
| 60 | + studies |
| 61 | +).show() |
| 62 | +optunahub.load_module("visualization/plot_hypervolume_history_multi").plot_hypervolume_history( |
| 63 | + studies, reference_point=[200.0, 100.0] |
| 64 | +).show() |
| 65 | +``` |
| 66 | + |
| 67 | + |
| 68 | + |
| 69 | + |
| 70 | +## Others |
| 71 | + |
| 72 | +### Test |
| 73 | + |
| 74 | +To execute the tests for MoCmaSamler, please run the following commands. The test file is provided in the package. |
| 75 | + |
| 76 | +```sh |
| 77 | +pip install pytest |
| 78 | +``` |
| 79 | + |
| 80 | +```python |
| 81 | +pytest -s tests/test_sampler.py |
| 82 | +``` |
| 83 | + |
| 84 | +### Reference |
| 85 | + |
| 86 | +Christian Igel, Nikolaus Hansen, Stefan Roth. Covariance Matrix Adaptation for Multi-objective Optimization, Evolutionary Computatio. (2007) 15 (1): 1–28. https://doi.org/10.1162/evco.2007.15.1.1. |
| 87 | + |
| 88 | +### BibTeX |
| 89 | + |
| 90 | +```bibtex |
| 91 | +@article{igel2007covariance, |
| 92 | + title={Covariance matrix adaptation for multi-objective optimization}, |
| 93 | + author={Igel, Christian and Hansen, Nikolaus and Roth, Stefan}, |
| 94 | + journal={Evolutionary computation}, |
| 95 | + volume={15}, |
| 96 | + number={1}, |
| 97 | + pages={1--28}, |
| 98 | + year={2007}, |
| 99 | + publisher={MIT Press One Rogers Street, Cambridge, MA 02142-1209, USA journals-info~…} |
| 100 | +} |
| 101 | +``` |
0 commit comments