qiskit-documentation/docs/api/qiskit/0.31/qiskit.optimization.applica...

35 lines
1.9 KiB
Plaintext
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: tsp (v0.31)
description: API reference for qiskit.optimization.applications.ising.tsp in qiskit v0.31
in_page_toc_min_heading_level: 2
python_api_type: module
python_api_name: qiskit.optimization.applications.ising.tsp
---
<span id="module-qiskit.optimization.applications.ising.tsp" />
<span id="qiskit-optimization-applications-ising-tsp" />
# qiskit.optimization.applications.ising.tsp
Convert symmetric TSP instances into Pauli list Deal with TSPLIB format. Design the tsp object w as a two-dimensional np.array e.g., w\[i, j] = x means that the length of a edge between i and j is x Note that the weights are symmetric, i.e., w\[j, i] = x always holds.
**Functions**
| | |
| --------------------------------------------------- | -------------------------------------------- |
| `calc_distance`(coord\[, name]) | calculate distance |
| `get_operator`(ins\[, penalty]) | Generate Hamiltonian for TSP of a graph. |
| `get_tsp_solution`(x) | Get graph solution from binary string. |
| `parse_tsplib_format`(filename) | Read graph in TSPLIB format from file. |
| `random_tsp`(n\[, low, high, savefile, seed, name]) | Generate a random instance for TSP. |
| `tsp_feasible`(x) | Check whether a solution is feasible or not. |
| `tsp_value`(z, w) | Compute the TSP value of a solution. |
**Classes**
| | |
| ------------------------------ | --------------------------------------------------- |
| `TspData`(name, dim, coord, w) | Create new instance of TspData(name, dim, coord, w) |