This project addresses the complex 3D packing problem for loading packages into Unit Load Devices (ULDs) for flights. The solution prioritizes efficient utilization of ULDs, adherence to weight and volume constraints, and optimization of cost. The algorithm ensures priority packages are always packed while maintaining high packing efficiency and minimizing costs.
Key outputs of the program include:
- Packing Decisions: Specifies which package is packed in which ULD, along with orientation and coordinates.
- Performance Metrics: Reports costs, packing efficiency, and other relevant statistics.
- Visualization: Generates:
- A graph illustrating the relationship between cost optimization and volume optimization.
- A 3D visualization of each ULD with its packed packages.
- Greedy Algorithm with Heuristics: Uses sorting, permutation, and multi-threading to achieve optimal packing and cost minimization.
- Priority Handling: Ensures all priority packages are packed, leaving economy packages optional.
- Cost Optimization: Balances cost and volume considerations to achieve minimum total cost.
- Parallel Processing: Utilizes multi-core processing for improved performance.
- Visualization:
- Cost vs. Optimization graph.
- 3D visual representation of packing inside each ULD.
- Detailed Outputs:
output.txt
: Packing assignments and details.costs.txt
: Packing cost metrics.data.png
: Cost vs. optimization graph.- Animated or static 3D views of ULDs with packages.
- Clone this repository.
- Ensure you have Python 3.8 or higher installed.
- Install required dependencies:
pip install matplotlib rectpack
-
Prepare the input file (
input.txt
) containing ULD and package details. The format should be as follows:<cost of splitting priority packages> <number of ULDs> <ULD_ID>,<length>,<width>,<height>,<weight_limit> ... <number of packages> <package_ID>,<length>,<width>,<height>,<weight>,<type>,<cost> ...
-
Run the main script:
python FedEx.py
-
Generate visualizations:
- Cost vs. optimization graph is generated automatically and saved as
data.png
. - To visualize ULDs with packages in 3D, run:
python visualize.py
- Cost vs. optimization graph is generated automatically and saved as
-
Outputs will be generated:
output.txt
: Packing details (package assignments, ULD coordinates, etc.).costs.txt
: Costs for each iteration of optimization.data.png
: Graph showing cost vs. optimization.- 3D visualizations of ULDs with packages.
-
GPU Usage
- If you are running on a GPU, the threading code may require adjustments depending on the specific library used (e.g., CUDA or OpenCL). You may need to modify the threading parts of the code to ensure the parallel computation can efficiently utilize the GPU's capabilities. This might involve switching from CPU-based multiprocessing to GPU-accelerated frameworks such as TensorFlow, PyTorch, or similar.
- By default, the code assumes a CPU-based environment unless otherwise configured. If using GPU, ensure that the proper libraries (such as cuPy for NumPy-compatible GPU arrays) are installed, and adjust the threading configuration as needed for maximum performance.
Lists the ULD each package is assigned to, with orientation and coordinates.
Example:
P-1,U1,0,0,0,20,15,10
P-2,U3,0,0,10,10,10,20
...
Includes metrics such as:
- Cost: Total minimized cost for each iteration.
- Cost vs. Optimization Data: Correlation between optimization parameters and packing cost.
Example:
1: 1600
2: 1500
3: 1550
...
Graph illustrating the relationship between cost and optimization. The minimum cost is highlighted.
3D visualizations of packages inside ULDs are rendered. Each ULD shows the placement of priority and economy packages, with priority packages visually distinct (black).
- Input Parsing: Reads and parses input data for ULDs and packages.
- Package Sorting:
- Priority and economy packages sorted by dimensions and cost/volume ratio.
- Greedy Packing:
- Iterates through ULD permutations.
- Packs priority packages first, followed by economy packages.
- Fixes weight constraints and optimizes voids.
- Multi-threading:
- Divides the workload across available CPU threads for faster execution.
- Visualization:
- Generates a cost vs. optimization graph using
plotter.py
. - Creates 3D representations of ULDs and packages using
visualize.py
.
- Generates a cost vs. optimization graph using
Each ULD is displayed with packed packages. Priority packages are shown in black, while economy packages are color-coded.
This project utilizes:
- RectPack for 2D rectangle packing.
- Matplotlib for visualizing results.