> ## Documentation Index
> Fetch the complete documentation index at: https://docs.automaticrostering.visma.net/llms.txt
> Use this file to discover all available pages before exploring further.

# Basic rule concepts

> Learn about the rules the solver can follow when generating rosters.

Rules allow you to control shift assignments, availability, work patterns, and other aspects of roster generation so the resulting schedule meets your business requirements.

Across the v2 rule schemas, the shared top-level fields are ordered consistently as `id`, `labels`, `importance`, `isDesired`, `filters`, `targets`, `options`, and `periods`. Rule-specific fields appear after those shared fields.

## Rule importance

Rules can be configured with different levels of importance:

### Strict rules

When a rule is set to `STRICT` importance, the solver will **never** violate it. These rules act as hard requirements that must be satisfied for the roster to be valid. If the solver cannot satisfy all strict rules, it will fail to generate a roster.

### Importance levels

Alternatively, rules can be assigned a regular importance level that indicates how strongly the solver should consider them: `VERY_LOW`, `LOW`, `MEDIUM`, `HIGH`, or `VERY_HIGH`.

The solver will attempt to satisfy rules with higher importance levels more strongly, but may violate them if necessary to satisfy strict rules or other higher-priority requirements.

## Filters

Every rule can receive `filters` which allow you to make the rule apply only to specific employees or shifts. This provides fine-grained control over which parts of your roster are affected by each rule.

Filters can target entities in two ways:

* **By ID**: Specify exact IDs of employees or shifts that the rule should apply to
* **By labels**: Specify labels that employees or shifts must have for the rule to apply

For example, you might want a rule that only applies to employees with the label `"senior"` working shifts with the label `"night"`. This allows you to create complex, targeted rules for different groups of employees and shifts.

<Tip>
  Below is an example of a `HIGH` importance rule that applies to employees with the id `employee-1` and `employee-2` working shifts with the label `night`.

  ```json theme={null}
  {
    "id": "rule-123",
    "labels": ["night-shifts", "senior-staff"],
    "importance": "HIGH",
    "filters": {
      "employees": {
        "ids": ["employee-1", "employee-2"]
      },
      "shifts": {
        "labels": ["night"]
      }
    }
  }
  ```

  Note that each rule will have additional fields specific to the rule type.
</Tip>

## Available rules

<Columns cols={3}>
  <Card title="Availability" icon="user-check" href="/v2/rules/availability">
    Specify when employees are (preferably) available for work.
  </Card>

  <Card title="Utilization" icon="user-clock" href="/v2/rules/utilization">
    Control the minimum and maximum utilization of employees over specific periods.
  </Card>

  <Card title="Cooldown" icon="hourglass-start" href="/v2/rules/cooldown">
    Define minimum rest periods between shifts for employees.
  </Card>

  <Card title="Consecutive" icon="arrows-left-right" href="/v2/rules/consecutive">
    Control the minimum and maximum number of consecutive shifts.
  </Card>

  <Card title="Pattern" icon="calendar-week" href="/v2/rules/pattern">
    Define work patterns that employees should follow.
  </Card>

  <Card title="Periodic Rest" icon="bed" href="/v2/rules/periodic-rest">
    Ensure employees get rest periods at regular intervals.
  </Card>

  <Card title="Period Distribution" icon="calendar-days" href="/v2/rules/period-distribution">
    Control how work is distributed across different periods.
  </Card>
</Columns>
