def csv_contour(rho_single: float, sigma_list: List[float], utilization: float, perform_param: PerformParameter, pure_snc: False = False) -> pd.DataFrame: agg_list = [0] * len(sigma_list) for i, sigma in enumerate(sigma_list): agg_list[i] = single_hop_contour(sigma_single=sigma, rho_single=rho_single, utilization=utilization, perform_param=perform_param, pure_snc=pure_snc) results_df = pd.DataFrame({ "aggregation": agg_list, }, index=sigma_list) if pure_snc: filename = "contour_{0}_rho_{1}_utilization_{2}_pure".format( perform_param.to_name_value(), str(rho_single), str("%.2f" % utilization)) else: filename = "contour_{0}_rho_{1}_utilization_{2}".format( perform_param.to_name_value(), str(rho_single), str("%.2f" % utilization)) results_df.to_csv(filename + '.csv', index=True, quoting=csv.QUOTE_NONNUMERIC) return results_df
def compare_aggregation(aggregations: List[int], sigma_single: float, rho_single: float, service_rate: float, perform_param: PerformParameter, opt_method: OptMethod) -> pd.DataFrame: dnc_fifo_single = [0.0] * len(aggregations) const_opt = [0.0] * len(aggregations) leaky_mass_1 = [0.0] * len(aggregations) leaky_mass_2_opt = [0.0] * len(aggregations) exact_mass_2_opt = [0.0] * len(aggregations) for i, agg in enumerate(aggregations): dnc_fifo_single[i], const_opt[i], leaky_mass_1[i], leaky_mass_2_opt[ i], exact_mass_2_opt[i] = single_hop_comparison( aggregation=agg, sigma_single=sigma_single, rho_single=rho_single, service_rate=service_rate * agg, perform_param=perform_param, opt_method=opt_method) results_df = pd.DataFrame( { "DNCBound": dnc_fifo_single, "constBound": const_opt, "leakyMassOne": leaky_mass_1, "leakyMassTwo": leaky_mass_2_opt, "exactMassTwo": exact_mass_2_opt }, index=aggregations) filename = ( "regulated_single_{0}_sigma_{1}_rho_{2}_utilization_{3}_{4}").format( perform_param.to_name_value(), str(sigma_single), str(rho_single), str("%.2f" % (rho_single / service_rate)), opt_method.name) results_df.to_csv(filename + '.csv', index=True, quoting=csv.QUOTE_NONNUMERIC) return results_df
def csv_tandem_compare_servers( foi_arrival: ArrivalDistribution, cross_arrival: ArrivalDistribution, foi_arrival2: ArrivalDistribution, cross_arrival2: ArrivalDistribution, rate: float, max_servers: int, perform_param: PerformParameter, opt_method: OptMethod, nc_analysis: NCAnalysis) -> pd.DataFrame: """Write dataframe results into a csv file. Args: foi_arrival: flow of interest's arrival distribution foi_arrival2: competitor's flow of interest's arrival distribution cross_arrival: distribution of cross arrivals cross_arrival2: competitor's distribution of cross arrivals rate: service rate of servers max_servers: max number of servers in tandem perform_param: performance parameter values opt_method: optimization method nc_analysis: Network Calculus analysis type Returns: csv file """ bounds = [0.0] * max_servers bounds2 = [0.0] * max_servers filename = "tandem_{0}".format(perform_param.to_name_value()) arr_list: List[ArrivalDistribution] = [foi_arrival] arr_list2: List[ArrivalDistribution] = [foi_arrival2] ser_list: List[ConstantRate] = [] for _i in range(max_servers): print("current_number_servers {0}".format(_i + 1)) start = timer() arr_list.append(cross_arrival) arr_list2.append(cross_arrival2) ser_list.append(ConstantRate(rate=rate)) bounds[_i], bounds2[_i] = tandem_compare( arr_list=arr_list, arr_list2=arr_list2, ser_list=ser_list, opt_method=opt_method, perform_param=perform_param, nc_analysis=nc_analysis) end = timer() print("duration: {0}".format(end - start)) filename += "_max" + str(max_servers) + "servers_" + foi_arrival.to_value( ) + "_rate=" + str(rate) results_df = pd.DataFrame({ "bounds": bounds, "bounds2": bounds2 }, index=range(1, max_servers + 1)) results_df = results_df[["bounds", "bounds2"]] results_df.to_csv( filename + '.csv', index=True, quoting=csv.QUOTE_NONNUMERIC) return results_df