Forced Routes

In some cases, one may have a routing problem where the sequence of stops is already known and only the desired travel times, polylines, and driving directions are desired. In the first example, we have only a single vehicle with a single shift and we force it to visit a sequence of stops. Note that it would be very easy to add more stops to this route, but no optimization is done in this case. One important note is that the sequence of stops must be feasible for the associated shift – in other words, if MARE computes the travel time and determines that it is not possible to visit the provided sequence of stops within the time for the shift, then no route is returned. In this case, a simple solution may be to increase the length of the shift.

Single Forced Route

{
  "forced_routes": [
    {
      "shift_id": "v1 shift",
      "stops": [
        {
          "stop_id": "688798",
          "stop_type": "order"
        },
		{
          "stop_id": "677048",
          "stop_type": "order"
        },
		{
          "stop_id": "692039",
          "stop_type": "order"
        },
        {
          "stop_id": "690020",
          "stop_type": "order"
        },
        {
          "stop_id": "689105",
          "stop_type": "order"
        }
      ]
    }
  ],
  "constraints": [
    {
      "penalty_per_violation": 1,
      "violation_increment": 1,
      "constraint_name": "limit travel",
      "max_travel_time_seconds": 0,
      "constraint_type": "Travel_Time"
    },
    {
      "violation_increment": 1,
      "constraint_name": "visit as many orders as possible",
      "penalty_per_violation": 10000,
      "constraint_type": "Visit_Range"
    }
  ],
  "orders": [
    {
      "order_id": "688798",
      "duration": 60,
      "location_id": "loc1"
    },
    {
      "order_id": "689105",
      "duration": 60,
      "location_id": "loc3"
    },
    {
      "order_id": "692039",
      "duration": 60,
      "location_id": "loc5"
    },
    {
      "order_id": "583368",
      "duration": 60,
      "location_id": "loc6"
    },
    {
      "order_id": "677048",
      "duration": 60,
      "location_id": "loc7"
    },
    {
      "order_id": "685086",
      "duration": 60,
      "location_id": "loc8"
    },
    {
      "order_id": "690020",
      "duration": 60,
      "location_id": "loc9"
    }
  ],
  "vehicles": [
    {
      "shifts": [
        {
          "end_location_id": "loc11",
          "break_end": [
            "2017-08-24T13:00:00-04:00"
          ],
          "break_start": [
            "2017-08-24T12:00:00-04:00"
          ],
          "shift_start": "2017-08-24T08:00:00-04:00",
          "shift_id": "v1 shift",
          "start_location_id": "loc11",
          "shift_end": "2017-08-24T18:00:00-04:00"
        }
      ],
      "vehicle_id": "Vehicle 1"
    }
  ],
  "locations": [
    {
      "latitude": 33.3300399,
      "longitude": -84.07639,
      "location_id": "loc1"
    },
    {
      "latitude": 34.07687,
      "longitude": -84.52763,
      "location_id": "loc3"
    },
    {
      "latitude": 34.02463,
      "longitude": -84.1256499,
      "location_id": "loc5"
    },
    {
      "latitude": 33.78583,
      "longitude": -84.30268,
      "location_id": "loc6"
    },
    {
      "latitude": 34.07687,
      "longitude": -84.5738499,
      "location_id": "loc7"
    },
    {
      "latitude": 33.98557,
      "longitude": -83.7661399,
      "location_id": "loc8"
    },
    {
      "latitude": 34.02403,
      "longitude": -84.69128,
      "location_id": "loc9"
    },
    {
      "latitude": 33.57832,
      "longitude": -84.26431,
      "location_id": "loc11"
    }
  ]
}
The sequence of stops could be made more efficient but no re-ordering of a forced route is allowed.

Multiple Forced Routes

In this example, we force the routes for all four shifts. Note that breaks can be incorporated but again the sequence of stops in the route cannot be changed.

