Skip to main content

View on GitHub

Open this notebook in GitHub to run it yourself
This notebook shows how to implement the QuSO algorithm for the cooling system problem presented in the paper: Quantum Simulation-Based Optimization of a Cooling System.

Matrix Block Encoding

As discussed in the paper, we simulate the cooling system cooling_system.png by solving the linear system of equations A(x)T~=B,A(x)\tilde{T}=B, where A(x)A(x) is the system matrix depending on the binary values xijx_{ij}, T~\tilde{T} is the temperature vector, and BB is the vector containing the external heat or cooling sources. In order to solve the system above, we need to block encode matrix A(x)A(x), which will be shown in the following:
For exampe, if we consider the case where all connections are switched on, we want to encode this matrix:
Output:
Let’s do that using our block encoding:
Output:
Output:
Output:
We have successfully block-encoded the matrix from above!

QSVT for Matrix Inversion and Solving Our Linear System

Next, we use our block encoding to solve our linear system (cf. above). Since this is a fixed, classically-known matrix (not yet conditioned on the quantum connection-switch register used later), we can use BlockEncoding.inverse() directly to build the QSVT-based matrix inversion.
output
Output:

Synthesize Circuit

Output:

Execute Circuit

Output:
Output:
As the QSVT result agrees with the classical solution of our linear system up to an acceptable error, we have successfully solved the linear system using QSVT. The QuSO algorithm below still needs its own, manually-constructed QSVT solver (qsvt_solve_system, using the phases computed above), because it must share a single QSVT phase sequence across a superposition of possible connection configurations — a single BlockEncoding object (and its .inverse()) only encodes one fixed matrix, so it can’t represent that quantum-controlled family of matrices.

QuSO Algorithm

Only a few operations are missing to build the QuSO algorithm. In the following, we will implement the Quantum Amplitude Estimation (QAE) and Quantum Phase Application (QPA) routine to embed all operations in a QuSO circuit.
We take 5 QPE phase qubits qpe_phase_size.
Note: The circuit becomes very big. Thus, we do not synthesize the circuit in this demo-notebook because it takes a lot of time.
As explained in the paper, we can still simulate how QuSO would perform by preparing the state after QAE instead of running QAE. In this example, we synthesize the circuit with one layer of QAOA and 1 phase qubit n_phase_qubits to shoten the synthesis time. You can increase n_phase_qubits to 5 and get better results.

Synthesizing the Variational Circuit

Output:
Output:
Output:
By using more phase qubits and optimizing on the gamma and betas parameters, you can find the optimal solution with high probability.