def sdp( c, Ai_blocks, primalstar=None, dualstart=None, solver='dsdp', verbose=0, interpret=False, maxiters=1000, tolerance=10e-7 ):
  if cvxopt is None:
    raise NotAvailableError(sdp.__name__)


  c = cvxopt.matrix( c )

  h = []
  G = []

  for A in Ai_blocks:
      h.append( cvxopt.matrix( A[0].astype(float).tolist() ) )
      G.append( cvxopt.matrix( [ (-A[i]).flatten().astype(float).tolist()[0] for i in range(1,len(A)) ] ) )

  if solver != 'dsdp' and solver != 'conelp':
      raise Exception('error: unknown solver (available: dsdp or conelp)')

  if solver == 'conelp': solver == ''

  cvxopt.solvers.options['show_progress'] = (1 if verbose > 0 else 0) #True/False (default: True)
  cvxopt.solvers.options['maxiters'] = maxiters #positive integer (default: 100)
  # cvxopt.solvers.options['refinement'] #positive integer (default: 1)
  cvxopt.solvers.options['abstol'] = tolerance #scalar (default: 1e-7)
  cvxopt.solvers.options['reltol'] = tolerance #scalar (default: 1e-6)
  cvxopt.solvers.options['feastol'] = tolerance #scalar (default: 1e-7).

  cvxopt.solvers.options['DSDP_Monitor'] = (1 if verbose > 0 else 0) #True/False (default: 0)
  cvxopt.solvers.options['DSDP_MaxIts'] = maxiters #positive integer
  cvxopt.solvers.options['DSDP_GapTolerance'] = tolerance #scalar (default: 1e-5).

  sol = cvxopt.solvers.sdp(c, Gs=G, hs=h, solver=solver)

  if not interpret:
      if verbose >= 0: print(sol['status'])
      return sol

  if verbose > 0:
      print('------------------------------\nsol[\'status\'] : '+sol['status']+'\n\n____________________________________')

  if sol['status'] == 'optimal':
      if verbose >= 0: print('optimal')
      return numpy.matrix(sol['x'])

  else:

      sp = 'residual as primal infeasibility certificate'
      sd = 'residual as dual infeasibility certificate'

      if solver == 'dsdp' and sol['status'] == 'unknown':

          if sol[sp] is not None:
              s = 'primal infeasible'
          elif sol[sp] is not None:
              s = 'dual infeasible'
          else:
              s = 'unknown'

          if verbose >= 0: print(s)
          if verbose >= 0: print(sp + ': ' + str(sol[sp]) + '\n' + sd + ': ' + str(sol[sd]))
          return


      else:

          if verbose >= 0: print(sol['status'])
          if verbose >= 0: print(sp + ': ' + str(sol[sp]) + '\n' + sd + ': ' + str(sol[sd]))
          return
dataset/ETHPy150Open cdsousa/SymPyBotics/sympybotics/dynident/regression.py/sdp/original