Time windows - fixing arrival time

In this example we will show you how to use time windows. Time windows are defined on jobs. A job can have a time
window. We will always ensure that the resource arrives at the beginning of the time window.

{
  "resources": [
    {
      "name": "R-1",
      "shifts": [
        {
          "from": "2023-01-01T08:00:00",
          "to": "2023-01-01T17:00:00"
        },
        {
          "from": "2023-01-02T08:00:00",
          "to": "2023-01-02T17:00:00"
        }
      ]
    }
  ],
  "jobs": [
    {
      "name": "JOB-1",
      "location": {
        "latitude": 50.54963315022148,
        "longitude": 4.848855475505483
      },
      "duration": 3600,
      "windows": [
        {
          "from": "2023-01-02T09:00:00",
          "to": "2023-01-02T10:00:00",
          "hard": true,
          "weight": 100
        }
      ]
    },
    {
      "name": "JOB-2",
      "location": {
        "latitude": 50.65910297910443600,
        "longitude": 4.007987934186738
      },
      "duration": 3600,
      "windows": [
        {
          "from": "2023-01-02T09:30:00",
          "to": "2023-01-02T10:30:00",
          "hard": true,
          "weight": 100
        }
      ]
    },
    {
      "name": "JOB-3",
      "location": {
        "latitude": 50.324969095932296,
        "longitude": 4.010111317974326
      },
      "duration": 3600
    },
    {
      "name": "JOB-4",
      "location": {
        "latitude": 50.53457539132416,
        "longitude": 4.69167867847318
      },
      "duration": 3600
    },
    {
      "name": "JOB-5",
      "location": {
        "latitude": 50.94837893617721,
        "longitude": 4.001604640663746
      },
      "duration": 3600
    },
    {
      "name": "JOB-6",
      "location": {
        "latitude": 50.89633806889935,
        "longitude": 4.45161298168845
      },
      "duration": 3600
    },
    {
      "name": "JOB-7",
      "location": {
        "latitude": 50.48191907288704,
        "longitude": 4.311723085641562
      },
      "duration": 3600
    },
    {
      "name": "JOB-8",
      "location": {
        "latitude": 50.1824046123600988,
        "longitude": 4.355240303516217
      },
      "duration": 3600
    },
    {
      "name": "JOB-9",
      "location": {
        "latitude": 50.09960152277046,
        "longitude": 4.46586698360070229
      },
      "duration": 3600
    },
    {
      "name": "JOB-10",
      "location": {
        "latitude": 50.78868282668716,
        "longitude": 4.167956383823208
      },
      "duration": 3600
    }
  ],
  "options": {
    "partialPlanning": true
  }
}
{
  "score": {
    "hardScore": 0,
    "mediumScore": -3600,
    "softScore": -21334,
    "feasible": true
  },
  "trips": [
    {
      "visits": [
        {
          "arrival": "2023-01-02T08:00:00",
          "job": "JOB-9",
          "location": "50.09960152277046;4.465866983600702"
        },
        {
          "arrival": "2023-01-02T10:18:01",
          "job": "JOB-2",
          "location": "50.65910297910444;4.007987934186738"
        },
        {
          "arrival": "2023-01-02T12:13:45",
          "job": "JOB-6",
          "location": "50.89633806889935;4.45161298168845"
        },
        {
          "arrival": "2023-01-02T13:59:47",
          "job": "JOB-4",
          "location": "50.53457539132416;4.69167867847318"
        }
      ],
      "resource": "R-1",
      "date": "2023-01-02",
      "departureTime": "2023-01-02T08:00:00",
      "waitTime": 0,
      "travelTime": 10787,
      "workTime": 25187,
      "serviceTime": 14400
    },
    {
      "visits": [
        {
          "arrival": "2023-01-01T08:00:00",
          "job": "JOB-8",
          "location": "50.1824046123601;4.355240303516217"
        },
        {
          "arrival": "2023-01-01T09:50:38",
          "job": "JOB-3",
          "location": "50.324969095932296;4.010111317974326"
        },
        {
          "arrival": "2023-01-01T11:33:03",
          "job": "JOB-7",
          "location": "50.48191907288704;4.311723085641562"
        },
        {
          "arrival": "2023-01-01T13:23:15",
          "job": "JOB-10",
          "location": "50.78868282668716;4.167956383823208"
        },
        {
          "arrival": "2023-01-01T14:55:42",
          "job": "JOB-5",
          "location": "50.94837893617721;4.001604640663746"
        }
      ],
      "resource": "R-1",
      "date": "2023-01-01",
      "departureTime": "2023-01-01T08:00:00",
      "waitTime": 0,
      "travelTime": 10542,
      "workTime": 28542,
      "serviceTime": 18000
    }
  ],
  "totalTravelTimeInSeconds": 21329,
  "totalServiceTimeInSeconds": 32400,
  "workloadFairness": 0.6666666666666666,
  "unserved": [
    "JOB-1"
  ],
  "status": "SOLVED"
}
{
  "score": {
    "hardScore": 0,
    "mediumScore": -3600,
    "softScore": -21334,
    "feasible": true
  },
  "unresolved": [
    {
      "constraint": "JOB_DAY_INDEX",
      "score": "-5soft"
    },
    {
      "constraint": "TRAVEL_TIME",
      "score": "-21329soft"
    },
    {
      "constraint": "UNUSED_RESOURCES",
      "score": "-3600medium"
    }
  ]
}