Open Dhud6 opened 4 months ago
I uploaded the initial structure of scheduler.py
and test_scheduler.py
. The main function, schedule_flight()
, needs to be implemented. I wrote some comments as a guide for the function. The unit tests need to be updated, and more will need to be added.
Description
Write the
singletons/scheduler.py
module. The module should only contain a staticScheduler
class.structlog.get_logger()
Scheduling a Flight
1. Finding compatible routes
Scheduling a flight is one of the most complex parts of the algorithm. The function should take the following parameters: the simulation time, the aircraft to be scheduled, the list of ALL routes, and the list of ALL passengers. Then, filter the list of all routes to find the routes compatible with the aircraft. For a route to be "compatible", the following criteria must be met:
You could write this a single, complex condition, but I highly discourage it as it is difficult to write, understand, and maintain. I recommend write a filter() for each condition and then casting the final filter object to a list.
2. Selecting the Route
You should select the route with the maximum net profit. You can do this easily by using the built-in
max()
function and specifying the key is the net profit. Then, refuel if needed, set the status of the aircraft to boarding with or without refueling, set the flight object of the aircraft to the current flight, append the flight to the list of all scheduled flights,Testing
All tests should test for both legal and illegal values (to verify that the class works as intended and catches errors). If you find yourself repeating code across unit tests, consider abstracting the repeated code into a pytest fixture.
you should test: