How to use the projectq.cengines.BasicEngine.__init__ function in projectq

To help you get started, we’ve selected a few projectq examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ProjectQ-Framework / ProjectQ / projectq / backends / _sim / _simulator.py View on Github external
through the state vector multiple times. Depending on the system (and,
        especially, number of threads), this may or may not be beneficial.

        Note:
            If the C++ Simulator extension was not built or cannot be found,
            the Simulator defaults to a Python implementation of the kernels.
            While this is much slower, it is still good enough to run basic
            quantum algorithms.

            If you need to run large simulations, check out the tutorial in
            the docs which gives futher hints on how to build the C++
            extension.
        """
        if rnd_seed is None:
            rnd_seed = random.randint(0, 4294967295)
        BasicEngine.__init__(self)
        self._simulator = SimulatorBackend(rnd_seed)
        self._gate_fusion = gate_fusion
github ProjectQ-Framework / ProjectQ / projectq / meta / _loop.py View on Github external
def __init__(self, num):
        """
        Initialize a LoopEngine.

        Args:
            num (int): Number of loop iterations.
        """
        BasicEngine.__init__(self)
        self._tag = LoopTag(num)
        self._cmd_list = []
        self._allocated_qubit_ids = set()
        self._deallocated_qubit_ids = set()
        # key: qubit id of a local qubit, i.e. a qubit which has been allocated
        #      and deallocated within the loop body.
        # value: list contain reference to each weakref qubit with this qubit
        #        id either within control_qubits or qubits.
        self._refs_to_local_qb = dict()
        self._next_engines_support_loop_tag = False
github ProjectQ-Framework / ProjectQ / projectq / meta / _compute.py View on Github external
def __init__(self):
        """
        Initialize a UncomputeEngine.
        """
        BasicEngine.__init__(self)
        # Save all qubit ids from qubits which are created or destroyed.
        self._allocated_qubit_ids = set()
        self._deallocated_qubit_ids = set()
github ProjectQ-Framework / ProjectQ / projectq / backends / _resource.py View on Github external
def __init__(self):
        """
        Initialize a resource counter engine.

        Sets all statistics to zero.
        """
        BasicEngine.__init__(self)
        self.gate_counts = {}
        self.gate_class_counts = {}
        self._active_qubits = 0
        self.max_width = 0
github ProjectQ-Framework / ProjectQ / projectq / cengines / _tagremover.py View on Github external
def __init__(self, tags=[ComputeTag, UncomputeTag]):
        """
        Construct the TagRemover.

        Args:
            tags: A list of meta tag classes (e.g., [ComputeTag, UncomputeTag])
                denoting the tags to remove
        """
        BasicEngine.__init__(self)
        assert isinstance(tags, list)
        self._tags = tags
github ProjectQ-Framework / ProjectQ / projectq / cengines / _ibmcnotmapper.py View on Github external
def __init__(self):
        """
        Initialize an IBM CNOT Mapper compiler engine.

        Resets the mapping.
        """
        BasicEngine.__init__(self)
        self._reset()
github ProjectQ-Framework / ProjectQ / projectq / backends / _ibm / _ibm.py View on Github external
verbose (bool): If True, statistics are printed, in addition to
                the measurement result being registered (at the end of the
                circuit).
            user (string): IBM Quantum Experience user name
            password (string): IBM Quantum Experience password
            device (string): Device to use ('ibmqx4', or 'ibmqx5')
                if use_hardware is set to True. Default is ibmqx4.
            num_retries (int): Number of times to retry to obtain
                results from the IBM API. (default is 3000)
            interval (float, int): Number of seconds between successive
                attempts to obtain results from the IBM API.
                (default is 1)
            retrieve_execution (int): Job ID to retrieve instead of re-
                running the circuit (e.g., if previous run timed out).
        """
        BasicEngine.__init__(self)
        self._reset()
        if use_hardware:
            self.device = device
        else:
            self.device = 'simulator'
        self._num_runs = num_runs
        self._verbose = verbose
        self._user = user
        self._password = password
        self._num_retries = num_retries
        self._interval = interval
        self._probabilities = dict()
        self.qasm = ""
        self._measured_ids = []
        self._allocated_qubits = set()
        self._retrieve_execution = retrieve_execution
github Huawei-HiQ / HiQsimulator / hiq / projectq / cengines / _greedyscheduler.py View on Github external
def __init__(self, supremacy_circuit=False, num_splits=10 ** 6, cluster_size=4):
        """
        Args:
            supremacy_circuit (bool): If you want to use random circuits, you can
                specify this parameter as True. Then all last CZ gates will be
                ignored, because they do not affect the result of final measurement.
            num_splits (int): Number of branch splits
            cluster_size (int): Maximum number of qubits in fused multi-qubit
                gate
        """
        BasicEngine.__init__(self)
        self._cmd_list = []
        self._was_scheduling = False
        self._init = False
        self._supremacy_circuit = supremacy_circuit
        self.NUM_SPLITS = num_splits
        self.CLUSTER_SIZE = cluster_size
        self._deallocations_cache = []
github ProjectQ-Framework / ProjectQ / projectq / cengines / _basicmapper.py View on Github external
def __init__(self):
        BasicEngine.__init__(self)
        self._current_mapping = None