How marco144803025/crew-scheduling-set-partitioning-problem works
Project Type and Purpose
• This is an open‐source, command‐line Python tool for solving the airline crew scheduling (set‐partitioning) problem using three metaheuristic algorithms: Simulated Annealing (SA), a standard binary Genetic Algorithm (BGA), and an improved BGA.
• Its primary function is to load a flight‐crew dataset, run the chosen algorithm, track cost and constraint satisfaction over iterations, generate evolution plots, and write detailed results to text files.
Top‐Level Architectural Components
a. CLI Layer
• argparse‐based parser
• Accepts flags: --algorithm, --dataset
b. Data Layer
• Dataset loader reads sppnw*.txt files
• Preprocesses into in‐memory data structures (flight list, crew pairing matrix)
c. Algorithm Orchestrator
• Dispatcher that picks SA, BGA, or improved BGA
• Common interfaces: initialize_solution(), evaluate_fitness(), record_iteration()
d. Metaheuristic Modules
• SA Module
– Temperature schedule, neighbor generator (bit flips), acceptance criterion
• Standard BGA Module
– Population initializer, tournament selection, crossover, mutation
• Improved BGA Module
– Pseudo‐random initialization, stochastic ranking constraint handler, heuristic improvement operator
e. Utilities
• Cost & coverage calculation routines
• Constraint checkers (ensure each flight covered exactly once)
• Random number services (random, numpy.random)
• Parallel evaluation (concurrent.futures)
f. Output Layer
• Plot generator (matplotlib) for cost history
• File writer for detailed results (airline_crew_scheduling.py writes to output folder)
Relationships and Data Flow
• User invokes CLI → CLI Layer parses inputs → Data Layer loads dataset
• CLI Layer calls Algorithm Orchestrator with dataset & algorithm choice
• Orchestrator dispatches to the selected Metaheuristic Module
→ calls initialize_solution(), then for each iteration:
– Module calls Utility routines for cost & coverage
– Module updates best solution & logs metrics
• At completion, Orchestrator calls Output Layer:
– Plot generator consumes logged metrics → produces PNG/figure
– File writer dumps solution & cost history to text files
Architectural Patterns & Design Principles
• Modular design: separate Algorithm modules implementing a common interface
• Single Responsibility: each layer (CLI, Data, Algorithms, Output) has a distinct role
• Open‐Closed: new algorithms can be plugged in by conforming to the orchestrator interface
• Reuse: shared utilities for cost evaluation, constraint checking, file I/O, plotting