Esempio n. 1
0
    while True:
        num = int(
            input(
                "Which graph would you like to check? \n Press ( 1 ) for asymptamatic \n Press ( 2 ) for symptamatic \n Press ( 3 ) for hospitalised \n Press ( 4 ) for ICU-ed \n Press ( 5 ) for ventilator cases \n Press ( 6 ) for death \n Press ( 7 ) for immune \n Press ( 8 ) for recovered \n Press ( 9 ) to exit"
            ))
        if num is 9:
            break
        age = int(
            input(
                "Press ( 1 ) for checking the trend among kids \n Press ( 2 ) for checking the trend among the youth \n Press ( 3 ) for checking the trend among the adults \n Press ( 4 ) to check overall trend "
            ))

        if num is 1:
            if age is 1:
                graph.generate(sim, sim.asympKidNum)
            if age is 2:
                graph.generate(sim, sim.asympYoungNum)
            if age is 3:
                graph.generate(sim, sim.asympAdultNum)
            if age is 4:
                graph.generate(sim, sim.asympNum)

        if num is 2:
            if age is 1:
                graph.generate(sim, sim.sympKidNum)
            if age is 2:
                graph.generate(sim, sim.sympYoungNum)
            if age is 3:
                graph.generate(sim, sim.sympAdultNum)
            if age is 4:
Esempio n. 2
0
class Tester:
    generator = None

    def readGraph(self, area, V, E):
        self.generator = GraphGenerator()
        graph = self.generator.readGraph(area, V, E)
        graph.toAjacencyForm()
        #graph.displayAjacencyForm()
        return graph

    def generateGraph(self, area, nodeNum, minDegree):
        self.generator = GraphGenerator()
        graph = self.generator.generate(area, nodeNum, minDegree)
        for i in range(0, len(graph.vertices)):
            graph.vertices[i].id = i
        graph.toAjacencyForm()
        #graph.displayAjacencyForm()
        return graph

    def preconfiguredTest(self):
        V2 = [[0, 0], [15, 3], [24, 0], [33, 3], [1, 6], [16, 6], [25, 6],
              [34, 6], [1, 12], [14, 12], [23, 12], [32, 12], [1, 18],
              [16, 18], [25, 18], [34, 18], [1, 24], [14, 24], [23, 24],
              [32, 24]]
        E4 = [[1, 2], [1, 5], [1, 10], [2, 4], [2, 5], [2, 7], [2,
                                                                10], [2, 11],
              [2, 14], [3, 4],
              [3, 6], [3, 7], [3, 8], [3, 10], [3, 11], [4, 6], [4, 7], [4, 8],
              [4, 12], [4, 15], [4, 16], [5, 6], [5, 9], [5, 10], [5, 13],
              [6, 7], [6, 8], [6, 10], [6, 11], [6, 14], [6, 15], [7, 8],
              [7, 11], [7, 12], [7, 14], [8, 11], [8, 15], [8, 16], [9, 10],
              [9, 13], [9, 17], [10, 11], [10, 12], [10, 14], [10,
                                                               15], [10, 18],
              [11, 12], [11, 14], [11, 15], [11, 16], [11, 18], [11, 19],
              [11, 20], [12, 15], [12, 19], [12, 20], [13, 17], [13, 18],
              [14, 16], [14, 18], [14, 19], [14, 20], [15, 16], [15, 18],
              [15, 19], [16, 19], [17, 18], [18, 19], [18, 20]]

        allCost = []
        for V, E in [(V2, E4)]:
            graphCost = []
            #for eT, nopt in [(0.0005, 6), (0.001, 7), (0.0015, 8), (0.002, 9), (0.0025, 10)]:
            for eT, nopt in [(SysParameters.eR, 8)]:
                SysParameters.eT = SysParameters.eR
                g = self.readGraph((100, 100), V, E)
                sim = DistCluster(g, self.generator.minDegree, nopt)
                sim.test()
                graphCost.append(sim.getCost())
            allCost.append(graphCost)
        print(allCost)

    def autoTest(self):
        allCost = []
        for minDegree in [3, 4, 5]:
            graphCost = []
            #for eT, nopt in [(0.0005, 6), (0.001, 7), (0.0015, 8), (0.002, 9), (0.0025, 10)]:
            #Modified for new cost calculation (for the new version to be submitted to TOSN)
            for eT, nopt in [(0.0005, 10000)]:
                SysParameters.eT = eT
                totalCost = 0
                repeat = 10
                for i in range(0, repeat):
                    g = self.generateGraph((20, 20), 40, minDegree)
                    sim = DistCluster(g, minDegree, nopt)
                    sim.test()
                    totalCost = totalCost + sim.getCost()
                graphCost.append(totalCost / repeat)
            allCost.append(graphCost)
        print(allCost)

    def simpleTest(self):
        g = self.generateGraph((20, 20), 40, 3)
        #SysParameters.eT=eT
        sim = DistCluster(g, 3, 6)
        sim.test()