UnitarySimulatorPy#

class qiskit.providers.basicaer.UnitarySimulatorPy(configuration=None, provider=None, **fields)[소스]#

기반 클래스: BackendV1

Python implementation of a unitary simulator.

Initialize a backend class

매개변수:
  • configuration (BackendConfiguration) – A backend configuration object for the backend object.

  • provider (qiskit.providers.Provider) – Optionally, the provider object that this Backend comes from.

  • fields – kwargs for the values to use to override the default options.

예외 발생:

AttributeError – if input field not a valid options

In addition to the public abstract methods, subclasses should also implement the following private methods:

classmethod _default_options()[소스]

Return the default options

This method will return a qiskit.providers.Options subclass object that will be used for the default options. These should be the default parameters to use for the options of the backend.

반환:

A options object with

default values set

반환 형식:

qiskit.providers.Options

Attributes

DEFAULT_CONFIGURATION = {'backend_name': 'unitary_simulator', 'backend_version': '1.1.0', 'basis_gates': ['u1', 'u2', 'u3', 'rz', 'sx', 'x', 'cx', 'id', 'unitary'], 'conditional': False, 'coupling_map': None, 'description': 'A python simulator for unitary matrix corresponding to a circuit', 'gates': [{'name': 'u1', 'parameters': ['lambda'], 'qasm_def': 'gate u1(lambda) q { U(0,0,lambda) q; }'}, {'name': 'u2', 'parameters': ['phi', 'lambda'], 'qasm_def': 'gate u2(phi,lambda) q { U(pi/2,phi,lambda) q; }'}, {'name': 'u3', 'parameters': ['theta', 'phi', 'lambda'], 'qasm_def': 'gate u3(theta,phi,lambda) q { U(theta,phi,lambda) q; }'}, {'name': 'rz', 'parameters': ['phi'], 'qasm_def': 'gate rz(phi) q { U(0,0,phi) q; }'}, {'name': 'sx', 'parameters': [], 'qasm_def': 'gate sx(phi) q { U(pi/2,7*pi/2,pi/2) q; }'}, {'name': 'x', 'parameters': [], 'qasm_def': 'gate x q { U(pi,7*pi/2,pi/2) q; }'}, {'name': 'cx', 'parameters': [], 'qasm_def': 'gate cx c,t { CX c,t; }'}, {'name': 'id', 'parameters': [], 'qasm_def': 'gate id a { U(0,0,0) a; }'}, {'name': 'unitary', 'parameters': ['matrix'], 'qasm_def': 'unitary(matrix) q1, q2,...'}], 'local': True, 'max_shots': 0, 'memory': False, 'n_qubits': 14, 'open_pulse': False, 'simulator': True, 'url': 'https://github.com/Qiskit/qiskit-terra'}#
DEFAULT_OPTIONS = {'chop_threshold': 1e-15, 'initial_unitary': None}#
MAX_QUBITS_MEMORY = 14#
options#

Return the options for the backend

The options of a backend are the dynamic parameters defining how the backend is used. These are used to control the run() method.

version = 1#

Methods

configuration()#

Return the backend configuration.

반환:

the configuration for the backend.

반환 형식:

BackendConfiguration

name()#

Return the backend name.

반환:

the name of the backend.

반환 형식:

str

properties()#

Return the backend properties.

반환:

the configuration for the backend. If the backend does not support properties, it returns None.

반환 형식:

BackendProperties

provider()#

Return the backend Provider.

반환:

the Provider responsible for the backend.

반환 형식:

Provider

run(qobj, **backend_options)[소스]#

Run qobj asynchronously.

매개변수:
  • qobj (Qobj) – payload of the experiment

  • backend_options (dict) – backend options

반환:

derived from BaseJob

반환 형식:

BasicAerJob

Additional Information:

backend_options: Is a dict of options for the backend. It may contain
    * "initial_unitary": matrix_like
    * "chop_threshold": double

The "initial_unitary" option specifies a custom initial unitary
matrix for the simulator to be used instead of the identity
matrix. This size of this matrix must be correct for the number
of qubits inall experiments in the qobj.

The "chop_threshold" option specifies a truncation value for
setting small values to zero in the output unitary. The default
value is 1e-15.

Example::

    backend_options = {
        "initial_unitary": np.array([[1, 0, 0, 0],
                                     [0, 0, 0, 1],
                                     [0, 0, 1, 0],
                                     [0, 1, 0, 0]])
        "chop_threshold": 1e-15
    }
run_experiment(experiment)[소스]#

Run an experiment (circuit) and return a single experiment result.

매개변수:

experiment (QobjExperiment) – experiment from qobj experiments list

반환:

A result dictionary which looks something like:

{
"name": name of this experiment (obtained from qobj.experiment header)
"seed": random seed used for simulation
"shots": number of shots used in the simulation
"data":
    {
    "unitary": [[[0.0, 0.0], [1.0, 0.0]],
                [[1.0, 0.0], [0.0, 0.0]]]
    },
"status": status string for the simulation
"success": boolean
"time taken": simulation time of this single experiment
}

반환 형식:

dict

예외 발생:
  • BasicAerError – if the number of qubits in the circuit is greater than 24.

  • Note that the practical qubit limit is much lower than 24.

set_options(**fields)#

Set the options fields for the backend

This method is used to update the options of a backend. If you need to change any of the options prior to running just pass in the kwarg with the new value for the options.

매개변수:

fields – The fields to update the options

예외 발생:

AttributeError – If the field passed in is not part of the options

status()#

Return the backend status.

반환:

the status of the backend.

반환 형식:

BackendStatus