Performance Optimization Guide
The VRP solver’s performance depends on multiple factors including problem size, constraint complexity, and configuration choices. This guide helps you understand and optimize solver performance for your specific use cases.
What Affects Solve Time?
The solver’s time complexity increases with:
Linear Factors Quadratic Factors Exponential Factors
Number of jobs (O(n))
Number of resources
Number of time windows
Basic constraints
Number of jobs (O(n))
Number of resources
Number of time windows
Basic constraints
Distance calculations (O(n²))
Job relations
Complex constraints
Alternative assignments
Optimal solution search
Complex interdependencies
Multi-objective optimization
Large solution spaces
Problem Size Guidelines
Small Problems (< 100 jobs)
{
"options" : {
"solveTime" : 10 // 10 seconds usually sufficient
}
}
Medium Problems (100-500 jobs)
{
"options" : {
"solveTime" : 60 , // 1 minute
"constructionHeuristic" : "FIRST_FIT"
}
}
Large Problems (500-2000 jobs)
{
"options" : {
"solveTime" : 300 , // 5 minutes
"constructionHeuristic" : "CHEAPEST_INSERTION" ,
"localSearchType" : "TABU_SEARCH"
}
}
Very Large Problems (> 2000 jobs)
{
"options" : {
"solveTime" : 600 , // 10 minutes
"partialPlanning" : true ,
"nearbySelection" : {
"enabled" : true ,
"maxDistance" : 50000 // 50km
}
}
}
Essential Options
Maximum solve time in seconds. Balance between quality and speed.
Initial solution strategy. Options:
FIRST_FIT
: Fastest, lower quality
CHEAPEST_INSERTION
: Balanced
AUTO
: Solver chooses based on problem
Optimization algorithm:
LATE_ACCEPTANCE
: Good for tight time windows
TABU_SEARCH
: Good for complex constraints
AUTO
: Adaptive selection
Speed Priority Quality Priority Balanced {
"options" : {
"solveTime" : 30 ,
"constructionHeuristic" : "FIRST_FIT" ,
"partialPlanning" : true ,
"explanation" : {
"enabled" : false // Disable for speed
}
}
}
Fast solutions with reasonable quality.
{
"options" : {
"solveTime" : 30 ,
"constructionHeuristic" : "FIRST_FIT" ,
"partialPlanning" : true ,
"explanation" : {
"enabled" : false // Disable for speed
}
}
}
Fast solutions with reasonable quality.
{
"options" : {
"solveTime" : 300 ,
"constructionHeuristic" : "CHEAPEST_INSERTION" ,
"localSearchType" : "TABU_SEARCH" ,
"moveThreadCount" : 4
}
}
Better solutions with more computation.
{
"options" : {
"solveTime" : 120 ,
"constructionHeuristic" : "AUTO" ,
"localSearchType" : "AUTO"
}
}
Good trade-off for most use cases.
Distance calculations significantly impact performance:
Matrix Types by Speed
Euclidean (Fastest)
{
"distanceUnit" : "meter" ,
"distanceCalculation" : "EUCLIDEAN"
}
No external API calls
Instant calculation
Lower accuracy
Haversine (Fast)
{
"distanceUnit" : "meter" ,
"distanceCalculation" : "HAVERSINE"
}
No external API calls
Quick calculation
Good for aerial distance
Road Distance (Slower)
{
"distanceMatrixType" : "osm" ,
"distanceMatrix" : {
"profile" : "car"
}
}
External API calls
Caching helps
Most accurate
Distance Matrix Optimization
Caching Strategy :
Pre-calculate frequently used distances
Store in request for reuse
Use matrixId
for persistent caching
Limit unique locations
With Caching
Pre-calculated
{
"distanceMatrix" : {
"matrixId" : "city-center-matrix-v2" ,
"cache" : true ,
"profile" : "car"
}
}
Low Impact Constraints
Basic time windows
Simple capacity checks
Fixed assignments
Priority values
Medium Impact Constraints
Multiple time windows
Multi-dimensional capacity
Skill/tag matching
Soft time preferences
High Impact Constraints
Complex job relations
Many-to-many dependencies
Dynamic time calculations
Alternative evaluations
Performance Tips :
Minimize hard constraints
Avoid unnecessary job relations
Use reasonable time window widths
Limit alternative calculations
Hardware Requirements
Minimum Requirements
CPU : 2 cores
Memory : 4GB RAM
Network : 10 Mbps
Storage : 1GB free
Recommended Specifications
Small Fleet (< 10 vehicles) Medium Fleet (10-50 vehicles) Large Fleet (> 50 vehicles)
CPU : 4 cores
Memory : 8GB RAM
Network : 50 Mbps
Storage : 5GB free
CPU : 4 cores
Memory : 8GB RAM
Network : 50 Mbps
Storage : 5GB free
CPU : 8 cores
Memory : 16GB RAM
Network : 100 Mbps
Storage : 10GB free
CPU : 16+ cores
Memory : 32GB+ RAM
Network : 1 Gbps
Storage : 20GB+ free
Key Metrics to Track
{
"performance" : {
"solveTimeInMillis" : 45230 ,
"scoreCalculationCount" : 125000 ,
"moveEvaluationCount" : 89000 ,
"bestScoreTime" : 38500 ,
"timeToFirstFeasible" : 12300 ,
"memoryUsageMB" : 1250
}
}
Metric Good Warning Critical Time to First Feasible < 20% of limit 20-50% > 50% Score Improvement Rate > 1%/sec 0.1-1%/sec < 0.1%/sec Memory Usage < 50% available 50-80% > 80% Move Evaluations/sec > 1000 100-1000 < 100
Optimization Strategies
1. Problem Decomposition
For very large problems, consider:
Geographic Clustering
Divide by regions or zones
Resource Grouping
Partition by vehicle types
Priority Batching
Process high-priority first
2. Incremental Solving
Phase 1: Core Jobs
Phase 2: Additional Jobs
{
"jobs" : [ "high-priority-jobs" ],
"options" : { "solveTime" : 60 }
}
3. Parallel Processing
When possible, run multiple scenarios:
const scenarios = [
{ weight: "minimize-vehicles" },
{ weight: "minimize-travel" },
{ weight: "balance-workload" }
];
const results = await Promise . all (
scenarios . map ( s => solveVRP ( jobs , resources , s ))
);
// Select best result based on business criteria
const best = selectOptimal ( results );
4. Feature Toggling
Disable non-essential features for speed:
Maximum Speed Balanced Full Features {
"options" : {
"explanation" : { "enabled" : false },
"alternativeStop" : { "enabled" : false },
"traffic" : { "enabled" : false },
"nearbySelection" : { "enabled" : true }
}
}
{
"options" : {
"explanation" : { "enabled" : false },
"alternativeStop" : { "enabled" : false },
"traffic" : { "enabled" : false },
"nearbySelection" : { "enabled" : true }
}
}
{
"options" : {
"explanation" : { "enabled" : false },
"alternativeStop" : { "enabled" : true },
"traffic" : { "enabled" : true , "lightweight" : true }
}
}
{
"options" : {
"explanation" : { "enabled" : true },
"alternativeStop" : { "enabled" : true },
"traffic" : { "enabled" : true },
"historicalTraffic" : { "enabled" : true }
}
}
Issue: Slow Initial Solutions
Long time to first feasible solution
Many jobs unassigned initially
Poor construction heuristic performance
Relax hard constraints temporarily
Use FIRST_FIT
construction
Enable partial planning
Reduce initial problem size
Issue: Plateau in Optimization
Score stops improving
Move count remains high
No better solutions found
Increase solve time
Adjust weight balance
Try different local search
Add solution diversity
Issue: Memory Exhaustion
Out of memory errors
Slow garbage collection
System thrashing
Reduce problem size
Disable explanation
Limit move thread count
Use geographic filtering
Best Practices
Performance Optimization Checklist :
Start Simple : Begin with minimal constraints and features
Measure Baseline : Record initial performance metrics
Profile Problems : Identify specific bottlenecks
Iterative Tuning : Make one change at a time
Cache Aggressively : Reuse distance calculations
Right-size Time : Don’t over-allocate solve time
Monitor Production : Track real-world performance
Document Settings : Record what works for your use case
Typical performance for well-configured problems:
Jobs Vehicles Constraints Time Quality 50 5 Basic 5s Optimal 200 20 Moderate 30s Near-optimal 500 50 Complex 120s Very good 1000 100 Complex 300s Good 2000 200 Moderate 600s Feasible
Actual performance varies based on geographic distribution, constraint complexity, and hardware. Use these as rough guidelines only.
Responses are generated using AI and may contain mistakes.