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