@@ -40,6 +40,7 @@ class TomographyFitter:
4040 """Base maximum-likelihood estimate tomography fitter class"""
4141
4242 _HAS_SDP_SOLVER = None
43+ _HAS_SDP_SOLVER_NOT_SCS = False
4344
4445 def __init__ (self ,
4546 result : Union [Result , List [Result ]],
@@ -120,12 +121,14 @@ def fit(self,
120121 ** kwargs ) -> np .array :
121122 r"""Reconstruct a quantum state using CVXPY convex optimization.
122123
123- **Fitter method**
124+ **Fitter method**
124125
125- The ``cvx`` fitter method used CVXPY convex optimization package.
126- The ``lstsq`` method uses least-squares fitting (linear inversion).
127- The ``auto`` method will use 'cvx' if the CVXPY package is found on
128- the system, otherwise it will default to 'lstsq'.
126+ The ``'cvx'`` fitter method uses the CVXPY convex optimization package
127+ with a SDP solver.
128+ The ``'lstsq'`` method uses least-squares fitting.
129+ The ``'auto'`` method will use ``'cvx'`` if the both the CVXPY and a suitable
130+ SDP solver packages are found on the system, otherwise it will default
131+ to ``'lstsq'``.
129132
130133 **Objective function**
131134
@@ -165,9 +168,14 @@ def fit(self,
165168 **CVXPY Solvers:**
166169
167170 Various solvers can be called in CVXPY using the `solver` keyword
168- argument. See the `CVXPY documentation
171+ argument. If ``psd=True`` an SDP solver is required other an SOCP
172+ solver is required. See the `CVXPY documentation
169173 <https://www.cvxpy.org/tutorial/advanced/index.html#solve-method-options>`_
170174 for more information on solvers.
175+ Note that the default SDP solver ('SCS') distributed
176+ with CVXPY will not be used for the ``'auto'`` method due its reduced
177+ accuracy compared to other solvers. When using the ``'cvx'`` method we
178+ strongly recommend installing one of the other supported SDP solvers.
171179
172180 References:
173181
@@ -200,7 +208,11 @@ def fit(self,
200208 # Choose automatic method
201209 if method == 'auto' :
202210 self ._check_for_sdp_solver ()
203- if self ._HAS_SDP_SOLVER :
211+ if self ._HAS_SDP_SOLVER_NOT_SCS :
212+ # We don't use the SCS solver for automatic method as it has
213+ # lower accuracy than the other supported SDP solvers which
214+ # typically results in the returned matrix not being
215+ # completely positive.
204216 method = 'cvx'
205217 else :
206218 method = 'lstsq'
@@ -516,15 +528,17 @@ def _check_for_sdp_solver(cls):
516528 # pylint:disable=import-error
517529 import cvxpy
518530 solvers = cvxpy .installed_solvers ()
519- if 'CVXOPT' in solvers :
531+ # Check for other SDP solvers cvxpy supports
532+ if 'CVXOPT' in solvers or 'MOSEK' in solvers :
533+ cls ._HAS_SDP_SOLVER_NOT_SCS = True
520534 cls ._HAS_SDP_SOLVER = True
521535 return
522536 if 'SCS' in solvers :
523537 # Try example problem to see if built with BLAS
524538 # SCS solver cannot solver larger than 2x2 matrix
525539 # problems without BLAS
526540 try :
527- var = cvxpy .Variable ((4 , 4 ), PSD = True )
541+ var = cvxpy .Variable ((5 , 5 ), PSD = True )
528542 obj = cvxpy .Minimize (cvxpy .norm (var ))
529543 cvxpy .Problem (obj ).solve (solver = 'SCS' )
530544 cls ._HAS_SDP_SOLVER = True
0 commit comments