本文整理匯總了Python中Search.greedyProg方法的典型用法代碼示例。如果您正苦於以下問題:Python Search.greedyProg方法的具體用法?Python Search.greedyProg怎麽用?Python Search.greedyProg使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Search
的用法示例。
在下文中一共展示了Search.greedyProg方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: classicalCS2
# 需要導入模塊: import Search [as 別名]
# 或者: from Search import greedyProg [as 別名]
def classicalCS2(tchords):
allChords = pianoFilter(ChordSpaces.makeRange([(47, 67), (52, 76), (60, 81)]))
#print("Total number of possible chords: ", len(allChords))
# print(allChords[:10])
qSpace = ChordSpaces.partition(ChordSpaces.opEq, allChords)
# print(qSpace)
chords = map(lambda x: x.absChord, tchords)
# print(chords)
newChords = Search.greedyProg(qSpace, ChordSpaces.opEq, testPred, Search.nearFall, chords)
print(newChords)
for i in range(len(tchords)):
tchords[i].absChord = [] + newChords[i]
示例2: classicalCS2WithRange
# 需要導入模塊: import Search [as 別名]
# 或者: from Search import greedyProg [as 別名]
def classicalCS2WithRange(tchords, voiceRange = [(47, 67), (52, 76), (60, 81)]):
#allChords = pianoFilter(ChordSpaces.makeRange(voiceRange))
allChords = PTGG.filter(ChordSpaces.makeRange(voiceRange), Constraints.satbFilter)
#print("Total number of possible chords: ", len(allChords))
# print(allChords[:10])
qSpace = ChordSpaces.partition(ChordSpaces.opcEq, allChords)
print(qSpace)
chords = map(lambda x: x.absChord, tchords)
newChords = Search.greedyProg(qSpace, ChordSpaces.opcEq, testPred, Search.nearFall, chords)
#print("New Chords: ", newChords)
print(newChords)
for i in range(len(tchords)):
tchords[i].absChord = [] + newChords[i]
示例3: range
# 需要導入模塊: import Search [as 別名]
# 或者: from Search import greedyProg [as 別名]
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)