Shift Capacity Rules¶
The number of activities allocated to a resource within a shift or in multiple consecutive shifts or over a given period of time may be limited using shift capacity rules. This section will explain how.
Rules¶
A resource or resource type may be given a collection of rules. One of the categories of rules that can be defined is SHIFT_CAPACITY (see the Scheduling Schema for further details on rule categories).
Each shift capacity rule can be used to place limitations on the number of activities that are assigned to the resource. Each rule that is set up will be evaluated independently for each resource that it applies to. This means that multiple rules may be defined for the same resource, limiting the number of activities in different ways or over different periods of time. Every rule must be satisfied for the schedule to be valid.
Each rule may either be evaluated over the resource's shifts, or over a provided reference period (e.g. the rule can be evaluated over any 48 hour period within the schedule).
There are four types of shift capacity rules:
- SHIFT_MAX_TOTAL_ACTIVITY_COUNT: This rule limits the number of activities that can be allocated within the defined time frame for the rule (shift or reference period)
- SHIFT_MAX_TOTAL_VALUE: This rule limits the total activity value that can be scheduled within a given number of shifts/reference period. The base value is used for each activity when calculating the total value.
- SHIFT_MAX_TOTAL_DURATION: This rule limits the total activity duration that can be allocated within any shift/reference period.
- SHIFT_CUSTOM_METRIC: This rule uses an activity's custom metric value as the limiting factor within a given number of shifts/reference period. Custom metrics can be defined in the Custom_Metric table and applied to activities or activity types. They define values for activities that are not used in any scoring calculations when scheduling the activity, so a higher custom metric value does not give an activity a higher scheduling incentive, but the higher value could limit whether the activity can be scheduled according to the SHIFT_CUSTOM_METRIC rule.
Note
Rules are only applied to CALL, DEPOT and REPEATABLE activities.
Note
There is no limit to the number of rules that can apply to a single resource, so rules of different rule types can be created, or even multiple rules of the same type (e.g. two activity count rules could be created over different periods of time, or two custom metric rules could be created for different custom metrics applying to the same activity).
Note
For count, value and custom metric rules, an activity counts as being included in a reference period if its start time is within the reference period. For duration rules, the portion of the activity and/or travel time within the reference period counts towards the total duration for the rule. Where fixed time activities overlap, the overlapping time will be counted for each visit.
Note
Rules should be used to place restrictions on combinations of activities scheduled to a resource. To restrict individual activities from being scheduled to a resource, other methods should be used, such as skills or resource preferences.
Rule Override¶
We can now specify a rule collection for a resource's shift, so that rules can be configured on a shift-by-shift basis, rather than applying the rules to the entire resource schedule. Any rule set at shift level will override the rule set directly against a resource, only when the 'NumberOfShifts' parameter set in the resource rule matches the parameter set in the shift rule. In the case of the SHIFT_CUSTOM_METRIC rules, we will override the maximum limit when the 'NumberOfShifts' and 'MetricId' for the resource rule matches the shift rule.
Note
Rule defined at shift level will override a rule at resource level only if the rules have matching rule type and matching ‘NumberOfShifts’. If there are any non matching rules at either resource or resource's shift, then both rules would apply to the shift.
Parameters¶
Parameters for the rules are defined via the Rule_Parameter table. The following parameters may be specified:
- ReferencePeriod: An optional parameter that applies to any of the shift capacity rule types. It defines the length of the reference period to use for the rule. (Timespan)
- MaximumCount: A mandatory parameter for activity count rules. Defines the maximum number of activities permitted within the given number of shifts or the reference period. (Integer)
- MaximumTotalDuration: A mandatory parameter for activity duration rules. Defines the maximum total activity duration permitted within the given number of shifts or the reference period. (Timespan)
- IncludeTravel: An optional parameter for activity duration rules. Specifies whether or not travel durations should be included in the total duration. The default is false. (Boolean)
- MaximumTotalValue: A mandatory parameter for activity value rules or custom metric rules. Defines the maximum total activity value or custom metric value permitted within the shift/reference period. (Double)
- MetricId: A mandatory parameter for custom metric rules. Defines the id of the custom metric to use for this rule. (String)
- NumberOfShifts: An optional parameter that applies to any of the shift capacity rule types. Defines the total number of consecutive shifts against which the rule applies. (Integer)
Note
If a rule is defined at resource level and if neither 'ReferencePeriod' nor 'NumberOfShifts' parameters are specified, then the rule is considered shift based and will apply over each shift. If both parameters are provided, then 'ReferencePeriod' takes precedence and 'NumberOfShifts' will be ignored.
Note
If a rule is defined at shift level, it is required to specify 'NumberOfShifts' parameter. If not provided, the rule is validated against each individual shift. If both 'ReferencePeriod' and 'NumberOfShifts' parameters are specified, then the rule will be ignored.
Examples¶
Multiple rules using reference periods¶
In this example, there are two shift capacity rules defined. The first limits the number of activities over any 42 hour period to 5, and the second limits the total duration of the activities within any 18 hour period to 5 hours. In essence, the first rule applies over any two consecutive shifts, while the second applies to individual shifts.
The rules have not been defined over 48 and 24 hour reference periods since this can have unintended consequences. For example, if there is an activity allocated at 09:15, and another activity allocated at 09:10 two days later, then these two activities are within 48 hours of each other. It may not be desired that they both contribute to the count within the same two day period, hence the use of 42 hours in this example.

Multiple rules using number of shifts and reference periods¶
In this example, two shift capacity rules are defined. The first rule is set to allow four hours of total activity duration to be allocated in a four-hour reference period. The second rule is set to allow a maximum activity count of two over two consecutive shifts - as defined by the number of shifts parameter. The result is that we restrict the schedule to two activities in a two-shift window.

Custom metric rule¶
In this example, custom metrics have been applied to each activity, with each activity being given a custom metric value numbered from 1 to 20, matching its activity id.
A rule has been defined to limit the total custom metric value per shift (not over a reference period) to 30.

Override resource rule by a shift rule¶
In this example, we have a rule defined at resource level which is applied to all the resource shifts. The resource rule allows the DSE to allocate a maximum of 2 activities per shift. We have another rule of the same rule type defined against the resource’s shift, only on day 1. As per this rule, the resource is allowed to have a maximum of 3 activities scheduled per shift. The resource rule is overridden by the shift rule on day 1 and produces an output with 3 activities scheduled on day 1 and 2 activities scheduled on day 2.

Merge resource rule and shift rule¶
Starting with the same rules as above, now suppose that there is an extra resource rule for the maximum value to be 1000 across 2 days. In this case, the resource schedule will be validated against two rules on day 1 i.e: count rule set at the shift level and value rule set at the resource level. On day 2, it uses count rule and value rule both set at the resource level for validation. The result is that the DSE schedules just a single activity of value 1000 across the first 2 shifts.
