2

Assume there is a set of N points named A. I'd like to select K points and make a subset of A, which is A', where the minimum distance between points are maximum over subsets.

  • the distance between all points within A' is defined as y(x, x'), x∈A, x'∈A
  • the minimum distance is defined as k(A') = min_{x∈A', x'∈A', x!=x'}(y(x,x'))
  • C = argmin_A'(k(A')) where A'⊂A, |A'| = K
  • N = 100
  • K = 10

I want to solve and get set C. Is there an efficient algorithm to solve this?

The sample result is like the following, which is quite heavy to solve ; O(N^K).

enter image description here

import numpy as np
from matplotlib import pyplot as plt
from itertools import combinations

N=30
K=5

# generate sample point
mean = [0, 0]
cov = [[1, 0], [0, 1]]
rs=np.random.multivariate_normal(mean,cov, N)

def calc_min_dist(arr):
    dist_arr = ((arr[None,:,:] - arr[:,None,:])**2).sum(axis=2)**.5
    min_dist = min(dist_arr[dist_arr>0])
    return min_dist

def min_points(arr, K):
    max_value = 0
    max_index = [range(K)]
    index = list(range(len(arr)))
    for sub_index in combinations(index, K):
        sub_arr = arr[tuple([sub_index])]
        dist = calc_min_dist(sub_arr)
        if max_value < dist:
            max_value = dist
            max_index = sub_index
    return max_value, max_index

# solve
min_value, sub_index = min_points(rs, K)

# plot result
fig, ax = plt.subplots()
ax.scatter(*rs.T)
ax.scatter(*rs[tuple([sub_index])].T)
  • 2
    Related: [Choosing a subset to maximize the minimum distance between points](https://cs.stackexchange.com/questions/22767/choosing-a-subset-to-maximize-the-minimum-distance-between-points) – Stef May 27 '22 at 10:52
  • 1
    Also: [Selecting most scattered points from a set of points](https://scicomp.stackexchange.com/questions/20030/selecting-most-scattered-points-from-a-set-of-points) and [Obtain the subset of dots with maximal average distance](https://stackoverflow.com/questions/47788108/obtain-the-subset-of-dots-with-maximal-average-distance) – Stef May 27 '22 at 10:54
  • These article seems to be related and the problem definition seems to be more accurate. Thanks. – Iwano Natsuki May 29 '22 at 12:09

0 Answers0