Solver as a Service
Sign Up Now →Sign Up Now

Milestone 4: make time explicit

Preview

Add a stable day key, start, duration, and shift type to each shift. The first time rule prevents one employee from occupying two groups on the same day:

contract: entity_exclusive
parameters:
  key_attribute: day
  limit: 1

The records now carry the data that the rule reads:

{
  "staff": [
    {
      "id": "alice",
      "skills": ["sales", "key_holder"],
      "max_hours": 16,
      "acceptable_shift_ids": ["mon-open", "tue-open"]
    },
    {
      "id": "ben",
      "skills": ["sales"],
      "max_hours": 16,
      "acceptable_shift_ids": ["mon-close", "tue-close"]
    }
  ],
  "shifts": [
    {
      "id": "mon-open",
      "day": 0,
      "start_hour": 8,
      "duration_hours": 8,
      "shift_type": "open",
      "required_skill": "key_holder",
      "required_staff": 1
    },
    {
      "id": "mon-close",
      "day": 0,
      "start_hour": 12,
      "duration_hours": 8,
      "shift_type": "close",
      "required_skill": "sales",
      "required_staff": 1
    }
  ]
}

The naming is intentional. A contract parameter such as day_attribute: day is wiring: it tells the shared engine which record field carries that concept. The manifest does not contain a retailer-specific if shift == close branch.