{
   "forced_routes": [
    {
      "stops": [
        {
          "stop_id": "loc20",
          "stop_type": "location"
        },
        {
          "stop_id": "665537",
          "stop_type": "order"
        },
        {
          "stop_id": "623404",
          "stop_type": "order"
        },
        {
          "stop_id": "688798",
          "stop_type": "order"
        },
        {
          "stop_id": "674660",
          "stop_type": "order"
        },
        {
          "stop_id": "685382",
          "stop_type": "order"
        },
        {
          "stop_id": "693854",
          "stop_type": "order"
        },
        {
          "stop_id": "688899",
          "stop_type": "order"
        },
        {
          "stop_id": "392888",
          "stop_type": "order"
        },
        {
          "stop_id": "413170",
          "stop_type": "order"
        },
        {
          "stop_id": "583368",
          "stop_type": "order"
        },
        {
          "stop_id": "691287",
          "stop_type": "order"
        },
        {
          "stop_id": "691449",
          "stop_type": "order"
        },
        {
          "stop_id": "678545",
          "stop_type": "order"
        },
        {
          "stop_id": "649953",
          "stop_type": "order"
        },
        {
          "stop_id": "693192",
          "stop_type": "order"
        },
        {
          "stop_id": "loc20",
          "stop_type": "location"
        }
      ],
      "shift_id": "v1shift"
    },
    {
      "stops": [
        {
          "stop_id": "loc99",
          "stop_type": "location"
        },
        {
          "stop_id": "690020",
          "stop_type": "order"
        },
        {
          "stop_id": "693098",
          "stop_type": "order"
        },
        {
          "stop_id": "683931",
          "stop_type": "order"
        },
        {
          "stop_id": "340637",
          "stop_type": "order"
        },
        {
          "stop_id": "loc99",
          "stop_type": "location"
        }
      ],
      "shift_id": "v2shift"
    },
    {
      "stops": [
        {
          "stop_id": "loc16",
          "stop_type": "location"
        },
        {
          "stop_id": "692431",
          "stop_type": "order"
        },
        {
          "stop_id": "685945",
          "stop_type": "order"
        },
        {
          "stop_id": "692829",
          "stop_type": "order"
        },
        {
          "stop_id": "685086",
          "stop_type": "order"
        },
        {
          "stop_id": "640723",
          "stop_type": "order"
        },
        {
          "stop_id": "loc16",
          "stop_type": "location"
        }
      ],
      "shift_id": "v3shift"
    },
    {
      "stops": [
        {
          "stop_id": "loc100",
          "stop_type": "location"
        },
        {
          "stop_id": "695124",
          "stop_type": "order"
        },
        {
          "stop_id": "677048",
          "stop_type": "order"
        },
        {
          "stop_id": "689105",
          "stop_type": "order"
        },
        {
          "stop_id": "694498",
          "stop_type": "order"
        },
        {
          "stop_id": "617086",
          "stop_type": "order"
        },
        {
          "stop_id": "693858",
          "stop_type": "order"
        },
        {
          "stop_id": "509217",
          "stop_type": "order"
        },
        {
          "stop_id": "692039",
          "stop_type": "order"
        },
        {
          "stop_id": "692592",
          "stop_type": "order"
        },
        {
          "stop_id": "695743",
          "stop_type": "order"
        },
        {
          "stop_id": "loc100",
          "stop_type": "location"
        }
      ],
      "shift_id": "v4shift"
    }
  ],
  "orders": [
    {
      "duration": 600,
      "order_id": "688798",
      "location_id": "loc1"
    },
    {
      "duration": 600,
      "order_id": "689105",
      "location_id": "loc3"
    },
    {
      "duration": 1800,
      "order_id": "692039",
      "location_id": "loc5"
    },
    {
      "duration": 600,
      "order_id": "583368",
      "location_id": "loc6"
    },
    {
      "duration": 600,
      "order_id": "677048",
      "location_id": "loc7"
    },
    {
      "duration": 600,
      "order_id": "685086",
      "location_id": "loc8"
    },
    {
      "duration": 600,
      "order_id": "690020",
      "location_id": "loc9"
    },
    {
      "duration": 600,
      "order_id": "674660",
      "location_id": "loc11"
    },
    {
      "duration": 600,
      "order_id": "413170",
      "location_id": "loc13"
    },
    {
      "duration": 600,
      "order_id": "685945",
      "location_id": "loc14"
    },
    {
      "duration": 600,
      "order_id": "692592",
      "location_id": "loc15"
    },
    {
      "duration": 600,
      "order_id": "678545",
      "location_id": "loc17"
    },
    {
      "duration": 600,
      "order_id": "692829",
      "location_id": "loc18"
    },
    {
      "duration": 600,
      "order_id": "695124",
      "location_id": "loc19"
    },
    {
      "duration": 600,
      "order_id": "693192",
      "location_id": "loc21"
    },
    {
      "duration": 600,
      "order_id": "649953",
      "location_id": "loc22"
    },
    {
      "duration": 600,
      "order_id": "694498",
      "location_id": "loc23"
    },
    {
      "duration": 600,
      "order_id": "693854",
      "location_id": "loc24"
    },
    {
      "duration": 600,
      "order_id": "688899",
      "location_id": "loc25"
    },
    {
      "duration": 600,
      "order_id": "617086",
      "location_id": "loc26"
    },
    {
      "duration": 600,
      "order_id": "340637",
      "location_id": "loc27"
    },
    {
      "duration": 600,
      "order_id": "693098",
      "location_id": "loc28"
    },
    {
      "duration": 600,
      "order_id": "683931",
      "location_id": "loc29"
    },
    {
      "duration": 600,
      "order_id": "685382",
      "location_id": "loc30"
    },
    {
      "duration": 600,
      "order_id": "691449",
      "location_id": "loc31"
    },
    {
      "duration": 600,
      "order_id": "509217",
      "location_id": "loc32"
    },
    {
      "duration": 600,
      "order_id": "691287",
      "location_id": "loc33"
    },
    {
      "duration": 600,
      "order_id": "640723",
      "location_id": "loc34"
    },
    {
      "duration": 600,
      "order_id": "665537",
      "location_id": "loc35"
    },
    {
      "duration": 600,
      "order_id": "693858",
      "location_id": "loc36"
    },
    {
      "duration": 600,
      "order_id": "392888",
      "location_id": "loc37"
    },
    {
      "duration": 600,
      "order_id": "623404",
      "location_id": "loc38"
    },
    {
      "duration": 600,
      "order_id": "695743",
      "location_id": "loc39"
    },
    {
      "duration": 600,
      "order_id": "692431",
      "location_id": "loc40"
    }
  ],
  "locations": [
    {
      "latitude": 33.3300399,
      "location_id": "loc1",
      "longitude": -84.07639
    },
    {
      "latitude": 33.5179638,
      "location_id": "loc2",
      "longitude": -84.4153667
    },
    {
      "latitude": 34.07687,
      "location_id": "loc3",
      "longitude": -84.52763
    },
    {
      "latitude": 33.73872,
      "location_id": "loc4",
      "longitude": -85.15883
    },
    {
      "latitude": 34.02463,
      "location_id": "loc5",
      "longitude": -84.1256499
    },
    {
      "latitude": 33.78583,
      "location_id": "loc6",
      "longitude": -84.30268
    },
    {
      "latitude": 34.07687,
      "location_id": "loc7",
      "longitude": -84.5738499
    },
    {
      "latitude": 33.98557,
      "location_id": "loc8",
      "longitude": -83.7661399
    },
    {
      "latitude": 34.02403,
      "location_id": "loc9",
      "longitude": -84.69128
    },
    {
      "latitude": 33.57832,
      "location_id": "loc11",
      "longitude": -84.26431
    },
    {
      "latitude": 33.56882,
      "location_id": "loc12",
      "longitude": -84.51451
    },
    {
      "latitude": 33.8200999,
      "location_id": "loc13",
      "longitude": -84.30606
    },
    {
      "latitude": 33.98078,
      "location_id": "loc14",
      "longitude": -84.02126
    },
    {
      "latitude": 33.98596,
      "location_id": "loc15",
      "longitude": -84.20871
    },
    {
      "latitude": 34.098671,
      "location_id": "loc16",
      "longitude": -83.789905
    },
    {
      "latitude": 33.68959,
      "location_id": "loc17",
      "longitude": -84.3739
    },
    {
      "latitude": 33.8965699,
      "location_id": "loc18",
      "longitude": -84.08495
    },
    {
      "latitude": 34.0078,
      "location_id": "loc19",
      "longitude": -84.5491
    },
    {
      "latitude": 33.44852,
      "location_id": "loc20",
      "longitude": -84.78468
    },
    {
      "latitude": 33.45099,
      "location_id": "loc21",
      "longitude": -84.7372199
    },
    {
      "latitude": 33.7084199,
      "location_id": "loc22",
      "longitude": -84.44377
    },
    {
      "latitude": 34.0286,
      "location_id": "loc23",
      "longitude": -84.37416
    },
    {
      "latitude": 33.82054,
      "location_id": "loc24",
      "longitude": -84.23121
    },
    {
      "latitude": 33.83828,
      "location_id": "loc25",
      "longitude": -84.21402
    },
    {
      "latitude": 34.05614,
      "location_id": "loc26",
      "longitude": -84.31995
    },
    {
      "latitude": 33.7435386,
      "location_id": "loc27",
      "longitude": -84.6712
    },
    {
      "latitude": 33.99045,
      "location_id": "loc28",
      "longitude": -84.8082699
    },
    {
      "latitude": 33.84614,
      "location_id": "loc29",
      "longitude": -84.7469
    },
    {
      "latitude": 33.68736,
      "location_id": "loc30",
      "longitude": -84.23972
    },
    {
      "latitude": 33.7757999,
      "location_id": "loc31",
      "longitude": -84.3845599
    },
    {
      "latitude": 34.19941,
      "location_id": "loc32",
      "longitude": -84.1556
    },
    {
      "latitude": 33.75112,
      "location_id": "loc33",
      "longitude": -84.35911
    },
    {
      "latitude": 33.9854531,
      "location_id": "loc34",
      "longitude": -83.707189
    },
    {
      "latitude": 33.52079,
      "location_id": "loc35",
      "longitude": -84.36567
    },
    {
      "latitude": 34.104,
      "location_id": "loc36",
      "longitude": -84.2661811
    },
    {
      "latitude": 33.88826,
      "location_id": "loc37",
      "longitude": -84.20234
    },
    {
      "latitude": 33.4439,
      "location_id": "loc38",
      "longitude": -84.32034
    },
    {
      "latitude": 33.96681,
      "location_id": "loc39",
      "longitude": -84.23654
    },
    {
      "latitude": 34.1162,
      "location_id": "loc40",
      "longitude": -83.81919
    },
    {
      "latitude": 34.07697,
      "location_id": "loc99",
      "longitude": -85.0148499
    },
    {
      "latitude": 33.9157,
      "location_id": "loc100",
      "longitude": -84.52097
    }
  ],
  "vehicles": [
    {
      "shifts": [
        {
          "end_location_id": "loc20",
          "shift_start": "2017-08-24T08:05:00-04:00",
          "break_start": [
            "2017-08-24T12:00:00-04:00"
          ],
          "shift_id": "v1shift",
          "shift_end": "2017-08-24T17:10:00-04:00",
          "break_end": [
            "2017-08-24T13:00:00-04:00"
          ],
          "start_location_id": "loc20"
        }
      ],
      "vehicle_id": "Vehicle1"
    },
    {
      "shifts": [
        {
          "end_location_id": "loc99",
          "shift_start": "2017-08-24T10:05:00-04:00",
          "break_start": [
            "2017-08-24T12:00:00-04:00"
          ],
          "shift_id": "v2shift",
          "shift_end": "2017-08-24T15:10:00-04:00",
          "break_end": [
            "2017-08-24T13:00:00-04:00"
          ],
          "start_location_id": "loc99"
        }
      ],
      "vehicle_id": "Vehicle2"
    },
    {
      "shifts": [
        {
          "end_location_id": "loc16",
          "shift_start": "2017-08-24T07:05:00-04:00",
          "break_start": [
            "2017-08-24T09:00:00-04:00"
          ],
          "shift_id": "v3shift",
          "shift_end": "2017-08-24T13:10:00-04:00",
          "break_end": [
            "2017-08-24T10:00:00-04:00"
          ],
          "start_location_id": "loc16"
        }
      ],
      "vehicle_id": "Vehicle3"
    },
    {
      "shifts": [
        {
          "end_location_id": "loc100",
          "shift_start": "2017-08-24T09:05:00-04:00",
          "break_start": [
            "2017-08-24T12:00:00-04:00"
          ],
          "shift_id": "v4shift",
          "shift_end": "2017-08-24T16:10:00-04:00",
          "break_end": [
            "2017-08-24T13:00:00-04:00"
          ],
          "start_location_id": "loc100"
        }
      ],
      "vehicle_id": "Vehicle4"
    }
  ],
  "constraints": [
    {
      "violation_increment": 1,
      "constraint_name": "limit travel",
      "penalty_per_violation": 1,
      "max_travel_time_seconds": 0,
      "constraint_type": "Travel_Time"
    },
    {
      "constraint_name": "visit as many orders as possible",
      "penalty_per_violation": 10000,
      "violation_increment": 1,
      "constraint_type": "Visit_Range"
    }
  ]
}