def size(self):
"""Computes the hypervolume of this concept."""
hypervolume = 0.0
num_cuboids = len(self._core._cuboids)
# use the inclusion-exclusion formula over all the cuboids
for l in range(1, num_cuboids + 1):
inner_sum = 0.0
subsets = list(itertools.combinations(self._core._cuboids, l))
for subset in subsets:
intersection = subset[0]
for cuboid in subset:
intersection = intersection.intersect_with(cuboid)
inner_sum += self._hypervolume_couboid(intersection)
hypervolume += inner_sum * (-1.0)**(l+1)
return hypervolume
评论列表
文章目录