{
  "performance": {
    "solveTimeInMillis": 45230,
    "scoreCalculationCount": 125000,
    "moveEvaluationCount": 89000,
    "bestScoreTime": 38500,
    "timeToFirstFeasible": 12300,
    "memoryUsageMB": 1250
  }
}

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.

Performance Fundamentals

What Affects Solve Time?

Performance Scaling

The solver’s time complexity increases with:

  • Number of jobs (O(n))
  • Number of resources
  • Number of time windows
  • Basic constraints

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
    }
  }
}

Configuration for Performance

Essential Options

solveTime
integer
default:"120"

Maximum solve time in seconds. Balance between quality and speed.

constructionHeuristic
string
default:"AUTO"

Initial solution strategy. Options:

  • FIRST_FIT: Fastest, lower quality
  • CHEAPEST_INSERTION: Balanced
  • AUTO: Solver chooses based on problem
localSearchType
string
default:"AUTO"

Optimization algorithm:

  • LATE_ACCEPTANCE: Good for tight time windows
  • TABU_SEARCH: Good for complex constraints
  • AUTO: Adaptive selection

Performance-Oriented Settings

{
  "options": {
    "solveTime": 30,
    "constructionHeuristic": "FIRST_FIT",
    "partialPlanning": true,
    "explanation": {
      "enabled": false  // Disable for speed
    }
  }
}

Fast solutions with reasonable quality.

Distance Matrix Performance

Distance calculations significantly impact performance:

Matrix Types by Speed

1

Euclidean (Fastest)

{
  "distanceUnit": "meter",
  "distanceCalculation": "EUCLIDEAN"
}
  • No external API calls
  • Instant calculation
  • Lower accuracy
2

Haversine (Fast)

{
  "distanceUnit": "meter",
  "distanceCalculation": "HAVERSINE"
}
  • No external API calls
  • Quick calculation
  • Good for aerial distance
3

Road Distance (Slower)

{
  "distanceMatrixType": "osm",
  "distanceMatrix": {
    "profile": "car"
  }
}
  • External API calls
  • Caching helps
  • Most accurate

Distance Matrix Optimization

Caching Strategy:

  1. Pre-calculate frequently used distances
  2. Store in request for reuse
  3. Use matrixId for persistent caching
  4. Limit unique locations
{
  "distanceMatrix": {
    "matrixId": "city-center-matrix-v2",
    "cache": true,
    "profile": "car"
  }
}

Constraint Impact on Performance

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
  • CPU: 4 cores
  • Memory: 8GB RAM
  • Network: 50 Mbps
  • Storage: 5GB free

Performance Monitoring

Key Metrics to Track

{
  "performance": {
    "solveTimeInMillis": 45230,
    "scoreCalculationCount": 125000,
    "moveEvaluationCount": 89000,
    "bestScoreTime": 38500,
    "timeToFirstFeasible": 12300,
    "memoryUsageMB": 1250
  }
}

Performance Indicators

MetricGoodWarningCritical
Time to First Feasible< 20% of limit20-50%> 50%
Score Improvement Rate> 1%/sec0.1-1%/sec< 0.1%/sec
Memory Usage< 50% available50-80%> 80%
Move Evaluations/sec> 1000100-1000< 100

Optimization Strategies

1. Problem Decomposition

For very large problems, consider:

1

Geographic Clustering

Divide by regions or zones

2

Temporal Splitting

Separate by time periods

3

Resource Grouping

Partition by vehicle types

4

Priority Batching

Process high-priority first

2. Incremental Solving

{
  "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:

{
  "options": {
    "explanation": {"enabled": false},
    "alternativeStop": {"enabled": false},
    "traffic": {"enabled": false},
    "nearbySelection": {"enabled": true}
  }
}

Common Performance Issues

Issue: Slow Initial Solutions

Issue: Plateau in Optimization

Issue: Memory Exhaustion

Best Practices

Performance Optimization Checklist:

  1. Start Simple: Begin with minimal constraints and features
  2. Measure Baseline: Record initial performance metrics
  3. Profile Problems: Identify specific bottlenecks
  4. Iterative Tuning: Make one change at a time
  5. Cache Aggressively: Reuse distance calculations
  6. Right-size Time: Don’t over-allocate solve time
  7. Monitor Production: Track real-world performance
  8. Document Settings: Record what works for your use case

Performance Benchmarks

Typical performance for well-configured problems:

JobsVehiclesConstraintsTimeQuality
505Basic5sOptimal
20020Moderate30sNear-optimal
50050Complex120sVery good
1000100Complex300sGood
2000200Moderate600sFeasible

Actual performance varies based on geographic distribution, constraint complexity, and hardware. Use these as rough guidelines only.