NLESC-quantum / quantum_comp

Apache License 2.0
0 stars 1 forks source link

Using QUBO to solve Linear systems #23

Closed NicoRenaud closed 2 years ago

NicoRenaud commented 2 years ago

We can use Quantum Anealler to solve linear systems. We first need to recast the problem as a QUBO and then implement it on the the QA architecture.

Some work has been done in that area already

PabRod commented 2 years ago

Quick and dirty implementation in Python:

def non_square_solver(A, b):
    """ Solve an overdetermined system 

    The system Ax = b, where A is a non-square matrix,
    can be turned into a square-matrix problem by

    A^t A x = A^t b

    Q x = c

    x = Q^{-1} c
    """
    At = np.transpose(A)
    Q = np.matmul(At, A)
    c = np.matmul(At, b)

    Qinv = np.linalg.inv(Q)

    return np.matmul(Qinv, c)
NicoRenaud commented 2 years ago

we have it implemented and its also part of qalcore now