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:Maximum seconds of continuous driving before a break is required
Drive Time Ordering
Ensure jobs are visited in chronological order based on actual drive times:Drive Time Ordering prevents the solver from scheduling later appointments before earlier ones on the same route, even if it might be more efficient.
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
Vehicle Restrictions
Disallowed Vehicles
Explicitly prevent certain resources from servicing specific jobs:Restriction Priority:
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
Planned Arrival Penalty = |actual_arrival - planned_arrival| × plannedWeightResource Change Penalty = (resource_changed ? 1 : 0) × plannedResourceWeight
Use Cases for Planning Adherence
Customer Communications
Customer Communications
When customers have been notified of arrival times, minimize changes to maintain trust.
Incremental Optimization
Incremental Optimization
Re-optimize routes while keeping most assignments stable.
Partial Replanning
Partial Replanning
Add new jobs while minimizing disruption to existing schedule.
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
When to Use Proximity Scoring:
- 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:The radius in meters to consider two jobs as neighbors. Jobs within this distance are expected to be visited consecutively. Set to 0 to disable proximity scoring.
The distance calculation method:
HAVERSINE: Fast straight-line distance (great-circle distance)REAL: Actual road network distance from routing engine
Penalty applied when a job with nearby neighbors is not visited immediately after one of those neighbors. Higher values create stronger clustering.
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)
Best For:
- Single building or complex
- Multi-unit residential
- Office tower floors
Medium Radius (200-500m)
Medium Radius (200-500m)
Best For:
- City blocks
- Small neighborhoods
- Shopping centers
- Campus buildings
Large Radius (500-1000m)
Large Radius (500-1000m)
Best For:
- Large neighborhoods
- Suburban areas
- Business parks
- Service territories
Very Large Radius (1000m+)
Very Large Radius (1000m+)
Best For:
- District-level clustering
- Regional grouping
- Large facilities
Interaction with Other Constraints
Proximity scoring works alongside other constraints:Hard Constraints Take Priority
Time windows, capacity limits, and hard tags always take precedence over proximity scoring.
Balanced with Soft Constraints
Proximity penalties are weighed against other soft constraints like travel time, urgency, and planning adherence.
Troubleshooting
Neighbors Not Being Visited Together
Neighbors Not Being Visited Together
Possible Causes:
- 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
Possible Causes:
- 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
Analyze your job locations to understand natural clustering:
- Plot jobs on a map
- Identify typical cluster sizes
- Measure distances between related locations
Test Radius Values
Experiment with different proximity radii:
- Start conservative (smaller radius)
- Gradually increase until desired grouping achieved
- Monitor impact on total route efficiency
Balance with Business Goals
Consider trade-offs:
- Tighter clustering may increase total travel time
- Looser clustering may miss efficiency opportunities
- Find the sweet spot for your operation
Use Appropriate Distance Type
Choose based on your environment:
- Dense urban grids → HAVERSINE often sufficient
- Complex road networks → REAL provides better accuracy
- High-volume operations → HAVERSINE for speed
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
Complex Constraint Example
Performance Considerations
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
Symptoms: High unassigned job countCheck:
- 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
Symptoms: Soft constraints violated despite high weightsCheck:
- 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
Symptoms: Valid but inefficient routesCheck:
- 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
Begin with essential constraints only:
- Basic time windows
- Required capacities
- Critical tags
Monitor Impact
Track key metrics:
- Constraint violation counts
- Solution quality scores
- Computation time
- Unassigned job reasons
Related Features
Tag & Ranking
Advanced tag matching and preferences
Time Windows
Time-based constraints
Period Rules
Long-term resource constraints
Cost Optimization
How constraints affect costs