🌐 Enterprise-Grade Global Supply Chain Facility Location & Spatial Optimization Platform.
This system transitions a simple clustering notebook into an absolute overkill supply chain planning system. It equips analysts and planners with mathematical solvers, REST API endpoints, and a rich, interactive 3D Globe dashboard to perform multi-scenario distribution network optimization.
- K-Means (Euclidean 3D): Fast baseline clustering operating on Cartesian coordinates projected back to the WGS-84 sphere.
- K-Medoids (Exact Geodesic): Vectorized PAM (Partitioning Around Medoids) algorithm operating on pre-computed geodesic distance matrices.
-
PyTorch Spherical Gradient Descent: Adam optimizer performing gradient descent on the unit sphere
$S^2$ , projecting centers via$C \leftarrow \frac{C}{|C|_2}$ at each epoch. -
MILP Facility Location: Solves the Uncapacitated and Capacitated Facility Location Problem (UFLP/CFLP) using the
CBCsolver viaPuLP. Includes candidate site selection bounds to scale safely.
-
Dynamic Demand Weighting: Choose between Raw Population demand and Purchasing Power Adjusted (
$Population \times GDP_{per capita}$ ) demand weighting. -
Infrastructure Readiness (LPI Index): Penalize placing distribution centers in countries with low logistics capabilities using a customizable weight multiplier
$\beta$ on the distance function: $$D'{ij} = D{ij} \times \left(1 + \beta \times \left(5.0 - \text{LPI}_j\right)\right)$$ - Scenario Planning (Forced DCs): Force placement in key supply chain hubs (e.g., Singapore, Rotterdam) and solve for the remaining slots.
- FastAPI Backend Service: Exposes high-throughput JSON optimization and benchmark endpoints.
- Streamlit Interactive 3D Globe: Render networks in the browser, showing geodesic routing arcs, customer demand sizes, and DC profiles.
-
Create and Activate Virtual Environment:
python3 -m venv .venv source .venv/bin/activate -
Install Package (Editable Mode):
pip install -r requirements.txt pip install -e . -
Run Unit Tests:
python -m unittest tests/test_optimizers.py
Run both the API and Streamlit Dashboard concurrently:
docker-compose up --build- FastAPI API: http://localhost:8000
- FastAPI Swagger Docs: http://localhost:8000/docs
- Streamlit Dashboard: http://localhost:8501
Deploy the platform onto a cluster (with services and replica controls):
kubectl apply -f k8s/deployment.ymlPayload:
{
"algorithm": "milp",
"n_clusters": 5,
"metric": "geodesic",
"weight_column": "gdp_adjusted",
"lpi_factor": 0.5,
"candidate_limit": 50
}Allows comparing runtime, total distance, and selected sites across all solvers in one call.
Run the dashboard locally using Streamlit:
streamlit run app.pyUse the sidebar to change algorithms, toggle demand weighting modes, scale infrastructure readiness parameters, and add scenario constraints.
You can deploy this dashboard directly from GitHub for free using Streamlit Community Cloud:
- Push this repository to your GitHub account.
- Visit Streamlit Share and log in with your GitHub account.
- Click New app, then select your repository, branch, and set the Main file path to
app.py. - Click Deploy! Your interactive dashboard will be live and shared publicly.