entity_server = EntityServer(total_number_servers, service_time_generator)
print(entity_server.describe())

entity_creator.add_sim_event_listener(entity_server)

truncation_point = 100000
steady_state_observations = 10000

inner_delay_in_queue_stat = TruncatingSimpleStatsTally('delay_in_queue',
                                                       truncation_point)
entity_server.add_state_change_listener(inner_delay_in_queue_stat)

inner_number_in_queue_stat = CollectionSizeTimeVarying('queue')
entity_server.add_state_change_listener(inner_number_in_queue_stat)

outer_number_in_queue_stat = SimpleStatsTally('outer_number_in_queue')

outer_delay_in_queue_stat = SimpleStatsTally('mean_delay_in_queue')

p = 0.975
numberReps = 50

EventList.stop_on_event(truncation_point + steady_state_observations,
                        'start_service')

print('\nRunning {reps:d} replications with truncation at {tp:,d} observations and {ss:,d} observations in steady-state '.\
      format(reps=numberReps,tp=truncation_point, ss=steady_state_observations))
start = time()
for rep in range(1, numberReps + 1):
    if rep % 10 == 0:
        print('rep {rep:d} halfwidth {hw:,.4f}'.format(
transfer_line = TransferLine(number_stations, number_machines, service_times)
print(transfer_line.describe())

adapter = Adapter('job_arrival', 'arrival')
adapter.connect(job_creator, transfer_line)

number_available_machines_stat = IndexedSimpleStatsTimeVarying('number_available_machines')
transfer_line.add_state_change_listener(number_available_machines_stat)

delay_in_queue_stat = IndexedSimpleStatsTally('delay_in_queue')
transfer_line.add_state_change_listener(delay_in_queue_stat)

time_at_station_stat = IndexedSimpleStatsTally('time_at_station')
transfer_line.add_state_change_listener(time_at_station_stat)

time_in_system_stat = SimpleStatsTally('time_in_system')
transfer_line.add_state_change_listener(time_in_system_stat)

number_in_queue_stat = IndexedCollectionSizeTimeVaryingStat('queue')
transfer_line.add_state_change_listener(number_in_queue_stat)

total_delay_in_queue_stat = SimpleStatsTally('total_delay_in_queue')
transfer_line.add_state_change_listener(total_delay_in_queue_stat)

time_in_system_stat = SimpleStatsTally('time_in_system')
transfer_line.add_state_change_listener(time_in_system_stat)

EventList.stop_at_time(100000.0)

start = time()
EventList.verbose = False
Exemplo n.º 3
0
from simkit.stats import SimpleStatsTally
from math import nan

simple_stats_tally = SimpleStatsTally()
simple_stats_tally.new_observation(nan)
simple_stats_tally.new_observation(1)
simple_stats_tally.new_observation(2)
print(simple_stats_tally)
entity_creator = EntityCreator(interarrival)
print (entity_creator.describe())

alpha = 1.7
beta = 1.8
number_servers = 2
generator = RandomVariate.instance('Gamma', alpha=alpha, beta=beta)
entity_server = EntityServer(number_servers, generator)

print(entity_server.describe())

entity_creator.add_sim_event_listener(entity_server)

dumper = SimpleStateChangeDumper()

delay_in_queue_stat = SimpleStatsTally("delay_in_queue")
entity_server.add_state_change_listener(delay_in_queue_stat)

time_in_system_stat = SimpleStatsTally('time_in_system')
entity_server.add_state_change_listener(time_in_system_stat)

number_in_queue_stat = CollectionSizeTimeVarying("queue")
entity_server.add_state_change_listener(number_in_queue_stat)
service_mean = alpha * beta

EventList.stop_at_time(100000.0)
EventList.verbose = False

start = time()
EventList.reset()
EventList.start_simulation()
Exemplo n.º 5
0
from simkit.stats import SimpleStatsTally
from math import nan

sst = SimpleStatsTally("test")
sst.new_observation(nan)

print(sst)

for x in range(1, 11):
    sst.new_observation(x)
    sst.new_observation(nan)

print(sst)
Exemplo n.º 6
0
    print(rv4)

    rv5 = RandomVariate.instance('Discrete',
                                 values=[1, 2, 3, 4],
                                 frequencies=[10, 20, 30, 40])
    print(rv5)

    rv5 = RandomVariate.instance('Discrete',
                                 values=[4.0, 3.0, 2.0, 1.0],
                                 frequencies=[100, 200, 300, 400])
    print(rv5)

    rv6 = RandomVariate.instance('Poisson', mean=2.3)
    print(rv6)
    number = 1000000
    sst = SimpleStatsTally(str(rv6))
    for i in range(number):
        sst.new_observation(rv6.generate())
    print(sst)

    rv7 = RandomVariate.instance('Binomial', n=20, p=0.3)
    sst = SimpleStatsTally(str(rv7))
    for i in range(number):
        sst.new_observation(rv7.generate())
    print(sst)

    rv8 = RandomVariate.instance('Uniform', min=0.9, max=2.2)
    sst = SimpleStatsTally(str(rv8))
    for i in range(number):
        sst.new_observation(rv8.generate())
    print(sst)
entityServer = EntityServer(numberServers, generator)

print(entityServer)

interarrivalMean = 2.0
interarrival = Exponential(interarrivalMean)
entityCreator = EntityCreator(interarrival)
print(entityCreator)
print(entityCreator.interarrival_time_generator)

entityCreator.add_sim_event_listener(entityServer)

dumper = SimpleStateChangeDumper()
# entity_server.add_state_change_listener(dumper)

delayInQueueStat = SimpleStatsTally("delayInQueue")
entityServer.add_state_change_listener(delayInQueueStat)

timeInSystemStat = SimpleStatsTally('time_in_system')
entityServer.add_state_change_listener(timeInSystemStat)

numberInQueueStat = SimpleStatsTimeVarying("number_in_queue")
entityServer.add_state_change_listener(numberInQueueStat)
# queue = []
# heappush(queue, Entity() )
# heappush(queue, Entity() )
# print(queue)

expected = (serviceMean * interarrivalMean) / (interarrivalMean - serviceMean)
print('expected avg time_in_system: {avg:.4f}'.format(avg=expected))
print('expected avg delayInQueue: {avg:.4f}'.format(
Exemplo n.º 8
0
    print(rv4)

    rv5 = RandomVariate.instance('Discrete',
                                 values=[1, 2, 3, 4],
                                 frequencies=[10, 20, 30, 40])
    print(rv5)

    rv5 = RandomVariate.instance('Discrete',
                                 values=[4.0, 3.0, 2.0, 1.0],
                                 frequencies=[100, 200, 300, 400])
    print(rv5)

    rv6 = RandomVariate.instance('Poisson', mean=2.3)
    print(rv6)
    number = 1000000
    sst = SimpleStatsTally(str(rv6))
    for i in range(number):
        sst.new_observation(rv6.generate())
    print(sst)

    rv7 = RandomVariate.instance('Binomial', n=20, p=0.3)
    sst = SimpleStatsTally(str(rv7))
    for i in range(number):
        sst.new_observation(rv7.generate())
    print(sst)

    rv8 = RandomVariate.instance('Uniform', min=0.9, max=2.2)
    sst = SimpleStatsTally(str(rv8))
    for i in range(number):
        sst.new_observation(rv8.generate())
    print(sst)