Skip to content

Games and learning

quantum_tsp_tutorials

Maintained by mstechly

This repository contains code with tutorials of how to approach optimization problems using quantum computing.

Jupyter NotebookApache-2.0
quantum_tsp_tutorials illustration

Resource snapshot

Category

Games and learning

Stars

107

Last pushed

Jun 25, 2023Updated 3y ago

Open issues

1

What it is

quantum_tsp_tutorials is maintained by mstechly and sits in the Games and learning lane of the open-source quantum map.

This repository contains code with tutorials of how to approach optimization problems using quantum computing.

Last verified by Qtangl generator on May 27, 2026

Who it's for

Beginners, educators, and curious developers who want a more approachable path into quantum concepts.

What you can build or learn

  • Get a gentler introduction before diving into full SDKs.
  • See how different projects teach circuits, superposition, and measurement.
  • Identify resources that work well for onboarding or self-study.

Code samples

Examples from the repository.

01 Introduction To Tsp (tutorials/01_Introduction_to_TSP.ipynb)
def create_cities(N):
    """
    Creates an array of random points of size N.
    """
    cities = []
    for i in range(N):
        cities.append(np.random.rand(2) * 10)
    return np.array(cities)
02 Qaoa (tutorials/02_QAOA.ipynb)
import numpy as np
from grove.pyqaoa.maxcut_qaoa import maxcut_qaoa
import pyquil.api as api
qvm_connection = api.QVMConnection()
03 Naive Approach (tutorials/03_Naive_approach.ipynb)
import numpy as np
%matplotlib inline


def points_order_to_binary_state(points_order):
    """
    Transforms the order of points from the standard representation: [0, 1, 2],
    to the binary one: [1,0,0,0,1,0,0,0,1]
    """
    number_of_points = len(points_order)
    binary_state = np.zeros((len(points_order))**2)
    for j in range(len(points_order)):
        p = points_order[j]
        binary_state[(number_of_points) * (j) + (p)] = 1
    return binary_state

def binary_state_to_points_order(binary_state):
    """
    Transforms the the order of points from the binary representation: [1,0,0,0,1,0,0,0,1],
    to the binary one: [0, 1, 2]
    """
    points_order = []
    number_of_points = int(np.sqrt(len(binary_state)))
    for p in range(number_of_points):
        for j in range(number_of_points):
            if binary_state[(number_of_points) * p + j] == 1:
                points_order.append(j)
    return points_order

License

Apache-2.0

SPDX identifier detected from the repository metadata or license files.

Repository README

Preview from the project README.

Rendered as Markdown inside a scrollable preview. Long READMEs stay contained; expand or open on GitHub for the full document.

~386 words · about 2 min readOpen on GitHub

Quantum TSP tutorial

Introduction

This repository contains code with tutorials on how to approach optimization problems using quantum computing. I used Travelling Salesman Problem for this tutorials, though the idea is, that after finishing it, you should be able to implement any similar optimization problem.

Is this tutorial right for you?

I have created this tutorial with specific audience in mind. It means people, who:

  • are curious about quantum computing,
  • don't have any background in quantum physics,
  • have some programming experience,
  • really want to learn this topic.

The last point is the most important. My goal here is not to show you how to solve TSP with a quantum computer. My goal is to teach you how to solve optimization problems with QC, make sure your solution works and how to improve it. To do all that you need to put some effort into it and spend a couple of hours trying to understand all the concepts. But this is on purpose - this is the best way I know to actually learn the topic and integrate this knowledge.

I did my best to provide you with all the necessary knowledge, code examples etc. If you think something is not clear, missing, you have a better idea - well, I encourage you to do one of these two things:

I don't want to say that it is super advanced and hard - as stated earlier, you don't have to be a quantum computing expert.

Dependencies

In this tutorial I used pyquil 2.2.1 and grove 1.7.0 . API of these librares may change in next versions - let me know if something is broken so I can fix it :)

About the author

My name is Michał and I work as Quantum Software Engineer at Zapata Computing. You can find more materials onmy blog Musty thoughts.

If you want to contact me - feel free to do so: michal.stechy@gmail.com .

Unitary Fund

This project is supported by Unitary Fund. If you have an idea for an open-source project for near term hybrid quantum-classical programming, this is a good place for you!

Thanks

Thanks to Jacek Łysiak and Katerina Gratsea for feedback!

Read on GitHub

Activity

Latest release

—

Watchers

4

Python support

—

Learn digest

Get monthly updates when library entries change.

Monthly digest: new library entries, updated flagships, and one editorial pick.

Related resources

Keep exploring nearby tools.

quantumlib

Cirq

Python framework for creating, editing, and running Noisy Intermediate-Scale Quantum (NISQ) circuits.

PythonApache-2.0Flagship

4,971 stars · Updated 3mo ago

XanaduAI

pennylane

PennyLane is an open-source quantum software platform for quantum computing, quantum machine learning, and quantum chemistry.

PythonApache-2.0FlagshipQtangl relevant

3,229 stars · Updated 3mo ago

QISKit

qiskit

Qiskit is an open-source SDK for working with quantum computers at the level of extended quantum circuits, operators, and primitives.

PythonApache-2.0FlagshipQtangl relevant

7,412 stars · Updated 3mo ago

stared

quantum-game

Quantum Game (old version) - a puzzle game with real quantum mechanics in a browser

JavaScriptMITFlagshipArchive

359 stars · Updated 10mo ago

Microsoft

QuantumKatas

Tutorials and programming exercises for learning Q# and quantum computing

Jupyter NotebookMITFlagshipArchive

4,862 stars · Updated 2y ago

Strilanc

Quirk

A drag-and-drop quantum circuit simulator that runs in your browser.

JavaScriptApache-2.0Flagship

1,080 stars · Updated 2y ago