def test_evaluate(self):
        node_profile = NodeProfileMultiObjective(dep_times=[3, 1], label_class=LabelTime)

        node_profile.update([LabelTime(departure_time=3, arrival_time_target=4)])
        self.assertEquals(4, min_arrival_time_target(node_profile.evaluate(3)))

        node_profile.update([LabelTime(departure_time=1, arrival_time_target=1)])
        self.assertEquals(1, min_arrival_time_target(node_profile.evaluate(1)))
Exemplo n.º 2
0
 def test_pareto_optimality(self):
     event_list_raw_data = [(0, 2, 0, 10, "trip_1", 1),
                            (0, 1, 2, 5, "trip_2", 1),
                            (1, 2, 5, 8, "trip_3", 1)]
     transit_connections = list(
         map(lambda el: Connection(*el), event_list_raw_data))
     walk_speed = 2
     source_stop = 0
     target_stop = 2
     transfer_margin = 0
     start_time = 0
     end_time = 20
     walk_network = networkx.Graph()
     csa_profile = MultiObjectivePseudoCSAProfiler(transit_connections,
                                                   target_stop, start_time,
                                                   end_time,
                                                   transfer_margin,
                                                   walk_network, walk_speed)
     csa_profile.run()
     source_profile = csa_profile.stop_profiles[source_stop]
     self.assertEqual(
         min_arrival_time_target(source_profile.evaluate(0, 0)), 8)
     found_labels = source_profile.get_final_optimal_labels()
     labels_should_be = list()
     labels_should_be.append(
         LabelTimeWithBoardingsCount(0,
                                     10,
                                     n_boardings=1,
                                     first_leg_is_walk=False))
     labels_should_be.append(
         LabelTimeWithBoardingsCount(2,
                                     8,
                                     n_boardings=2,
                                     first_leg_is_walk=False))
     self._assert_label_sets_equal(found_labels, labels_should_be)
Exemplo n.º 3
0
    def test_walk_is_faster_than_by_trip(self):
        event_list_raw_data = [(0, 1, 0, 10, "trip_1", 1)]
        transit_connections = list(
            map(lambda el: Connection(*el), event_list_raw_data))
        walk_speed = 0.5
        source_stop = 0
        target_stop = 1
        transfer_margin = 0
        start_time = 0
        end_time = 50

        walk_network = networkx.Graph()
        walk_network.add_edge(0, 1, d_walk=1)
        csa_profile = MultiObjectivePseudoCSAProfiler(transit_connections,
                                                      target_stop, start_time,
                                                      end_time,
                                                      transfer_margin,
                                                      walk_network, walk_speed)
        csa_profile.run()
        source_profile = csa_profile.stop_profiles[source_stop]
        self.assertEqual(
            min_arrival_time_target(
                source_profile.evaluate(0, first_leg_can_be_walk=True)), 2)
        found_tuples = source_profile.get_final_optimal_labels()
        self.assertEqual(len(found_tuples), 0)
Exemplo n.º 4
0
    def test_target_node_not_in_walk_network(self):
        event_list_raw_data = [(0, 1, 0, 10, "trip_1", 1)]
        transit_connections = list(
            map(lambda el: Connection(*el), event_list_raw_data))
        walk_speed = 2
        source_stop = 0
        target_stop = 1
        transfer_margin = 0
        start_time = 0
        end_time = 50

        walk_network = networkx.Graph()
        csa_profile = MultiObjectivePseudoCSAProfiler(transit_connections,
                                                      target_stop, start_time,
                                                      end_time,
                                                      transfer_margin,
                                                      walk_network, walk_speed)
        csa_profile.run()
        source_profile = csa_profile.stop_profiles[source_stop]
        self.assertEqual(
            min_arrival_time_target(source_profile.evaluate(0, 0)), 10)
        found_tuples = source_profile.get_final_optimal_labels()
        self.assertEqual(len(found_tuples), 1)
 def test_identity_profile(self):
     identity_profile = NodeProfileMultiObjective(dep_times=[10])
     identity_profile.update([LabelTimeWithBoardingsCount(10, 10, 0, True)])
     self.assertEqual(10, min_arrival_time_target(identity_profile.evaluate(10, first_leg_can_be_walk=True)))