hv_contributions#

moocore.hv_contributions(x, /, ref, maximise=False, ignore_dominated=True)[source]#

Hypervolume contributions of a set of points.

Computes the hypervolume contribution of each point of a set of points with respect to a given reference point. Duplicated and dominated points have zero contribution. By default, dominated points are ignored, that is, they do not affect the contribution of other points. See the Notes below for more details.

See also

For details about the hypervolume, see Hypervolume metric.

Parameters:
  • x (ArrayLike) – Numpy array of numerical values, where each row gives the coordinates of a point. If the array is created from the read_datasets() function, remove the last column.

  • ref (ArrayLike) – Reference point as a 1D vector. Must be same length as a single point in x.

  • 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 objective

  • ignore_dominated (bool, default: True) – Whether dominated points are ignored when computing the contribution of nondominated points. The value of this parameter has an effect on the return values only if the input contains dominated points. Setting this to False slows down the computation significantly. See the Notes below for a detailed explanation.

Returns:

array – An array of floating-point values as long as the number of rows in x. Each value is the contribution of the corresponding point in x.

Notes

The hypervolume contribution of point \(\vec{p} \in X\) is defined as \(\text{hvc}(\vec{p}) = \text{hyp}(X) - \text{hyp}(X \setminus \{\vec{p}\})\). This definition implies that duplicated points have zero contribution even if not dominated, because removing one of the duplicates does not change the hypervolume of the remaining set. Moreover, dominated points also have zero contribution. However, a point that is dominated by a single (dominating) nondominated point reduces the contribution of the latter, because removing the dominating point makes the dominated one become nondominated.

Handling this special case is non-trivial and makes the computation more expensive, thus the default (ignore_dominated=True) ignores all dominated points in the input, that is, their contribution is set to zero and their presence does not affect the contribution of any other point. Setting ignore_dominated=False will consider dominated points according to the mathematical definition given above, but the computation will be slower.

When the input only consists of mutually nondominated points, the value of ignore_dominated does not change the result, but the default value is significantly faster.

The current implementation uses a \(O(n \log n)\) dimension-sweep algorithm for 2D. With ignore_dominated=True, the 3D case uses the HVC3D algorithm [1], which has \(O(n \log n)\) complexity. Otherwise, the implementation uses the naive algorithm that requires calculating the hypervolume \(|X|+1\) times.

References

Examples

>>> x = np.array([[5, 1], [1, 5], [4, 2], [4, 4], [5, 1]])
>>> moocore.hv_contributions(x, ref=(6, 6), ignore_dominated=True)
... ## Explanation:
... # hvc[(5,1)] = 0 = duplicated
... # hvc[(1,5)] = 3 = (4 - 1) * (6 - 5)
... # hvc[(4,2)] = 3 = (5 - 4) * (5 - 2)
... # hvc[(4,4)] = 0 = dominated
... # hvc[(5,1)] = 0 = duplicated
array([0., 3., 3., 0., 0.])
>>> moocore.hv_contributions(x, ref=(6, 6), ignore_dominated=False)
... ## Explanation:
... # hvc[(5,1)] = 0 = duplicated
... # hvc[(1,5)] = 3 = (4 - 1) * (6 - 5)
... # hvc[(4,2)] = 2 = (5 - 4) * (4 - 2)
... # hvc[(4,4)] = 0 = dominated
... # hvc[(5,1)] = 0 = duplicated
array([0., 3., 2., 0., 0.])
>>> x = np.array([[5, 5], [4, 6], [2, 7], [7, 4]])
>>> moocore.hv_contributions(x, ref=[10, 10])
array([2., 1., 6., 3.])