Period Rules
Define operational constraints for resource work periods
Overview
Period rules enable you to set operational constraints that apply across all shifts for a resource. These rules ensure compliance with regulations, safety requirements, and operational policies by limiting or requiring specific work patterns.
Period rules are particularly useful for implementing driver regulations, union agreements, and safety policies that span multiple shifts.
Available Rule Types
Drive Time Rules
Control the amount of time resources spend driving:
Maximum driving time in seconds allowed during the period
Minimum driving time in seconds required during the period
Work Time Rules
Manage total working hours:
Maximum total work time in seconds (includes driving and service time)
Minimum total work time in seconds required
Use minimum drive time rules cautiously. They may force the solver to create longer routes than necessary to meet the minimum requirement.
Implementation Example
This example demonstrates how a maximum drive time rule affects route planning:
The solver assigned only 3 jobs to respect the 10,000-second (2.78 hour) maximum drive time rule:
- Total drive time: 6,917 seconds (well under limit)
- Jobs completed: 3 out of 10
- Unserved jobs: 7 (would exceed drive time if included)
The constraint forced a trade-off between service coverage and compliance with driving regulations.
Common Rule Patterns
Standard Driver Regulations
European driving regulations:
Minimum Utilization Requirements
Ensure resources meet minimum productivity:
Combined Rules
Multiple rules work together:
Rule Scope and Application
Period Definition
Rules apply to the entire planning period, not individual shifts:
Multi-Day Planning
For multi-day scenarios, rules apply per day:
Best Practices
Start with regulatory requirements
Implement legally required limits first (e.g., DOT hours of service, EU driving time regulations).
Add operational constraints
Layer in company policies and union agreements after regulatory compliance.
Test with partial planning
Enable partialPlanning: true
when rules might prevent full job assignment.
Monitor rule impact
Use the explanation API to understand how rules affect job assignments.
Balance min/max rules
Avoid overly restrictive combinations that create infeasible scenarios.
Troubleshooting
Too Many Unassigned Jobs
If rules cause excessive unassigned jobs:
Solution strategies
Solution strategies
- Review rule strictness: Are limits realistic for your operation?
- Add more resources: Distribute work across more vehicles
- Adjust job locations: Cluster jobs to reduce travel
- Extend shift times: Provide more working hours within rules
- Use soft constraints: Consider making some rules soft with penalties
Inefficient Routes
When minimum rules force unnecessary travel:
Replace minimum drive time rules with minimum job count or revenue targets to achieve utilization goals without forcing inefficient routing.
Advanced Scenarios
Time-Based Rule Variations
While not directly supported, you can simulate time-based variations using multiple resources:
Combining with Other Constraints
Rules work alongside other VRP features:
Performance Impact
Period rules are evaluated continuously during optimization. Complex rule combinations may increase solve time, especially with tight constraints that limit feasible solutions.
Consider:
- Fewer, simpler rules perform better than many complex rules
- Hard rules that severely limit options increase computation time
- Partial planning helps when rules make full assignment impossible