Overview
The explanation endpoint helps you understand why the VRP solver made specific routing decisions. It provides:- Detailed breakdown of constraint violations and their impact on the solution score
- Alternative routing scenarios for each job
- Insights into why certain solutions are infeasible
Use explanations to debug infeasible solutions, optimize route quality, and provide transparency to end-users about routing decisions.
Basic Explanation
Every VRP solution includes a score that reflects the quality of the routing plan. The explanation endpoint breaks down this score by constraint.Request a Simple Explanation
After solving a VRP problem, retrieve the explanation using:Understanding the Response
Overall solution quality metrics.
List of constraints contributing to the score.
Alternative Positions Analysis
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.Enable Alternative Analysis
SetexplanationOptions.enabled
to true
in your solve request:
Computing alternatives increases processing time. Only enable when you need detailed routing analysis.
Alternative Position Response
The explanation now includes alternative positions for each job: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.
Practical Example
Let’s analyze a routing scenario with time window constraints:1
Define the problem
Create a VRP request with two jobs and tight time windows:
VRP Request
2
Analyze the solution
The solver finds a feasible solution where job1 (with the tighter time window) is served first:
Solution
3
Review alternatives
The explanation reveals why job2 cannot be served first:
Alternative Analysis
Job1’s narrow time window (09:00-09:20) would be violated if job2 were served first, making this alternative infeasible.
Common Constraint Types
Understanding constraint violations helps you improve your routing solutions:Hard Constraints (Must be satisfied)
Hard Constraints (Must be satisfied)
- TIME_WINDOW_CONFLICT: Job served outside its time window
- SHIFT_END_CONFLICT: Route extends beyond worker shift
- ALLOWED_RESOURCES: Job assigned to unauthorized resource
- TAG_HARD: Required skills/equipment missing
- TRIP_CAPACITY: Vehicle capacity exceeded
Soft Constraints (Optimization goals)
Soft Constraints (Optimization goals)
- TRAVEL_TIME: Total travel time minimization
- WAIT_TIME: Idle time between jobs
- RESOURCE_USAGE: Number of resources utilized
- FAIR_WORK: Workload distribution balance
- PREFERRED_RESOURCE_CONFLICT: Preference violations
Best Practices
Next Steps
- Explore constraint configuration to customize routing behavior
- Learn about scoring optimization to balance multiple objectives
- Review performance tuning for large-scale routing problems