Ejemplo n.º 1
0
def func(n):
    while True:
        for e in range(Integer(5), Integer(20)):
            lmbda = random.uniform(Integer(20), Integer(100))
            mu = [random.uniform(Integer(2), Integer(10)), random.uniform(Integer(2), Integer(10))]
            c = [random.randint(Integer(2), Integer(7)), random.randint(Integer(2), Integer(7))]
            skip = [random.uniform(RealNumber("0.5"), Integer(5)), random.uniform(RealNumber("0.5"), Integer(5))]

            print lmbda
            print mu
            print c
            print skip

            start = time.time()
            Object2 = TwoQueueVia.Queue(lmbda, mu, c, skip, bounds=[Integer(20), Integer(20)])
            ViaOut = Object2.VIA(RealNumber("0.1"))
            viatime = time.time() - start

            Object5 = Simm.RoutingSimm(
                lmbda,
                mu,
                c,
                skip,
                Integer(500),
                ViaOut[Integer(2)],
                Integer(100),
                [Integer(0), Integer(0)],
                Policy_type="Matrix",
            )

            start = time.time()
            Object6 = StaticHeuristic.independant(lmbda, mu, c, skip)
            indepPolicy = Object6.calculate_D(Integer(20), Integer(20))
            indeptime = time.time() - start

            Object7 = TwoQueueVia.Queue(lmbda, mu, c, skip, Policy=indepPolicy)
            Object8 = Simm.RoutingSimm(
                lmbda,
                mu,
                c,
                skip,
                Integer(500),
                indepPolicy,
                Integer(100),
                [Integer(0), Integer(0)],
                Policy_type="Matrix",
            )
            indepCost = Object7.VIA(RealNumber("0.1"))[Integer(0)]

            start = time.time()
            Object9 = StaticHeuristic.n2Simm(lmbda, mu, c, skip)
            SimmN2Policy = Object9.calculate_D(Integer(20), Integer(20))
            SimmN2time = time.time() - start

            Object10 = TwoQueueVia.Queue(lmbda, mu, c, skip, Policy=SimmN2Policy)

            SimmN2Cost = Object10.VIA(RealNumber("0.1"))[Integer(0)]
            Object11 = Simm.RoutingSimm(
                lmbda,
                mu,
                c,
                skip,
                Integer(500),
                SimmN2Policy,
                Integer(100),
                [Integer(0), Integer(0)],
                Policy_type="Matrix",
            )

            start = time.time()
            Object12 = StaticHeuristic.simulation(lmbda, mu, c, skip)
            SimmPolicy = Object12.calculate_D(Integer(20), Integer(20))
            Simmtime = time.time() - start

            Object13 = TwoQueueVia.Queue(lmbda, mu, c, skip, Policy=SimmPolicy)
            SimmCost = Object13.VIA(RealNumber("0.1"))[Integer(0)]
            Object14 = Simm.RoutingSimm(
                lmbda,
                mu,
                c,
                skip,
                Integer(500),
                SimmPolicy,
                Integer(100),
                [Integer(0), Integer(0)],
                Policy_type="Matrix",
            )
            start = time.time()

            outfile = open("./Static/MDP/Comparisons/out/Timings4.csv", "ab")
            output = csv.writer(outfile)
            outrow = []
            outrow.append(e)
            outrow.append(lmbda)
            outrow.append(mu[Integer(0)])
            outrow.append(mu[Integer(1)])
            outrow.append(c[Integer(0)])
            outrow.append(c[Integer(1)])
            outrow.append(skip[Integer(0)])
            outrow.append(skip[Integer(1)])

            outrow.append(indepCost)
            outrow.append(Object8[Integer(0)])
            outrow.append(indeptime)
            outrow.append(indepPolicy.str())

            outrow.append(ViaOut[Integer(0)])
            outrow.append(Object5[Integer(0)])
            outrow.append(viatime)
            outrow.append(ViaOut[Integer(2)].str())

            outrow.append(SimmCost)
            outrow.append(Simmtime)
            outrow.append(Object14[Integer(0)])
            outrow.append(SimmPolicy.str())

            outrow.append(SimmN2Cost)
            outrow.append(Object11[Integer(0)])
            outrow.append(SimmN2time)
            outrow.append(SimmN2Policy.str())

            output.writerow(outrow)
            outfile.close()
