Esempio n. 1
0
def make_datas_var_options_var_sps_raw(maxSPs=160, maxOpts=8, max_runs=20, filename="results/radar_plot_raw.csv"):
    global servers, ram, cpu, serviceProviders, bandwidth, containers, ramReq, cpuReq
    generate_input_datas(avgCpu=9600, avgRam=100)
    npp = NetworkProvider().getInstance()
    df = pd.DataFrame(columns=["options", "service_providers", "utility", "K", "remaining_cpu", "remaining_ram", "time_elapsed"])
    for i in range(max_runs):
        Random.seed((i+1)*3)
        j = 10
        while j <= maxSPs:
            serviceProviders = UniformRandomVariable(j, j)
            k = 1

            while k <= maxOpts:
                options = UniformRandomVariable(k, k)
                generator = GeneratorForModelAlibaba(servers, serviceProviders,
                                            options, containers, [cpu, ram], bandwidth, [cpuReq, ramReq], K=1)
                generator.generate()  # TODO make multithread by not using a singleton (can I?)
                #generator.save_to_csv(i)
                #npp.clean_cluster()
                t1 = time.time()
                npp.makePlacement(1)
                t2 = time.time()
                #generator.save_for_ilp()

                #os.system("glpsol --math modelglpk.mod -d scenario.dat --proxy 600")
                df.loc[len(df)] = {"options": k, "service_providers": j, "utility": npp.getBandwidthSaving(),
                                   "K": generator.getK(), "remaining_cpu": npp.getRemainingResources()[0],
                                   "remaining_ram": npp.getRemainingResources()[1], "time_elapsed": t2-t1}
                print(df)
                k *= 2
            j *= 2
    df.to_csv(filename)
Esempio n. 2
0
def simpleHeuristic(maxOpt, make_graph=True):
    bwOpts2 = pd.DataFrame(columns=["BandwidthSaving", "ServiceProviders"])
    rrOpts2 = pd.DataFrame(columns=["ServiceProviders", "CPU", "RAM"])
    timing = pd.DataFrame(columns=["ServiceProviders", "Time"])
    k = pd.DataFrame(columns=["ServiceProviders", "K"])
    options = UniformRandomVariable(10, 10)
    for i in range(1, maxOpt + 1):
        serviceProviders = UniformRandomVariable(i, i)
        generator = GeneratorForModelAlibaba(servers, serviceProviders,
                                            options, containers, [cpu, ram], bandwidth, [cpuReq, ramReq], K=1)
        generator.generate()  # TODO make multithread by not using a singleton (can I?)
        npp = NetworkProvider().getInstance()
        print([str(item) for item in npp.getServiceProviders()])
        t1 = time.time()
        npp.makePlacement(i)
        t2 = time.time()
        timing.loc[len(timing)] = {"ServiceProviders": i, "Time": t2 - t1}
        bwOpts2.loc[len(bwOpts2)] = {"ServiceProviders": i, "BandwidthSaving": npp.getBandwidthSaving()}
        rrOpts2.loc[len(rrOpts2)] = {"ServiceProviders": i, "CPU": npp.getRemainingResources()[0], "RAM": npp.getRemainingResources()[1]}
        k.loc[len(k)] = {"ServiceProviders": i, "K": generator.getK()}
    return bwOpts2, rrOpts2, timing
Esempio n. 3
0
def make_datas_var_options_var_sps(maxSPs=160, maxOpts=8, ret_func=NetworkProvider().getInstance().getBandwidthSaving, filename="results/radar_plot.csv"):
    global servers, ram, cpu, serviceProviders, bandwidth, containers, ramReq, cpuReq
    generate_input_datas(avgCpu=9600, avgRam=100)
    npp = NetworkProvider().getInstance()
    serviceProvidersNb = []
    i = 10
    while i <= maxSPs:
        serviceProvidersNb += [i]
        i *= 2

    optionsNb = []
    i = 1
    while i <= maxOpts:
        optionsNb += [i]
        i *= 2

    df = pd.DataFrame({
        'options': optionsNb,
    })

    def column_label(sps):
        return "%d SPs" % sps
    # add Columns to dataframe for each service provider
    for sp in serviceProvidersNb:
        df[column_label(sp)] = None

    for sps in serviceProvidersNb:
        serviceProviders = UniformRandomVariable(sps, sps)
        for opts in optionsNb:
            options = UniformRandomVariable(opts, opts)
            generator = GeneratorForModelAlibaba(servers, serviceProviders,
                                            options, containers, [cpu, ram], bandwidth, [cpuReq, ramReq], K=1)
            generator.generate()  # TODO make multithread by not using a singleton (can I?)
            npp.makePlacement(1)
            df.loc[df["options"] == opts, column_label(sps)] = ret_func()
            print(df)

    df.to_csv(filename, index=False)
