Skip to main content

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:
integer
Maximum driving time in seconds allowed during the period
integer
Minimum driving time in seconds required during the period

Work Time Rules

Manage total working hours:
integer
Maximum total work time in seconds (includes driving and service time)
integer
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:

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

Each rule’s period is an explicit { "from", "to" } date-time window that you compute and pass in yourself — there is no rolling DAY/WEEK/MONTH keyword and the solver does not derive “today” or “this week” on your behalf. If period is omitted (null), the rule encompasses the entire planning period, spanning all of a resource’s shifts:

Multi-Day Planning

For multi-day scenarios, a rule only applies to the exact window given in its period — it does not automatically reset each day. To cap driving on each individual day, declare one rule per day, each with its own period:

Best Practices

1

Start with regulatory requirements

Implement legally required limits first (e.g., DOT hours of service, EU driving time regulations).
2

Add operational constraints

Layer in company policies and union agreements after regulatory compliance.
3

Test with partial planning

Enable partialPlanning: true when rules might prevent full job assignment.
4

Monitor rule impact

Use the explanation API to understand how rules affect job assignments.
5

Balance min/max rules

Avoid overly restrictive combinations that create infeasible scenarios.

Troubleshooting

Too Many Unassigned Jobs

If rules cause excessive unassigned jobs:
  1. Review rule strictness: Are limits realistic for your operation?
  2. Add more resources: Distribute work across more vehicles
  3. Adjust job locations: Cluster jobs to reduce travel
  4. Extend shift times: Provide more working hours within rules
  5. 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

Breaks

Configure mandatory rest periods within shifts

Shift Management

Define when resources are available to work

Resource Constraints

Set capacity, skills, and regional limitations

Weights

Fine-tune how rules impact optimization