Ejemplo n.º 2
0
def func(n):
    while True :
        lmbda = random.uniform(Integer(20),Integer(50))
        mu = [random.uniform(Integer(5),Integer(10)),random.uniform(Integer(2),Integer(5))]
        c = [random.randint(Integer(4),Integer(7)),random.randint(Integer(2),Integer(4))]
        skip = [random.uniform(RealNumber('0.5'),RealNumber('0.8')),random.uniform(RealNumber('0.5'),RealNumber('0.8'))]

        print lmbda
        print mu
        print c
        print skip

        Object2 = TwoQueueVia.Queue(lmbda,mu,c,skip)
        ViaOut = Object2.VIA(RealNumber('0.1'))
        Object5 = Simm.RoutingSimm(lmbda,mu,c,skip,Integer(500),ViaOut[Integer(2)],Integer(100),[Integer(0),Integer(0)],Policy_type = 'Matrix')


        Object6 = StaticHeuristic.independant(lmbda,mu,c,skip)
        indepPolicy = Object6.calculate_D(Integer(20),Integer(20))

        Object7 = TwoQueueVia.Queue(lmbda,mu,c,skip,Policy = indepPolicy)
        Object8 = Simm.RoutingSimm(lmbda,mu,c,skip,Integer(500),indepPolicy,Integer(100),[Integer(0),Integer(0)],Policy_type = 'Matrix')
        indepCost = Object7.VIA(RealNumber('0.1'))[Integer(0)]

        Object9 = StaticHeuristic.n2Simm(lmbda,mu,c,skip)
        SimmN2Policy = Object9.calculate_D(Integer(20),Integer(20))
        Object10 = TwoQueueVia.Queue(lmbda,mu,c,skip,Policy = SimmN2Policy)

        SimmN2Cost = Object10.VIA(RealNumber('0.1'))[Integer(0)]
        Object11 = Simm.RoutingSimm(lmbda,mu,c,skip,Integer(500),SimmN2Policy,Integer(100),[Integer(0),Integer(0)],Policy_type = 'Matrix')

        Object12 = StaticHeuristic.simulation(lmbda,mu,c,skip)
        SimmPolicy = Object9.calculate_D(Integer(20),Integer(20))
        Object13 = TwoQueueVia.Queue(lmbda,mu,c,skip,Policy = SimmPolicy)
        SimmCost = Object13.VIA(RealNumber('0.1'))[Integer(0)]
        Object14 = Simm.RoutingSimm(lmbda,mu,c,skip,Integer(500),SimmPolicy,Integer(100),[Integer(0),Integer(0)],Policy_type = 'Matrix')

        outfile = open('./Static/MDP/Comparisons/out/HiS1.csv','ab')
        output = csv.writer(outfile)
        outrow = []
        outrow.append(lmbda)
        outrow.append(mu[Integer(0)])
        outrow.append(mu[Integer(1)])
        outrow.append(c[Integer(0)])
        outrow.append(c[Integer(1)])
        outrow.append(skip[Integer(0)])
        outrow.append(skip[Integer(1)])

        outrow.append(indepCost)
        outrow.append(Object8[Integer(0)])
        outrow.append(indepPolicy.str())

        outrow.append(ViaOut[Integer(0)])
        outrow.append(Object5[Integer(0)])
        outrow.append(ViaOut[Integer(2)].str())

        outrow.append(SimmCost)
        outrow.append(Object14[Integer(0)])
        outrow.append(SimmPolicy.str())

        outrow.append(SimmN2Cost)
        outrow.append(Object11[Integer(0)])
        outrow.append(SimmN2Policy.str())

        output.writerow(outrow)
        outfile.close()
