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

33 lines
2.1 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
description: API reference for qiskit.optimization.applications.ising.tsp
in_page_toc_min_heading_level: 2
python_api_type: module
python_api_name: 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. It supports only EUC\_2D edge weight type. See [https://wwwproxy.iwr.uni-heidelberg.de/groups/comopt/software/TSPLIB95/](https://wwwproxy.iwr.uni-heidelberg.de/groups/comopt/software/TSPLIB95/) and [http://elib.zib.de/pub/mp-testdata/tsp/tsplib/tsp/index.html](http://elib.zib.de/pub/mp-testdata/tsp/tsplib/tsp/index.html) 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) |