308 lines
13 KiB
Plaintext
308 lines
13 KiB
Plaintext
---
|
||
title: EvolvedOperatorAnsatz
|
||
description: API reference for qiskit.circuit.library.EvolvedOperatorAnsatz
|
||
in_page_toc_min_heading_level: 1
|
||
python_api_type: class
|
||
python_api_name: qiskit.circuit.library.EvolvedOperatorAnsatz
|
||
---
|
||
|
||
# EvolvedOperatorAnsatz
|
||
|
||
<Class id="qiskit.circuit.library.EvolvedOperatorAnsatz" isDedicatedPage={true} github="https://github.com/qiskit/qiskit/tree/stable/0.45/qiskit/circuit/library/evolved_operator_ansatz.py" signature="qiskit.circuit.library.EvolvedOperatorAnsatz(operators=None, reps=1, evolution=None, insert_barriers=False, name='EvolvedOps', parameter_prefix='t', initial_state=None, flatten=None)" modifiers="class">
|
||
Bases: [`NLocal`](qiskit.circuit.library.NLocal "qiskit.circuit.library.n_local.n_local.NLocal")
|
||
|
||
The evolved operator ansatz.
|
||
|
||
**Parameters**
|
||
|
||
* **operators** (*BaseOperator |* [*OperatorBase*](qiskit.opflow.OperatorBase "qiskit.opflow.OperatorBase") *|*[*QuantumCircuit*](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit") *|*[*list*](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.12)") *| None*) – The operators to evolve. If a circuit is passed, we assume it implements an already evolved operator and thus the circuit is not evolved again. Can be a single operator (circuit) or a list of operators (and circuits).
|
||
* **reps** ([*int*](https://docs.python.org/3/library/functions.html#int "(in Python v3.12)")) – The number of times to repeat the evolved operators.
|
||
* **evolution** ([*EvolutionBase*](qiskit.opflow.evolutions.EvolutionBase "qiskit.opflow.evolutions.EvolutionBase") *|*[*EvolutionSynthesis*](qiskit.synthesis.EvolutionSynthesis "qiskit.synthesis.EvolutionSynthesis") *| None*) – A specification of which evolution synthesis to use for the [`PauliEvolutionGate`](qiskit.circuit.library.PauliEvolutionGate "qiskit.circuit.library.PauliEvolutionGate"), if the operator is from [`qiskit.quantum_info`](quantum_info#module-qiskit.quantum_info "qiskit.quantum_info") or an opflow converter object if the operator is from [`qiskit.opflow`](opflow#module-qiskit.opflow "qiskit.opflow"). Defaults to first order Trotterization.
|
||
* **insert\_barriers** ([*bool*](https://docs.python.org/3/library/functions.html#bool "(in Python v3.12)")) – Whether to insert barriers in between each evolution.
|
||
* **name** ([*str*](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.12)")) – The name of the circuit.
|
||
* **parameter\_prefix** ([*str*](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.12)") *| Sequence\[*[*str*](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.12)")*]*) – Set the names of the circuit parameters. If a string, the same prefix will be used for each parameters. Can also be a list to specify a prefix per operator.
|
||
* **initial\_state** ([*QuantumCircuit*](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit") *| None*) – A [`QuantumCircuit`](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit") object to prepend to the circuit.
|
||
* **flatten** ([*bool*](https://docs.python.org/3/library/functions.html#bool "(in Python v3.12)") *| None*) – Set this to `True` to output a flat circuit instead of nesting it inside multiple layers of gate objects. By default currently the contents of the output circuit will be wrapped in nested objects for cleaner visualization. However, if you’re using this circuit for anything besides visualization its **strongly** recommended to set this flag to `True` to avoid a large performance overhead for parameter binding.
|
||
|
||
## Attributes
|
||
|
||
### ancillas
|
||
|
||
<Attribute id="qiskit.circuit.library.EvolvedOperatorAnsatz.ancillas">
|
||
Returns a list of ancilla bits in the order that the registers were added.
|
||
</Attribute>
|
||
|
||
### calibrations
|
||
|
||
<Attribute id="qiskit.circuit.library.EvolvedOperatorAnsatz.calibrations">
|
||
Return calibration dictionary.
|
||
|
||
The custom pulse definition of a given gate is of the form `{'gate_name': {(qubits, params): schedule}}`
|
||
</Attribute>
|
||
|
||
### clbits
|
||
|
||
<Attribute id="qiskit.circuit.library.EvolvedOperatorAnsatz.clbits">
|
||
Returns a list of classical bits in the order that the registers were added.
|
||
</Attribute>
|
||
|
||
### data
|
||
|
||
<Attribute id="qiskit.circuit.library.EvolvedOperatorAnsatz.data" />
|
||
|
||
### entanglement
|
||
|
||
<Attribute id="qiskit.circuit.library.EvolvedOperatorAnsatz.entanglement">
|
||
Get the entanglement strategy.
|
||
|
||
**Returns**
|
||
|
||
The entanglement strategy, see `get_entangler_map()` for more detail on how the format is interpreted.
|
||
</Attribute>
|
||
|
||
### entanglement\_blocks
|
||
|
||
<Attribute id="qiskit.circuit.library.EvolvedOperatorAnsatz.entanglement_blocks">
|
||
The blocks in the entanglement layers.
|
||
|
||
**Returns**
|
||
|
||
The blocks in the entanglement layers.
|
||
</Attribute>
|
||
|
||
### evolution
|
||
|
||
<Attribute id="qiskit.circuit.library.EvolvedOperatorAnsatz.evolution">
|
||
The evolution converter used to compute the evolution.
|
||
|
||
**Returns**
|
||
|
||
The evolution converter used to compute the evolution.
|
||
|
||
**Return type**
|
||
|
||
[EvolutionBase](qiskit.opflow.evolutions.EvolutionBase "qiskit.opflow.evolutions.EvolutionBase") or [EvolutionSynthesis](qiskit.synthesis.EvolutionSynthesis "qiskit.synthesis.EvolutionSynthesis")
|
||
</Attribute>
|
||
|
||
### extension\_lib
|
||
|
||
<Attribute id="qiskit.circuit.library.EvolvedOperatorAnsatz.extension_lib" attributeValue="'include "qelib1.inc";'" />
|
||
|
||
### flatten
|
||
|
||
<Attribute id="qiskit.circuit.library.EvolvedOperatorAnsatz.flatten">
|
||
Returns whether the circuit is wrapped in nested gates/instructions or flattened.
|
||
</Attribute>
|
||
|
||
### global\_phase
|
||
|
||
<Attribute id="qiskit.circuit.library.EvolvedOperatorAnsatz.global_phase">
|
||
Return the global phase of the current circuit scope in radians.
|
||
</Attribute>
|
||
|
||
### header
|
||
|
||
<Attribute id="qiskit.circuit.library.EvolvedOperatorAnsatz.header" attributeValue="'OPENQASM 2.0;'" />
|
||
|
||
### initial\_state
|
||
|
||
<Attribute id="qiskit.circuit.library.EvolvedOperatorAnsatz.initial_state">
|
||
Return the initial state that is added in front of the n-local circuit.
|
||
|
||
**Returns**
|
||
|
||
The initial state.
|
||
</Attribute>
|
||
|
||
### insert\_barriers
|
||
|
||
<Attribute id="qiskit.circuit.library.EvolvedOperatorAnsatz.insert_barriers">
|
||
If barriers are inserted in between the layers or not.
|
||
|
||
**Returns**
|
||
|
||
`True`, if barriers are inserted in between the layers, `False` if not.
|
||
</Attribute>
|
||
|
||
### instances
|
||
|
||
<Attribute id="qiskit.circuit.library.EvolvedOperatorAnsatz.instances" attributeValue="167" />
|
||
|
||
### layout
|
||
|
||
<Attribute id="qiskit.circuit.library.EvolvedOperatorAnsatz.layout">
|
||
Return any associated layout information about the circuit
|
||
|
||
This attribute contains an optional [`TranspileLayout`](qiskit.transpiler.TranspileLayout "qiskit.transpiler.TranspileLayout") object. This is typically set on the output from [`transpile()`](compiler#qiskit.compiler.transpile "qiskit.compiler.transpile") or [`PassManager.run()`](qiskit.transpiler.PassManager#run "qiskit.transpiler.PassManager.run") to retain information about the permutations caused on the input circuit by transpilation.
|
||
|
||
There are two types of permutations caused by the [`transpile()`](compiler#qiskit.compiler.transpile "qiskit.compiler.transpile") function, an initial layout which permutes the qubits based on the selected physical qubits on the [`Target`](qiskit.transpiler.Target "qiskit.transpiler.Target"), and a final layout which is an output permutation caused by [`SwapGate`](qiskit.circuit.library.SwapGate "qiskit.circuit.library.SwapGate")s inserted during routing.
|
||
</Attribute>
|
||
|
||
### metadata
|
||
|
||
<Attribute id="qiskit.circuit.library.EvolvedOperatorAnsatz.metadata">
|
||
The user provided metadata associated with the circuit.
|
||
|
||
The metadata for the circuit is a user provided `dict` of metadata for the circuit. It will not be used to influence the execution or operation of the circuit, but it is expected to be passed between all transforms of the circuit (ie transpilation) and that providers will associate any circuit metadata with the results it returns from execution of that circuit.
|
||
</Attribute>
|
||
|
||
### num\_ancillas
|
||
|
||
<Attribute id="qiskit.circuit.library.EvolvedOperatorAnsatz.num_ancillas">
|
||
Return the number of ancilla qubits.
|
||
</Attribute>
|
||
|
||
### num\_clbits
|
||
|
||
<Attribute id="qiskit.circuit.library.EvolvedOperatorAnsatz.num_clbits">
|
||
Return number of classical bits.
|
||
</Attribute>
|
||
|
||
### num\_layers
|
||
|
||
<Attribute id="qiskit.circuit.library.EvolvedOperatorAnsatz.num_layers">
|
||
Return the number of layers in the n-local circuit.
|
||
|
||
**Returns**
|
||
|
||
The number of layers in the circuit.
|
||
</Attribute>
|
||
|
||
### num\_parameters
|
||
|
||
<Attribute id="qiskit.circuit.library.EvolvedOperatorAnsatz.num_parameters" />
|
||
|
||
### num\_parameters\_settable
|
||
|
||
<Attribute id="qiskit.circuit.library.EvolvedOperatorAnsatz.num_parameters_settable">
|
||
The number of total parameters that can be set to distinct values.
|
||
|
||
This does not change when the parameters are bound or exchanged for same parameters, and therefore is different from `num_parameters` which counts the number of unique [`Parameter`](qiskit.circuit.Parameter "qiskit.circuit.Parameter") objects currently in the circuit.
|
||
|
||
**Returns**
|
||
|
||
The number of parameters originally available in the circuit.
|
||
|
||
<Admonition title="Note" type="note">
|
||
This quantity does not require the circuit to be built yet.
|
||
</Admonition>
|
||
</Attribute>
|
||
|
||
### num\_qubits
|
||
|
||
<Attribute id="qiskit.circuit.library.EvolvedOperatorAnsatz.num_qubits" />
|
||
|
||
### op\_start\_times
|
||
|
||
<Attribute id="qiskit.circuit.library.EvolvedOperatorAnsatz.op_start_times">
|
||
Return a list of operation start times.
|
||
|
||
This attribute is enabled once one of scheduling analysis passes runs on the quantum circuit.
|
||
|
||
**Returns**
|
||
|
||
List of integers representing instruction start times. The index corresponds to the index of instruction in `QuantumCircuit.data`.
|
||
|
||
**Raises**
|
||
|
||
[**AttributeError**](https://docs.python.org/3/library/exceptions.html#AttributeError "(in Python v3.12)") – When circuit is not scheduled.
|
||
</Attribute>
|
||
|
||
### operators
|
||
|
||
<Attribute id="qiskit.circuit.library.EvolvedOperatorAnsatz.operators">
|
||
The operators that are evolved in this circuit.
|
||
|
||
**Returns**
|
||
|
||
The operators to be evolved (and circuits) contained in this ansatz.
|
||
|
||
**Return type**
|
||
|
||
[list](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.12)")
|
||
</Attribute>
|
||
|
||
### ordered\_parameters
|
||
|
||
<Attribute id="qiskit.circuit.library.EvolvedOperatorAnsatz.ordered_parameters">
|
||
The parameters used in the underlying circuit.
|
||
|
||
This includes float values and duplicates.
|
||
|
||
**Examples**
|
||
|
||
```python
|
||
>>> # prepare circuit ...
|
||
>>> print(nlocal)
|
||
┌───────┐┌──────────┐┌──────────┐┌──────────┐
|
||
q_0: ┤ Ry(1) ├┤ Ry(θ[1]) ├┤ Ry(θ[1]) ├┤ Ry(θ[3]) ├
|
||
└───────┘└──────────┘└──────────┘└──────────┘
|
||
>>> nlocal.parameters
|
||
{Parameter(θ[1]), Parameter(θ[3])}
|
||
>>> nlocal.ordered_parameters
|
||
[1, Parameter(θ[1]), Parameter(θ[1]), Parameter(θ[3])]
|
||
```
|
||
|
||
**Returns**
|
||
|
||
The parameters objects used in the circuit.
|
||
</Attribute>
|
||
|
||
### parameter\_bounds
|
||
|
||
<Attribute id="qiskit.circuit.library.EvolvedOperatorAnsatz.parameter_bounds">
|
||
The parameter bounds for the unbound parameters in the circuit.
|
||
|
||
**Returns**
|
||
|
||
A list of pairs indicating the bounds, as (lower, upper). None indicates an unbounded parameter in the corresponding direction. If `None` is returned, problem is fully unbounded.
|
||
</Attribute>
|
||
|
||
### parameters
|
||
|
||
<Attribute id="qiskit.circuit.library.EvolvedOperatorAnsatz.parameters" />
|
||
|
||
### preferred\_init\_points
|
||
|
||
<Attribute id="qiskit.circuit.library.EvolvedOperatorAnsatz.preferred_init_points">
|
||
Getter of preferred initial points based on the given initial state.
|
||
</Attribute>
|
||
|
||
### prefix
|
||
|
||
<Attribute id="qiskit.circuit.library.EvolvedOperatorAnsatz.prefix" attributeValue="'circuit'" />
|
||
|
||
### qregs
|
||
|
||
<Attribute id="qiskit.circuit.library.EvolvedOperatorAnsatz.qregs" attributeTypeHint="list[QuantumRegister]">
|
||
A list of the quantum registers associated with the circuit.
|
||
</Attribute>
|
||
|
||
### qubits
|
||
|
||
<Attribute id="qiskit.circuit.library.EvolvedOperatorAnsatz.qubits">
|
||
Returns a list of quantum bits in the order that the registers were added.
|
||
</Attribute>
|
||
|
||
### reps
|
||
|
||
<Attribute id="qiskit.circuit.library.EvolvedOperatorAnsatz.reps">
|
||
The number of times rotation and entanglement block are repeated.
|
||
|
||
**Returns**
|
||
|
||
The number of repetitions.
|
||
</Attribute>
|
||
|
||
### rotation\_blocks
|
||
|
||
<Attribute id="qiskit.circuit.library.EvolvedOperatorAnsatz.rotation_blocks">
|
||
The blocks in the rotation layers.
|
||
|
||
**Returns**
|
||
|
||
The blocks in the rotation layers.
|
||
</Attribute>
|
||
</Class>
|
||
|