Skip to content

Commit 0a74d52

Browse files
committed
Make bi-objective NDS optimization opt-in and move benchmark to tests #754
- Add native_biobj_sorting parameter to fast_non_dominated_sort (default False) - Move test_comparison.py from pymoo/ to tests/benchmark/run_native_biobj.py - Simplify benchmark to use actual pymoo implementation Benchmark results show minimal performance improvement: Size Default (ms) Native BiObj (ms) Speedup Correct 50 0.107 0.036 2.98x Yes 100 0.103 0.100 1.03x Yes 500 1.038 1.065 0.98x Yes 1000 3.205 3.094 1.04x Yes 2000 8.615 8.642 1.00x Yes Not much improvement compared to moocore, thus not enabled by default. Addresses review comments from @MLopez-Ibanez
1 parent 2f048cd commit 0a74d52

File tree

6 files changed

+101
-359
lines changed

6 files changed

+101
-359
lines changed

pymoo/functions/standard/non_dominated_sorting.py

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,30 @@
1010
from pymoo.util.dominator import Dominator
1111

1212

13-
def fast_non_dominated_sort(F, dominator=Dominator(), **kwargs):
14-
"""Fast non-dominated sorting algorithm."""
13+
def fast_non_dominated_sort(F, dominator=Dominator(), native_biobj_sorting=False, **kwargs):
14+
"""Fast non-dominated sorting algorithm.
15+
16+
Parameters
17+
----------
18+
F : np.ndarray
19+
Objective values for each individual.
20+
dominator : Dominator
21+
Dominator object for custom dominance relations.
22+
native_biobj_sorting : bool
23+
If True, use specialized O(N log N) algorithm for bi-objective problems.
24+
Default is False.
25+
"""
1526
if F.size == 0:
1627
return []
17-
28+
1829
n_points, n_objectives = F.shape
19-
30+
2031
# For single objective or single point, return immediately
2132
if n_points <= 1:
2233
return [list(range(n_points))] if n_points == 1 else []
23-
24-
# For bi-objective problems, use specialized O(N log N) algorithm
25-
if n_objectives == 2:
34+
35+
# For bi-objective problems, optionally use specialized O(N log N) algorithm
36+
if native_biobj_sorting and n_objectives == 2:
2637
return _fast_biobjective_nondominated_sort(F)
2738

2839
if "dominator" in kwargs:

pymoo/test_comparison.py

Lines changed: 0 additions & 352 deletions
This file was deleted.

tests/benchmark/__init__.py

Whitespace-only changes.
156 Bytes
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)