In this example we will show you how to use job relations. Job relations are defined on jobs. They can be used to express different links between jobs:

  • SEQUENCE: the jobs need to be visited in the given order
  • DIRECT_SEQUENCE: the jobs need to be visited in the given order, one after the other
  • SAME_TRIP: the jobs need to be visited in the same trip, the sequence does not matter
  • SAME_TIME: the jobs need to be visited at the same time, the assigned resource will be different
  • PICKUP_AND_DELIVERY: the jobs need to be in the same trip and the pickup needs to happen before the dropoff. (special case of job relation)
  • SAME_RESOURCE: the jobs need to be visited by the same resource (could be another day)

Sequence relation

sequence
{
  "resources": [
    {
      "name": "R-1"
    },
    {
      "name": "R-2"
    }
  ],
  "jobs": [
    {
      "name": "JOB-1",
      "duration": 3600
    },
    {
      "name": "JOB-2",
      "duration": 3600
    },
    {
      "name": "JOB-3",
      "duration": 3600
    }
  ],
  "relations": [
    {
      "type": "SEQUENCE",
      "jobs": [
        "JOB-1",
        "JOB-2",
        "JOB-3"
      ]
    }
  ]
}

Direct Sequence relation

direct sequence
{
  "resources": [
    {
      "name": "R-1"
    }
  ],
  "jobs": [
    {
      "name": "JOB-1",
      "duration": 3600
    },
    {
      "name": "JOB-2",
      "duration": 3600
    },
    {
      "name": "JOB-3",
      "duration": 3600
    }
  ],
  "relations": [
    {
      "type": "DIRECT_SEQUENCE",
      "jobs": [
        "JOB-1",
        "JOB-2"
      ]
    }
  ]
}

Same time relation

If there are Jobs that need multiple resources assigned to it, you should duplicate those jobs and add the requirement that they should start at the same time.

same time
{
  "resources": [
    {
      "name": "R-1"
    },
    {
      "name": "R-2"
    }
  ],
  "jobs": [
    {
      "name": "JOB-1",
      "duration": 3600
    },
    {
      "name": "JOB-2",
      "duration": 3600
    },
    {
      "name": "JOB-3",
      "duration": 3600
    }
  ],
  "relations": [
    {
      "type": "SAME_TIME",
      "jobs": [
        "JOB-1",
        "JOB-2"
      ]
    }
  ]
}

Pickup and delivery relation

A very specific case of a SAME_TRIP relation in combination with a SEQUENCE relation that requires first to do the pickup and then the delivery. The shortcut is the PICKUP_AND_DELIVERY job relation for maximum two jobs, the first is the pickup, the second is the delivery.

pickup and delivery
{
  "resources": [
    {
      "name": "R-1"
    }
  ],
  "jobs": [
    {
      "name": "JOB-1",
      "duration": 3600
    },
    {
      "name": "JOB-2",
      "duration": 3600
    },
    {
      "name": "JOB-3",
      "duration": 3600
    }
  ],
  "relations": [
    {
      "type": "PICKUP_AND_DELIVERY",
      "jobs": [
        "JOB-1",
        "JOB-2"
      ]
    }
  ]
}

Same trip relation

If the sequence is independent but they need to be done in the same tour or trip or day, then you can use a SAME_TRIP relation.

same trip
{
  "resources": [
    {
      "name": "R-1"
    }
  ],
  "jobs": [
    {
      "name": "JOB-1",
      "duration": 3600
    },
    {
      "name": "JOB-2",
      "duration": 3600
    },
    {
      "name": "JOB-3",
      "duration": 3600
    }
  ],
  "relations": [
    {
      "type": "SAME_TRIP",
      "jobs": [
        "JOB-1",
        "JOB-2"
      ]
    }
  ]
}

Same resource relation

If a job needs to be done by the same resource throughout the planning period, then set the SAME_RESOURCE relation.

same resource
{
  "resources": [
    {
      "name": "R-1"
    }
  ],
  "jobs": [
    {
      "name": "JOB-1",
      "duration": 3600
    },
    {
      "name": "JOB-2",
      "duration": 3600
    },
    {
      "name": "JOB-3",
      "duration": 3600
    }
  ],
  "relations": [
    {
      "type": "SAME_RESOURCE",
      "jobs": [
        "JOB-1",
        "JOB-2"
      ]
    }
  ]
}