diff --git a/package/samplers/moead/README.md b/package/samplers/moead/README.md index d0de99db..2c96998f 100644 --- a/package/samplers/moead/README.md +++ b/package/samplers/moead/README.md @@ -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 --- @@ -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 @@ -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 @@ -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 @@ -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). diff --git a/package/samplers/moead/_child_generation_strategy.py b/package/samplers/moead/_child_generation_strategy.py index 98ed6147..15f9ccbe 100644 --- a/package/samplers/moead/_child_generation_strategy.py +++ b/package/samplers/moead/_child_generation_strategy.py @@ -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. @@ -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] ] diff --git a/package/samplers/moead/moead.py b/package/samplers/moead/moead.py index 5925bb09..38496e0e 100644 --- a/package/samplers/moead/moead.py +++ b/package/samplers/moead/moead.py @@ -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 @@ -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, diff --git a/package/samplers/moead/requirements.txt b/package/samplers/moead/requirements.txt new file mode 100644 index 00000000..1fda602f --- /dev/null +++ b/package/samplers/moead/requirements.txt @@ -0,0 +1 @@ +scipy==1.13.1 \ No newline at end of file