本文整理汇总了Python中priorityQueue.PriorityQueue.insertUnlessPresent方法的典型用法代码示例。如果您正苦于以下问题:Python PriorityQueue.insertUnlessPresent方法的具体用法?Python PriorityQueue.insertUnlessPresent怎么用?Python PriorityQueue.insertUnlessPresent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类priorityQueue.PriorityQueue
的用法示例。
在下文中一共展示了PriorityQueue.insertUnlessPresent方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: isSolution
# 需要导入模块: from priorityQueue import PriorityQueue [as 别名]
# 或者: from priorityQueue.PriorityQueue import insertUnlessPresent [as 别名]
#print "Popping ", incumbent
if (incumbent[0] >= bestScore):
#print "Rejecting ", incumbent
continue
if isSolution(incumbent):
print "Found new best: ", incumbent
bestScore = incumbent[0]
bestState = incumbent
continue
for r in breakpointReversals(incumbent[2]) :
newstate = applyReversal(incumbent, r)
if newstate[0] < bestScore:
acceptCount += 1
queue.insertUnlessPresent(newstate)
else:
rejectCount += 1
#print "Rejecting ", newstate
maxQueueLen = max(maxQueueLen, len(queue))
print "Best: ", bestState
# Validate the result
print "Start: ", start
perm = list(start)
for rev in bestState[1]:
perm = list(reverse(perm, rev))
print rev, ":", perm