Learn how to analyze VRP solutions and explore alternative routing options using the explanation endpoint
The explanation endpoint helps you understand why the VRP solver made specific routing decisions. It provides:
Use explanations to debug infeasible solutions, optimize route quality, and provide transparency to end-users about routing decisions.
Every VRP solution includes a score that reflects the quality of the routing plan. The explanation endpoint breaks down this score by constraint.
After solving a VRP problem, retrieve the explanation using:
Overall solution quality metrics.
List of constraints contributing to the score.
Enable alternative position analysis to explore what-if scenarios for job routing. This feature evaluates all possible positions for each job and explains why certain placements were rejected.
Set explanationOptions.enabled
to true
in your solve request:
Computing alternatives increases processing time. Only enable when you need detailed routing analysis.
The explanation now includes alternative positions for each job:
Each alternative position includes:
Proposed arrival time at the job location.
Latest possible arrival time while maintaining schedule feasibility.
Identifier of the preceding job or trip start in this scenario.
List of constraints violated in this alternative scenario.
Let’s analyze a routing scenario with time window constraints:
Define the problem
Create a VRP request with two jobs and tight time windows:
Analyze the solution
The solver finds a feasible solution where job1 (with the tighter time window) is served first:
Review alternatives
The explanation reveals why job2 cannot be served first:
Job1’s narrow time window (09:00-09:20) would be violated if job2 were served first, making this alternative infeasible.
Understanding constraint violations helps you improve your routing solutions:
Hard Constraints (Must be satisfied)
Soft Constraints (Optimization goals)