Ejemplo n.º 1
0
    def setUpClass(cls):
        Settings.default_settings()
        cls.network = Network(nodes=["Alice", "Bob"])
        cls.network.start()

        cls.alice = CQCConnection("Alice")
        cls.bob = CQCConnection("Bob")
Ejemplo n.º 2
0
    def setUpClass(cls):
        cls._alice = None
        cls._bob = None

        Settings.default_settings()
        cls.network = Network(nodes=["Alice", "Bob"])
        cls.network.start()
Ejemplo n.º 3
0
    def setUpClass(cls):
        cls.iterations = 100
        sys.stdout.write(
            "Testing factory gates with {} iterations \r\n".format(
                cls.iterations))

        Settings.default_settings()
        cls.network = Network()
        cls.network.start()
Ejemplo n.º 4
0
    def tearDownClass(cls):
        # Set config files back to default
        for file in ["Nodes.cfg", "topology.json", "settings.ini"]:
            simulaqron_path = get_simulaqron_path.main()
            file_path = os.path.join(simulaqron_path, "config", file)
            os.remove(file_path)

        construct_node_configs()
        Settings.default_settings()
Ejemplo n.º 5
0
    def setUpClass(cls):
        cls.iterations = 100
        sys.stdout.write(
            "Testing single qubit gates gates with {} iterations \r\n".format(
                cls.iterations))

        Settings.default_settings()
        cls.network = Network(nodes=["Alice"])
        cls.network.start()
Ejemplo n.º 6
0
def max_registers(value):
    """How many registers a node can hold."""
    Settings.set_setting("BACKEND", "maxregs_per_node", str(value))
Ejemplo n.º 7
0
def t1(value):
    """The effective T1 to be used for noisy qubits"""
    Settings.set_setting("BACKEND", "t1", str(value))
Ejemplo n.º 8
0
def noisy_qubits(value):
    """Whether qubits should be noisy (on/off)"""
    if value == "on":
        Settings.set_setting("BACKEND", "noisy_qubits", 'True')
    else:
        Settings.set_setting("BACKEND", "noisy_qubits", 'False')
Ejemplo n.º 9
0
def nodes_file(value):
    """The path to the topology file to be used, can be ""."""
    Settings.set_setting("BACKEND", "nodes_file", value)
Ejemplo n.º 10
0
def log_level(value):
    """Log level for both backend and frontend."""
    Settings.set_setting("BACKEND", "loglevel", value)
    Settings.set_setting("FRONTEND", "loglevel", value)
Ejemplo n.º 11
0
def set_settings(settings):
    for section, section_settings in settings.items():
        for key, value in section_settings.items():
            Settings.set_setting(section=section, key=key, value=value)
Ejemplo n.º 12
0
 def tearDownClass(cls):
     cls.network.stop()
     Settings.default_settings()
Ejemplo n.º 13
0
 def setUpClass(cls):
     Settings.default_settings()
     cls.node_names = ["Alice", "Bob", "Charlie"]
     cls.network = Network(cls.node_names)
     cls.network.start()
Ejemplo n.º 14
0
def max_qubits(value):
    """Max virt-qubits per node and max sim-qubits per register."""
    Settings.set_setting("BACKEND", "maxqubits_per_node", str(value))
Ejemplo n.º 15
0
def backend(value):
    """The backend to use (stabilizer, projectq, qutip)."""
    Settings.set_setting("BACKEND", "backend", value)
Ejemplo n.º 16
0
def default():
    """Sets all settings back to default"""
    Settings.default_settings()
Ejemplo n.º 17
0
    def tearDownClass(cls):
        cls.alice.close()
        cls.bob.close()

        cls.network.stop()
        Settings.default_settings()
Ejemplo n.º 18
0
def construct_topology_config(topology, nodes, save_fig=True):
    """
    Constructs a json file at config/topology.json, used to define the topology of the network.

    :param topology: str
        Should be one of the following: None, 'complete', 'ring', 'random_tree'.
    :param nodes: list of str
        List of the names of the nodes.
    :param save_fig: bool
        Whether to save a picture of the network
    :return: None
    """
    if topology:
        if isinstance(topology, dict):
            adjacency_dct = {node: topology[node] for node in nodes}
        elif topology == "complete":
            adjacency_dct = {}
            for i, node in enumerate(nodes):
                adjacency_dct[node] = nodes[:i] + nodes[i + 1:]

        elif topology == "ring":
            adjacency_dct = {}
            nn = len(nodes)
            for i, node in enumerate(nodes):
                adjacency_dct[node] = [
                    nodes[(i - 1) % nn], nodes[(i + 1) % nn]
                ]

        elif topology == "path":
            adjacency_dct = {}
            nn = len(nodes)
            for i, node in enumerate(nodes):
                if i == 0:
                    adjacency_dct[node] = [nodes[i + 1]]
                elif i == (nn - 1):
                    adjacency_dct[node] = [nodes[i - 1]]
                else:
                    adjacency_dct[node] = [
                        nodes[(i - 1) % nn], nodes[(i + 1) % nn]
                    ]

        elif topology == "random_tree":
            adjacency_dct = get_random_tree(nodes)

        elif topology[:16] == "random_connected":
            try:
                nr_edges = int(topology[17:])
            except ValueError:
                raise ValueError(
                    "When specifying a random connected graph use the format 'random_connected_{nr_edges}',"
                    "where 'nr_edges' is the number of edges of the graph.")
            except IndexError:
                raise ValueError(
                    "When specifying a random connected graph use the format 'random_connected_{nr_edges}',"
                    "where 'nr_edges' is the number of edges of the graph.")
            adjacency_dct = get_random_connected(nodes, nr_edges)

        else:
            raise ValueError("Unknown topology name")

        # Get path to SimulaQron folder
        simulaqron_path = get_simulaqron_path.main()

        if save_fig:
            network = nx.from_dict_of_lists(adjacency_dct)
            try:
                nx.draw(network, with_labels=True)
            except _tkinter.TclError as err:
                logging.warning(
                    "Could not draw since there seems to be no screen. Error: {}"
                    .format(err))
            else:
                fig_path = os.path.join(simulaqron_path, "config/topology.png")
                plt.savefig(fig_path)

        topology_file = os.path.join(simulaqron_path, "config/topology.json")
        with open(topology_file, "w") as top_file:
            json.dump(adjacency_dct, top_file)

        Settings.set_setting("BACKEND", "topology_file",
                             "config/topology.json")
    else:
        Settings.set_setting("BACKEND", "topology_file", "")
Ejemplo n.º 19
0
def conn_retry_time(value):
    """If setup fails, how long to wait until a retry."""
    Settings.set_setting("BACKEND", "waittime", str(value))
Ejemplo n.º 20
0
    def setUpClass(cls):
        cls.iterations = 8

        Settings.default_settings()
        cls.network = Network(nodes=["Alice", "Bob"])
        cls.network.start()
Ejemplo n.º 21
0
def recv_timeout(value):
    """When receiving a qubit or EPR pair, how long to wait until raising a timeout."""
    Settings.set_setting("BACKEND", "recvtimeout", str(value))
    Settings.set_setting("BACKEND", "recveprtimeout", str(value))
Ejemplo n.º 22
0
 def setUpClass(cls):
     Settings.default_settings()
     cls.network = Network(nodes=["Alice"])
     cls.network.start()
Ejemplo n.º 23
0
def recv_retry_time(value):
    """When receiving a qubit or EPR pair, how long to wait between checks of whether a qubit is received."""
    Settings.set_setting("BACKEND", "waittimerecv", str(value))