本文整理匯總了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)