VehicleRouting#

class VehicleRouting(graph, num_vehicles=2, depot=0)[source]#

Bases: GraphOptimizationApplication

Optimization application for the "vehicle routing problem" [1] based on a NetworkX graph.

References

[1]: "Vehicle routing problem", https://en.wikipedia.org/wiki/Vehicle_routing_problem

প্যারামিটার:
  • graph (Graph | ndarray | List) -- A graph representing a problem. It can be specified directly as a NetworkX graph, or as an array or list format suitable to build out a NetworkX graph.

  • num_vehicles (int) -- The number of vehicles

  • depot (int) -- The index of the depot node where all the vehicle depart

Attributes

depot#

Getter of depot

রিটার্নস:

The node index of the depot where all the vehicles depart

graph#

Getter of the graph

রিটার্নস:

A graph for a problem

num_vehicles#

Getter of num_vehicles

রিটার্নস:

The number of the vehicles

Methods

static create_random_instance(n, low=0, high=100, seed=None, num_vehicle=2, depot=0)[source]#

Create a random instance of the vehicle routing problem.

প্যারামিটার:
  • n (int) -- the number of nodes.

  • low (int) -- The minimum value for the coordinate of a node.

  • high (int) -- The maximum value for the coordinate of a node.

  • seed (int | None) -- the seed for the random coordinates.

  • num_vehicle (int) -- The number of the vehicles

  • depot (int) -- The index of the depot node where all the vehicle depart

রিটার্নস:

A VehicleRouting instance created from the input information

রিটার্ন টাইপ:

VehicleRouting

draw(result=None, pos=None)#

Draw a graph with the result. When the result is None, draw an original graph without colors.

প্যারামিটার:
interpret(result)[source]#

Interpret a result as a list of the routes for each vehicle

প্যারামিটার:

result (OptimizationResult | ndarray) -- The calculated result of the problem

রিটার্নস:

A list of the routes for each vehicle

রিটার্ন টাইপ:

List[List[List[int]]]

static sample_most_likely(state_vector)#

Compute the most likely binary string from state vector.

প্যারামিটার:

state_vector (QuasiDistribution | Statevector | ndarray | Dict) -- state vector or counts or quasi-probabilities.

রিটার্নস:

binary string as numpy.ndarray of ints.

রেইজেস:

ValueError -- if state_vector is not QuasiDistribution, Statevector, np.ndarray, or dict.

রিটার্ন টাইপ:

ndarray

to_quadratic_program()[source]#

Convert a vehicle routing problem instance into a QuadraticProgram

রিটার্নস:

The QuadraticProgram created from the vehicle routing problem instance.

রিটার্ন টাইপ:

QuadraticProgram