-
Notifications
You must be signed in to change notification settings - Fork 401
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Fix overflow and division by zero errors: Add checks to prevent division by zero and apply regularization to avoid extremely large results in exponentiation when the base is too small. * Add example for AGE-MOEA-II with constrained problems * Fix NumbaDeprecationWarning in AGE-MOEA and AGE-MOEA-II * Add additional checks for Inf and NaN values * Fix more overflow errors * Adding more overflow checks * Fixing division-by-zero errors in survival_score(..)
- Loading branch information
1 parent
e00e3c1
commit ad98c14
Showing
3 changed files
with
119 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
from pymoo.indicators.igd import IGD | ||
from pymoo.util.ref_dirs import get_reference_directions | ||
from pymoo.algorithms.moo.age2 import AGEMOEA2 | ||
from pymoo.optimize import minimize | ||
|
||
from pymoo.problems.many import C1DTLZ1, DC1DTLZ1, DC1DTLZ3, DC2DTLZ1, DC2DTLZ3, DC3DTLZ1, DC3DTLZ3, C1DTLZ3, \ | ||
C2DTLZ2, C3DTLZ1, C3DTLZ4 | ||
import ray | ||
import numpy as np | ||
|
||
benchmark_algorithms = [ | ||
AGEMOEA2(), | ||
] | ||
|
||
benchmark_problems = [ | ||
C1DTLZ1, DC1DTLZ1, DC1DTLZ3, DC2DTLZ1, DC2DTLZ3, DC3DTLZ1, DC3DTLZ3, C1DTLZ3, C2DTLZ2, C3DTLZ1, C3DTLZ4 | ||
] | ||
|
||
|
||
def run_benchmark(problem_class, algorithm): | ||
# Instantiate the problem | ||
problem = problem_class() | ||
|
||
res = minimize( | ||
problem, | ||
algorithm, | ||
pop_size=100, | ||
verbose=True, | ||
seed=1, | ||
termination=('n_gen', 2000) | ||
) | ||
|
||
# Step 4: Generate the reference points | ||
ref_dirs = get_reference_directions("uniform", problem.n_obj, n_points=528) | ||
|
||
# Obtain the true Pareto front (for synthetic problems) | ||
pareto_front = problem.pareto_front(ref_dirs) | ||
|
||
# Calculate IGD | ||
if res.F is None: | ||
igd = np.Infinity | ||
else: | ||
igd = IGD(pareto_front)(res.F) | ||
|
||
result = { | ||
"problem": problem, | ||
"algorithm": algorithm, | ||
"result": res, | ||
"igd": igd | ||
} | ||
|
||
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) | ||
|
||
for res in result: | ||
print(f"Algorithm = {res['algorithm'].__class__.__name__}, " | ||
f"Problem = {res['problem'].__class__.__name__}, " | ||
f"IGD = {res['igd']}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters