def generate_insights(filename,config_file=None,threshold=0.3): print('Generating insights for the file ' + str(filename)) data_frame = load_data(filename) unique_data,categorical_attributes,measure_attributes,categorical_index,timeseries_attributes,discarded_attributes = data_preprocessing(data_frame,config_file,threshold) # Multi processing for correlation # TODO: Change logic based on the number of cores for correlation out_queue = Queue() correlation_p = Process(target=generate_correlation_insights, args=(data_frame,measure_attributes,out_queue)) correlation_p.start() tau = 2 top_k = 40 maxOneInsPerSub = True result = ins.Insights(data_frame, tau, top_k, categorical_attributes, measure_attributes, timeseries_attributes, maxOneInsPerSub) result = sorted(result, key=lambda elem: elem[0], reverse=True) # print("\n") # for r in result: # print(r, "\n") corr_result = out_queue.get() if correlation_p.is_alive(): correlation_p.join() print('Generating insight graph') print("--- %s Minutes ---" % str(round(float((int(time.time()) - int(start_time)) /60), 2))) generate_graphs(result,categorical_index,top_k,corr_result,filename) print("--- %s Minutes ---" % str(round(float((int(time.time()) - int(start_time)) /60), 2)))
def main_10_cities(): # Create the TSP tsp = create_tsp_problem(length=200, width=200, cities=10) plot_tsp_grid(tsp, "Genetic_Algorithm") # Random Hillclimbing rhc_run_stats, rhc_run_curves = hillclimbing.solve_with_hillclimbing( tsp, "RHC_TSP") rhc_data_strings = { 'title': 'RHC - 10 Cities', 'Parameters': ['Restarts'], 'limit_time': 0, 'limit_iterations': 0 } graphs.generate_graphs(rhc_run_stats, rhc_run_curves, rhc_data_strings) # Mimic mimic_run_stats, mimic_run_curves = mimic.solve_with_mimic( tsp, "MIMIC_TSP") mimic_data_strings = { 'title': 'MIMIC - 10 Cities', 'Parameters': ['Population Size', 'Keep Percent'], 'limit_time': 5, 'limit_iterations': 100 } graphs.generate_graphs(mimic_run_stats, mimic_run_curves, mimic_data_strings) # Solve with Genetic Algorithm ga_run_stats, ga_run_curves = genetic_algorithm.solve_with_ga( tsp, "GA_TSP") ga_data_strings = { 'title': 'Genetic Algorithms - 10 Cities', 'Parameters': ['Mutation Rate', 'Population Size'], 'limit_time': 1, 'limit_iterations': 800 } graphs.generate_graphs(ga_run_stats, ga_run_curves, ga_data_strings) # Simulated Annealing sa_run_stats, sa_run_curves = simulated_annealing.solve_with_sim_annealing( tsp, "SA_TSP") sa_data_strings = { 'title': 'Simulated Annealing - 10 Cities', 'Parameters': ['Temperature'], 'limit_time': 0.4, 'limit_iterations': 1000 } graphs.generate_graphs(sa_run_stats, sa_run_curves, sa_data_strings)
def main_20_items(): t_pct = 0.1 knapsack = create_knapsack_problem(20) # Random Hillclimbing rhc_run_stats, rhc_run_curves = hillclimbing.solve_with_hillclimbing( knapsack, "RHC_Knapsack") rhc_data_strings = { 'title': 'RHC - Knapsack', 'Parameters': ['Restarts'], 'limit_time': 0, 'limit_iterations': 0 } graphs.generate_graphs(rhc_run_stats, rhc_run_curves, rhc_data_strings) # Mimic mimic_run_stats, mimic_run_curves = mimic.solve_with_mimic( knapsack, "MIMIC_Knapsack") mimic_data_strings = { 'title': 'MIMIC - Knapsack', 'Parameters': ['Population Size', 'Keep Percent'], 'limit_time': 10, 'limit_iterations': 50 } graphs.generate_graphs(mimic_run_stats, mimic_run_curves, mimic_data_strings) # Solve with Genetic Algorithm ga_run_stats, ga_run_curves = genetic_algorithm.solve_with_ga( knapsack, "GA_Knapsack") ga_data_strings = { 'title': 'Genetic Algorithms - Knapsack', 'Parameters': ['Mutation Rate', 'Population Size'], 'limit_time': 11, 'limit_iterations': 800 } graphs.generate_graphs(ga_run_stats, ga_run_curves, ga_data_strings) # Simulated Annealing sa_run_stats, sa_run_curves = simulated_annealing.solve_with_sim_annealing( knapsack, "SA_Knapsack") sa_data_strings = { 'title': 'Simulated Annealing - Knapsack', 'Parameters': ['Temperature'], 'limit_time': 0.5, 'limit_iterations': 1500 } graphs.generate_graphs(sa_run_stats, sa_run_curves, sa_data_strings)
def main_20_items(): t_pct = 0.1 six_peaks = create_six_peeks_problem(20, 0.1) # Random Hillclimbing rhc_run_stats, rhc_run_curves = hillclimbing.solve_with_hillclimbing(six_peaks, "RHC_6P") rhc_data_strings = { 'title': 'RHC - 6 Peaks', 'Parameters': ['Restarts'], 'limit_time': 0, 'limit_iterations': 0 } graphs.generate_graphs(rhc_run_stats, rhc_run_curves, rhc_data_strings) # Mimic mimic_run_stats, mimic_run_curves = mimic.solve_with_mimic(six_peaks, "MIMIC_6P") mimic_data_strings = { 'title': 'MIMIC - 6 Peaks', 'Parameters': ['Population Size', 'Keep Percent'], 'limit_time': 10, 'limit_iterations': 100 } graphs.generate_graphs(mimic_run_stats, mimic_run_curves, mimic_data_strings) # Solve with Genetic Algorithm ga_run_stats, ga_run_curves = genetic_algorithm.solve_with_ga(six_peaks, "GA_6P") ga_data_strings = { 'title': 'Genetic Algorithms - 6 Peaks', 'Parameters': ['Mutation Rate', 'Population Size'], 'limit_time': 0.35, 'limit_iterations': 100 } graphs.generate_graphs(ga_run_stats, ga_run_curves, ga_data_strings) # Simulated Annealing sa_run_stats, sa_run_curves = simulated_annealing.solve_with_sim_annealing(six_peaks, "SA_6P") sa_data_strings = { 'title': 'Simulated Annealing - 6 Peaks', 'Parameters': ['Temperature'], 'limit_time': 0.3, 'limit_iterations': 1500 } graphs.generate_graphs(sa_run_stats, sa_run_curves, sa_data_strings)