--- license: mit language: - en tags: - cvrp - vehicle-routing - drone - attention-model - pomo - onnx - optimization library_name: onnx --- # Drone CVRP Neural Solver (Attention Model + POMO) ONNX-exported neural network for solving Capacitated Vehicle Routing Problems (CVRP) in drone delivery contexts. ## Architecture - **Encoder**: 6-layer Transformer with 8-head multi-head attention (128-dim embeddings, 512-dim FFN) - **Decoder**: Autoregressive pointer-network with glimpse mechanism (Kool et al. 2019) - **Input features**: 4D per node — x, y, z (altitude), demand - **Training**: REINFORCE with greedy rollout baseline, 1000 epochs on random CVRP-50 instances The model supports **dynamic batch and problem sizes** up to 200 nodes. ## ONNX Interface | Port | Name | Shape | Type | |------|------|-------|------| | Input | `locs` | `[batch, nodes, 3]` | float32 | | Input | `demand` | `[batch, nodes, 1]` | float32 | | Input | `capacity` | `[batch, 1]` | float32 | | Output | `actions` | `[batch, max_steps]` | int64 | | Output | `log_p` | `[batch, max_steps]` | float32 | The wrapper automatically prepends a depot at `(0.5, 0.5, 0.0)` with zero demand. Set `capacity` high (e.g. 999) for unconstrained TSP optimization, or use the trained value (40) for standard CVRP-50 benchmark routing. ## Training Recipe | Parameter | Value | |-----------|-------| | Problem size | 50 customers | | Batch size | 512–1024 | | Epochs | 500–1000 | | Learning rate | 1e-4 (cosine annealing) | | Warmup | 10 epochs | | Demand range | {1..9} | | Vehicle capacity | 40 | | Entropy bonus | 0.01 | ## Usage ```python import numpy as np import onnxruntime as ort session = ort.InferenceSession("cvrp50_model.onnx") locs = np.random.rand(1, 10, 3).astype(np.float32) demand = np.ones((1, 10, 1), dtype=np.float32) capacity = np.array([[999.0]], dtype=np.float32) actions, log_p = session.run(None, { "locs": locs, "demand": demand, "capacity": capacity, }) print(actions[0, :20]) ``` ## Demo Try it live in the [Drone VRP Space](https://aerialblancaservices-drone-vrp.hf.space) — side-by-side comparison with a nearest-neighbor heuristic, physics-based energy modeling, and interactive route visualization. ## References - Kool, van Hoof, Welling (2018). *Attention, Learn to Solve Routing Problems!* ([arXiv:1803.08475](https://arxiv.org/abs/1803.08475)) - Kwon et al. (2020). *POMO: Policy Optimization with Multiple Optima for Reinforcement Learning* ([arXiv:2010.16011](https://arxiv.org/abs/2010.16011)) - Dorling et al. (2017). *Vehicle Routing Problems for Drone Delivery* ([arXiv:1609.02906](https://arxiv.org/abs/1609.02906))