In this example we will show you how to use tags. Tags are defined on jobs. Both jobs and resources can have tags. If tag do string matching on the name, the solver will ensure that jobs and resources with the same tag are matched.

hard tag
{
  "name": "technician",
  "weight": 1,
  "hard": true
}
soft tag
{
  "name": "John",
  "weight": 3600,
  "hard": false
}

The second tag is a soft tag. Soft tags are used to express preferences. In this case, we want to assign the job to a resource with tag "John". If no resource with tag "John" is available, the solver will assign the job to a resource without tag "John". The weight of the soft tag will enforce that a detour of possible 3600 seconds (1 hour) can be made in order to ensure that the job is assigned to a resource with tag "John".

Rankings vs Tags

For more nuanced resource preferences, consider using the rankings feature. While tags provide binary matching (resource has tag or doesn’t), rankings allow you to express graduated preferences for resources on a scale of 1-100, where lower values indicate stronger preferences. See the Rankings example for details.

Hard tags

{
  "resources": [
    {
      "name": "R-1",
      "start": {
        "latitude": 50.324969095932296,
        "longitude": 4.010111317974326
      },
      "shifts": [
        {
          "from": "2023-01-01T08:00:00",
          "to": "2023-01-01T17:00:00"
        }
      ],
      "tags": [
        "technician"
      ]
    },
    {
      "name": "R-2",
      "shifts": [
        {
          "from": "2023-01-01T08:00:00",
          "to": "2023-01-01T17:00:00"
        }
      ],
      "tags": [
        "maintenance"
      ]
    }
  ],
  "jobs": [
    {
      "name": "JOB-1 by R1?",
      "location": {
        "latitude": 50.54963315022148,
        "longitude": 4.848855475505483
      },
      "priority": 100,
      "duration": 3600,
      "tags": [
        {
          "name": "technician",
          "weight": 1,
          "hard": true
        }
      ]
    },
    {
      "name": "JOB-2",
      "location": {
        "latitude": 50.65910297910443600,
        "longitude": 4.007987934186738
      },
      "tags": [
        {
          "name": "maintenance",
          "weight": 1,
          "hard": true
        }
      ],
      "priority": 100,
      "duration": 3600
    },
    {
      "name": "JOB-3",
      "location": {
        "latitude": 50.324969095932296,
        "longitude": 4.010111317974326
      },
      "duration": 3600
    },
    {
      "name": "JOB-4",
      "location": {
        "latitude": 50.53457539132416,
        "longitude": 4.69167867847318
      },
      "priority": 100,
      "duration": 3600
    },
    {
      "name": "JOB-5",
      "location": {
        "latitude": 50.94837893617721,
        "longitude": 4.001604640663746
      },
      "priority": 100,
      "duration": 3600
    },
    {
      "name": "JOB-6",
      "location": {
        "latitude": 50.89633806889935,
        "longitude": 4.45161298168845
      },
      "priority": 100,
      "duration": 3600
    },
    {
      "name": "JOB-7",
      "location": {
        "latitude": 50.48191907288704,
        "longitude": 4.311723085641562
      },
      "priority": 100,
      "duration": 3600
    },
    {
      "name": "JOB-8",
      "location": {
        "latitude": 50.1824046123600988,
        "longitude": 4.355240303516217
      },
      "duration": 3600
    }
  ],
  "options": {
    "partialPlanning": true
  }
}

Soft tags

{
  "resources": [
    {
      "name": "R-1",
      "start": {
        "latitude": 50.324969095932296,
        "longitude": 4.010111317974326
      },
      "shifts": [
        {
          "from": "2023-01-01T08:00:00",
          "to": "2023-01-01T17:00:00"
        }
      ],
      "tags": [
        "technician",
        "John"
      ]
    },
    {
      "name": "R-2",
      "shifts": [
        {
          "from": "2023-01-01T08:00:00",
          "to": "2023-01-01T17:00:00"
        }
      ],
      "tags": [
        "maintenance"
      ]
    }
  ],
  "jobs": [
    {
      "name": "JOB-1 by R1?",
      "location": {
        "latitude": 50.54963315022148,
        "longitude": 4.848855475505483
      },
      "priority": 100,
      "duration": 3600,
      "tags": [
        {
          "name": "technician",
          "weight": 1,
          "hard": true
        }
      ]
    },
    {
      "name": "JOB-2",
      "location": {
        "latitude": 50.65910297910443600,
        "longitude": 4.007987934186738
      },
      "tags": [
        {
          "name": "maintenance",
          "weight": 1,
          "hard": true
        }
      ],
      "priority": 100,
      "duration": 3600
    },
    {
      "name": "JOB-3 soft tag",
      "location": {
        "latitude": 50.324969095932296,
        "longitude": 4.010111317974326
      },
      "tags": [
        {
          "name": "John",
          "hard": false,
          "weight": 3600
        }
      ],
      "duration": 3600
    },
    {
      "name": "JOB-4",
      "location": {
        "latitude": 50.53457539132416,
        "longitude": 4.69167867847318
      },
      "priority": 100,
      "duration": 3600
    },
    {
      "name": "JOB-5",
      "location": {
        "latitude": 50.94837893617721,
        "longitude": 4.001604640663746
      },
      "priority": 100,
      "duration": 3600
    },
    {
      "name": "JOB-6",
      "location": {
        "latitude": 50.89633806889935,
        "longitude": 4.45161298168845
      },
      "priority": 100,
      "duration": 3600
    },
    {
      "name": "JOB-7",
      "location": {
        "latitude": 50.48191907288704,
        "longitude": 4.311723085641562
      },
      "priority": 100,
      "duration": 3600
    },
    {
      "name": "JOB-8",
      "location": {
        "latitude": 50.1824046123600988,
        "longitude": 4.355240303516217
      },
      "duration": 3600
    }
  ],
  "options": {
    "partialPlanning": true
  }
}