Ejemplo n.º 3
0
def func(n):
    while True :
        for e in range(Integer(20),Integer(50)):
            lmbda = random.uniform(Integer(20),Integer(100))
            mu = [random.uniform(Integer(2),Integer(10)),random.uniform(Integer(2),Integer(10))]
            c = [random.randint(Integer(2),Integer(7)),random.randint(Integer(2),Integer(7))]
            skip = [random.uniform(RealNumber('0.5'),Integer(5)),random.uniform(RealNumber('0.5'),Integer(5))]
            print lmbda
            print mu
            print c
            print skip

            start = time.time()
            Object2 = TwoQueueVia.Queue(lmbda,mu,c,skip,bounds = [e-Integer(1),e-Integer(1)])
            ViaOut = Object2.VIA(RealNumber('0.1'))
            viatime = time.time() - start

            Object5 = Simm.RoutingSimm(lmbda,mu,c,skip,Integer(500),ViaOut[Integer(2)],Integer(100),[Integer(0),Integer(0)],Policy_type = 'Matrix')

            start = time.time()
            Object6 = StaticHeuristic.independant(lmbda,mu,c,skip)
            indepPolicy = Object6.calculate_D(e,e)
            indeptime = time.time() - start

            Object7 = TwoQueueVia.Queue(lmbda,mu,c,skip,Policy = indepPolicy)
            Object8 = Simm.RoutingSimm(lmbda,mu,c,skip,Integer(500),indepPolicy,Integer(100),[Integer(0),Integer(0)],Policy_type = 'Matrix')
            indepCost = Object7.VIA(RealNumber('0.1'))[Integer(0)]

            start = time.time()
            Object9 = StaticHeuristic.n2Simm(lmbda,mu,c,skip,run_time = Integer(7200))
            SimmN2Policy = Object9.calculate_D(e,e)
            SimmN2time = time.time() - start

            Object10 = TwoQueueVia.Queue(lmbda,mu,c,skip,Policy = SimmN2Policy)
            SimmN2Cost = Object10.VIA(RealNumber('0.1'))[Integer(0)]
            Object11 = Simm.RoutingSimm(lmbda,mu,c,skip,Integer(500),SimmN2Policy,Integer(100),[Integer(0),Integer(0)],Policy_type = 'Matrix')

            start = time.time()
            Object12 = StaticHeuristic.simulation(lmbda,mu,c,skip,run_time = Integer(7200))
            SimmPolicy = Object12.calculate_D(e,e)
            Simmtime = time.time() - start

            Object13 = TwoQueueVia.Queue(lmbda,mu,c,skip,Policy = SimmPolicy)
            SimmCost = Object13.VIA(RealNumber('0.1'))[Integer(0)]
            Object14 = Simm.RoutingSimm(lmbda,mu,c,skip,Integer(500),SimmPolicy,Integer(100),[Integer(0),Integer(0)],Policy_type = 'Matrix')

            start = time.time()
            Object15 = StaticHeuristic.n2Ana(lmbda,mu,c,skip,run_time = Integer(7200))
            n2AnaPolicy = Object15.calculate_D(e,e)
            n2Anatime = time.time() - start

            Object16 = TwoQueueVia.Queue(lmbda,mu,c,skip,Policy = n2AnaPolicy)
            n2AnaCost = Object16.VIA(RealNumber('0.1'))[Integer(0)]
            Object17 = Simm.RoutingSimm(lmbda,mu,c,skip,Integer(500),n2AnaPolicy,Integer(100),[Integer(0),Integer(0)],Policy_type = 'Matrix')

            start = time.time()
            Object18 = StaticHeuristic.n2approx(lmbda,mu,c,skip,run_time = Integer(7200))
            n2approxPolicy = Object18.calculate_D(e,e)
            n2approxtime = time.time() - start

            Object19 = TwoQueueVia.Queue(lmbda,mu,c,skip,Policy = n2approxPolicy)
            n2approxCost = Object19.VIA(RealNumber('0.1'))[Integer(0)]
            Object20 = Simm.RoutingSimm(lmbda,mu,c,skip,Integer(500),n2approxPolicy,Integer(100),[Integer(0),Integer(0)],Policy_type = 'Matrix')

            outfile = open('./Static/MDP/Comparisons/out/TimingsNew.csv','ab')
            output = csv.writer(outfile)

            outrow = []
            outrow.append(e)
            outrow.append(lmbda)
            outrow.append(mu[Integer(0)])
            outrow.append(mu[Integer(1)])
            outrow.append(c[Integer(0)])
            outrow.append(c[Integer(1)])
            outrow.append(skip[Integer(0)])
            outrow.append(skip[Integer(1)])

            outrow.append(indepCost)
            outrow.append(Object8[Integer(0)])
            outrow.append(indeptime)
            outrow.append(indepPolicy.str())

            outrow.append(ViaOut[Integer(0)])
            outrow.append(Object5[Integer(0)])
            outrow.append(viatime)
            outrow.append(ViaOut[Integer(2)].str())

            outrow.append(SimmCost)
            outrow.append(Simmtime)
            outrow.append(Object14[Integer(0)])
            outrow.append(SimmPolicy.str())

            outrow.append(SimmN2Cost)
            outrow.append(Object11[Integer(0)])
            outrow.append(SimmN2time)
            outrow.append(SimmN2Policy.str())

            outrow.append(n2AnaCost)
            outrow.append(Object17[Integer(0)])
            outrow.append(n2Anatime)
            outrow.append(n2AnaPolicy.str())

            outrow.append(n2approxCost)
            outrow.append(Object20[Integer(0)])
            outrow.append(n2approxtime)
            outrow.append(n2approxPolicy.str())

            output.writerow(outrow)
            outfile.close()