File Simulator.hpp

class Simulator

Subclassed by CircuitSimulator, GroverSimulator, ShorFastSimulator, ShorSimulator

Public Functions

inline explicit Simulator(const std::uint64_t randomSeed, const dd::DDPackageConfig &config = dd::DDPackageConfig())
inline explicit Simulator(const dd::DDPackageConfig &config = dd::DDPackageConfig())
virtual ~Simulator() = default
virtual std::map<std::string, std::size_t> simulate(std::size_t shots) = 0

Run the simulation in the (derived) class.

Parameters:

shots – number of shots to take from the final quantum state

Returns:

a map from the strings representing basis states to the number of times they have been measured

inline virtual std::map<std::string, std::string> additionalStatistics()
inline std::string measureAll(bool collapse = false)
inline virtual std::map<std::string, std::size_t> measureAllNonCollapsing(std::size_t shots)
std::map<std::string, std::size_t> sampleFromAmplitudeVectorInPlace(std::vector<std::complex<dd::fp>> &amplitudes, std::size_t shots)
inline virtual std::size_t getActiveNodeCount() const
inline virtual std::size_t getMatrixActiveNodeCount() const
inline virtual std::size_t countNodesFromRoot()
inline auto getCurrentDD() const -> const dd::vEdge&
std::pair<dd::ComplexValue, std::string> getPathOfLeastResistance() const
inline std::string getSeed() const
virtual std::size_t getNumberOfQubits() const = 0
virtual std::size_t getNumberOfOps() const = 0
virtual std::string getName() const = 0
inline void setTolerance(const dd::fp tolerance)
inline dd::fp getTolerance() const
std::vector<std::priority_queue<std::pair<double, dd::vNode*>, std::vector<std::pair<double, dd::vNode*>>>> getNodeContributions(const dd::vEdge &edge) const
double approximateByFidelity(std::unique_ptr<dd::Package> &localDD, dd::vEdge &edge, double targetFidelity, bool allLevels, bool actuallyRemoveNodes, bool verbose = false) const
inline double approximateByFidelity(double targetFidelity, bool allLevels, bool removeNodes, bool verbose = false)
double approximateBySampling(std::unique_ptr<dd::Package> &localDD, dd::vEdge &edge, std::size_t nSamples, std::size_t threshold, bool actuallyRemoveNodes, bool verbose = false)
inline double approximateBySampling(std::size_t nSamples, std::size_t threshold, bool removeNodes, bool verbose = false)

Public Members

std::unique_ptr<dd::Package> dd
dd::vEdge rootEdge = dd::vEdge::one()

Public Static Functions

static dd::vEdge removeNodes(std::unique_ptr<dd::Package> &localDD, dd::vEdge edge, std::map<dd::vNode*, dd::vEdge> &dagEdges)

Protected Attributes

std::mt19937_64 mt
std::uint64_t seed = 0
bool hasFixedSeed
dd::fp epsilon = 0.001