<commit_before>from __future__ import division
from __future__ import print_function
import os
import sys
import functools

# Update path
root = os.path.join(os.getcwd().split('proj1')[0], 'proj1')
if root not in sys.path:
    sys.path.append(root)
import numpy as np
import multiprocessing
from Utils.RandomUtil import Random
from Utils.PlotsUtils import histogram, line
from pdb import set_trace
from Simulator import simulate

rand = Random()

def customer_loss_rate(customers):
    served = np.sum([1 if customer.serviced == True else 0 for customer in customers])
    total = len(customers)
    return served / total


def plot_loss_rate(x, y):
    if x is None:
        x = np.arange(0.05, 1, 0.1)
    if y is None:
        y = [rand.exponential(lam=0.5) for _ in xrange(10)]
    line(x, y, x_label=r"$\rho", y_label=r"CLR", the_title=r"$\mathrm{CLR\ vs.\ }\rho$"
    set_trace()


def task_1_serial():
    rho_list = np.arange(0.05, 1, 0.1)
    C = [1e3, 1e5]
    serviced_pool = [map(functools.partial(simulate, server_lim = 20, max_serviced=lim, L=1, verbose=True), rho_list) for lim in C]
    set_trace()

def task_1_parallel():
    rho_list = np.arange(0.05, 1, 0.1)
    C = [1e3, 1e5]
    pool_0 = multiprocessing.Pool(processes=10)
    for lim in C:
        serviced_pool = pool_0.map(functools.partial(simulate, server_lim = 20, max_serviced=lim, L=1, verbose=False), rho_list)
        CLR = [customer_loss_rate(s) for s serviced_pool]
        plot_loss_rate(rho_list, CLR)
        set_trace()

if __name__ == "__main__":
    task_1_parallel()
    # plot_loss_rate(x=None, y=None)<commit_msg>Lab Machine Changes<commit_after>from __future__ import division
from __future__ import print_function
import os
import sys
import functools

# Update path
root = os.path.join(os.getcwd().split('proj1')[0], 'proj1')
if root not in sys.path:
    sys.path.append(root)
import numpy as np
import multiprocessing
from Utils.RandomUtil import Random
from Utils.PlotsUtils import histogram, line
from pdb import set_trace
from Simulator import simulate

rand = Random()

def customer_loss_rate(customers):
    served = np.sum([1 if customer.serviced == True else 0 for customer in customers])
    total = len(customers)
    return served / total


def plot_loss_rate(x, y):
    if x is None:
        x = np.arange(0.05, 1, 0.1)
    if y is None:
        y = [rand.exponential(lam=0.5) for _ in xrange(10)]
    line(x, y, x_label=r"$\rho", y_label=r"CLR", the_title=r"$\mathrm{CLR\ vs.\ }\rho$")
    set_trace()


def task_1_serial():
    rho_list = np.arange(0.05, 1, 0.1)
    C = [1e3, 1e5]
    serviced_pool = [map(functools.partial(simulate, server_lim = 20, max_serviced=lim, L=1, verbose=True), rho_list) for lim in C]
    set_trace()

def task_1_parallel():
    rho_list = np.arange(0.05, 1, 0.1)
    C = [1e3, 1e5]
    pool_0 = multiprocessing.Pool(processes=10)
    for lim in C:
        serviced_pool = pool_0.map(functools.partial(simulate, server_lim = 20, max_serviced=lim, L=1, verbose=False), rho_list)
        CLR = [customer_loss_rate(s) for s serviced_pool]
        plot_loss_rate(rho_list, CLR)
        # set_trace()

if __name__ == "__main__":
    task_1_parallel()
    # plot_loss_rate(x=None, y=None)
{'fraction_non_alphanumeric': 0.12170133498913381, 'fraction_numerical': 0.029804408568767465, 'mean_word_length': 3.738235294117647, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '645043', 'n_tokens_mistral': 1261, 'n_tokens_neox': 1206, 'n_words': 311}