Exemple #1
0
def test3():
    print('test3')

    sim.Environment(random_seed=1234567)
    print('string')
    d = sim.Distribution('Exponential (1000)')
    sample_and_print(d, 5)
    sim.random_seed(1234567)
    sample_and_print(d, 5)
    sim.random_seed(None)
    sample_and_print(d, 5)

    print('triangular')
    tr = sim.Triangular(1, 5, 3)
    sample_and_print(tr, 5)

    print('uniform')
    u = sim.Uniform(1, 1.1)
    sample_and_print(u, 5)
    print('constant')
    c = sim.Constant(10)
    sample_and_print(c, 5)

    print('normal')
    n = sim.Normal(1, 2)
    sample_and_print(n, 5)
    sample_and_print(n, 5)

    print('cdf')
    cdf = sim.Cdf((1, 0, 2, 25, 2, 75, 3, 100))
    sample_and_print(cdf, 5)
    sample_and_print(cdf, 5)

    print('pdf')
    pdf = sim.Pdf((1, 2), 1)
    sample_and_print(pdf, 5)

    print('pdf 1')
    pdf = sim.Pdf((sim.Uniform(10, 20), 10, sim.Uniform(20, 30), 80,
                   sim.Uniform(30, 40), 10))
    sample_and_print(pdf, 5)

    print('pdf 2')
    pdf = sim.Pdf(
        (sim.Uniform(10, 20), sim.Uniform(20, 30), sim.Uniform(30, 40)),
        (10, 80, 10))
    sample_and_print(pdf, 5)

    print('pdf 3')
    pdf = sim.Pdf(('red', 'green', 1000), (10, 1, 10))
    sample_and_print(pdf, 5)
Exemple #2
0
def test43():
    def test(d):
        d.print_info()
        print('mean=', d.mean())
        l=[d() for i in range(10000)]
        print('one sample', d())
        print('mean sampled =', sum(l)/(len(l)+1))
        print('-'  * 79)

    env=sim.Environment()

    test(sim.IntUniform(1,6))
    test(sim.Weibull(2,1))
    test(sim.Gamma(5,9))
    test(sim.Erlang(2,scale=3))
    test(sim.Exponential(rate=2))
    test(sim.Beta(32,300))
    test(sim.Normal(5,7))
    test(sim.Normal(5,7,use_gauss=True))

    test(sim.Distribution('Exponential(rate=2)'))
    test(sim.Normal(5,5))
Exemple #3
0
def test23():
    sim.a=100
    for d in ('uni(12,30)','n(12)','exponentia(a)','TRI(1)','(12)','12','  (  12,  30)  ','a'):
        print(d)
        print(sim.Distribution(d))
Exemple #4
0
def test7():
    print('test7')

    class X1(sim.Component):
        def process(self):
            yield self.request(r1,5,r2,2,greedy=True,fail_at=5)
            yield self.passivate()


    class X2(sim.Component):
        def process(self):
            yield self.request(r1,8,r2)
            yield self.passivate()

    class X3(sim.Component):
        def process(self):
            yield self.request(r1,7)
            yield self.passivate()


    de=sim.Environment(trace=True)

    x1=X1()
    x2=X2()
    x3=X3()

    X4=sim.Component()

    r1=sim.Resource(capacity=10,anonymous=True)
    r2=sim.Resource()
    r3=sim.Resource()

    q={}
    for i in range(1,5):
        q[i]=sim.Queue()

    x1.enter(q[1])
    x1.enter(q[2])
    x1.enter(q[3])

    x2.enter(q[1])
    x3.enter(q[1])



    env.run(10)
    r2.capacity(2)
    env.run(20)

    print(sim.default_env)

    print(x1)
    print(x2)
    print(x3)

    print (q[1])
    print (q[2])
    print (q[3])
    print (q[4])

    print(r1)
    print(r2)
    print(r3)

    d=sim.Exponential(10)
    print(d)
    print(sim.Uniform(1,2))
    print(sim.Triangular(40,150,55))
    print(sim.Distribution('Constant(5)'))
groups = []
with sim.ItemFile('job shop.txt') as f:
    job_select_method = f.read_item()

    while True:
        name = f.read_item()
        if name == '//':
            break
        number_of_machines = f.read_item_int()
        fraction = f.read_item_float()
        color = f.read_item()
        groups.append(Group(name=name, job_select_method=job_select_method,
            fraction=fraction, number_of_machines=number_of_machines, color=color))

    duration_dist = sim.Distribution(f.read_item())
    inter_arrival_time_dist = sim.Distribution(f.read_item())
    number_of_tasks_dist = sim.Distribution(f.read_item())
    start_slack = f.read_item_float()

plant = sim.Queue('plant')

group_dist = sim.Pdf(groups, probabilities=[group.fraction for group in groups])

JobGenerator(inter_arrival_time_dist=inter_arrival_time_dist, number_of_tasks_dist=number_of_tasks_dist,
    group_dist=group_dist, duration_dist=duration_dist)

scale_x = 1

animation()
env.run(100000)