当前位置: 首页>>代码示例>>Python>>正文


Python Search.greedyProg方法代码示例

本文整理汇总了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]
开发者ID:donya,项目名称:PythonKulitta,代码行数:14,代码来源:ClassicalFG.py

示例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]
开发者ID:donya,项目名称:PythonKulitta,代码行数:15,代码来源:ClassicalFG.py

示例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)
开发者ID:donya,项目名称:PythonKulitta,代码行数:32,代码来源:KulittaTests.py


注:本文中的Search.greedyProg方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。