Skip to content

Commit b3629e7

Browse files
committed
Only warn on failed hypervolume calculation
1 parent defd9b4 commit b3629e7

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

src/omnsga/drivers.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import random
2+
import warnings
23
from copy import deepcopy
34
from itertools import chain
45

@@ -414,16 +415,20 @@ def ind_stats_with_cv(ind):
414415

415416
def pop_hv(algorithm=None):
416417
def func(fitness_values):
417-
hv = pygmo.hypervolume(fitness_values)
418-
ref_point = hv.refpoint(offset=1)
419-
# https://esa.github.io/pygmo/tutorials/advanced_hypervolume_computation_and_analysis.html#pushing-efficiency-further
420-
hv.copy_points = False
421-
# hv.set_verify(False)
422-
423-
if algorithm:
424-
return hv.compute(ref_point, hv_algo=algorithm)
425-
else:
426-
return hv.compute(ref_point)
418+
try:
419+
hv = pygmo.hypervolume(fitness_values)
420+
ref_point = hv.refpoint(offset=1)
421+
# https://esa.github.io/pygmo/tutorials/advanced_hypervolume_computation_and_analysis.html#pushing-efficiency-further
422+
hv.copy_points = False
423+
# hv.set_verify(False)
424+
425+
if algorithm:
426+
return hv.compute(ref_point, hv_algo=algorithm)
427+
else:
428+
return hv.compute(ref_point)
429+
except Exception as exc:
430+
warnings.warn(f"Error computing hypervolume: {exc}")
431+
return np.nan
427432

428433
return func
429434

0 commit comments

Comments
 (0)