def solve_sdp(sdp, solver=None, solverparameters=None):
solvers = autodetect_solvers(solverparameters)<EOL>solver = solver.lower() if solver is not None else solver<EOL>if solvers == []:<EOL><INDENT>raise Exception("<STR_LIT>" +<EOL>"<STR_LIT>")<EOL><DEDENT>elif solver is not None and solver not in solvers:<EOL><INDENT>print("<STR_LIT>" + str(solvers))<EOL>if solver == "<STR_LIT>":<EOL><INDENT>try:<EOL><INDENT>import cvxopt<EOL><DEDENT>except ImportError:<EOL><INDENT>pass<EOL><DEDENT>else:<EOL><INDENT>raise Exception("<STR_LIT>"<EOL>"<STR_LIT>")<EOL><DEDENT><DEDENT>raise Exception("<STR_LIT>" + solver)<EOL><DEDENT>elif solver is None:<EOL><INDENT>solver = solvers[<NUM_LIT:0>]<EOL><DEDENT>primal, dual, x_mat, y_mat, status = None, None, None, None, None<EOL>tstart = time.time()<EOL>if solver == "<STR_LIT>":<EOL><INDENT>primal, dual, x_mat, y_mat, status =solve_with_sdpa(sdp, solverparameters)<EOL><DEDENT>elif solver == "<STR_LIT>":<EOL><INDENT>primal, dual, x_mat, y_mat, status =solve_with_cvxpy(sdp, solverparameters)<EOL><DEDENT>elif solver == "<STR_LIT>":<EOL><INDENT>if solverparameters is None:<EOL><INDENT>solverparameters_ = {"<STR_LIT>": "<STR_LIT>"}<EOL><DEDENT>else:<EOL><INDENT>solverparameters_ = solverparameters.copy()<EOL>solverparameters_["<STR_LIT>"] = "<STR_LIT>"<EOL><DEDENT>primal, dual, x_mat, y_mat, status =solve_with_cvxpy(sdp, solverparameters_)<EOL><DEDENT>elif solver == "<STR_LIT>":<EOL><INDENT>primal, dual, x_mat, y_mat, status =solve_with_mosek(sdp, solverparameters)<EOL><DEDENT>elif solver == "<STR_LIT>":<EOL><INDENT>primal, dual, x_mat, y_mat, status =solve_with_cvxopt(sdp, solverparameters)<EOL>for constraint in sdp.constraints[sdp._n_inequalities:]:<EOL><INDENT>idx = sdp._constraint_to_block_index[constraint]<EOL>sdp._constraint_to_block_index[constraint] = (idx[<NUM_LIT:0>],)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise Exception("<STR_LIT>" + solver)<EOL><DEDENT>sdp.solution_time = time.time() - tstart<EOL>sdp.primal = primal<EOL>sdp.dual = dual<EOL>sdp.x_mat = x_mat<EOL>sdp.y_mat = y_mat<EOL>sdp.status = status<EOL>return primal, dual, x_mat, y_mat<EOL>
Call a solver on the SDP relaxation. Upon successful solution, it
    returns the primal and dual objective values along with the solution
    matrices.

    :param sdpRelaxation: The SDP relaxation to be solved.
    :type sdpRelaxation: :class:`ncpol2sdpa.SdpRelaxation`.
    :param solver: The solver to be called, either `None`, "sdpa", "mosek",
                   "cvxpy", "scs", or "cvxopt". The default is `None`,
                   which triggers autodetect.
    :type solver: str.
    :param solverparameters: Parameters to be passed to the solver. Actual
                             options depend on the solver:

                             SDPA:

                               - `"executable"`:
                                 Specify the executable for SDPA. E.g.,
                                 `"executable":"/usr/local/bin/sdpa"`, or
                                 `"executable":"sdpa_gmp"`
                               - `"paramsfile"`: Specify the parameter file

                             Mosek:
                             Refer to the Mosek documentation. All
                             arguments are passed on.

                             Cvxopt:
                             Refer to the PICOS documentation. All
                             arguments are passed on.

                             Cvxpy:
                             Refer to the Cvxpy documentation. All
                             arguments are passed on.

                             SCS:
                             Refer to the Cvxpy documentation. All
                             arguments are passed on.
    :type solverparameters: dict of str.
    :returns: tuple of the primal and dual optimum, and the solutions for the
              primal and dual.
    :rtype: (float, float, list of `numpy.array`, list of `numpy.array`)