微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

javascript – JS – 基于密度的精细点数

假设我有一个如下数组(每个小数组是[x,y]):
var myPoints = [[25,28],[26,26],[70,40],[50,50],[300,300],[285,350],[1000,1000]];

假设我需要将阵列缩小到4分. (这是一个小例子,我的实际阵列有几千个点)我怎样才能根据密度对阵列进行细化,以便从点距离较近的区域中移除更多的点,从较低密度的区域移除较少的点?

在这种情况下(将上面的数组从8项减少到4项)我希望返回的数组看起来如下所示:

var thinnedPoints = [[25,1000]];

关于如何处理这个问题的想法是生成一个字典,将点映射到它与另一个点的最小距离(例如,靠近另一个点的点将具有较小的最小距离)然后根据递增的最小距离对字典进行排序,然后删除字典中的每个n’tn项.

这种方法的问题是我不知道如何有效地为每个点生成距离最近的其他点值的距离.

有没有一种有效的方法生成这些值,或者是否有另一种方法来处理这种基于密度的细化问题?

谢谢!

解决方法

看起来你想要解决P中心问题或P中值问题.

Approximability Results for the p-Center Problem by Stefan Buettcher,

The p-Center problem,also kNown as the Min-Max Multicenter problem
or the Facility Location problem,is a famous problem from operations
research. Informally,it is the problem of placing fire stations in a
city so that the maximum time to reach any point in the city is
minimized.

从J. Reese开始于Methods for Solving the p-Median Problem: An Annotated Bibliography

The p-median problem is simply stated as: Given a graph or a network
G = (V,E),find Vp ⊆ V such that |Vp| = p,where p may either
be variable or fixed […],and that the sum of the shortest distances
from the vertices in {V\Vp} to their nearest vertex in Vp is
minimized.

这两个问题一般都是NP完全的,所以没有(已知的)方法在多项式时间内解决它们.但是你可以尝试各种启发式方法.

原文地址:https://www.jb51.cc/js/157919.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