View source on GitHub |
A SimulatesFinalState that simulates a circuit by moments.
Inherits From: SimulatesFinalState
Whereas a general SimulatesFinalState may return the entire simulator state at the end of a circuit, a SimulatesIntermediateState can simulate stepping through the moments of a circuit.
Implementors of this interface should implement the _core_iterator method.
Note that state here refers to simulator state, which is not necessarily a state vector.
Methods
simulate
simulate(
program: 'cirq.AbstractCircuit',
param_resolver: 'cirq.ParamResolverOrSimilarType' = None,
qubit_order: 'cirq.QubitOrderOrList' = cirq.QubitOrder.DEFAULT
,
initial_state: Any = None
) -> TSimulationTrialResult
Simulates the supplied Circuit.
This method returns a result which allows access to the entire simulator's final state.
Args | |
---|---|
program
|
The circuit to simulate. |
param_resolver
|
Parameters to run with the program. |
qubit_order
|
Determines the canonical ordering of the qubits. This is often used in specifying the initial state, i.e. the ordering of the computational basis states. |
initial_state
|
The initial state for the simulation. The form of this state depends on the simulation implementation. See documentation of the implementing class for details. |
Returns | |
---|---|
SimulationTrialResults for the simulation. Includes the final state. |
simulate_moment_steps
simulate_moment_steps(
circuit: 'cirq.AbstractCircuit',
param_resolver: 'cirq.ParamResolverOrSimilarType' = None,
qubit_order: 'cirq.QubitOrderOrList' = cirq.QubitOrder.DEFAULT
,
initial_state: Any = None
) -> Iterator[TStepResult]
Returns an iterator of StepResults for each moment simulated.
If the circuit being simulated is empty, a single step result should be returned with the state being set to the initial state.
Args | |
---|---|
circuit
|
The Circuit to simulate. |
param_resolver
|
A ParamResolver for determining values of Symbols. |
qubit_order
|
Determines the canonical ordering of the qubits. This is often used in specifying the initial state, i.e. the ordering of the computational basis states. |
initial_state
|
The initial state for the simulation. This can be
either a raw state or a TSimulationState . The form of the
raw state depends on the simulation implementation. See
documentation of the implementing class for details.
|
Returns | |
---|---|
Iterator that steps through the simulation, simulating each moment and returning a StepResult for each moment. |
simulate_sweep
simulate_sweep(
program: 'cirq.AbstractCircuit',
params: 'cirq.Sweepable',
qubit_order: 'cirq.QubitOrderOrList' = cirq.QubitOrder.DEFAULT
,
initial_state: Any = None
) -> List[TSimulationTrialResult]
Wraps computed states in a list.
Prefer overriding simulate_sweep_iter
.
simulate_sweep_iter
simulate_sweep_iter(
program: 'cirq.AbstractCircuit',
params: 'cirq.Sweepable',
qubit_order: 'cirq.QubitOrderOrList' = cirq.QubitOrder.DEFAULT
,
initial_state: Any = None
) -> Iterator[TSimulationTrialResult]
Simulates the supplied Circuit.
This method returns a result which allows access to the entire state vector. In contrast to simulate, this allows for sweeping over different parameter values.
Args | |
---|---|
program
|
The circuit to simulate. |
params
|
Parameters to run with the program. |
qubit_order
|
Determines the canonical ordering of the qubits. This is often used in specifying the initial state, i.e. the ordering of the computational basis states. |
initial_state
|
The initial state for the simulation. This can be
either a raw state or an SimulationStateBase . The form of the
raw state depends on the simulation implementation. See
documentation of the implementing class for details.
|
Returns | |
---|---|
List of SimulationTrialResults for this run, one for each possible parameter resolver. |