本文整理汇总了Python中Search.pairProg方法的典型用法代码示例。如果您正苦于以下问题:Python Search.pairProg方法的具体用法?Python Search.pairProg怎么用?Python Search.pairProg使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Search
的用法示例。
在下文中一共展示了Search.pairProg方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: range
# 需要导入模块: import Search [as 别名]
# 或者: from Search import pairProg [as 别名]
return a % 12 == b % 12
testSpace = [[i2, i2 + 12] for i2 in range(12)]
testMel = [0, 4, 7, 2]
testMelBuckets = [testSpace[i2] for i2 in testMel]
# print testSpace
# print testMel
# print testMelBuckets
# ============Testing allSolns and versions of pairProg============
def testPred (a, b):
return abs(a - b) <= 7
print "test all solns"
print "expected:"
# expetedAllSolns = [[0,4,7,2],[0,4,7,14],[0,4,19,2],[0,4,19,14],[0,16,7,2],[0,16,7,14],[0,16,19,2],[0,16,19,14],[12,4,7,2],[12,4,7,14],[12,4,19,2],[12,4,19,14],[12,16,7,2],[12,16,7,14],[12,16,19,2],[12,16,19,14]]
print Search.allSols(testSpace, testEq, testMel)
print Search.pairProg(testSpace, testEq, testPred, testMel)
# ============Testing greedyProg and fallBack ============
# def testFallBack(bucket, g, x):
# if bucket is None or len(bucket) == 0:
# raise ("error!", "empty")
# else:
# return (g, bucket[0])
print "greedyProg"
print Search.greedyProg(testSpace, testEq, testPred, Search.nearFall, testMel)