setup_exact_model

setup_exact_model(lse)[source]

Construct a cvxpy.Problem for finding exact static MPF coefficients.

Note

The coefficients found via this optimization problem will be identical to the analytical ones obtained from the LSE.solve() method. This additional interface exists to highlight the parallel to the setup_approximate_model() interface. It also serves educational purposes for how-to approach optimization problems targeting MPF coefficients.

The optimization problem constructed by this class is defined as follows:

  • the cost function minimizes the L1-norm (norm1) of the variables (LSE.x)

  • the constraints correspond to each equation of the LSE:

    \[\sum_j A_{ij} x_j = b_i\]

Here is an example:

>>> from qiskit_addon_mpf.static import setup_lse, setup_exact_model
>>> lse = setup_lse([1,2,3], order=2, symmetric=True)
>>> problem, coeffs = setup_exact_model(lse)
>>> print(problem)
minimize norm1(x)
subject to Sum([1. 1. 1.] @ x, None, False) == 1.0
           Sum([1. 0.25   0.11111111] @ x, None, False) == 0.0
           Sum([1. 0.0625 0.01234568] @ x, None, False) == 0.0

You can then solve the problem and extract the expansion coefficients like so:

>>> final_cost = problem.solve()
>>> print(coeffs.value)  
[ 0.04166667 -1.06666667  2.025     ]
Parameters:

lse (LSE) – the linear system of equations from which to build the model.

Returns:

The optimization problem and coefficients variable.

Return type:

tuple[Problem, Variable]

References

[1]: A. Carrera Vazquez et al., Quantum 7, 1067 (2023).

https://quantum-journal.org/papers/q-2023-07-25-1067/