def connect_to_dwave(): """ Establish a connection to the D-Wave, and use this to talk to a solver. We rely on the qOp infrastructure to set the environment variables properly. """ try: url = os.environ["DW_INTERNAL__HTTPLINK"] token = os.environ["DW_INTERNAL__TOKEN"] try: proxy = os.environ["DW_INTERNAL__HTTPPROXY"] except KeyError: proxy = "" conn = RemoteConnection(url, token, proxy) except KeyError: url = "<local>" token = "<N/A>" conn = local_connection except IOError as e: qmasm.abend("Failed to establish a remote connection (%s)" % e) try: qmasm.solver_name = os.environ["DW_INTERNAL__SOLVER"] except: # Solver was not specified: Use the first available solver. qmasm.solver_name = conn.solver_names()[0] try: qmasm.solver = conn.get_solver(qmasm.solver_name) except KeyError: qmasm.abend("Failed to find solver %s on connection %s" % (qmasm.solver_name, url))
def list_remote_solvers(): remote_connection = RemoteConnection(sys.argv[1], sys.argv[2]) solver_names = remote_connection.solver_names() print "solvers' names: ", solver_names