Commit bfa2747f authored by Georgios Dagkakis's avatar Georgios Dagkakis

Geometric distribution fixed

parent f0f4e5ea
......@@ -40,7 +40,8 @@ import simpy
class G:
seed=1450 #the seed of the random number generator
Rnd = Random(seed) #random number generator
import numpy
numpyRnd=numpy
ObjList=[] #a list that holds all the CoreObjects
EntityList=[] #a list that holds all the Entities
......
......@@ -529,9 +529,11 @@ def main(argv=[], input_data=None):
G.Router.isInitialized=False
if G.seed:
G.Rnd=Random('%s%s' % (G.seed, i))
G.Rnd=Random('%s%s' % (G.seed, i))
G.numpyRnd.random.seed(G.seed)
else:
G.Rnd=Random()
G.Rnd=Random()
G.numpyRnd.random.seed()
createWIP()
initializeObjects()
Globals.setWIP(G.EntityList)
......
......@@ -25,6 +25,7 @@ Created on 14 Feb 2013
'''
holds methods for generations of numbers from different distributions
'''
class RandomNumberGenerator(object):
def __init__(self, obj, distributionType, mean=0, stdev=0, min=0, max=0, alpha=0, beta=0,
logmean=0,logsd=0, probability=0, shape=0, scale=0, location=0):
......@@ -43,8 +44,6 @@ class RandomNumberGenerator(object):
self.location=float(location or 0)
self.obj = obj
def generateNumber(self):
from Globals import G
if(self.distributionType=="Fixed"): #if the distribution is Fixed
......@@ -76,7 +75,7 @@ class RandomNumberGenerator(object):
else:
continue
elif(self.distributionType=="Geometric"): #if the distribution is Geometric
return 1
return G.numpyRnd.random.geometric(self.probability)
elif(self.distributionType=="Lognormal"): #if the distribution is Lognormal
# XXX from the files lognormvariate(mu, sigma)
# it would be better to use same mean,stdev
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment