def func(n): #infile = open('./out/Timings.csv','rb') infile = open('./Static/MDP/Comparisons/out/Timings.csv','rb') data = csv.reader(infile) data = [row for row in data] infile.close() for row in data: e = eval(row[Integer(0)]) lmbda = eval(row[Integer(1)]) mu = [eval(row[Integer(2)]),eval(row[Integer(3)])] c = [eval(row[Integer(4)]),eval(row[Integer(5)])] skip = [eval(row[Integer(6)]),eval(row[Integer(7)])] print lmbda print mu print c print skip start = time.time() Object6 = StaticHeuristic.n2Ana(lmbda,mu,c,skip) N2Policy = Object6.calculate_D(e,e) N2time = time.time() - start Object7 = TwoQueueVia.Queue(lmbda,mu,c,skip,Policy = N2Policy) Object8 = Simm.RoutingSimm(lmbda,mu,c,skip,Integer(500),N2Policy,Integer(100),[Integer(0),Integer(0)],Policy_type = 'Matrix') N2Cost = Object7.VIA(RealNumber('0.1'))[Integer(0)] outfile = open('./Static/MDP/Comparisons/out/Timings2.csv','ab') #outfile = open('./out/Timings2.csv','ab') output = csv.writer(outfile) outrow = row + [N2Cost,Object8[Integer(0)],N2time,N2Policy.str()] output.writerow(outrow) outfile.close()
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()