AnthonyCxx / comfort-airlines

High Point University 2024 Senior Software Engineering Project
2 stars 0 forks source link

Write `scheduler.py` module #35

Open Dhud6 opened 4 months ago

Dhud6 commented 4 months ago

Description

Write the singletons/scheduler.py module. The module should only contain a static Scheduler class.

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:

  1. The source airport of the route must be the current location of the aircraft
  2. The aircraft type of the route must be the type of the aircraft
  3. The fuel requirement of the route must be less than or equal to the fuel capacity of the aircraft.
  4. There must be at least 1 passenger at the aircraft's current location that wants to take that route
  5. If the aircraft needs maintenance, the destination airport of the route must be a hub

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:

Dhud6 commented 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.