playing with optimal flight crew numbers
This isn’t some fancy optimization engine you’d find in big shot crew management software, but it’s a sort of solid, back of the envelope method to get a mathematically optimal crew count for a given schedule. I’ve been tinkering with this to see how I can balance flights, rest, and duty hours without overcomplicating things. I have used this method quite successfully in some of the projects that I had worked on earlier, and will probably use this to get ball park figures when required.
Optimizing Crew for Flights
Imagine you’ve got a stack of flights: dates, departure times, arrival times, airports, and you need to figure out the smallest number of crews to cover them all. Each crew flies a plane, lands, rests, and hops back on another flight, but only if they’re in the right place with enough rest. My goal? Build a method that assigns crews efficiently, respects rest rules, and keeps duty hours in check. It’s rudimentary, sure, but for specific schedules, it’s a quick way to get a solid crew estimate.
Time, Duty, and Rest
Let’s break it down with some equations. First, flight duration, how long a crew’s in the air. For a flight leaving at and landing at on start date ( d ):
If (like 23:00 to 01:00), it crosses midnight, so:
This gives ( D ) in hours. That’s the Flight Duty Period (FDP), I kept it simple and made FDP equal to flight time, though real rules might tweak it. Next, rest periods. After landing, a crew needs downtime before their next flight. I set it as:
. They can only fly again if the next flight’s departure and starts where they landed. Total duty hours per crew can’t exceed a cap...say, 100 hours over 28 days (this is an actual FDP limit, flight time limitations for consecutive 28 day periods as per EASA and MCAR Air Ops). That’s:
The optimization problem? Minimize the number of crews ( C ) while covering all flights, subject to these constraints. It’s a scheduling puzzle, assign flights to the fewest crews possible without breaking rest or duty rules.
Two Approaches, One Goal
I tackled this two ways: a greedy scheduler and a linear programming (LP) solver. Both start with an Excel file (excel still rules in quick data organization) loaded into a pandas DataFrame with columns like start_date, dep_time, arr_time, departureairport, and destinationairport.
Greedy Scheduler
This is the quick-and-dirty method. I built a class to:
- Load and stretch a 7 day schedule into 28 days by repeating it four times, shifting dates with timedelta(days=7 * i).
- Sort flights by start date and departure time.
- Assign each flight to an available crew, or a new one if none fit.
For each flight:
- Calculate duration ( D ) with a flight duration calculator (basic arithematic operation).
- Check available crew sets (they need to be at the departure airport, rested) (time since last landing ), and under 100 hours total FDP.
- Pick the crew with the least duty hours if multiple are available; if none, add a new crew.
- Track each crew set's flights and duty.
The output? Minimum crew count and duty stat: min, max, average, and standard deviation .
Linear Programming
This one’s a bit more rigorous, using pulp. Setup:
- Define binary variables if crew ( c ) flies flight ( f ), 0 otherwise.
- Binary if crew ( c ) is used.
- Objective: Minimize
- Constraints:
- Each flight gets one crew:
- Link usage to assignments: (where ( n ) is flight count).
- Rest/location rule: If crew ( c ) flies ( f1 ) then ( f2 ), then and , enforced with if conditions fail.
Solve it, extract assignments, and tally FDPs per crew.
What Came Out
The greedy method spat out a minimum crew count, let’s call it and duty hours per crew. I ran it again with and to see how extra crews spread the load.
Stats showed:
- Min hours: Lowest FDP among crews.
- Max hours: Highest FDP.
- Average:
- Std Dev: Spread of hours, tighter with more crews.
The LP method gave the same (if the schedule’s tight) but guaranteed optimality, every flight covered, no overlaps, rest rules intact.
What I Learned
This method’s a solid starter kit. The greedy approach is fast and good for quick estimates when you’re sketching out a schedule. It’s not perfect, it might overshoot crew sets if it picks poorly early on. The LP version nails the minimum almost every time, balancing rest and location constraints. Neither matches the big optimization engines that juggle crew preferences, all regulatory constraints, costs, and more. But for a basic “how many do I need?” question, this works.
Pros? It’s simple, adaptable, tweak rest rules or FDP caps, and gives you a visual if you require them. Cons? No crew fatigue curves or multi-leg complexities, and also it does not address the multitude of constraints of aircrew FDP regulations. Next step, I’d slowly add the FDP regulatory constraints and prioritize things like home base returns. For now, it’s a practical plug-in tool, input flights, get your optimal minimum flight crew number, and adjust as needed.