Resource Period Rules
Period rules enforce time-based constraints on resources over an explicit date-time window, ensuring compliance with labor laws, safety regulations, and operational policies. This guide covers work time, drive time, service time, and job-complexity limits.Period Rule Configuration
Define rules within each resource, using therules array (not periodRules):
Rule Fields
Each entry inrules is a flat object — there is no type/value wrapper. Set whichever of these fields apply; any field left out means “no constraint” for that dimension.
Work Time Rules
Work time is service time + drive time:- Daily Limit
- Weekly Limit
- Monthly Limit
Drive Time Rules
Actual time spent driving/traveling only:Service Time Rules
Productive time at job locations:Service Time = Time spent performing jobs (excludes travel and breaks)
Building Daily, Weekly, and Monthly Windows
Sinceperiod is always an explicit window, “daily” and “weekly” limits are expressed by generating one rule per window client-side, not by a keyword:
1
Daily limit
For each calendar day the resource works, add one rule whose
period.from/period.to span exactly that day (midnight to midnight, in the relevant time zone).2
Weekly limit
Add one rule whose
period spans the 7-day range you care about (a rolling week or a fixed calendar week — your choice, since you supply the exact bounds).3
Monthly limit
Add one rule whose
period spans the calendar (or rolling 30-day) range you care about.Legal Compliance Examples
EU Drivers’ Hours
US DOT Hours of Service
An 8-day rolling window (e.g. the US 70-hour/8-day option) is just another explicit
period — set from/to to span 8 days instead of 7.Enforcement Tiers
Rules aren’t uniformly “hard” or “soft” — each bound has a fixed tier, and there is no per-rulehard/weight override:
max*fields (maxWorkTime,maxServiceTime,maxDriveTime,maxJobComplexity) are hard constraints. The solver will leave a job unassigned rather than push a resource over the limit, unless doing so is the only way to reach a feasible solution at all.min*fields (minWorkTime,minServiceTime,minDriveTime,minJobComplexity) are medium-tier (utilization) constraints. They express a preference for keeping resources busy but will be traded off against other medium/soft objectives.- Both tiers are scaled by a single global weight,
options.weights.periodRuleWeight(default1), which multiplies the size of the violation — it does not change which tier a rule falls into.
Complex Scenarios
Quota Management
Minimum service requirements alongside a maximum work-time ceiling:Job-Type Quotas
Cap how many jobs of a given type a resource can complete in a period withjobTypeLimitations:
Pooled Rules (groupTag)
A period rule normally caps each declaring resource individually. Setting groupTag on a rule promotes it into a pool: the rule’s limits then apply collectively across every resource that declares an identical rule with the same groupTag.
This is useful when a sub-group of resources needs a shared ceiling rather than per-resource caps — for example, “no more than 10 ‘Install’ jobs per week across all contractors combined”, regardless of how the work is divided among them.
groupTagis a free identifier you choose; it is not related toResource.tags.- Every resource that should share the pool declares an identical rule (same period and same field values) with the same
groupTag. - The first declaration encountered is canonical. Any later declaration that doesn’t match the canonical period or fields is excluded from the pool and a warning is logged — that resource simply doesn’t participate. The remaining matching resources still form the pool.
- A pool with one declaring resource behaves like a per-resource rule.
- A resource may belong to multiple pools by declaring multiple rules with different
groupTagvalues. - All rule fields (
min/maxWorkTime,min/maxServiceTime,min/maxDriveTime,min/maxJobComplexity,jobTypeLimitations) apply collectively when pooled.
Best Practices
1
Start Conservative
Set limits slightly below legal requirements for buffer
2
Precompute Windows
Since
period is explicit, generate the from/to values for each day/week/month window client-side before building the request.3
Combine Daily and Weekly Rules
Declare both granularities on the same resource for comprehensive control
4
Monitor Utilization
Compare a resource’s
totalServiceTimeInSeconds and related response fields against your rule values to see how close it is to its limitsTroubleshooting
Rules seem to have no effect
Rules seem to have no effect
Possible cause: The field is misspelled or misplaced — a stray/renamed field (e.g.
periodRules instead of rules, or a type/value wrapper around the limit) is silently dropped during parsing rather than rejected, so the resource ends up with no constraints at all.Check: Confirm the resource has a top-level rules array (not periodRules), and that each entry uses direct fields like maxWorkTime/maxDriveTime rather than a type/value pair.Jobs Not Assigned Due to Period Rules
Jobs Not Assigned Due to Period Rules
Symptoms: Jobs remain unassigned even though resources appear to have free capacity.Check:
- The exact
from/tobounds on each rule — a window that doesn’t cover the shift you expect won’t constrain it, and one that’s too broad may combine more work than intended. - Whether the limit is a
max*(hard) ormin*(medium) field — onlymax*violations will block an assignment outright.
- Add more resources or shifts
- Loosen the rule value or widen the window
- Distribute work across more days
Performance Impact
Performance Impact
Symptoms: Slow solving with many rules.Check:
- Number of rules per resource
- How many distinct pools (
groupTagvalues) are in play
- Limit rules to the ones you actually need enforced
- Avoid unnecessarily narrow windows that force many separate rule entries
Related Features
Resource Management
Basic resource configuration
Break Management
Daily break requirements
Advanced Constraints
Other resource constraints
Time Scheduling
Multi-day shift patterns