File size: 5,060 Bytes
8993164 d2dd262 8993164 b7d8b96 6889862 8993164 e4f69db 8993164 6889862 8993164 6889862 8993164 75eb8ff 8993164 03abde0 41ff10f 8993164 d41548e 8993164 e4f69db 8993164 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 | ---
license: mit
pretty_name: RouteOptimizer
datasets:
- albones80/route-optimizer-scenarios
tags:
- optimization
- operations-research
- mining
- fleet-dispatch
- milp
- pulp
- cbc
- routing
task_categories:
- other
---
# RouteOptimizer
<p align="center">
<img src="assets/demo-cli.gif" alt="RouteOptimizer CLI demo: scenario to dispatch and shift-plan JSON" width="100%"/>
</p>
<p align="center">
<img src="assets/demo-cli.png" alt="CLI in and dispatch.json out" width="100%"/>
</p>
This repository has two parts:
1. **Dispatch policy** — a small neural network in [`dispatch_policy/`](dispatch_policy/)
(13 → 16 → 8 → 1). It was trained to imitate the A\* solver’s choice among
legal dispatch actions on synthetic mines. On a held-out set it picks the
solver’s action about **91%** of the time (a demand-greedy baseline is about **56%**).
The checkpoint does not prove a plan is optimal.
2. **Operations-research solvers** — A\* dispatch and a PuLP/CBC shift plan, which
still produce the proven plans. Sample scenarios and the file format are included
so you can run those solvers offline.
There is no haul-history model and no claim that the network replaces the solver.
Rights: Alfonso Bonillas / [alioit.com](https://www.alioit.com/route-optimizer). License: **MIT**
([`LICENSE`](LICENSE)).
## Trained weights
| File | Role |
|------|------|
| [`dispatch_policy/weights.npz`](dispatch_policy/weights.npz) | NumPy checkpoint (layer matrices `W0`…`W2`, biases, feature mean/std) |
| [`dispatch_policy/config.json`](dispatch_policy/config.json) | Architecture, feature names, holdout accuracy |
```python
from route_optimizer.policy import load_policy
policy = load_policy() # packaged checkpoint, or pass a path to weights.npz
action = policy.choose(state) # highest-scoring legal action
```
Teacher: A\* on synthetic format-v1 scenarios. License: MIT.
## What it does
- **Dispatch policy** — ranks the legal moves at a fleet state.
- **Dispatch (A\*)** — builds a truck movement plan over a shift horizon from a
scenario file.
- **Shift plan (MILP)** — solves a mine-wide truck-flow plan with **PuLP + CBC**
(open-source; no commercial solver license).
Both tools read local JSON scenarios and write JSON results. They do **not** call
SQL Server or the network at run time.
## What it does not do
- It does **not** train or serve ML models.
- It does **not** include production haul databases or live telematics.
- It does **not** require Gurobi, CPLEX, or other commercial solvers.
- A second anonymized haul-history sample is **not** published until the data
owner approves release.
## Install
### pip package
```bash
pip install route-optimizer
```
Interactive demo: [Hugging Face Space](https://huggingface.co/spaces/albones80/route-optimizer-demo) ·
[Colab notebook](https://colab.research.google.com/github/AlfonsoALIO/RouteOptimizer/blob/master/notebooks/route_optimizer_demo.ipynb).
Console scripts: `route-optimizer`, `route-optimizer-dispatch`,
`route-optimizer-shift-plan`.
### Docker image
Build from the same repository (image tag matches the package version in
`pyproject.toml`, currently `0.1.0`):
```bash
git clone https://github.com/AlfonsoALIO/RouteOptimizer.git
cd RouteOptimizer
./scripts/build_docker.sh
# → route-optimizer:0.1.0
```
Run with a mounted folder and networking disabled:
```bash
docker run --rm --network=none \
-v "$PWD/samples:/data/samples:ro" \
-v "$PWD/out:/data/out" \
route-optimizer:0.1.0 \
dispatch /data/samples/tiny_feasible.json -o /data/out/dispatch.json --segments 8 --trucks 2
```
## Scenario file format
See [`docs/scenario-format.md`](docs/scenario-format.md) (format version `"1"`).
Units: tons, hours, minutes.
## Sample scenarios
| File | Role |
|------|------|
| [`samples/tiny_feasible.json`](samples/tiny_feasible.json) | Small mine; **dispatch and shift-plan** both succeed quickly |
| [`samples/toy_mine.json`](samples/toy_mine.json) | Larger synthetic toy mine used by the in-repo fixture (dispatch) |
```bash
# pip — end-to-end on the small sample
route-optimizer dispatch samples/tiny_feasible.json -o out/dispatch.json --segments 8 --trucks 2
route-optimizer shift-plan samples/tiny_feasible.json -o out/shift_plan.json --segments 4
# optional wall-clock cap
route-optimizer dispatch samples/toy_mine.json -o out/toy_dispatch.json --segments 58 --trucks 21 --time-limit 60
```
## Links
| Resource | URL |
|----------|-----|
| Source / pip install | https://github.com/AlfonsoALIO/RouteOptimizer |
| Docker build script | https://github.com/AlfonsoALIO/RouteOptimizer/blob/master/scripts/build_docker.sh |
| Scenario format | [`docs/scenario-format.md`](docs/scenario-format.md) |
| Synthetic scenarios (dataset) | https://huggingface.co/datasets/albones80/route-optimizer-scenarios |
| License | [`LICENSE`](LICENSE) (MIT) |
| alioit.com | https://www.alioit.com/route-optimizer |
## Citation / credit
RouteOptimizer — Alfonso Bonillas / alioit.com — MIT License.
|