Ejemplo n.º 1
0
 def test_compute_pareto_front_smart_randomized(self):
     import random
     for i in range(10):
         labels = [LabelTimeWithBoardingsCount(random.randint(0, 1000), random.randint(0, 1000), random.randint(0, 10), 0)
                   for _ in range(1000)]
         pareto_optimal_labels_old = compute_pareto_front_naive(labels)
         pareto_optimal_labels_smart = compute_pareto_front(labels)
         self.assertEqual(len(pareto_optimal_labels_old), len(pareto_optimal_labels_smart))
Ejemplo n.º 2
0
 def get_final_optimal_labels(self):
     non_walk_valid_labels = []
     for label in self._labels:
         if label.duration() < self._walk_to_target_duration:
             non_walk_valid_labels.append(label)
     return [
         label.get_copy()
         for label in compute_pareto_front_naive(non_walk_valid_labels)
     ]
Ejemplo n.º 3
0
 def test_compute_pareto_front_smart(self):
     labels = []
     for n in [1, 2, 10]: #, 500]:
         for dep_time in range(0, n):
             for n_veh_legs in range(2):
                 for arr_time in range(dep_time, dep_time  + 10):
                     label = LabelTimeWithBoardingsCount(dep_time, arr_time - n_veh_legs, n_veh_legs, False)
                     labels.append(label)
         import random
         random.shuffle(labels)
         labels_copy = copy.deepcopy(labels)
         pareto_optimal_labels = compute_pareto_front_naive(labels)
         self.assertEqual(len(pareto_optimal_labels), n * 2)
         pareto_optimal_labels = compute_pareto_front(labels_copy)
         self.assertEqual(len(pareto_optimal_labels), n * 2)