Python and Bash Integration: Orchestrating the Solver
While Rave handles the domain-specific business logic, an airline's optimization ecosystem requires heavy orchestration. You cannot simply double-click an .exe to run a massive crew pairing optimization. It requires staging data, configuring parameters, dispatching solver processes, and aggregating results.
This orchestration is predominantly handled using Python and Bash/Linux scripting.
1. The Orchestration Pipeline
The typical workflow for an optimization run spans several stages, managed by shell scripts and Python glue code:
sequenceDiagram
participant Bash as Bash Script (Cron/Airflow)
participant Py as Python Pre-Processor
participant Solver as CARMEN Optimizer
participant Post as Python Post-Processor
Bash->>Py: Trigger run & pass arguments
Py->>Py: Fetch flight data & format XML
Py->>Solver: Launch solver binary with configs
Solver->>Solver: Evaluate search space using Rave rules
Solver-->>Py: Output pairing results
Py->>Post: Parse results, calculate KPIs
Post-->>Bash: Save final reports to DB
2. Using Python for Data Marshalling
Because Rave rules depend on external input data supplied by the application running the Rave code, Python is frequently used to transform upstream airline data (from legacy mainframes or modern APIs) into the exact formats the CARMEN optimizer expects.
Python scripts will typically:
- Parse flight timetables.
- Set bounded parameters for the Rave rules (e.g., dynamically adjusting maximum duty times for a specific "what-if" scenario run).
- Handle solver callbacks.
3. Using Bash for Execution
Optimization runs can take hours or even days, often running on massive computing clusters. Bash scripts are essential for resource management, setting environment variables, and invoking the solver binaries.
-
Environment Setup: Setting library paths to ensure the optimizer finds the compiled Rave dynamic link library.
-
Parallel Execution: Spawning multiple solver instances to explore different parameter configurations simultaneously.