Skip to content

MOEA/D

MOEA/D decomposes a multi-objective problem into a set of scalar subproblems, defined by a set of weight vectors, and solves them simultaneously by exploiting the neighborhood relationships between subproblems.

from jmetal.algorithm.multiobjective.moead import MOEAD
from jmetal.core.quality_indicator import HyperVolume
from jmetal.operator.crossover import DifferentialEvolutionCrossover
from jmetal.operator.mutation import PolynomialMutation
from jmetal.problem import DTLZ1
from jmetal.util.aggregation_function import PenaltyBoundaryIntersection
from jmetal.util.plotting import save_plt_to_file
from jmetal.util.solution import (
    print_function_values_to_file,
    print_variables_to_file,
    read_solutions,
)
from jmetal.util.termination_criterion import StoppingByEvaluations

if __name__ == "__main__":
    problem = DTLZ1()
    problem.reference_front = read_solutions(filename="resources/reference_fronts/DTLZ2.3D.pf")

    max_evaluations = 50000

    algorithm = MOEAD(
        problem=problem,
        population_size=91,
        crossover=DifferentialEvolutionCrossover(CR=1.0, F=0.5),
        mutation=PolynomialMutation(
            probability=1.0 / problem.number_of_variables(), distribution_index=20
        ),
        aggregation_function=PenaltyBoundaryIntersection(dimension=problem.number_of_objectives()),
        neighbor_size=20,
        neighbourhood_selection_probability=0.9,
        max_number_of_replaced_solutions=2,
        weight_files_path="resources/MOEAD_weights",
        termination_criterion=StoppingByEvaluations(max_evaluations=max_evaluations),
    )

    algorithm.run()
    front = algorithm.result()

    hypervolume = HyperVolume([1.0, 1.0, 1.0])
    print(
        "Hypervolume: " + str(hypervolume.compute([front[i].objectives for i in range(len(front))]))
    )

    # Save results to file
    print_function_values_to_file(front, "FUN." + algorithm.label)
    print_variables_to_file(front, "VAR." + algorithm.label)

    # Save a PNG visualization of the front (and optional HTML if Plotly available)
    png = save_plt_to_file(front, "FUN." + algorithm.label, out_dir=".", html_plotly=True)
    print(f"Saved front plot to: {png}")

    print(f"Algorithm: {algorithm.get_name()}")
    print(f"Problem: {problem.name()}")
    print(f"Computing time: {algorithm.total_computing_time}")

See examples/multiobjective/moead/ for the MOEA/D-DRA and MOEA/D-IEpsilon variants.