Beispiel #1
0
def runAnalysis(args):
    if len(args) != 2:
        print "must provide an algorithm and input size!"
        return
    algorithmKey = args[0]
    if algorithmKey not in algorithms:
        print "sorry! That algorithm was not recognized."\
        , "\nHere are the options:"
        for _algorithmKey in algorithms.keys():
            print "\n\t", _algorithmKey
        return
    algorithm = algorithms[algorithmKey]

    if int(args[1]) > 5:
        print "input larger than 5 is terribly slow, don't do it!"
        return
    inputSize = int(args[1])
    lattice = DedekindLattice(inputSize)
    callCounts = {}

    while True:
        currentNode = lattice.getNextNode()

        if currentNode == None:
            break

        modifyIsConsistent(currentNode)
        fullConstraints = getFullSet(inputSize)
        algorithm(currentNode, fullConstraints)

        if currentNode.callCount not in callCounts:
            callCounts[currentNode.callCount] = 1
        else:
            callCounts[currentNode.callCount] += 1
    printStatistics(callCounts)
Beispiel #2
0
 def testBottomUpemptyNode(self):
     answer = BottomUp.computeAllMIS(self.emptyNode, getFullSet(6))
     self.assertEquals(answer, self.emptyAnswerSet)
Beispiel #3
0
 def testRandomEmptyNode(self):
     answer = Random.computeAllMIS(self.emptyNode, getFullSet(6))
     self.assertEquals(answer, self.emptyAnswerSet)
Beispiel #4
0
 def testTopDownemptyNode(self):
     answer = TopDown.computeAllMIS(self.emptyNode, getFullSet(6))
     self.assertEquals(answer, self.emptyAnswerSet)
Beispiel #5
0
 def testHittingSetTreeEmptyNode(self):
     answer = HittingSetTree.computeAllMIS(self.emptyNode, getFullSet(6))
     self.assertEquals(answer, self.emptyAnswerSet)
Beispiel #6
0
 def testBottomUp(self):
     answer = BottomUp.computeAllMIS(self.dedekindNode, getFullSet(6))
     self.assertEquals(answer, self.answerSet)
Beispiel #7
0
 def testTopDown(self):
     answer = TopDown.computeAllMIS(self.dedekindNode, getFullSet(6))
     self.assertEquals(answer, self.answerSet)
Beispiel #8
0
 def testRandom(self):
     answer = Random.computeAllMIS(self.dedekindNode, getFullSet(6))
     self.assertEquals(answer, self.answerSet)
Beispiel #9
0
 def testHittingSetTree(self):
     answer = HittingSetTree.computeAllMIS(self.dedekindNode, getFullSet(6))
     self.assertEquals(answer, self.answerSet)