2525
2626from paretoset import paretoset
2727
28+ from seqme .core .rank import is_pareto_front as seqme_is_pareto_front
29+
2830# See https://github.com/multi-objective/testsuite/tree/main/data
2931files = {
3032 # range are the (start, stop, num) parameters for np.geomspace()
@@ -50,6 +52,18 @@ def get_dataset(name):
5052 return moocore .get_dataset (files [name ]["file" ])[:, :- 1 ]
5153
5254
55+ # Exclude the conversion to torch from the timing.
56+ setup = {"botorch" : lambda z : torch .from_numpy (z )}
57+
58+
59+ def check_values (a , b , what , n , name ):
60+ np .testing .assert_allclose (
61+ a ,
62+ b ,
63+ err_msg = f"In { name } , maxrow={ n } , { what } ={ b } not equal to moocore={ a } " ,
64+ )
65+
66+
5367title = "is_non_dominated(keep_weakly=False)"
5468file_prefix = "ndom"
5569names = files .keys ()
@@ -60,6 +74,7 @@ def get_dataset(name):
6074 bench = Bench (
6175 name = name ,
6276 n = n ,
77+ setup = setup ,
6378 bench = {
6479 "moocore" : lambda z : moocore .is_nondominated (
6580 z , maximise = True , keep_weakly = False
@@ -69,38 +84,17 @@ def get_dataset(name):
6984 z , sense = z .shape [1 ] * ["max" ], distinct = True , use_numba = True
7085 ),
7186 },
87+ check = check_values ,
7288 )
7389
74- values = {}
7590 for maxrow in n :
76- z = x [:maxrow , :]
77- for what in bench .keys ():
78- if what == "botorch" :
79- # Exclude the conversion to torch from the timing.
80- zz = torch .from_numpy (z )
81- else :
82- zz = z
83- values [what ] = bench (what , maxrow , zz )
84-
85- # Check values
86- for what in bench .keys ():
87- if what == "moocore" :
88- continue
89- a = values ["moocore" ]
90- b = values [what ]
91- np .testing .assert_array_equal (
92- a ,
93- b ,
94- err_msg = f"In { name } , maxrow={ maxrow } , { what } ={ b } not equal to moocore={ a } " ,
95- )
96-
97- del values
91+ values = bench (maxrow , x [:maxrow , :])
92+
9893 bench .plots (file_prefix = file_prefix , title = title , log = "xy" )
9994
10095
10196title = "is_non_dominated(keep_weakly=True)"
10297file_prefix = "wndom"
103-
10498names = files .keys ()
10599for name in names :
106100 x = get_dataset (name )
@@ -109,6 +103,7 @@ def get_dataset(name):
109103 bench = Bench (
110104 name = name ,
111105 n = n ,
106+ setup = setup ,
112107 bench = {
113108 "moocore" : lambda z : bool2pos (
114109 moocore .is_nondominated (z , maximise = True , keep_weakly = True )
@@ -128,33 +123,16 @@ def get_dataset(name):
128123 - z , only_non_dominated_front = True
129124 ),
130125 "desdeo" : lambda z : bool2pos (desdeo_is_nondominated (- z )),
126+ "seqme" : lambda z : bool2pos (
127+ seqme_is_pareto_front (- z , assume_unique_lexsorted = True )
128+ ),
131129 },
130+ check = check_values ,
132131 )
133132
134- values = {}
135133 for maxrow in n :
136- z = x [:maxrow , :]
137- for what in bench .keys ():
138- if what == "botorch" :
139- # Exclude the conversion to torch from the timing.
140- zz = torch .from_numpy (z )
141- else :
142- zz = z
143- values [what ] = bench (what , maxrow , zz )
144-
145- # Check values
146- for what in bench .keys ():
147- if what == "moocore" :
148- continue
149- a = values ["moocore" ]
150- b = values [what ]
151- np .testing .assert_allclose (
152- a ,
153- b ,
154- err_msg = f"In { name } , maxrow={ maxrow } , { what } ={ b } not equal to moocore={ a } " ,
155- )
156-
157- del values
134+ values = bench (maxrow , x [:maxrow , :])
135+
158136 bench .plots (file_prefix = file_prefix , title = title , log = "xy" )
159137
160138
0 commit comments