def func(n): while True : lmbda = random.uniform(Integer(20),Integer(50)) mu = [random.uniform(Integer(2),Integer(5)),random.uniform(Integer(2),Integer(5))] c = [random.randint(Integer(2),Integer(4)),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 static_pol = StaticPolicy.find_opt(lmbda,mu,c,skip)[Integer(0)] State = Simm.Func(lmbda,mu,c,skip,Integer(100),static_pol,False,Integer(500000),True,Integer(3600))[Integer(0)] outfile = open('./Static/MDP/Comparisons/out/Ndata/Ndata(%.02f,%s,%s,%s).csv' %(lmbda,mu,c,skip),'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)]) output.writerow(outrow) for i in range(Integer(20)): for e in range(Integer(20)): outrow = [e,i,State['%s,%s' %(e,i)].expectedi2] output.writerow(outrow) outfile.close()
def __init__(self,lmbda,mu,c,beta,run_time = _sage_const_600 ): self.lmbda = lmbda self.mu = mu self.c = c self.beta = beta self.run_time = run_time self.Di = {} self.indexpol = {} self.static_policy,self.longrun = StaticPolicy.find_opt(self.lmbda,self.mu,self.c,self.beta) self.lmbda_list = [max(_sage_const_0 ,lmbda*self.static_policy[_sage_const_0 ]),max(_sage_const_0 ,lmbda*(self.static_policy[_sage_const_0 ] + self.static_policy[_sage_const_1 ]))] self.rho = [(self.lmbda_list[e])/(mu[e]*c[e]) for e in range(_sage_const_2 )] self.p0 = self.find_P0(self.static_policy)
def calcN2(lmbda, mu, c, skip, n1, n2): static_pol = StaticPolicy.find_opt(lmbda, mu, c, skip)[_sage_const_0] Lambda = [static_pol[_sage_const_0] * lmbda, (static_pol[_sage_const_0] + static_pol[_sage_const_1]) * lmbda] plot_data = {} a = Queue(Lambda, mu, c, skip, static_pol) p0 = a.find_P0()[_sage_const_0] value = _sage_const_0 a.tdict = {} for t in range(_sage_const_1, _sage_const_100): a.tdict[t] = probtime1stqueue(t, n1, Lambda[_sage_const_0], c[_sage_const_0], mu[_sage_const_0]) cumprob = _sage_const_0 t = _sage_const_0 while cumprob < _sage_const_0p999: t += _sage_const_1 for j in range(c[_sage_const_0] + _sage_const_1): if j == _sage_const_0: value += ( a.interpolate(t) * p0 * matrixform( _sage_const_0 + lmbda * static_pol[_sage_const_1], mu[_sage_const_1], c[_sage_const_1], t, n2 ) ) elif j < c: value += ( a.interpolate(t) * (p0 * ((Lambda[_sage_const_0] / mu[_sage_const_0]) ** (j)) * (_sage_const_1 / math.factorial(j))) * matrixform( j * mu[_sage_const_0] + lmbda * static_pol[_sage_const_1], mu[_sage_const_1], c[_sage_const_1], t, n2, ) ) else: value += ( a.interpolate(t) * ( _sage_const_1 - sum( [ ((Lambda[_sage_const_0] / mu[_sage_const_0]) ** (j)) * (_sage_const_1 / math.factorial(j)) for j in range(_sage_const_1, c) ] ) - p0 ) * matrixform( c[_sage_const_0] * mu[_sage_const_0] + lmbda * static_pol[_sage_const_1], mu[_sage_const_1], c[_sage_const_1], t, n2, ) ) cumprob += a.tdict[t] print cumprob return int(value + _sage_const_0p5)