APEXiA
OR · Investigación de operaciones

Rutas que se optimizan solas: investigación de operaciones en la calle

2026-06-12 · 7 min · Español

Hay dos preguntas que toda distribuidora responde a diario, casi siempre a ojo: ¿a quién visito hoy y en qué orden? (el vendedor) y ¿qué facturas monto en qué camión y por qué ruta? (el despacho). Son problemas matemáticos con nombre y apellido — TSP y CVRP — que la academia resolvió hace décadas. Lo que faltaba era conectarlos con la realidad de la calle dominicana: clientes sin dirección formal, camiones con capacidades distintas, y el precio del gasoil cambiando cada semana.

Primero, ¿a quién? La IA elige; la matemática ordena

Esta es la división de trabajo que define nuestro enfoque compound: el modelo de fuga de clientes (churn) decide quién necesita una visita — el cliente que lleva 2.2× su ciclo normal sin comprar, el que está desacelerando — y la investigación de operaciones decide en qué orden visitarlos. Ni el LLM resuelve rutas, ni el TSP sabe quién está en riesgo. Cada herramienta hace lo que la matemática le permite hacer bien.

El modelo elige a quién. El solver elige el orden. El vendedor decide — con un plan en el bolsillo en vez de una corazonada.

La ruta del vendedor: TSP en milisegundos

Para la ruta de visitas usamos el clásico nearest-neighbor con mejora 2-opt — Python puro, sin dependencias pesadas. Una ruta de 15–20 visitas se resuelve en milisegundos, lo suficientemente rápido para recalcular cada vez que el vendedor agrega o quita un cliente del plan. ¿Y las coordenadas? Tres fuentes en cascada: el GPS capturado al momento de tomar pedidos en el local (la mejor), geocodificación de las direcciones del ERP con un servidor propio de mapas, y el catálogo de zonas como respaldo.

El despacho: CVRP con la flota real

Cargar camiones es un problema más duro — capacidades, pesos, múltiples viajes — y ahí sí usamos artillería: OR-Tools, el solver de optimización de Google, con restricciones tomadas de la realidad, no de un supuesto:

RestricciónDe dónde sale
Capacidad de cada camión (kg)La flota real registrada en el CRM — del camión de 3.5 t a la patana de 30 t
Peso de cada pedidoPeso por producto × cantidades de la factura
Costo de combustible por rutaRendimiento km/galón del camión × precio oficial del gasoil de esa semana (MICM)
DestinosLas mismas coordenadas verificadas de la ruta de visitas

El resultado: el encargado de despacho arma el carrito de facturas, presiona Optimizar, y recibe los viajes propuestos por camión con distancia y combustible estimado. Puede aceptarlos o moverlos — la herramienta propone, la persona dispone.

Por qué no “IA” para todo

La moda dicta ponerle un LLM a todo. Nosotros hicimos lo contrario a propósito: las rutas son matemática determinista — mismo input, misma ruta, explicable y auditable. El LLM participa donde aporta: interpretando la pregunta del usuario, redactando el resumen del día, clasificando la intención del pedido por WhatsApp. Es la misma filosofía compound de todo APEXiA: determinismo donde importa, IA donde ayuda, y verificación en el medio.

Un solver no alucina. Para mover camiones con diésel a RD$290 el galón, eso no es un detalle académico — es plata.

Lo que sigue

La frontera natural es cerrar el ciclo con las entregas reales: cuando el CRM se convierta en la fuente de verdad de pedidos y entregas, la carga automática del despacho (“móntame todo lo no entregado”) será un botón — la tubería ya existe. Optimización que aprende del cumplimiento real: ahí es donde la investigación de operaciones y la IA se encuentran de verdad.

¿Tus rutas se deciden a corazonada?
La optimización de rutas es parte de iAx CRM — pruébalo con la distribuidora de demostración, flota incluida.
Solicitar demo
OR · Operations Research

Routes that optimize themselves: operations research on the street

2026-06-12 · 7 min · English

There are two questions every distributor answers daily, almost always by eye: who do I visit today, and in what order? (the salesperson) and which invoices do I load on which truck, and by what route? (dispatch). These are mathematical problems with a first and last name — TSP and CVRP — that academia solved decades ago. What was missing was connecting them to the reality of the Dominican street: customers without a formal address, trucks with different capacities, and the price of diesel changing every week.

First, who? The AI chooses; the math puts them in order

This is the division of labor that defines our compound approach: the customer churn model decides who needs a visit — the customer who has gone 2.2× their normal cycle without buying, the one who is slowing down — and operations research decides in what order to visit them. The LLM doesn't solve routes, and the TSP doesn't know who is at risk. Each tool does what the math allows it to do well.

The model picks who. The solver picks the order. The salesperson decides — with a plan in their pocket instead of a hunch.

The salesperson's route: TSP in milliseconds

For the visit route we use the classic nearest-neighbor heuristic with 2-opt improvement — pure Python, no heavy dependencies. A route of 15–20 visits is solved in milliseconds, fast enough to recalculate every time the salesperson adds or removes a customer from the plan. And the coordinates? Three sources in cascade: the GPS captured when taking orders at the customer's premises (the best), geocoding of the ERP addresses with our own self-hosted map server, and the zone catalog as a fallback.

Dispatch: CVRP with the real fleet

Loading trucks is a harder problem — capacities, weights, multiple trips — and there we do bring out the artillery: OR-Tools, Google's optimization solver, with constraints taken from reality, not from an assumption:

ConstraintWhere it comes from
Each truck's capacity (kg)The real fleet registered in the CRM — from the 3.5 t truck to the 30 t semi-trailer (patana)
Each order's weightWeight per product × invoice quantities
Fuel cost per routeThe truck's km-per-gallon mileage × that week's official diesel price (MICM)
DestinationsThe same verified coordinates from the visit route

The result: the dispatch manager builds the invoice cart, presses Optimize, and receives the proposed trips per truck with estimated distance and fuel. They can accept them or move them around — the tool proposes, the person disposes.

Why not “AI” for everything

Fashion dictates bolting an LLM onto everything. We deliberately did the opposite: routes are deterministic math — same input, same route, explainable and auditable. The LLM takes part where it adds value: interpreting the user's question, drafting the day's summary, classifying the intent of a WhatsApp order. It's the same compound philosophy behind all of APEXiA: determinism where it matters, AI where it helps, and verification in between.

A solver doesn't hallucinate. When you're moving trucks on diesel at RD$290 a gallon, that's not an academic detail — it's money.

What's next

The natural frontier is closing the loop with the actual deliveries: once the CRM becomes the source of truth for orders and deliveries, auto-loading the dispatch (“load up everything not yet delivered”) will be a button — the pipeline already exists. Optimization that learns from real fulfillment: that's where operations research and AI truly meet.

Are your routes decided on a hunch?
Route optimization is part of iAx CRM — try it with the demo distributor, fleet included.
Request a demo