Feature request: Turn restrictions

Hi!

Could the optimization solution please take into account turn restriction data, like the route API service does? The results returned in our testing would be greatly improved!

Luke

We are working on it. But even if this heavy PR is done we still have a lot more to do to consider this in the Route Optimization API without a really bad performance.

Hey, @karussell. Just checking if there was any progress made on this feature.

Yes, this is implemented since several years and also deployed and used by default for all motor vehicles in the GraphHopper Directions API: Turn Restriction Support for GraphHopper's Directions API - GraphHopper Directions API

Do you have problem with this somewhere?

@karussell Ah my bad, sorry! I misinterpreted this thread, I was looking for specifying turn costs and avoiding u-turns (even though they might not be restricted by the mapping data).

Currently there are no turn costs considered and we restrict u-turns only for truck and bigger angles (if there is no restriction in the mapping data).

@karussell Thanks. If it is currently expected to avoid big u-turns for trucks, would this be a bug? Happy to file it if so. This is a route for a truck that does 2 u-turns, but it could do the route without any.

Optimization request:

{
  "configuration": {
    "routing": {
      "calc_points": true,
      "return_snapped_waypoints": true
    }
  },
  "objectives": [
    {
      "type": "min",
      "value": "completion_time"
    }
  ],
  "vehicles": [
    {
      "vehicle_id": "v1",
      "type_id": "custom_vehicle_type",
      "start_address": {
        "location_id": "v1",
        "lat": 45.452675,
        "lon": -73.887324
      },
      "end_address": {
        "location_id": "end",
        "lat": 45.454196,
        "lon": -73.889089
      },
      "earliest_start": 1508839200,
      "return_to_depot": true
    }
  ],
  "vehicle_types": [
    {
      "type_id": "custom_vehicle_type",
      "profile": "truck"
    }
  ],
  "services": [
    {
      "id": "s1",
      "type": "service",
      "address": {
        "location_id": "s1",
        "lat": 45.452845,
        "lon": -73.889637
      },
      "duration": 120
    },
    {
      "id": "s2",
      "type": "service",
      "address": {
        "location_id": "s2",
        "lat": 45.453474,
        "lon": -73.8896
      },
      "duration": 120
    }
  ]
}

Note that there is a difference between turn costs inside a route like for sharp turns and I was referring to that when I said “we restrict u-turns only for truck and bigger angles”.

And then there can be U-turns at via points. You can also avoid them (for all motor vehicles) and you need to specify the curbside parameter like "curbside": "right" in the address of at least one address. This will also enforce that there are no U-turns. To avoid an error for incorrect locations in oneways you need to set curbside_strictness to “soft”. (Can be also done on the vehicle_types level which is sometimes necessary e.g. if you mix motor vehicle profiles with outdoor profiles like bike.)