def test_deterministic_scheduler_with_one_conflict(self):

        Config.params["scheduler"]["name"] = "deterministic_scheduler"

        # Create mock objects, then schedule it
        simulation = self.SimulationMock(
            self.a1, self.a3, self.g1, self.g2, self.s1, self.runway_start)
        scheduler = get_scheduler()
        schedule = scheduler.schedule(simulation)

        self.assertEqual(len(schedule.itineraries), 2)

        # a3 has an early departure time, so it goes first
        self.assertTrue(self.a1 in schedule.itineraries)
        self.assertTrue(self.a3 in schedule.itineraries)

        # Gets itineraries
        iti1 = schedule.itineraries[self.a1]
        iti2 = schedule.itineraries[self.a3]

        self.assertEqual(iti1.targets[0], self.g1)
        self.assertEqual(iti1.targets[1], self.s1)
        self.assertEqual(iti1.targets[2], self.runway_start)

        self.assertEqual(iti2.targets[0], self.g2)
        self.assertEqual(iti2.targets[1], self.g2)
        self.assertEqual(iti2.targets[2], self.s1)
        self.assertEqual(iti2.targets[3], self.runway_start)
    def test_deterministic_scheduler_with_one_unsolvable_conflict(self):

        # Sets two aircraft standing at the same node
        self.a4.location = self.s1
        self.a5.location = self.s1

        # Create mock objects, then schedule it
        simulation = self.SimulationMock(
            self.a4, self.a5, self.g1, self.g2, self.s1, self.runway_start)
        scheduler = get_scheduler()
        schedule = scheduler.schedule(simulation)

        self.assertEqual(len(schedule.itineraries), 2)

        # a3 has an early departure time, so it goes first
        self.assertTrue(self.a4 in schedule.itineraries)
        self.assertTrue(self.a5 in schedule.itineraries)

        # Gets itineraries
        iti1 = schedule.itineraries[self.a4]
        iti2 = schedule.itineraries[self.a5]

        self.assertEqual(schedule.n_unsolvable_conflicts, 0)

        self.assertEqual(iti1.targets[0], self.s1)
        self.assertEqual(iti1.targets[1], self.runway_start)

        self.assertEqual(iti2.targets[0], self.s1)
        self.assertEqual(iti2.targets[1], self.s1)
        self.assertEqual(iti2.targets[2], self.runway_start)
Example #3
0
    def test_naive_scheduler(self):
        Config.params["scheduler"]["name"] = "naive_scheduler"
        a1 = Aircraft("A1", None, self.g1, State.stop)
        a3 = Aircraft("A3", None, self.g2, State.stop)

        # Create mock objects, then schedule it
        simulation = self.SimulationMock(
            a1, a3, self.g1, self.g2, self.s1, self.runway_start)
        scheduler = get_scheduler()
        schedule, priority = scheduler.schedule(simulation)

        self.assertEqual(len(schedule.itineraries), 2)

        # a1 has an early departure time, so it goes first
        self.assertTrue(self.a1 in schedule.itineraries)
        self.assertTrue(self.a3 in schedule.itineraries)

        # Gets itineraries
        iti1 = schedule.itineraries[self.a1]
        iti2 = schedule.itineraries[self.a3]

        self.assertEqual(iti1.targets[1].nodes[0], self.g1)
        self.assertEqual(iti1.targets[1].nodes[1], self.s1)
        self.assertEqual(iti1.targets[2].nodes[0], self.s1)
        self.assertEqual(iti1.targets[2].nodes[1], self.runway_start)

        self.assertEqual(iti2.targets[1].nodes[0], self.g2)
        self.assertEqual(iti2.targets[1].nodes[1], self.s1)
        self.assertEqual(iti2.targets[2].nodes[0], self.s1)
        self.assertEqual(iti2.targets[2].nodes[1], self.runway_start)