Skip to main content

View on GitHub

Open this notebook in GitHub to run it yourself
Author: Bill Wisotsky
Currently, more than 100,000 patients are on the waiting list in the United States for a kidney transplant from a deceased donor. This is addressed by a program called the Kidney Exchange Program. This program won the 2012 Nobel Prize in Economics for Alvin E. Roth and Lloyd S. Shapley’s contributions to the theory of stable matchings and the design of markets. In summary, in a donor pair, the recipient needs a kidney transplant and a donor is willing to give a kidney to the recipient. About 13\frac{1}{3} of those pairs are not compatible for a direct exchange. This is tackled by considering two incompatible pairs together: Donor 1 may be compatible with Recipient 2, and Donor 2 may be compatible with Recipient
  1. In this example, a two-way swap becomes feasible.
This is the core of the kidney exchange program. This is considered an NP-Hard combinatorial optimization problem that becomes exponentially more difficult as the size of the pool increases. The longest chain in history involved 35 tranplants in the United States in

Creating a Pyomo Model for a Simple Kidney Exchange Problem

In this very simple example, patients and donors represent sets of patients who receive a kidney from a donor. Compatibility is a dictionary mapping of patient-donor pairs to their compatibility scores. Binary decision variables are defined for each patient-donor pair x[donor,patient]. The objective is to maximize the total compatibility score: Maximized,pAmMcdpxdpm Maximize \sum_{d,p\in A}^{} \sum_{m\in M}c_{dp}x_{dpm} where
  • d=donors
  • p=patients
  • c=compatability score
Contraints are added to ensure that each donor donates only once d,pAxdpm=ydm\sum_{d,p\in A}^{}x_{dpm} = y_{dm} and each patient receives once d,pAxdpm=ypm\sum_{d,p\in A}^{}x_{dpm} = y_{pm}. Create a PYOMO model to feed into Classiq, as illustrated in the Classiq documentation. Start by solving with a classical solver to get initial results for comparison to the QAOA results at the end.
Output:

Generating the QAOA Process

Creating Parameters for the Quantum Circuit

Create the initial parameters, modifying them when necessary:
  1. Define the number of layers (num_layers) of the QAOA ansatz.
  2. Define penalty_energy for invalid solutions, which influences the convergence rate.
While smaller positive values are preferred, you may have to tweak them.

Forming the QAOA model as a Qmod

Combine everything together to form the entire QAOA model as a Qmod:
  1. Synthesize the quantum model.
  2. Show the quantum model in the Classiq platform.
Output:
Output:

Defining the Classical Optimizer Part of the QAOA

Modify these parameters:
  • max_iterations - maximum number of optimizer iterations, set to
  • quantile - describes the quantile considered in the CVaR expectation value.
See [1] for more information. Execute the quantum model and store the result.
View the convergence graph.
NOTE: When looking at the graph, recall that this is a maximization problem.
Output:
output

Retrieving and Displaying the Solutions

To view the solutions:
  • Print them out
  • Graph them using a histogram
  • Show `Donor
  • Recipients` in Network Graph

Print out the top 10 solutions with the highest cost or objective:
Output:

Histogram of Cost, Weighted by Probability

output

Creating a Network Graph

Create a network graph for the best solution found. NOTE: This is a maximization problem and the classical solver of the QAOA process returns all possible results. Filter out the solution with the highest cost that represents the the highest compatability score:
Output:
output

References

[1] Barkoutsos, P. K., Nannicini, G., Robert, A., Tavernelli, I., & Woerner, S. (2020). Improving variational quantum optimization using CVaR. Quantum, 4, 256.