362 lines
14 KiB
Plaintext
362 lines
14 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/1.1/qiskit/circuit/library/n_local/evolved_operator_ansatz.py#L30-L223" 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 |* [*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 |* [*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"). 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">
|
||
A list of `AncillaQubit`s in the order that they were added. You should not mutate this.
|
||
</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">
|
||
A list of `Clbit`s in the order that they were added. You should not mutate this.
|
||
</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**
|
||
|
||
[EvolutionSynthesis](qiskit.synthesis.EvolutionSynthesis "qiskit.synthesis.EvolutionSynthesis")
|
||
</Attribute>
|
||
|
||
### 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">
|
||
The global phase of the current circuit scope in radians.
|
||
</Attribute>
|
||
|
||
### 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="160" />
|
||
|
||
### 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">
|
||
Arbitrary user-defined metadata for the circuit.
|
||
|
||
Qiskit will not examine the content of this mapping, but it will pass it through the transpiler and reattach it to the output, so you can track your own metadata.
|
||
</Attribute>
|
||
|
||
### num\_ancillas
|
||
|
||
<Attribute id="qiskit.circuit.library.EvolvedOperatorAnsatz.num_ancillas">
|
||
Return the number of ancilla qubits.
|
||
</Attribute>
|
||
|
||
### num\_captured\_vars
|
||
|
||
<Attribute id="qiskit.circuit.library.EvolvedOperatorAnsatz.num_captured_vars">
|
||
The number of real-time classical variables in the circuit marked as captured from an enclosing scope.
|
||
|
||
This is the length of the `iter_captured_vars()` iterable. If this is non-zero, [`num_input_vars`](#qiskit.circuit.library.EvolvedOperatorAnsatz.num_input_vars "qiskit.circuit.library.EvolvedOperatorAnsatz.num_input_vars") must be zero.
|
||
</Attribute>
|
||
|
||
### num\_clbits
|
||
|
||
<Attribute id="qiskit.circuit.library.EvolvedOperatorAnsatz.num_clbits">
|
||
Return number of classical bits.
|
||
</Attribute>
|
||
|
||
### num\_declared\_vars
|
||
|
||
<Attribute id="qiskit.circuit.library.EvolvedOperatorAnsatz.num_declared_vars">
|
||
The number of real-time classical variables in the circuit that are declared by this circuit scope, excluding inputs or captures.
|
||
|
||
This is the length of the `iter_declared_vars()` iterable.
|
||
</Attribute>
|
||
|
||
### num\_input\_vars
|
||
|
||
<Attribute id="qiskit.circuit.library.EvolvedOperatorAnsatz.num_input_vars">
|
||
The number of real-time classical variables in the circuit marked as circuit inputs.
|
||
|
||
This is the length of the `iter_input_vars()` iterable. If this is non-zero, [`num_captured_vars`](#qiskit.circuit.library.EvolvedOperatorAnsatz.num_captured_vars "qiskit.circuit.library.EvolvedOperatorAnsatz.num_captured_vars") must be zero.
|
||
</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">
|
||
Returns the number of qubits in this circuit.
|
||
|
||
**Returns**
|
||
|
||
The number of qubits.
|
||
</Attribute>
|
||
|
||
### num\_vars
|
||
|
||
<Attribute id="qiskit.circuit.library.EvolvedOperatorAnsatz.num_vars">
|
||
The number of real-time classical variables in the circuit.
|
||
|
||
This is the length of the `iter_vars()` iterable.
|
||
</Attribute>
|
||
|
||
### 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 `QuantumRegister`s in this circuit. You should not mutate this.
|
||
</Attribute>
|
||
|
||
### qubits
|
||
|
||
<Attribute id="qiskit.circuit.library.EvolvedOperatorAnsatz.qubits">
|
||
A list of `Qubit`s in the order that they were added. You should not mutate this.
|
||
</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>
|
||
|
||
### name
|
||
|
||
<Attribute id="qiskit.circuit.library.EvolvedOperatorAnsatz.name" attributeTypeHint="str">
|
||
A human-readable name for the circuit.
|
||
</Attribute>
|
||
|
||
### cregs
|
||
|
||
<Attribute id="qiskit.circuit.library.EvolvedOperatorAnsatz.cregs" attributeTypeHint="list[ClassicalRegister]">
|
||
A list of the `ClassicalRegister`s in this circuit. You should not mutate this.
|
||
</Attribute>
|
||
|
||
### duration
|
||
|
||
<Attribute id="qiskit.circuit.library.EvolvedOperatorAnsatz.duration" attributeTypeHint="int | float | None">
|
||
The total duration of the circuit, set by a scheduling transpiler pass. Its unit is specified by [`unit`](#qiskit.circuit.library.EvolvedOperatorAnsatz.unit "qiskit.circuit.library.EvolvedOperatorAnsatz.unit").
|
||
</Attribute>
|
||
|
||
### unit
|
||
|
||
<Attribute id="qiskit.circuit.library.EvolvedOperatorAnsatz.unit">
|
||
The unit that [`duration`](#qiskit.circuit.library.EvolvedOperatorAnsatz.duration "qiskit.circuit.library.EvolvedOperatorAnsatz.duration") is specified in.
|
||
</Attribute>
|
||
</Class>
|
||
|