<jupyter_start><jupyter_text>Perform a short-run simulation to show example output This code simulates a 2-server robotic milking parlor (queue) with exponentially distributed arrivals, normally distributed service times and deterministic downtime.<jupyter_code># baseline simulation
# two robots running
# lambda = 500, mu = 300, sigma = 100
# duration = 10 days = 864000 seconds
exps = exp_generator(30000, 300)
arrivals = time_totalizer(exps)
services = norm_generator(30000, 300, 100)
breakdowns = 0
initial_queue = 0
servers = 2
duration = 864000
mt = [7200, 7200]  # time bewtween deterministic maintenance
md = 1800  # maintenance duration
(times, total_customers, customers,
 service_durations,
 d1, dt2, oc1,
 oc2, cc) = parallel_plant(arrivals, services, breakdowns,
                           initial_queue, servers, duration,
                           mt, md)
start_time = 10000
end_time = 30000
fig1 = plt.figure(figsize=(30, 20))
fig1_iterator = 1

for items in [[customers, 'Queue Length', 'Customers'],
              [oc1, 'Server 1 Occupied', 'Yes = 1'],
              [oc2, 'Server 2 Occupied', 'Yes = 1'],
              [cc, 'Cumulative Customers', 'Customers'],
              [d1, 'Server 1 Uptime', 'Yes = 1'],
              [dt2, 'Server 2 Uptime', 'Yes = 1']]:
    ax_val = fig1.add_subplot(6, 1, fig1_iterator)
    ax_val.plot(times[start_time:end_time], items[0][start_time:end_time])
    ax_val.set_title(items[1], fontsize=30)
    ax_val.set_xlabel('Seconds', fontsize=20)
    ax_val.set_ylabel(items[2], fontsize=30)
    ax_val.tick_params(axis='both', labelsize=20)
    fig1_iterator += 1
plt.tight_layout()<jupyter_output><empty_output><jupyter_text>Long-Run Simulation with Varying Arrival Times In an exponentially distributed system, inter-arrival times should decrease proportionally with population increases.  This set of simulations explores the increase in queue length as inter-arrival time decreases.  As inter-arrival time decreases, server utilization reaches 100% and queue length can only increase.<jupyter_code># perform a long-run simulation of parlor with parallel server
# run 11 simulations with varying mean arrivals
lambda_list = [325, 300, 250, 212, 200, 195, 190, 185, 180, 175, 170]
service_dist = [300, 100]  # mean and standard deviation of service time
total_customers_list = []
customers_list = []
dt1_list = []
dt2_list = []
oc1_list = []
oc2_list = []
cc_list = []
for i in lambda_list:
    exps = exp_generator(30000, i)
    arrivals = time_totalizer(exps)
    services = norm_generator(30000, service_dist[0], service_dist[1])
    (times, total_customers, customers,
     service_durations,
     dt1, dt2, oc1, oc2,
     cc) = parallel_plant(arrivals, services, breakdowns,
                       initial_queue, servers, duration,
                       mt, md)
    total_customers_list.append(total_customers)
    customers_list.append(customers)
    dt1_list.append(dt1)  #downtime
    dt2_list.append(dt2)
    oc1_list.append(oc1)  #occupancy
    oc2_list.append(oc2)
    cc_list.append(cc)  #cumulative customers
# plot results of varying inter-arrival times
start_time = 0
end_time = -1
fig1 = plt.figure(figsize=(30, 20))
fig1_iterator = 1

for item in customers_list[0:8]:  # this loop generates subplots for each run
    # ax_val = 'a'#'ax' + _ + item
    ax_val = fig1.add_subplot(8, 1, fig1_iterator)
    ax_val.plot(times[start_time:end_time], item[start_time:end_time])
    ax_val.set_ylabel('Customers', fontsize=20)
    ax_val.tick_params(axis='both', labelsize=20)
    ax_val.set_xlabel('Seconds', fontsize=20)
    fig1_iterator += 1
plt.tight_layout()
# calculate max and mean queue lengths for each run
mean_q_len = []  # mean queue length for each run
max_q_len = []  # maximum queue length for each run
for i in customers_list:
    current_mean = np.mean(i)
    current_max = np.max(i)
    mean_q_len.append(current_mean)
    max_q_len.append(current_max)
    current_samples = len(i)
    threshold_counter = 0  # counter for number of seconds above 8 in queue
    for item in i:
        if item > 8:
            threshold_counter += 1
# create dataframe for plotting queue length vs. arrival rate
lengths_df = pd.DataFrame(lambda_list, columns=['ii_time', ])
lengths_df['queue_length'] = mean_q_len

# convert inter-arrival times to arrival rate
lengths_df['arrival_rate'] = 1/lengths_df.ii_time
# plot queue length vs. arrival rate
ax = lengths_df.plot('arrival_rate', 'queue_length')
ax.set_xlabel('Arrival Rate (Arrrivals/s)', fontsize=10)
ax.set_ylabel('Queue Length', fontsize=10)
ax.set_title('Mean Queue Length vs. Arrival Rate', fontsize=10)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10338910338910338, 'fraction_numerical': 0.045903045903045905, 'mean_word_length': 4.096174863387978, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '329594', 'license': 'MIT', 'n_tokens_mistral': 1698, 'n_tokens_neox': 1523, 'n_words': 426, 'path': 'milker_analysis_example.ipynb', 'repo_name': 'karreric1/robot_milking_simulator', 'size': '4662'}