Esempio n. 4
0
def simpleHeuristic(maxOpt, make_graph=True):
    bwOpts2 = pd.DataFrame(columns=["t", "BandwidthSaving", "Options"])
    rrOpts2 = pd.DataFrame(columns=["t", "Options", "CPU", "RAM"])
    timing = pd.DataFrame(columns=["t", "Options", "Time"])
    activeServices = pd.DataFrame(columns=["t", "Options", "Services"])
    options = UniformRandomVariable(maxOpt, maxOpt)
    generator = GeneratorForModel(servers, serviceProviders, options,
                                  containers, [cpu, ram], bandwidth,
                                  [cpuReq, ramReq], execution_time)
    generator.generate(
    )  # TODO make multithread by not using a singleton (can I?)

    for t in range(0, time_limit, time_window):
        npp = NetworkProvider().getInstance()
        t1 = time.time()
        npp.makePlacement(maxOpt, t)
        t2 = time.time()
        # Add service providers for next time iteration
        generator.generateServiceProviders()
        timing.loc[len(timing)] = {"Options": maxOpt, "Time": t2 - t1, "t": t}
        bwOpts2.loc[len(bwOpts2)] = {
            "Options": maxOpt,
            "BandwidthSaving": npp.getBandwidthSaving(),
            "t": t
        }
        rrOpts2.loc[len(rrOpts2)] = {
            "Options": maxOpt,
            "CPU": npp.getRemainingResources()[0],
            "RAM": npp.getRemainingResources()[1],
            "t": t
        }
        activeServices.loc[len(activeServices)] = {
            "Options":
            maxOpt,
            "t":
            t,
            "Services":
            len(
                list(
                    filter(lambda x: x.getDefaultOption(),
                           npp.getServiceProviders())))
        }
    if make_graph:
        makeGraph(bwOpts2, rrOpts2, timing, activeServices)
    return bwOpts2, rrOpts2, timing, activeServices
Esempio n. 5
0
def generate_input_datas(avgCpu=32, avgRam=32768, avgServers=8, avgContainers=8, avgServiceProviders=50, avgOptions=5,
                         K=1.8):
    global servers, ram, cpu, serviceProviders, bandwidth, containers, ramReq, cpuReq, maxxCpu, maxxRam, options, Kk, aavgServiceProviders

    Kk = K

    maxxCpu = avgCpu * avgServers
    maxxRam = avgRam * avgServers
    aavgServiceProviders = avgServiceProviders

    servers = UniformRandomVariable(avgServers, avgServers)
    ram = NormalRandomVariable(avgRam, 0)
    cpu = NormalRandomVariable(avgCpu, 0)

    serviceProviders = UniformRandomVariable(avgServiceProviders, avgServiceProviders)
    bandwidth = ResourceDependentRandomVariable(UniformRandomVariable(1, 5))
    containers = UniformRandomVariable(avgContainers, avgContainers)

    ramReq = UniformRandomVariable(0, K * (avgRam * avgServers) / (avgContainers * avgServiceProviders), False)
    cpuReq = UniformRandomVariable(0, K * (avgCpu * avgServers) / (avgContainers * avgServiceProviders), False)

    options = UniformRandomVariable(avgOptions, avgOptions)
    return servers, ram, cpu, serviceProviders, bandwidth, containers, ramReq, cpuReq, options
Esempio n. 6
0
def generate_input_datas(avgCpu=1, avgRam=1, avgServers=8, avgContainers=8, avgServiceProviders=50, K=1.8):
    global maxxCpu, maxxRam

    maxxCpu = avgCpu * avgServers
    maxxRam = avgRam * avgServers
    # avgBandwidth = 100
    global servers, ram, cpu, serviceProviders, bandwidth, containers, ramReq, cpuReq

    servers = UniformRandomVariable(avgServers, avgServers)
    ram = NormalRandomVariable(avgRam, 0)
    cpu = NormalRandomVariable(avgCpu, 0)

    serviceProviders = UniformRandomVariable(avgServiceProviders, avgServiceProviders)
    # bandwidth = NormalRandomVariable(avgBandwidth, 50)
    bandwidth = ResourceDependentRandomVariable(UniformRandomVariable(1,5))
    containers = UniformRandomVariable(avgContainers, avgContainers)

    ramReq = UniformRandomVariable(0, K * (avgRam * avgServers) / (avgContainers * avgServiceProviders), False)
    cpuReq = UniformRandomVariable(0, K * (avgCpu * avgServers) / (avgContainers * avgServiceProviders), False)
    return servers, ram, cpu, serviceProviders, bandwidth, containers, ramReq, cpuReq
Esempio n. 7
0
def generate_input_datas(maxCpu=30,
                         maxRam=30000,
                         avgServers=8,
                         avgContainers=8,
                         avgServiceProviders=5,
                         K=1.6,
                         trate=1,
                         ttime_window=20,
                         execution_time_scale=2):
    Random.seed(1)
    avgRam = maxRam / avgServers
    avgCpu = maxCpu / avgServers
    # avgBandwidth = 100
    global servers, ram, cpu, serviceProviders, bandwidth, containers, ramReq, cpuReq, rate, time_window, time_limit
    global serviceProviders, execution_time

    servers = UniformRandomVariable(avgServers, avgServers)
    ram = NormalRandomVariable(avgRam, 0)
    cpu = NormalRandomVariable(avgCpu, 0)

    serviceProviders = UniformRandomVariable(avgServiceProviders,
                                             avgServiceProviders)
    # bandwidth = NormalRandomVariable(avgBandwidth, 50)
    bandwidth = ResourceDependentRandomVariable(UniformRandomVariable(1, 5))
    containers = UniformRandomVariable(avgContainers, avgContainers)

    ramReq = UniformRandomVariable(
        0,
        K * (avgRam * avgServers) / (avgContainers * avgServiceProviders))
    cpuReq = UniformRandomVariable(
        0,
        K * (avgCpu * avgServers) / (avgContainers * avgServiceProviders))

    rate = trate  # req/slot
    time_window = ttime_window  # min/slot
    time_limit = 200  # limit time for batch execution

    serviceProviders = PoissonRandomVariable(time_window * rate)
    execution_time = ExponentialRandomVariable(execution_time_scale)

    return servers, ram, cpu, serviceProviders, bandwidth, containers, ramReq, cpuReq