# Path: gtfspy/routing/connection.py
# class Connection:
# 
#     WALK_SEQ = -1
#     WALK_TRIP_ID = -1
# 
#     def __init__(self, departure_stop, arrival_stop, departure_time, arrival_time, trip_id, seq,
#                  is_walk=False, arrival_stop_next_departure_time=float('inf')):
#         self.departure_stop = departure_stop
#         self.arrival_stop = arrival_stop
#         self.departure_time = departure_time
#         self.arrival_time = arrival_time
#         self.trip_id = trip_id
#         self.is_walk = is_walk
#         self.seq = int(seq)
#         self.arrival_stop_next_departure_time = arrival_stop_next_departure_time
# 
#     def duration(self):
#         return self.arrival_time - self.departure_time
# 
#     def __str__(self):
#         return pformat(self.__dict__)
# 
#     def __eq__(self, other):
#         return self.__dict__ == other.__dict__
# 
#     def __repr__(self):
#         return '<%s:%s:%s:%s:%s:%s:%s:%s>' % (
#             self.__class__.__name__, self.departure_stop, self.arrival_stop,
#             self.departure_time, self.arrival_time, self.trip_id, self.is_walk, self.arrival_stop_next_departure_time)
# 
#     def __hash__(self):
#         return hash(self.__repr__())


import numpy
from gtfspy.routing.label import LabelTimeWithBoardingsCount, merge_pareto_frontiers, compute_pareto_front, \
    LabelVehLegCount, LabelTime, LabelTimeBoardingsAndRoute, LabelTimeAndRoute
from gtfspy.routing.connection import Connection
        self._closed = True

    def _compute_real_connection_labels(self):
        pareto_optimal_labels = []
        # do not take those bags with first event is a pseudo-connection
        for dep_time in self._connection_dep_times:
            index = self.dep_times_to_index[dep_time]
            pareto_optimal_labels.extend([label for label in self._label_bags[index] if not label.first_leg_is_walk])
        if self.label_class == LabelTimeWithBoardingsCount or self.label_class == LabelTime \
                or self.label_class == LabelTimeBoardingsAndRoute:
            pareto_optimal_labels = [label for label in pareto_optimal_labels
                                     if label.duration() < self._walk_to_target_duration]

        if self.label_class == LabelVehLegCount and self._walk_to_target_duration < float('inf'):
            pareto_optimal_labels.append(LabelVehLegCount(0))
        self._real_connection_labels = [label.get_copy() for label in compute_pareto_front(pareto_optimal_labels,
                                                                                           finalization=True)]

    def _compute_final_pareto_optimal_labels(self, neighbor_label_bags, walk_durations, departure_arrival_stops):
        labels_from_neighbors = []
        for i, (label_bag, walk_duration)in enumerate(zip(neighbor_label_bags, walk_durations)):
            for label in label_bag:
                if self.label_class == LabelTimeBoardingsAndRoute or self.label_class == LabelTimeAndRoute:
                    departure_arrival_tuple = departure_arrival_stops[i]
                    departure_time = label.departure_time - walk_duration
                    arrival_time = label.departure_time
                    connection = Connection(departure_arrival_tuple[0],
                                            departure_arrival_tuple[1],
                                            departure_time,
                                            arrival_time,

# Path: gtfspy/routing/connection.py
# class Connection:
# 
#     WALK_SEQ = -1
#     WALK_TRIP_ID = -1
# 
#     def __init__(self, departure_stop, arrival_stop, departure_time, arrival_time, trip_id, seq,
#                  is_walk=False, arrival_stop_next_departure_time=float('inf')):
#         self.departure_stop = departure_stop
#         self.arrival_stop = arrival_stop
#         self.departure_time = departure_time
#         self.arrival_time = arrival_time
#         self.trip_id = trip_id
#         self.is_walk = is_walk
#         self.seq = int(seq)
#         self.arrival_stop_next_departure_time = arrival_stop_next_departure_time
# 
#     def duration(self):
#         return self.arrival_time - self.departure_time
# 
#     def __str__(self):
#         return pformat(self.__dict__)
# 
#     def __eq__(self, other):
#         return self.__dict__ == other.__dict__
# 
#     def __repr__(self):
#         return '<%s:%s:%s:%s:%s:%s:%s:%s>' % (
#             self.__class__.__name__, self.departure_stop, self.arrival_stop,
#             self.departure_time, self.arrival_time, self.trip_id, self.is_walk, self.arrival_stop_next_departure_time)
# 
#     def __hash__(self):
#         return hash(self.__repr__())


# Path: gtfspy/routing/node_profile_multiobjective.py
import numpy
from gtfspy.routing.label import LabelTimeWithBoardingsCount, merge_pareto_frontiers, compute_pareto_front, \
    LabelVehLegCount, LabelTime, LabelTimeBoardingsAndRoute, LabelTimeAndRoute
from gtfspy.routing.connection import Connection

        self._closed = True

    def _compute_real_connection_labels(self):
        pareto_optimal_labels = []
        # do not take those bags with first event is a pseudo-connection
        for dep_time in self._connection_dep_times:
            index = self.dep_times_to_index[dep_time]
            pareto_optimal_labels.extend([label for label in self._label_bags[index] if not label.first_leg_is_walk])
        if self.label_class == LabelTimeWithBoardingsCount or self.label_class == LabelTime \
                or self.label_class == LabelTimeBoardingsAndRoute:
            pareto_optimal_labels = [label for label in pareto_optimal_labels
                                     if label.duration() < self._walk_to_target_duration]

        if self.label_class == LabelVehLegCount and self._walk_to_target_duration < float('inf'):
            pareto_optimal_labels.append(LabelVehLegCount(0))
        self._real_connection_labels = [label.get_copy() for label in compute_pareto_front(pareto_optimal_labels,
                                                                                           finalization=True)]

    def _compute_final_pareto_optimal_labels(self, neighbor_label_bags, walk_durations, departure_arrival_stops):
        labels_from_neighbors = []
        for i, (label_bag, walk_duration)in enumerate(zip(neighbor_label_bags, walk_durations)):
            for label in label_bag:
                if self.label_class == LabelTimeBoardingsAndRoute or self.label_class == LabelTimeAndRoute:
                    departure_arrival_tuple = departure_arrival_stops[i]
                    departure_time = label.departure_time - walk_duration
                    arrival_time = label.departure_time
                    connection = Connection(departure_arrival_tuple[0],
                                            departure_arrival_tuple[1],
                                            departure_time,
                                            arrival_time,

                                            Connection.WALK_TRIP_ID,