Skip to main content

vrp

VRP or Vehicle Routing problem is a generalization of the Travelling Salesman Problem. The goal of the problem is to find the shortest route that visits each node once, starting and finishing from the same node, called a depot, while using a fleet of vehicles. Each vehicle does not need to be at every location, it is enough that every node is visited by at least one vehicle. The problem is NP-hard in optimization, and therefore methods such as constraint programming, approximations or heuristics are a good approach for solving. The current implementation of VRP includes constraint programming with GEKKO solver which works with 1 depot and an arbitrary number of vehicles. The algorithm uses the distance calculator to determine the distance between driving points, and works only with geographical locations, meaning each node needs to have its lat and lng property.

(location:Location {lat: 44.1194, lng: 15.2314})

docs-source

TraitValue
Module typemodule
ImplementationPython
Graph directionundirected
Edge weightsunweighted
Parallelismsequential
Too slow?

If this algorithm implementation is too slow for your use case, contact us and request a rewrite to C++ !

Proceduresโ€‹

info

If you want to execute this algorithm on graph projections, subgraphs or portions of the graph, be sure to check out the guide on How to run a MAGE module on subgraphs.

route(depot_node, number_of_vehicles)โ€‹

Input:โ€‹

  • depot_node: Vertex โžก Depot node with its corresponding lat and lng coordinate properties.
  • number_of_vehicles: integer = 1 โžก Designates how many vehicles are used. Set to 1 by default

Output:โ€‹

  • from_vertex: Vertex โžก Beginning point of one part of the route
  • to_vertex: Vertex โžก Ending point of one part of the route
  • vehicle_id: integer โžก Vehicle ID that will drive the corresponding path (from_vertex)->(to_vertex) All pairs of the route represent the full route with all vehicles used.

Usage:โ€‹

MATCH (d:Depot)
CALL vrp.route(d) YIELD from_vertex, to_vertex, vehicle_id;

Exampleโ€‹