All problems
QD Grid Coverage
Problem
Measure the coverage of a 2D quality-diversity archive.
Map each point into a bins[0] x bins[1] grid over the ranges [mins, maxs], clamping points outside the range into the boundary cells, and return the fraction of grid cells that contain at least one point. An empty point list or non-positive cell count returns 0.0.
Hint
Use a set of cell indices so duplicates do not inflate coverage.
Test cases
case 1
in: [[[0,0],[1,1],[0,1]],[0,0],[2,2],[2,2]]
expected: 0.75
case 2
in: [[[0.1,0.1],[0.2,0.2],[1.5,1.5]],[0,0],[2,2],[2,2]]
expected: 0.5
case 3
in: [[[0,0],[4,4]],[0,0],[2,2],[2,2]]
expected: 0.5
case 4
in: [[],[0,0],[1,1],[2,2]]
expected: 0
Starter codePython
def qd_grid_coverage(points, mins, maxs, bins):
# Your code here
pass4 test cases · run your code against them in the editor