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)
def testBottomUpemptyNode(self): answer = BottomUp.computeAllMIS(self.emptyNode, getFullSet(6)) self.assertEquals(answer, self.emptyAnswerSet)
def testRandomEmptyNode(self): answer = Random.computeAllMIS(self.emptyNode, getFullSet(6)) self.assertEquals(answer, self.emptyAnswerSet)
def testTopDownemptyNode(self): answer = TopDown.computeAllMIS(self.emptyNode, getFullSet(6)) self.assertEquals(answer, self.emptyAnswerSet)
def testHittingSetTreeEmptyNode(self): answer = HittingSetTree.computeAllMIS(self.emptyNode, getFullSet(6)) self.assertEquals(answer, self.emptyAnswerSet)
def testBottomUp(self): answer = BottomUp.computeAllMIS(self.dedekindNode, getFullSet(6)) self.assertEquals(answer, self.answerSet)
def testTopDown(self): answer = TopDown.computeAllMIS(self.dedekindNode, getFullSet(6)) self.assertEquals(answer, self.answerSet)
def testRandom(self): answer = Random.computeAllMIS(self.dedekindNode, getFullSet(6)) self.assertEquals(answer, self.answerSet)
def testHittingSetTree(self): answer = HittingSetTree.computeAllMIS(self.dedekindNode, getFullSet(6)) self.assertEquals(answer, self.answerSet)