anyoptimization / pymoo

NSGA2, NSGA3, R-NSGA3, MOEAD, Genetic Algorithms (GA), Differential Evolution (DE), CMAES, PSO
https://pymoo.org
Apache License 2.0
2.2k stars 381 forks source link

AGEMOEA2 has too many error when benchmarked by test problems. #620

Open muazhari opened 1 month ago

muazhari commented 1 month ago
from pymoo.termination import get_termination
from pymoo.algorithms.moo.age import AGEMOEA
from pymoo.algorithms.moo.sms import SMSEMOA
from pymoo.util.ref_dirs import get_reference_directions, LayerwiseRieszEnergyReferenceDirectionFactory
from pymoo.algorithms.moo.ctaea import CTAEA
from pymoo.algorithms.moo.age2 import AGEMOEA2
from pymoo.core.variable import Binary, Choice, Integer, Real
from pymoo.core.problem import LoopedElementwiseEvaluation, RayParallelization
from pymoo.algorithms.moo.nsga2 import RankAndCrowding, NSGA2
from pymoo.core.mixed import MixedVariableGA, MixedVariableMating, MixedVariableDuplicateElimination, \
    MixedVariableSampling
from pymoo.optimize import minimize

from pymoo.problems.many import C1DTLZ1, DC1DTLZ1, DC1DTLZ3, DC2DTLZ1, DC2DTLZ3, DC3DTLZ1, DC3DTLZ3, C1DTLZ3, \
    C2DTLZ2, C3DTLZ1, C3DTLZ4, DTLZ1
from pymoo.core.problem import ElementwiseProblem
import ray
import numpy as np

benchmark_algorithms = [
    # SMSEMOA(),
    AGEMOEA2(),
]

benchmark_problems = [
    C1DTLZ1, DC1DTLZ1, DC1DTLZ3, DC2DTLZ1, DC2DTLZ3, DC3DTLZ1, DC3DTLZ3, C1DTLZ3, C2DTLZ2, C3DTLZ1, C3DTLZ4
]

def run_benchmark(problem, algorithm):
    res = minimize(
        problem(),
        algorithm,
        verbose=True,
        seed=1
    )

    result = {
        "problem": problem,
        "algorithm": algorithm,
        "result": res
    }

    return result

tasks = []
for problem in benchmark_problems:
    for algorithm in benchmark_algorithms:
        tasks.append(ray.remote(run_benchmark).remote(problem, algorithm))
result = ray.get(tasks) 

Output: image

blankjul commented 1 month ago

AGE-MOEA2 was added here #272.

@apanichella Have you tested the implementation on these test problems as well?

apanichella commented 1 month ago

I did some tests for constraints problem in the original MATLAB implementation and it worked well. I think that happens when there are not enough points for the derivative.

I am doing some tests to check this. A fix will follow later today :)