cirq.SimulatesIntermediateState

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

View source

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

View source

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

View source

Wraps computed states in a list.

Prefer overriding simulate_sweep_iter.

simulate_sweep_iter

View source

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.