quantum_launcher.problems.problem_formulations.hamiltonians.tsp

quantum_launcher.problems.problem_formulations.hamiltonians.tsp#

Summary#

Functions:

make_connection_hamiltonian

Creates a Hamiltonian that represents the costs of picking each path.

make_non_collision_hamiltonian

Creates a Hamiltonian representing constraints for the TSP problem.

problem_to_hamiltonian

Creates a Hamiltonian for the TSP problem.

Reference#

quantum_launcher.problems.problem_formulations.hamiltonians.tsp.make_non_collision_hamiltonian(node_count: int, quadratic=False)[source]#

Creates a Hamiltonian representing constraints for the TSP problem. (Each node visited only once, one node per timestep) Qubit mapping: [step1:[node1, node2,… noden]],[step2],…[stepn]

Parameters:
  • node_count (int) – Number of nodes in the TSP problem

  • quadratic – Whether to encode as a QUBO problem

Returns:

Hamiltonian representing the constraints

Return type:

np.ndarray

quantum_launcher.problems.problem_formulations.hamiltonians.tsp.make_connection_hamiltonian(edge_costs: ndarray, return_to_start: bool = True) ndarray[source]#

Creates a Hamiltonian that represents the costs of picking each path.

Parameters:

tsp_matrix – Edge cost matrix of the TSP problem

Returns:

Optimal chain of nodes to visit

Return type:

np.ndarray

quantum_launcher.problems.problem_formulations.hamiltonians.tsp.problem_to_hamiltonian(problem: TSP, constraints_weight: int = 5, costs_weight: int = 1, return_to_start: bool = True, onehot: Literal['exact', 'quadratic'] = 'exact') ndarray[source]#

Creates a Hamiltonian for the TSP problem.

Parameters:
  • problem (TSP) – TSP problem instance

  • quadratic – Whether to encode as a quadratic Hamiltonian

  • constraints_weight (int) – Weight of the constraints in the Hamiltonian

  • costs_weight (int) – Weight of the costs in the Hamiltonian

Returns:

Hamiltonian representing the TSP problem

Return type:

np.ndarray