예제 #1
0
def new_time_from_previous(time_between, start):
    sigma = int(time_between / 10)
    mu = 0
    mini = int(-time_between / 5)
    maxi = int(time_between / 2)
    delta = geo.gaussian_trunc(mini, maxi, mu, sigma)
    t = delta + time_between
    t = convert_to_tuple(t)
    new_time = add_times(start, t)
    return new_time
예제 #2
0
def generate_hubs():

    n_lines = geo.gaussian_trunc(n_lines_mini, n_lines_maxi, n_lines_mu,
                                 n_lines_sigma)

    lines = geo.generate_lines(n_lines, r_line_mu, r_line_sigma)
    intersections = geo.find_intersections(lines)
    outliers, clusters = geo.points_to_glue(intersections,
                                            intersection_sensitivity)
    glued_inter = geo.glue_inter(outliers, clusters, intersections)
    merged_lines = geo.merge_lines(lines, glued_inter)
    stations = geo.generate_stations(merged_lines, position_variance,
                                     av_dist_btw_stations)
    stations = geo.merge_stations(stations, glued_inter)

    outliers, clusters = geo.points_to_glue(stations,
                                            close_stations_sensitivity)
    glued_stations = geo.glue_stations(outliers, clusters, stations)
    filtered_stations = geo.remove_duplicate_lines(glued_stations)
    hubs = geo.compute_hubs(filtered_stations)
    return hubs, filtered_stations
예제 #3
0
def generate_transportation():
    # Global topology : lines
    n_lines = geo.gaussian_trunc(n_lines_mini, n_lines_maxi, n_lines_mu,
                                 n_lines_sigma)
    lines = geo.generate_lines(n_lines, r_line_mu, r_line_sigma)
    intersections = geo.find_intersections(lines)
    outliers, clusters = geo.points_to_glue(intersections,
                                            intersection_sensitivity)
    glued_inter = geo.glue_inter(outliers, clusters, intersections)
    merged_lines = geo.merge_lines(lines, glued_inter)

    # Local topology : stations
    stations = geo.generate_stations(merged_lines, position_variance,
                                     av_dist_btw_stations)
    stations = geo.merge_stations(stations, glued_inter)
    outliers, clusters = geo.points_to_glue(stations,
                                            close_stations_sensitivity)
    glued_stations = geo.glue_stations(outliers, clusters, stations)
    filtered_stations = geo.remove_duplicate_lines(glued_stations)
    hubs = geo.compute_hubs(filtered_stations)
    fast_lines = geo.build_fast_lines(hubs, r_line_mu, r_line_sigma,
                                      min_n_stations_per_fast_line, n_meters)
    n_fast_lines = len(fast_lines)
    updated_stations = geo.update_compatibilities(filtered_stations,
                                                  fast_lines)

    # Toponymy
    names = nm.generate_names(len(updated_stations))
    updated_stations = nm.add_names(names, updated_stations)
    lines_dict = sch.build_lines_dict(updated_stations)
    network = sch.build_Network(lines_dict, slow_speed, fast_speed)

    # Schedule and itineraries
    network = sch.compute_whole_schedule(network)
    stations = network.get_all_stations()
    graph = it.convert_Network_to_Graph(network)
    all_shortest_paths = it.all_shortest_paths_and_lengths(graph)
    xml.generate_xml(network)
    xml.generate_rdf(network)
    return network, stations, all_shortest_paths, hubs
예제 #4
0
def generate_departure_times(start):
    if is_less_or_equal(start, (7, 30, 0)):
        mu = 6 * 60
        sigma = 3 * 60
    else:
        if is_less_or_equal(start, (10, 0, 0)):
            mu = 2 * 60
            sigma = 30
        else:
            if is_less_or_equal(start, (18, 0, 0)):
                mu = 4 * 60
                sigma = 2 * 60
            else:
                if is_less_or_equal(start, (21, 0, 0)):
                    mu = 2 * 60
                    sigma = 60
                else:
                    mu = 6 * 60
                    sigma = 4 * 60
    delta = geo.gaussian_trunc(60, 600, mu, sigma)
    delta = convert_to_tuple(delta)
    new_start = add_times(delta, start)
    return new_start
예제 #5
0
    network = sch.build_Network(lines_dict, slow_speed, fast_speed)

    # Schedule and itineraries
    network = sch.compute_whole_schedule(network)
    stations = network.get_all_stations()
    graph = it.convert_Network_to_Graph(network)
    all_shortest_paths = it.all_shortest_paths_and_lengths(graph)
    xml.generate_xml(network)
    xml.generate_rdf(network)
    return network, stations, all_shortest_paths, hubs


if __name__ == "__main__":

    # Global topology : lines
    n_lines = geo.gaussian_trunc(n_lines_mini, n_lines_maxi, n_lines_mu,
                                 n_lines_sigma)
    lines = geo.generate_lines(n_lines, r_line_mu, r_line_sigma)
    dis.display_segments(lines, [], 'simple segments')
    intersections = geo.find_intersections(lines)
    dis.display_segments(lines, intersections,
                         'simple segments with intersections')
    outliers, clusters = geo.points_to_glue(intersections,
                                            intersection_sensitivity)
    glued_inter = geo.glue_inter(outliers, clusters, intersections)
    dis.display_segments(lines, glued_inter,
                         'simple segments with "glued" intersections')
    merged_lines = geo.merge_lines(lines, glued_inter)
    dis.display_network(merged_lines, glued_inter, [], [], [],
                        'lines crossing the intersections')

    # Local topology : stations