qiskit.optimization.applications.ising.vehicle_routing¶
Converts vehicle routing instances into a list of Paulis, and provides some related routines (extracting a solution, checking its objective function value).
Functions

Converts an instance of a vehicle routing problem into a list of Paulis. 

Computes the cost of a solution to an instance of a vehicle routing problem. 

Constructs auxiliary matrices from a vehicle routing instance, 

Tries to obtain a feasible solution (in vector form) of an instance 

get_operator
(instance, n, K)[código fonte]¶ Converts an instance of a vehicle routing problem into a list of Paulis.
 Parâmetros
instance (
ndarray
) – a customerstocustomers distance matrix.n (
int
) – the number of customers.K (
int
) – the number of vehicles available.
 Tipo de retorno
WeightedPauliOperator
 Retorna
operator for the Hamiltonian.

get_vehiclerouting_cost
(instance, n, K, x_sol)[código fonte]¶ Computes the cost of a solution to an instance of a vehicle routing problem.
 Parâmetros
instance (
ndarray
) – a customerstocustomers distance matrix.n (
int
) – the number of customers.K (
int
) – the number of vehicles available.x_sol (
ndarray
) – a solution, i.e., a path, in its binary representation.
 Tipo de retorno
float
 Retorna
objective function value.

get_vehiclerouting_matrices
(instance, n, K)[código fonte]¶  Constructs auxiliary matrices from a vehicle routing instance,
which represent the encoding into a binary quadratic program. This is used in the construction of the qubit ops and computation of the solution cost.
 Parâmetros
instance (
ndarray
) – a customerstocustomers distance matrix.n (
int
) – the number of customers.K (
int
) – the number of vehicles available.
 Tipo de retorno
Tuple
[ndarray
,ndarray
,float
] Retorna
a matrix defining the interactions between variables. a matrix defining the contribution from the individual variables. the constant offset.

get_vehiclerouting_solution
(instance, n, K, result)[código fonte]¶  Tries to obtain a feasible solution (in vector form) of an instance
of vehicle routing from the results dictionary.
 Parâmetros
instance (
ndarray
) – a customerstocustomers distance matrix.n (
int
) – the number of customers.K (
int
) – the number of vehicles available.result (
MinimumEigensolverResult
) – a result obtained by QAOA.run or VQE.run.
 Tipo de retorno
List
[int
] Retorna
a solution, i.e., a path, in its binary representation.
 #TODO: support statevector simulation, results should be a statevector or counts format, not
a result from algorithm run