Exemplo n.º 1
0
polyline_ll = np.array(json.loads(pd.read_csv(test_route_data_path)['POLYLINE'][0]))
# Convert to utm
polyline = bmm.long_lat_to_utm(polyline_ll, graph)

save_dir = porto_sim_dir + '/tv_output/'

# Create save_dir if not found
if not os.path.exists(save_dir):
    os.makedirs(save_dir)

# Save simulation parameters
with open(save_dir + 'setup_dict', 'w+') as f:
    json.dump(setup_dict, f)

# Setup map-matching model
mm_model = bmm.ExponentialMapMatchingModel()
mm_model.max_speed = max_speed

# Run FFBSi
ffbsi_route = bmm.offline_map_match(graph,
                                    polyline,
                                    ffbsi_n_samps,
                                    timestamps=timestamps,
                                    mm_model=mm_model,
                                    max_rejections=max_rejections,
                                    initial_d_truncate=initial_truncation,
                                    **proposal_dict)
utils.clear_cache()

fl_pf_routes = np.empty((num_repeats, len(fl_n_samps), len(lags)), dtype=object)
fl_bsi_routes = np.empty((num_repeats, len(fl_n_samps), len(lags)), dtype=object)
Exemplo n.º 2
0
import bmm

np.random.seed(0)

# Load cam_graph
graph_path = os.getcwd() + '/cambridge_projected_simple.graphml'

if not os.path.exists(graph_path):
    download_cambridge_graph(graph_path)

# Load networkx cam_graph
cam_graph = load_graph(graph_path)

timestamps = 15

gen_model = bmm.ExponentialMapMatchingModel()
gen_model.distance_params['zero_dist_prob_neg_exponent'] = -np.log(0.10) / timestamps
gen_model.distance_params['lambda_speed'] = 0.05
gen_model.deviation_beta = 0.05
gen_model.gps_sd = 3.0
gen_model.max_speed = 50

num_inter_cut_off = None
num_pos_routes_cap = 500

# Generate simulated routes
num_routes = 20
min_route_length = 40
max_route_length = 50
sample_d_refine = 1
n_iter = 200