FFSimulator
The FFSimulator
is a simulator dedicated to simulate feed-forward experiments.
Like the Simulator
, it needs a strong simulation backend to be able to perform simulations.
However, the FFSimulator
is also able to compute circuits having FFConfigurator or
FFCircuitProvider but is unable to compute probability amplitudes.
Thus, only the probs_svd
and probs
computation methods are available.
>>> import perceval as pcvl
>>> sim = pcvl.FFSimulator(pcvl.SLOSBackend())
>>> ff_not = pcvl.FFCircuitProvider(2, 0, pcvl.Circuit(2)).add_configuration([0, 1], pcvl.PERM([1, 0]))
>>> sim.set_circuit([((0, 1), ff_not)]) # Since non-unitary components can't be added to Circuit, we directly provide a list; the number of modes is implicit
>>> sim.probs(pcvl.BasicState([0, 1, 1, 0]))
{
|0,1,0,1>: 1.0
}
- class perceval.simulators.feed_forward_simulator.FFSimulator(backend)
- compute_physical_logical_perf(value)
Tells the simulator to compute or not the physical and logical performances when possible
- Parameters:
value (
bool
) – True to compute the physical and logical performances, False otherwise.
- format_results(results, physical_perf, logical_perf)
Format the simulation results by computing the global performance, and returning the physical and logical performances only if needed.
- Parameters:
results – the simulation results
physical_perf – the physical performance
logical_perf – the logical performance
- keep_heralds(value)
Tells the simulator to keep or discard ancillary modes in output states
- Parameters:
value (
bool
) – True to keep ancillaries/heralded modes, False to discard them (default is keep).
- property min_detected_photons_filter: int
The simulated minimum number of photons that a state needs to have to be counted as valid. Includes the expected photons from the heralds.
- probs(input_state)
Compute the probability distribution from a BasicState input
- Parameters:
input_state (
BasicState
) – A basic state describing the input to simulate- Return type:
- Returns:
A BSDistribution
- probs_svd(input_dist, detectors=None, progress_callback=None)
Compute the probability distribution from a SVDistribution input and as well as performance scores
- Parameters:
input_dist (
SVDistribution
) – A state vector distribution describing the input to simulatedetectors (
Optional
[list
[IDetector
]]) – An optional list of detectorsprogress_callback (
Optional
[callable
]) – A function with the signature func(progress: float, message: str)
- Returns:
A dictionary of the form { “results”: BSDistribution, “global_perf”: float }
results is the post-selected output state distribution
global_perf is the probability that a state is post-selected
- set_min_detected_photons_filter(value)
Set a minimum number of detected photons in the output distribution, counting only the non-heralded modes.
- Parameters:
value (
int
) – The minimum photon count
- set_selection(min_detected_photons_filter=None, postselect=None, heralds=None)
Set the min_detected_photons_filter, postselect, and heralds, if defined.
- Parameters:
min_detected_photons_filter (
Optional
[int
]) – The minimum photon count.postselect (
Optional
[PostSelect
]) – The postselect to apply at the end of the computation.heralds (
Optional
[dict
[int
,int
]]) – The heralds to apply at the end of the computation. Only the output heralds are considered here. dictionary of the form {mode: expected}