Beispiel #1
0
e2 = EventGenerator(dayCycle, dayInterval)
e2.name = "Day Cycle Event"


def buyEvent():
    global s1
    global BUY_RATE

    s1.release(int(BUY_RATE.next()))


e3 = EventGenerator(buyEvent, BUY_INTERVAL.next)
e3.name = "Buy Event"

sim = Simulation()
sim.maxtick = 50000
sim.logs = True

sim.addactor(d1)
sim.addactor(d2)
sim.addactor(b1)
sim.addactor(s1)
sim.addactor(g1)
sim.addactor(e1)
sim.addactor(e2)
sim.addactor(e3)

sim.addprobe(pr1)
sim.addprobe(pr2)
sim.addprobe(pr3)
q1 = Queue([dl1])
q1.logs = True

pr1 = ActorProbe(q1)
pr1.name = 'Queue Probe'
q1.actorprobe = pr1

pr2 = ActorProbe(dl1)
pr2.name = 'Delay Probe'
dl1.actorprobe = pr2


g1 = AutomaticGenerator(q1, Entity, None, INTERVAL_RATE.next, 200)
g1.logs = True

sim = Simulation()
sim.logs = True

sim.addactor(d1)
sim.addactor(q1)
sim.addactor(dl1)
sim.addactor(g1)

sim.addprobe(pr1)
sim.addprobe(pr2)

sim.start()

drawProbs(pr1.calculatestatistics()[1], sim.tick, 'queue')
drawProbs(pr2.calculatestatistics()[1], sim.tick, 'delay')
Beispiel #3
0
pr1 = ActorProbe(q1)
pr1.name = 'Queue Probe'
q1.actorprobe = pr1

pr2 = ActorProbe(dl1)
pr2.name = 'Able Probe'
dl1.actorprobe = pr2

pr3 = ActorProbe(dl2)
pr3.name = 'Baker Probe'
dl2.actorprobe = pr3

g1 = AutomaticGenerator(q1, Entity, None, INTERVAL_RATE.next, 200)
g1.logs = True

sim = Simulation()
sim.logs = True

sim.addactor(d1)
sim.addactor(q1)
sim.addactor(dl1)
sim.addactor(dl2)
sim.addactor(g1)

sim.addprobe(pr1)
sim.addprobe(pr2)
sim.addprobe(pr3)

sim.start()

drawProbs(pr1.calculatestatistics()[1], sim.tick, 'queue')
Beispiel #4
0
def AgentOnStart():
    
    return {'fastfoodscore':0,
            'restaurantscore':0,
            'hotdogscore':0,
            'entertime':0,
            'lastentered': None,
            'timethereshold': NumberGenerator(UNIFORM, a=1, b=9).next(),
            'qualitythereshold': NumberGenerator(UNIFORM, a=1, b=10).next(),
            'costthereshold': NumberGenerator(TRIANGULAR, low=1, high=10, mid=2).next()
            }

g1 = AutomaticGenerator(s1, Agent, {'onenter': AgentOnEnter, 'onleave': AgentOnEnter, 'start': AgentOnStart}, INTERVAL_RATE.next, 800)
#g1.logs = True

sim = Simulation()
sim.maxtick = 100000
#sim.logs = True

sim.addactor(d1)

sim.addactor(s1)

sim.addactor(q1)
sim.addactor(dl1)

sim.addactor(q2)
sim.addactor(dl2)

sim.addactor(q3)
sim.addactor(dl3)
Beispiel #5
0
    return random.randrange(0,2)

def delayFunction(data):
    return random.randrange(2,5)

d1 = Disposer()
d1.name = "Disposer1"
d1.logs = True
d2 = Disposer()
d2.name = "Disposer2"
d2.logs = True
dl1 = Delay(d2, delayFunction)
dl1.name = "Delay1"
dl1.logs = True
b1 = Branch([d1, dl1], branchFunction)
b1.name = "Branch1"
b1.logs = True
g1 = Generator(b1, Entity, None, randomInterval, 20)
g1.name = "MyGenerator"
g1.logs = True
sim = Simulation()
sim.logs = True

sim.addactor(d1)
sim.addactor(d2)
sim.addactor(dl1)
sim.addactor(b1)
sim.addactor(g1)

sim.start()
Beispiel #6
0
pr1 = ActorProbe(q2)
pr1.name = "Probe Queue 2"
q2.actorprobe = pr1

########################################################

branchFunction = NumberGenerator(RANDINT, a=0, b=1)
b1 = Branch([q3, q2], branchFunction.next)

b1.actorenterprobe = pr7

g1 = AutomaticGenerator(b1, Entity, None, INTERVAL_RATE.next, MAX_ENTITIES)
g1.logs = False

sim = Simulation()
sim.logs = False

sim.addactor(g1)
sim.addactor(b1)
sim.addactor(d1)
sim.addactor(q2)
sim.addactor(dl2)
sim.addactor(q3)
sim.addactor(dl3)
sim.addactor(q4)
sim.addactor(dl4)

sim.addprobe(pr1)
sim.addprobe(pr2)
sim.addprobe(pr3)
Beispiel #7
0
    global DAY_INTERVAL
    return DAY_INTERVAL

e2 = EventGenerator(dayCycle, dayInterval)
e2.name = "Day Cycle Event"

def buyEvent():
    global s1
    global BUY_RATE

    s1.release(int(BUY_RATE.next()))

e3 = EventGenerator(buyEvent, BUY_INTERVAL.next)
e3.name = "Buy Event"

sim = Simulation()
sim.maxtick = 50000
sim.logs = True

sim.addactor(d1)
sim.addactor(d2)
sim.addactor(b1)
sim.addactor(s1)
sim.addactor(g1)
sim.addactor(e1)
sim.addactor(e2)
sim.addactor(e3)

sim.addprobe(pr1)
sim.addprobe(pr2)
sim.addprobe(pr3)
Beispiel #8
0
def delayFunction(data):
    return random.randrange(2, 5)


d1 = Disposer()
d1.name = "Disposer1"
d1.logs = True
d2 = Disposer()
d2.name = "Disposer2"
d2.logs = True
dl1 = Delay(d2, delayFunction)
dl1.name = "Delay1"
dl1.logs = True
b1 = Branch([d1, dl1], branchFunction)
b1.name = "Branch1"
b1.logs = True
g1 = Generator(b1, Entity, None, randomInterval, 20)
g1.name = "MyGenerator"
g1.logs = True
sim = Simulation()
sim.logs = True

sim.addactor(d1)
sim.addactor(d2)
sim.addactor(dl1)
sim.addactor(b1)
sim.addactor(g1)

sim.start()