相关疑难解决方法(0)

在Python中快速计算Pareto前沿

我在3D空间中有一组点,我需要从中找到Pareto前沿.执行速度在这里非常重要,并且当我添加测试点时,时间会非常快.

点集看起来像这样:

[[0.3296170319979843, 0.0, 0.44472108843537406], [0.3296170319979843,0.0, 0.44472108843537406], [0.32920760896951373, 0.0, 0.4440408163265306], [0.32920760896951373, 0.0, 0.4440408163265306], [0.33815192743764166, 0.0, 0.44356462585034007]]
Run Code Online (Sandbox Code Playgroud)

现在,我正在使用这个算法:

def dominates(row, candidateRow):
    return sum([row[x] >= candidateRow[x] for x in range(len(row))]) == len(row) 

def simple_cull(inputPoints, dominates):
    paretoPoints = set()
    candidateRowNr = 0
    dominatedPoints = set()
    while True:
        candidateRow = inputPoints[candidateRowNr]
        inputPoints.remove(candidateRow)
        rowNr = 0
        nonDominated = True
        while len(inputPoints) != 0 and rowNr < len(inputPoints):
            row = inputPoints[rowNr]
            if dominates(candidateRow, row):
                # If it is worse on all features remove the row from …
Run Code Online (Sandbox Code Playgroud)

python numpy

17
推荐指数
2
解决办法
1万
查看次数

查找部分有序集的最大元素的高效算法

我有一个偏序集,说A = [x1, x2, ...],这意味着每一个xixj集合中的,(恰好)的四种可能性之一为真:xi < xj,xi == xj,xi > xj,或xixj所无法比拟的.

我想找到的最大元素(即,这些元素xi是针对那些还没有元素xjxi < xj).什么是有效的算法(最小化比较次数)?我尝试构建DAG并进行拓扑排序,但只是构建图形需要进行O(n ^ 2)次比较,这太多了.

我在Python中这样做,但如果你不知道它我可以读其他语言,或伪代码.

algorithm poset

11
推荐指数
1
解决办法
1583
查看次数

标签 统计

algorithm ×1

numpy ×1

poset ×1

python ×1