A compact research scaffold to explore a Variational Quantum Eigensolver approach for the Permutation Flow Shop Problem.
- 🧩 PFSP utilities with exact evaluation and a brute‑force optimum for tiny instances.
- ⚛️ VQE runner that builds a
RealAmplitudescircuit, samples bitstrings, decodes them into job permutations, and optimizes the average makespan with SPSA → COBYLA.
If you use this code, please cite and see the companion paper:
- A Variational Quantum Algorithm for the Permutation Flow Shop Scheduling Problem — Baioletti, Fagiolo, Oddi, Rasconi (GECCO ’25 Companion, Malaga). [📄 PDF]
problem.py— PFSP utilities- 📥 Load Taillard‑like instances
- 🔢 Map integers/bitstrings to permutations (Lehmer‑like decoding)
- 🧮 Compute makespan for a permutation
- 🧪 (For small
n) brute‑force the optimum
vqe_pfsp.py— VQE experiment driver- 🧱 Builds a
RealAmplitudesansatz sized to ~log2(n!)qubits and measures all qubits - 🎯 Objective = empirical average makespan over measurement outcomes
- 🛠️ Optimizers: coarse SPSA, then COBYLA
- 📝 Batch runner over multiple instances and job sizes; results appended to
results/results_vqe_pfsp.csv
- 🧱 Builds a
Note
Python ≥ 3.9 is recommended.
Install all dependencies from the pinned list:
pip install -r requirements.txtImportant
If you upgrade packages, make sure the sampler/optimizer APIs used in the code still match your versions.
The loader expects a text format like Taillard’s PFSP instances:
- line 1: comment/header (ignored)
- line 2:
nj nm(numbers of jobs and machines) - line 3: comment/header (ignored)
- then
nmlines, each withnjintegers, listing the processing‑time column (machine‑wise).
Internally, times are stored as an array
ptime[j, m](job‑major, machine indexmin columns).
Example (not an actual instance):
Taillard PFSP instance
5 3
processing times by machine
2 5 7 4 3
1 3 9 2 4
6 4 2 8 5
- Put your Taillard instances somewhere (e.g.,
../Taillard/). - Run the batch experiments (from the repo root or adjust paths accordingly):
python vqe_pfsp.pyDefault main runs:
- pattern:
../Taillard/tai20_5_*.fsp - jobs list:
[2, 3, 4, 5, 6] - runs per (instance, n_jobs):
5
Results are appended to:
results/results_vqe_pfsp.csv
To customize, open vqe_pfsp.py and change the default arguments of VQE.run_experiments(...) or call it manually from a notebook/script.
Tip
For reproducibility, set a NumPy seed at the entry point before running experiments.
- 🧠 Encoding via Lehmer‑like decoding from measured bitstrings
- 🔢 Qubits ≈
(log2(n!)) - 📈 Objective: average makespan over shot samples
- 🧪 Small‑
nbrute force provides a ground‑truth optimum for sanity checks
This project is licensed under the MIT License.
See the LICENSE file for details.
Made with ⚛️ and a pinch of 🧪