def main() : timer = TimeStat() pntStater = PointStat() pnt_nums = PNT_NUM_LIST logging_format = "{method_name}-{pnt_num} done ." for pnt_num in pnt_nums : pnts = generate_pnts_in_random(pnt_num , is_static_random=False) pntStater.add_stat_pnts(pnts) timer.add_stat_pnt_num(pnt_num) # brute force method_name = "brute force" timer.start_time_stat() convex_hull_pnts = find_convex_hull_bruteforce(pnts) #print convex_hull_pnts plot_pnts = ready_plot_pnts_bruteforce(convex_hull_pnts) timer.end_time_stat() timer.add_stat_brute_force_timecost(timer.get_time_cost()) pntStater.add_stat_bruteforce_convex_hull(plot_pnts) logging.info(logging_format.format(**locals()) ) # graham scan method_name = "gramham scan" timer.start_time_stat() convex_hull_pnts = find_convex_hull_grahamscan(pnts) plot_pnts = ready_plot_pnts_grahamscan(convex_hull_pnts) timer.end_time_stat() timer.add_stat_graham_scan_timecost(timer.get_time_cost()) pntStater.add_stat_graham_convex_hull(plot_pnts) logging.info(logging_format.format(**locals()) ) # divide conquer method_name = "divide conquer" timer.start_time_stat() convex_hull_pnts = find_convex_hull_dc(pnts) plot_pnts = ready_plot_pnts_dc(convex_hull_pnts) timer.end_time_stat() timer.add_stat_dc_timecost(timer.get_time_cost()) pntStater.add_stat_dc_convex_hull(plot_pnts) logging.info(logging_format.format(**locals()) ) timer.print_time_cost() pntStater.draw_stat(convex_hull_pnt_plot_config) timer.draw_stat() plot.show()
def main(): timer = TimeStat() pntStater = PointStat() pnt_nums = PNT_NUM_LIST logging_format = "{method_name}-{pnt_num} done ." for pnt_num in pnt_nums: pnts = generate_pnts_in_random(pnt_num, is_static_random=False) pntStater.add_stat_pnts(pnts) timer.add_stat_pnt_num(pnt_num) # brute force method_name = "brute force" timer.start_time_stat() convex_hull_pnts = find_convex_hull_bruteforce(pnts) #print convex_hull_pnts plot_pnts = ready_plot_pnts_bruteforce(convex_hull_pnts) timer.end_time_stat() timer.add_stat_brute_force_timecost(timer.get_time_cost()) pntStater.add_stat_bruteforce_convex_hull(plot_pnts) logging.info(logging_format.format(**locals())) # graham scan method_name = "gramham scan" timer.start_time_stat() convex_hull_pnts = find_convex_hull_grahamscan(pnts) plot_pnts = ready_plot_pnts_grahamscan(convex_hull_pnts) timer.end_time_stat() timer.add_stat_graham_scan_timecost(timer.get_time_cost()) pntStater.add_stat_graham_convex_hull(plot_pnts) logging.info(logging_format.format(**locals())) # divide conquer method_name = "divide conquer" timer.start_time_stat() convex_hull_pnts = find_convex_hull_dc(pnts) plot_pnts = ready_plot_pnts_dc(convex_hull_pnts) timer.end_time_stat() timer.add_stat_dc_timecost(timer.get_time_cost()) pntStater.add_stat_dc_convex_hull(plot_pnts) logging.info(logging_format.format(**locals())) timer.print_time_cost() pntStater.draw_stat(convex_hull_pnt_plot_config) timer.draw_stat() plot.show()
def ready_plot_pnts_dc(dc_convex_hull_pnts): ''' Just use graham scan result ! ''' return ready_plot_pnts_grahamscan(dc_convex_hull_pnts)
def ready_plot_pnts_dc(dc_convex_hull_pnts) : ''' Just use graham scan result ! ''' return ready_plot_pnts_grahamscan(dc_convex_hull_pnts)