Advanced Constraints
Beyond basic routing constraints, the VRP solver supports sophisticated business rules for compliance, safety, and operational requirements. This guide covers advanced constraints including driving limits, tag matching, vehicle restrictions, and adherence penalties.Drive Time Constraints
Maximum Continuous Drive Time
Enforce legal or safety limits on continuous driving:- EU: 4.5 hours continuous driving max
- US DOT: Complex hours-of-service rules
- Always verify local regulations
Drive Time Ordering
Ensure jobs are visited in chronological order based on actual drive times:Tag-Based Constraints
Hard Tag Matching
Enforce strict requirements for skills, certifications, or equipment:Soft Tag Preferences
Create preferences without hard requirements:Tag Matching Rules
Hard Tags Must Match
Soft Tags Create Preference
Resource Tags Don't Restrict
Weight Calculation
Vehicle Restrictions
Disallowed Vehicles
Explicitly prevent certain resources from servicing specific jobs:disallowedResources
- Never assign these (hard constraint)allowedResources
- Only assign from this list (hard constraint)preferredResources
- Try these first (soft constraint)
Complex Restriction Example
Overtime Constraints
Overtime Penalties
Configure penalties for work beyond regular hours:Overtime Behavior
- Soft Overtime
- Hard Limit
- Graduated Penalties
Planning Adherence
Maintaining Planned Schedules
Penalize deviations from existing plans:Adherence Calculation
Use Cases for Planning Adherence
Customer Communications
Customer Communications
Incremental Optimization
Incremental Optimization
Partial Replanning
Partial Replanning
Job Proximity Scoring
Overview
Job proximity scoring encourages the solver to visit geographically nearby jobs consecutively on the same route. This feature is particularly valuable for dense urban delivery scenarios where multiple jobs exist within close proximity, such as apartment buildings, office complexes, or dense neighborhoods. Key Benefits:- More efficient route clustering
- Improved customer satisfaction (same-area deliveries)
- Better utilization of local knowledge
- Dense urban delivery areas
- Multi-unit buildings or complexes
- Neighborhood-based service routes
- Campus or facility management
- Any scenario with naturally occurring job clusters
Configuration
Job proximity scoring is controlled by three parameters in the request:HAVERSINE
: Fast straight-line distance (great-circle distance)REAL
: Actual road network distance from routing engine
Distance Type Options
Haversine Distance (Default)
Uses great-circle distance calculation based on latitude/longitude coordinates:- Advantages
- Best For
- Limitations
- Fast: No external API calls required
- Simple: Works with just coordinates
- Reliable: No dependency on routing service availability
- Consistent: Same calculation every time
Real Road Distance
Uses actual road network distances from your configured routing engine:- Advantages
- Best For
- Limitations
- Accurate: Reflects true travel distances
- Road-aware: Considers actual street networks
- Barrier-aware: Accounts for physical obstacles
Practical Examples
Example 1: Apartment Building Deliveries
Multiple deliveries in the same building should be handled together:Example 2: Neighborhood Service Routes
Cluster service calls in residential neighborhoods:Example 3: Campus or Facility Management
Service multiple locations within a campus or complex:Weight Tuning Guide
ThejobProximityWeight
determines how strongly the solver prioritizes neighbor clustering:
- Low Weight (100-500)
- Medium Weight (500-1500)
- High Weight (1500+)
- Neighbors visited together when convenient
- Other constraints take priority
- More flexibility in route construction
- Proximity is a nice-to-have
- Other constraints are more important
- Testing the feature initially
Choosing the Right Proximity Radius
Small Radius (50-200m)
Small Radius (50-200m)
- Single building or complex
- Multi-unit residential
- Office tower floors
Medium Radius (200-500m)
Medium Radius (200-500m)
- City blocks
- Small neighborhoods
- Shopping centers
- Campus buildings
Large Radius (500-1000m)
Large Radius (500-1000m)
- Large neighborhoods
- Suburban areas
- Business parks
- Service territories
Very Large Radius (1000m+)
Very Large Radius (1000m+)
- District-level clustering
- Regional grouping
- Large facilities
- Too Small: May miss natural clusters, reducing effectiveness
- Too Large: May create unwanted groupings, reducing route efficiency
- Rule of Thumb: Start with typical walking distance between locations in your service area
Interaction with Other Constraints
Proximity scoring works alongside other constraints:Hard Constraints Take Priority
Balanced with Soft Constraints
Does Not Guarantee Clustering
Troubleshooting
Neighbors Not Being Visited Together
Neighbors Not Being Visited Together
- Proximity weight too low compared to other constraints
- Conflicting time windows prevent consecutive visits
- Hard constraints forcing separation
- Insufficient resources to handle clusters
- Increase
jobProximityWeight
- Review time window constraints
- Check resource availability
- Use explanation endpoint to see actual penalties
Unexpected Neighbor Groupings
Unexpected Neighbor Groupings
- Proximity radius too large
- Distance type not appropriate for area
- Geography has unexpected characteristics
- Reduce
jobProximityRadius
- Try different
jobProximityDistanceType
- Review actual job locations
- Test with representative samples
Best Practices
Start with Analysis
- Plot jobs on a map
- Identify typical cluster sizes
- Measure distances between related locations
Test Radius Values
- Start conservative (smaller radius)
- Gradually increase until desired grouping achieved
- Monitor impact on total route efficiency
Balance with Business Goals
- Tighter clustering may increase total travel time
- Looser clustering may miss efficiency opportunities
- Find the sweet spot for your operation
Use Appropriate Distance Type
- Dense urban grids → HAVERSINE often sufficient
- Complex road networks → REAL provides better accuracy
- High-volume operations → HAVERSINE for speed
Monitor and Adjust
- Actual clustering rates
- Total route efficiency
- Customer feedback
- Driver convenience
Complete Example
Here’s a comprehensive example combining proximity scoring with other features:- Downtown jobs will be grouped together
- Suburb jobs will be grouped together
- Priority still influences which cluster is visited first
- Travel time minimization within each cluster
Constraint Interactions
Constraint Priority Hierarchy
Hard Constraints (Absolute)
- Time windows (hard)
- Capacity limits
- Disallowed resources
- Hard tags
- Shift boundaries (without overtime)
Soft Constraints (Weighted)
- Soft time windows
- Overtime penalties
- Tag preferences
- Planning adherence
- Preferred resources
Optimization Objectives
- Minimize total cost
- Minimize travel time
- Balance workload
- Maximize urgency satisfaction
Complex Constraint Example
Performance Considerations
- Basic tag matching
- Disallowed resources
- Simple overtime penalties
- Many soft constraints
- Complex tag hierarchies
- Planning adherence with many jobs
- Drive time ordering
- Many overlapping soft constraints
- Complex overtime structures
Optimization Tips
- Use Hard Constraints Sparingly: Each hard constraint reduces solution space
- Balance Weights: Keep soft constraint weights in reasonable ratios
- Test Incrementally: Add constraints one at a time to identify conflicts
- Monitor Infeasibility: Too many constraints can make problems unsolvable
Troubleshooting
Common Issues
Jobs Not Assigned Due to Constraints
Jobs Not Assigned Due to Constraints
- Tag requirements vs available resources
- Disallowed resource lists
- Time window compatibility
- Capacity constraints
- Review tag assignments
- Verify resource capabilities
- Consider soft constraints instead of hard
- Enable partial planning
Unexpected Constraint Violations
Unexpected Constraint Violations
- Competing constraint weights
- Hard constraint conflicts
- Resource availability
- Increase specific constraint weights
- Review weight ratios
- Check for conflicting requirements
- Add more resources
Poor Solution Quality
Poor Solution Quality
- Too many hard constraints
- Conflicting soft constraints
- Insufficient optimization time
- Convert some hard constraints to soft
- Adjust weight balance
- Increase solve time limit
- Simplify constraint model
Debugging Constraints
Use the explanation endpoint to understand constraint impacts:- Active constraints for each assignment
- Constraint violations and penalties
- Why certain assignments weren’t made
Best Practices
Start Simple
- Basic time windows
- Required capacities
- Critical tags
Add Incrementally
- Soft preferences
- Overtime rules
- Planning adherence
Monitor Impact
- Constraint violation counts
- Solution quality scores
- Computation time
- Unassigned job reasons
Document Rules
- Business reason for each constraint
- Weight selection rationale
- Expected behavior
- Fallback strategies