Skip to content

IMAbril/Supplier-Risk-Radar

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

📡 Supplier Risk Radar

EN · Supply-chain / supplier-risk analytics for Latin America, built on the CEPAL LAC-IOT 2011 multi-regional input-output table and a from-scratch linear algebra engine. English · Español


English

What it does

Given a focal firm — by default a Brazilian motor-vehicle manufacturer (sector s30, with Argentina as the alternative base) — the project quantifies its hidden upstream exposure across 40 sectors × 18 Latin American countries and turns it into decision-ready analytics:

  1. Upstream exposure map — the Leontief inverse (I − A)⁻¹ reveals the total requirements each unit of focal demand pulls from every industry in the region, split into direct first-round inputs and hidden higher-order dependencies (suppliers of suppliers, across borders). For the case-study firm, 46% of the upstream pull is hidden.
  2. Criticality & concentration — Herfindahl (HHI) concentration by country, sector and supplier; Rasmussen–Hirschman backward/forward linkages; eigenvector centrality via the power method.
  3. Disruption scenarios — demand shocks (Δx = (I−A)⁻¹Δd) and cost shocks through the dual Leontief price model (Δp = (I−Aᵀ)⁻¹Δv). Example: a +30% cost shock on Brazilian steel adds +2.6% to focal unit costs — two orders of magnitude more than the same shock in any other country.
  4. Diversification — re-source inputs across countries (input intensity preserved), rebuild the inverse and measure the concentration gain.
  5. Composite risk score — a transparent 0–100 score per supplier blending exposure, single-sourcing concentration, systemic criticality and a country-risk proxy, with configurable weights.

The from-scratch engine

All core numerics — LU decomposition with partial pivoting, triangular forward/back substitution, matrix inversion, power method — are hand-written in src/supplier_risk/linalg.py (no numpy.linalg.inv/solve, no scipy), and validated against numpy to ~4·10⁻¹⁵ at 720×720.

Quick start

pip install -r requirements.txt
python scripts/build_cache.py     # one-time: build A and (I-A)^-1, validate
pytest -q                         # 49 tests
streamlit run app/dashboard.py    # interactive dashboard (EN/ES)

The narrative case study lives in notebooks/case_study.ipynb (committed with executed outputs); methodology, formulas and limitations in docs/metodologia.md.

Project layout

src/supplier_risk/
  config.py      bilingual taxonomy (18 countries, 40 sectors), defaults, weights
  linalg.py      from-scratch LU / inverse / power method
  io_model.py    CEPAL workbook -> Z, A = Z·diag(1/x), Leontief inverse, cache
  risk.py        exposure, HHI, Rasmussen, spectral centrality, composite score
  scenarios.py   demand/cost/supply shocks, diversification
app/dashboard.py       Streamlit dashboard (EN/ES)
notebooks/case_study.ipynb   executed bilingual case study
scripts/build_cache.py       builds data/processed, validates vs numpy
tests/                       49 tests
docs/metodologia.md          methodology (EN/ES)

Español

Qué hace

Dada una empresa focal — por defecto un fabricante automotriz brasileño (sector s30, con Argentina como base alternativa) — el proyecto cuantifica su exposición upstream oculta a través de 40 sectores × 18 países de América Latina y la convierte en analítica accionable:

  1. Mapa de exposición upstream — la inversa de Leontief (I − A)⁻¹ revela los requerimientos totales que cada unidad de demanda focal tracciona de cada industria de la región, separados en insumos directos de primera ronda y dependencias ocultas de orden superior (proveedores de proveedores, a través de fronteras). Para la empresa del caso de estudio, el 46% de la tracción upstream es oculta.
  2. Criticidad y concentración — concentración de Herfindahl (HHI) por país, sector y proveedor; encadenamientos de Rasmussen–Hirschman hacia atrás y adelante; centralidad espectral vía método de la potencia.
  3. Escenarios de disrupción — shocks de demanda (Δx = (I−A)⁻¹Δd) y de costos con el modelo dual de precios de Leontief (Δp = (I−Aᵀ)⁻¹Δv). Ejemplo: un shock de +30% en el acero brasileño agrega +2,6% al costo unitario focal — dos órdenes de magnitud más que el mismo shock en cualquier otro país.
  4. Diversificación — redistribuir insumos entre países (manteniendo la intensidad de insumos), reconstruir la inversa y medir la ganancia de concentración.
  5. Score compuesto de riesgo — un score transparente de 0–100 por proveedor que combina exposición, concentración de fuente única, criticidad sistémica y un proxy de riesgo país, con pesos configurables.

El motor desde cero

Toda la numérica central — descomposición LU con pivoteo parcial, sustitución triangular hacia adelante/atrás, inversión de matrices, método de la potencia — está escrita a mano en src/supplier_risk/linalg.py (sin numpy.linalg.inv/solve, sin scipy), validada contra numpy a ~4·10⁻¹⁵ en 720×720.

Inicio rápido

pip install -r requirements.txt
python scripts/build_cache.py     # una vez: construye A y (I-A)^-1, valida
pytest -q                         # 49 tests
streamlit run app/dashboard.py    # dashboard interactivo (ES/EN)

El caso de estudio narrativo está en notebooks/case_study.ipynb (con salidas ejecutadas); metodología, fórmulas y limitaciones en docs/metodologia.md.


Authorship & credits / Autoría y créditos

  • Linear-algebra engine / Motor de álgebra lineal — the LU decomposition, matrix inverse and power method are adapted from the group academic project “Grupo 10 — Trabajo Práctico, Álgebra Lineal Computacional, 2C 2024” (contributors / integrantes: Abril Magali Ibarra, Santiago Roda), originally calcularLU, inversaLU, metodoPotencia in imabril/matrices_insumo-producto. The original group authorship of that engine is gratefully acknowledged; the triangular solves were re-implemented from scratch here and the elimination step vectorized (details in docs/metodologia.md §3).
  • Data / Datos — CEPAL/ECLAC, Latin American Input-Output Table (LAC-IOT) 2011, Trade and Integration Division; millions of US$ at basic prices. The country-risk proxy in config.py is illustrative and not part of the CEPAL data.
  • License / Licencia: MIT.

About

Supply-chain / supplier-risk analytics for Latin America, built on the CEPAL LAC-IOT 2011 multi-regional input-output table and a from-scratch linear algebra engine.

Resources

License

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors