Tutorial on Quantum Optimization
This document outlines the steps to set up the development environment for the project. Due to dependencies such as CPLEX, which currently supports up to Python 3.10, it is essential to use Python 3.10 or earlier.
(or you can use uv)
Ensure that Python 3.10 is installed on your system.
To verify your Python version, run:
python --version
# or
python3 --version
If Python 3.10 is not installed, follow the instructions below based on your operating system:
- Windows: Download from python.org
- macOS: Use
brew install python@3.10(if available) - Linux (Debian/Ubuntu): Install via
apt(see troubleshooting section)
⚠️ Note: Avoid using Python versions newer than 3.10 to ensure compatibility with CPLEX and other dependencies.
Begin by cloning the project repository:
git clone https://github.com/SMU-Quantum/AMSI_Winter_School_Quantum_Tutorial.git
cd AMSI_Winter_School_Quantum_Tutorial
Using a virtual environment is strongly recommended to isolate project dependencies.
python3.10 -m venv venv
On Windows, if
python3.10is not recognized, use:py -3.10 -m venv venv
| OS | Activation Command |
|---|---|
| Windows | venv\Scripts\activate |
| macOS | source venv/bin/activate |
| Linux | source venv/bin/activate |
After activation, you should see (venv) prefixed in your shell prompt.
Confirm that the correct Python interpreter is being used:
python --version
Expected output:
Python 3.10.x
Install all required packages from the requirements.txt file:
pip install -r requirements.txt
Ensure the virtual environment is active before running this command.
Install Python 3.10 and required components:
sudo apt update
sudo apt install python3.10 python3.10-venv python3.10-dev
Then create the virtual environment:
python3.10 -m venv venv
Install Python 3.10 using Homebrew:
brew install python@3.10
Due to Homebrew's path structure, you may need to use the full path:
# Intel Mac
/usr/local/bin/python3.10 -m venv venv
# Apple Silicon (M1/M2/M3)
/opt/homebrew/bin/python3.10 -m venv venv
Use the Python Launcher for Windows:
py -3.10 -m venv venv
This method reliably targets Python 3.10 even when multiple versions are installed.
"Quantum Computers can evaluate all possible solutions at the same time..."
→ A common misunderstanding, particularly for combinatorial optimization!
Suppose the equal superposition state:
Furthermore, suppose a function
Thus, we get:
And the quantum computer evaluates the exponential number of solutions in parallel!
Doesn't it?
Unfortunately:
- It remains an exponential number of possible solutions.
- The quantum computer does NOT tell us which one achieves the optimum.
- If we measure the qubits in the state above, we just sample every possible solution with the same probability of
$\frac{1}{2^n}$ , as we could easily do classically.
→ To get a quantum computer to tell us the optimal solution of a combinatorial optimization problem with probability higher than