Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update MOEA/D #153

Merged
merged 3 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 20 additions & 13 deletions package/samplers/moead/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
author: Hiroaki Natsume
title: MOEA/D sampler
description: Sampler using MOEA/D algorithm. MOEA/D stands for "Multi-Objective Evolutionary Algorithm based on Decomposition.
tags: [sampler, multiobjective]
tags: [Sampler, Multi-Objective Optimization, Evolutionary Algorithms]
optuna_versions: [4.0.0]
license: MIT License
---
Expand All @@ -13,6 +13,8 @@ Sampler using MOEA/D algorithm. MOEA/D stands for "Multi-Objective Evolutionary

This sampler is specialized for multiobjective optimization. The objective function is internally decomposed into multiple single-objective subproblems to perform optimization.

It may not work well with multi-threading. Check results carefully.

## Class or Function Names

- MOEADSampler
Expand All @@ -23,6 +25,12 @@ This sampler is specialized for multiobjective optimization. The objective funct
pip install scipy
```

or

```
pip install -r https://hub.optuna.org/samplers/moead/requirements.txt
```

## Example

```python
Expand All @@ -38,18 +46,17 @@ def objective(trial: optuna.Trial) -> tuple[float, float]:
return v0, v1


if __name__ == "__main__":
population_size = 100
n_trials = 1000
population_size = 100
n_trials = 1000

mod = optunahub.load_module("samplers/moead")
sampler = mod.MOEADSampler(
population_size=population_size,
scalar_aggregation_func="tchebycheff",
n_neighbors=population_size // 10,
)
study = optuna.create_study(sampler=sampler)
study.optimize(objective, n_trials=n_trials)
mod = optunahub.load_module("samplers/moead")
sampler = mod.MOEADSampler(
population_size=population_size,
scalar_aggregation_func="tchebycheff",
n_neighbors=population_size // 10,
)
study = optuna.create_study(sampler=sampler)
study.optimize(objective, n_trials=n_trials)
```

## Others
Expand All @@ -71,4 +78,4 @@ See `compare_2objective.py` in moead directory for details.

Q. Zhang and H. Li,
"MOEA/D: A Multiobjective Evolutionary Algorithm Based on Decomposition," in IEEE Transactions on Evolutionary Computation, vol. 11, no. 6, pp. 712-731, Dec. 2007,
doi: 10.1109/TEVC.2007.892759.
[doi: 10.1109/TEVC.2007.892759](https://doi.org/10.1109/TEVC.2007.892759).
3 changes: 2 additions & 1 deletion package/samplers/moead/_child_generation_strategy.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def __call__(
parent_population: list[FrozenTrial],
neighbors: dict[int, list[int]],
) -> dict[str, Any]:
"""Generate a child parameter from the given parent population by NSGA-II algorithm.
"""Generate a child parameter from the given parent population by MOEA/D algorithm.
Args:
study:
Target study object.
Expand All @@ -92,6 +92,7 @@ def __call__(
Returns:
A dictionary containing the parameter names and parameter's values.
"""
# TODO: this implementation might have unexpected behavior in the case of multi-threading.
subproblem_parent_population = [
parent_population[i] for i in neighbors[self._subproblem_id]
]
Expand Down
3 changes: 2 additions & 1 deletion package/samplers/moead/moead.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import hashlib
from typing import Any
from typing import Dict
from typing import Literal
from typing import TYPE_CHECKING

import optuna
Expand Down Expand Up @@ -34,7 +35,7 @@ def __init__(
*,
population_size: int = 100,
n_neighbors: int | None = None,
scalar_aggregation_func: str = "tchebycheff",
scalar_aggregation_func: Literal["weighted_sum", "tchebycheff"] = "tchebycheff",
mutation_prob: float | None = None,
crossover: BaseCrossover | None = None,
crossover_prob: float = 0.9,
Expand Down
1 change: 1 addition & 0 deletions package/samplers/moead/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
scipy==1.13.1