def generate_rectangle_sets(fname, r, p, q, max_side_length): trajectories = paths.read_dong_csv("/uusoc/scratch/raven4/dongx/trajectory_paper_code/data/samples/{}.tsv".format(fname)) disc = utils.disc_to_func("disc") while True: red, blue, planted_reg, _ = pyscan.plant_full_square(trajectories, r, p, q, disc) print(planted_reg.upX() - planted_reg.lowX(), max_side_length) if planted_reg.upX() - planted_reg.lowX() < max_side_length: break return red, blue
def generate_disk_sets(fname, r, p, q, min_r, max_r): disc = utils.disc_to_func("disc") trajectories = paths.read_dong_csv("/uusoc/scratch/raven1/dongx/trajectory_paper_code/data/samples/{}.tsv".format(fname)) while True: red, blue, planted_reg , planted_mx = pyscan.plant_full_disk(trajectories, r, p, q, disc) print(min_r, planted_reg.get_radius(), max_r) if min_r < planted_reg.get_radius() < max_r: break return red, blue
"s": s, "time": end_time - start_time, "m_disc_approx": mx, "m_disc": actual_mx } writer.writerow(row) f.flush() print(row) if max_time is not None and end_time - start_time > max_time: return if __name__ == "__main__": #trajectories = paths.read_geolife_files(10000) trajectories = paths.read_dong_csv( "/data/Dong_sets/Trajectory_Sets/samples/osm_eu_sample_100k_nw.tsv") st_pts, end_pts = pyscan.trajectories_to_flux(trajectories) st_pts = [ pyscan.WPoint(1.0, float(p[0]), float(p[1]), 1.0) for p in st_pts ] end_pts = [ pyscan.WPoint(1.0, float(p[0]), float(p[1]), 1.0) for p in end_pts ] r = .01 q = .8 eps_r = .01 for region_name in ["halfplane", "disk"]: scan_f = utils.range_to_func(region_name) print("Started planting")
chord_l = math.sqrt(4 * alpha * i - 2 * alpha * alpha) sample = [pyscan.grid_direc_kernel(pyscan.dp_compress(traj, alpha), chord_l, alpha) for traj in trajectories] print("Grid Direc Error {} {}".format(50 * i, 50 * post_process_error(test_disk_error(trajectories, sample, alpha, max_r)))) sample = [pyscan.grid_kernel(pyscan.dp_compress(traj, alpha), alpha) for traj in trajectories] print("Grid : {}".format(50 * post_process_error(test_disk_error(trajectories, sample, alpha, max_r)))) sample = [pyscan.halfplane_kernel(pyscan.dp_compress(traj, alpha), alpha) for traj in trajectories] print("Halfplane : {}".format(50 * post_process_error(test_disk_error(trajectories, sample, alpha, max_r)))) sample = [pyscan.dp_compress(traj, alpha) for traj in trajectories] print("DP Error: {}".format(50 * post_process_error(test_disk_error(trajectories, sample, alpha, max_r)))) #trajectories = paths.read_geolife_files(1000) trajectories = paths.read_dong_csv("/data/Dong_sets/Trajectory_Sets/samples/osm_eu_sample_10k_nw.tsv", filter_long=True) #trajectories = clean(trajectories) #print(len(trajectories)) #plot_plane_full_trajectories(trajectories, .25, 1.0, 0.0) r=.02 p =.5 q= 1.0 eps_r=.01 plot_trajectory_set(trajectories, 10000) #plot_full_trajectories_intersection_rect(trajectories, r) # OSM EU 1/30000, 1/300 # BJTAXI 1/500 1/5 #testing(trajectories, 1/30000, 1/300)
def generate_halfplane_sets(fname, r, p, q): disc = utils.disc_to_func("disc") trajectories = paths.read_dong_csv("/uusoc/scratch/raven1/dongx/trajectory_paper_code/data/samples/{}.tsv".format(fname)) red, blue, planted_reg, planted_mx = pyscan.plant_full_halfplane(trajectories, r, p, q, disc) return red, blue
import flux_testing import paths import utils import pyscan import file if __name__ == "__main__": #trajectories = paths.read_geolife_files(100) trajectories = paths.read_dong_csv(file.PATH + "bjtaxi_samples_100k_nw.tsv") st_pts, end_pts = pyscan.trajectories_to_flux(trajectories) st_pts = [ pyscan.WPoint(1.0, float(p[0]), float(p[1]), 1.0) for p in st_pts ] end_pts = [ pyscan.WPoint(1.0, float(p[0]), float(p[1]), 1.0) for p in end_pts ] r = .01 q = .2 p = .5 eps_r = .001 disc = utils.disc_to_func("disc") #red, blue, _, _ = pyscan.plant_partial_disk(trajectories, r, p, q, eps_r, disc) for region_name in ["disk"]: #, "rectangle", "disk"]: if region_name == "disk": method = pyscan.plant_disk elif region_name == "rectangle":