moocore.hv_approx#
- moocore.hv_approx(data, /, ref, maximise=False, nsamples=100000, seed=None, method='DZ2019')[source]#
Approximate the hypervolume indicator.
Approximate the value of the hypervolume metric with respect to a given reference point assuming minimization of all objectives. The default
method="DZ2019"
relies on Monte-Carlo sampling [1] and, thus, it gets more accurate, but slower, for higher values ofnsamples
.- Parameters:
data (
ArrayLike
) – Numpy array of numerical values, where each row gives the coordinates of a point. If the array is created from theread_datasets()
function, remove the last column.ref (
ArrayLike
) – Reference point as a 1D vector. Must be same length as a single point in thedata
.maximise (
bool
|list
[bool
], default:False
) – Whether the objectives must be maximised instead of minimised. Either a single boolean value that applies to all objectives or a list of booleans, with one value per objective. Also accepts a 1d numpy array with value 0/1 for each objectivensamples (
int
, default:100000
) – Number of samples for Monte-Carlo sampling. Higher values give more accurate approximation of the true hypervolume but require more time.seed (
int
ornumpy.random.Generator
) – Either an integer to seed the NumPy random number generator (RNG) or an instance of Numpy-compatible RNG.None
uses the default RNG of Numpy.method (
Literal
['DZ2019'
], default:'DZ2019'
) – Method to approximate the hypervolume.
- Returns:
float
– A single numerical value, the approximate hypervolume indicator
References
Examples
>>> x = np.array([[5, 5], [4, 6], [2, 7], [7, 4]]) >>> moocore.hv_approx(x, ref=[10, 10], seed = 42) 37.95471 >>> moocore.hypervolume(x, ref=[10, 10]) 38.0
Merge all the sets of a dataset by removing the set number column:
>>> x = moocore.get_dataset("input1.dat")[:, :-1]
Dominated points are ignored, so this:
>>> moocore.hv_approx(x, ref=10, seed = 42) 93.348976559100
gives the same hypervolume approximation as this:
>>> x = moocore.filter_dominated(x) >>> moocore.hv_approx(x, ref=10, seed = 42) 93.348976559100
The approximation is far from perfect for large sets:
>>> x = moocore.get_dataset("CPFs.txt")[:,:-1] >>> x = moocore.filter_dominated(-x, maximise = True) >>> x = moocore.normalise(x, to_range = [1,2]) >>> reference = 0.9 >>> moocore.hypervolume(x, ref = reference, maximise = True) 1.0570447464301551 >>> moocore.hv_approx(x, ref = reference, maximise = True, seed = 42) 1.056312559097445
Examples using
moocore.hv_approx
#Comparing methods for approximating the hypervolume
Comparing methods for approximating the hypervolume