20#ifdef INCLUDED_BY_FACTORY
45class GpuState :
public ISimulator {
54 void Initialize()
override {
56 if (simulationType == SimulationType::kStatevector) {
57 state = SimulatorsFactory::CreateGpuLibStateVectorSim();
59 const bool res = state->Create(nrQubits);
61 throw std::runtime_error(
62 "GpuState::Initialize: Failed to create "
63 "and initialize the statevector state.");
65 throw std::runtime_error(
66 "GpuState::Initialize: Failed to create the statevector state.");
67 }
else if (simulationType == SimulationType::kMatrixProductState) {
68 mps = SimulatorsFactory::CreateGpuLibMPSSim();
70 if (useDoublePrecision) mps->SetDataType(
true);
71 if (limitEntanglement && singularValueThreshold > 0.)
72 mps->SetCutoff(singularValueThreshold);
73 if (limitSize && chi > 0) mps->SetMaxExtent(chi);
74 const bool res = mps->Create(nrQubits);
76 throw std::runtime_error(
77 "GpuState::Initialize: Failed to create "
78 "and initialize the MPS state.");
80 throw std::runtime_error(
81 "GpuState::Initialize: Failed to create the MPS state.");
83 if (!useOptimalMeetingPosition)
84 mps->SetUseOptimalMeetingPosition(
false);
85 }
else if (simulationType == SimulationType::kTensorNetwork) {
86 tn = SimulatorsFactory::CreateGpuLibTensorNetSim();
88 const bool res = tn->Create(nrQubits);
90 throw std::runtime_error(
91 "GpuState::Initialize: Failed to create "
92 "and initialize the tensor network state.");
94 throw std::runtime_error(
95 "GpuState::Initialize: Failed to create the tensor network "
97 }
else if (simulationType == SimulationType::kPauliPropagator) {
98 pp = SimulatorsFactory::CreateGpuPauliPropagatorSimulatorUnique();
100 const bool res = pp->CreateSimulator(nrQubits);
102 throw std::runtime_error(
103 "GpuState::Initialize: Failed to create "
104 "and initialize the Pauli propagator state.");
106 pp->SetWillUseSampling(
true);
107 if (!pp->AllocateMemory(0.9))
108 throw std::runtime_error(
109 "GpuState::Initialize: Failed to allocate memory for the "
110 "Pauli propagator state.");
112 throw std::runtime_error(
113 "GpuState::Initialize: Failed to create the Pauli propagator "
116 throw std::runtime_error(
117 "GpuState::Initialize: Invalid simulation "
118 "type for initializing the state.");
133 void InitializeState(
size_t num_qubits,
134 std::vector<std::complex<double>> &litudes)
override {
135 if (num_qubits == 0)
return;
137 nrQubits = num_qubits;
140 if (simulationType != SimulationType::kStatevector)
141 throw std::runtime_error(
142 "GpuState::InitializeState: Invalid simulation "
143 "type for initializing the state.");
146 if (simulationType == SimulationType::kStatevector) {
147 state = SimulatorsFactory::CreateGpuLibStateVectorSim();
149 state->CreateWithState(
150 nrQubits,
reinterpret_cast<const double *
>(amplitudes.data()));
167 void InitializeState(
size_t num_qubits,
168 AER::Vector<std::complex<double>> &litudes)
override {
169 if (num_qubits == 0)
return;
171 nrQubits = num_qubits;
174 if (simulationType != SimulationType::kStatevector)
175 throw std::runtime_error(
176 "GpuState::InitializeState: Invalid simulation "
177 "type for initializing the state.");
180 if (simulationType == SimulationType::kStatevector) {
181 state = SimulatorsFactory::CreateGpuLibStateVectorSim();
183 state->CreateWithState(
184 nrQubits,
reinterpret_cast<const double *
>(amplitudes.data()));
201 void InitializeState(
size_t num_qubits,
202 Eigen::VectorXcd &litudes)
override {
203 if (num_qubits == 0)
return;
205 nrQubits = num_qubits;
208 if (simulationType != SimulationType::kStatevector)
209 throw std::runtime_error(
210 "GpuState::InitializeState: Invalid simulation "
211 "type for initializing the state.");
214 if (simulationType == SimulationType::kStatevector) {
215 state = SimulatorsFactory::CreateGpuLibStateVectorSim();
217 state->CreateWithState(
218 nrQubits,
reinterpret_cast<const double *
>(amplitudes.data()));
229 void Reset()
override {
237 pp->ClearOperators();
239 upcomingGateIndex = 0;
249 bool SupportsMPSSwapOptimization()
const override {
return true; }
259 void SetInitialQubitsMap(
260 const std::vector<long long int> &initialMap)
override {
262 mps->SetInitialQubitsMap(initialMap);
263 if (!dummySim || dummySim->getNrQubits() != initialMap.size()) {
265 std::make_unique<Simulators::MPSDummySimulator>(initialMap.size());
266 dummySim->SetMaxBondDimension(
267 limitSize ?
static_cast<long long int>(chi) : 0);
269 dummySim->setGrowthFactorGate(growthFactorGate);
270 dummySim->setGrowthFactorSwap(growthFactorSwap);
271 dummySim->SetInitialQubitsMap(initialMap);
275 void SetUseOptimalMeetingPosition(
bool enable)
override {
276 useOptimalMeetingPosition = enable;
277 if (mps) mps->SetUseOptimalMeetingPosition(enable);
280 void SetLookaheadDepth(
int depth)
override {
281 lookaheadDepth = depth;
282 if (mps && depth > 0 && !useOptimalMeetingPosition)
283 mps->SetUseOptimalMeetingPosition(
true);
286 void SetLookaheadDepthWithHeuristic(
int depth)
override {
287 lookaheadDepthWithHeuristic = depth;
288 if (lookaheadDepth < depth) SetLookaheadDepth(depth);
291 void SetUpcomingGates(
294 upcomingGates = gates;
295 upcomingGateIndex = 0;
297 if (!mps || lookaheadDepth <= 0)
return;
302 gateCounterObserver =
303 std::make_shared<GateCounterObserver>(upcomingGateIndex);
304 RegisterObserver(gateCounterObserver);
310 mps->SetCallbackContext((
void*)
this);
311 mps->SetMeetingPositionCallback(&GpuState::FindBestMeetingPosition);
322 long long int GetGatesCounter()
const override {
return upcomingGateIndex; }
333 void SetGatesCounter(
long long int counter)
override {
334 upcomingGateIndex = counter;
345 void IncrementGatesCounter()
override { ++upcomingGateIndex; }
347 double getGrowthFactorSwap()
const override {
return growthFactorSwap; }
348 double getGrowthFactorGate()
const override {
return growthFactorGate; }
350 void setGrowthFactorSwap(
double factor)
override {
351 growthFactorSwap = factor;
352 if (dummySim) dummySim->setGrowthFactorSwap(factor);
355 void setGrowthFactorGate(
double factor)
override {
356 growthFactorGate = factor;
357 if (dummySim) dummySim->setGrowthFactorGate(factor);
368 void Configure(
const char *key,
const char *value)
override {
369 if (std::string(
"method") == key) {
370 if (std::string(
"statevector") == value)
371 simulationType = SimulationType::kStatevector;
372 else if (std::string(
"matrix_product_state") == value)
373 simulationType = SimulationType::kMatrixProductState;
374 else if (std::string(
"tensor_network") == value)
375 simulationType = SimulationType::kTensorNetwork;
376 else if (std::string(
"pauli_propagator") == value)
377 simulationType = SimulationType::kPauliPropagator;
378 }
else if (std::string(
"matrix_product_state_truncation_threshold") ==
380 singularValueThreshold = std::stod(value);
381 if (singularValueThreshold > 0.) {
382 limitEntanglement =
true;
383 if (mps) mps->SetCutoff(singularValueThreshold);
384 if (tn) tn->SetCutoff(singularValueThreshold);
386 limitEntanglement =
false;
387 }
else if (std::string(
"matrix_product_state_max_bond_dimension") == key) {
388 chi = std::stoi(value);
391 if (mps) mps->SetMaxExtent(chi);
392 if (tn) tn->SetMaxExtent(chi);
395 }
else if (std::string(
"use_double_precision") == key) {
397 (std::string(
"1") == value || std::string(
"true") == value);
410 if (std::string(
"method") == key) {
411 switch (simulationType) {
412 case SimulationType::kStatevector:
413 return "statevector";
414 case SimulationType::kMatrixProductState:
415 return "matrix_product_state";
416 case SimulationType::kTensorNetwork:
417 return "tensor_network";
418 case SimulationType::kPauliPropagator:
419 return "pauli_propagator";
423 }
else if (std::string(
"matrix_product_state_truncation_threshold") ==
425 if (limitEntanglement && singularValueThreshold > 0.) {
426 std::ostringstream oss;
427 oss << std::setprecision(std::numeric_limits<double>::max_digits10)
428 << singularValueThreshold;
431 }
else if (std::string(
"matrix_product_state_max_bond_dimension") == key) {
432 if (limitSize && limitSize > 0)
return std::to_string(chi);
447 if ((simulationType == SimulationType::kStatevector && state) ||
448 (simulationType == SimulationType::kMatrixProductState && mps) ||
449 (simulationType == SimulationType::kPauliPropagator && pp))
452 const size_t oldNrQubits = nrQubits;
453 nrQubits += num_qubits;
473 void Clear()
override {
480 upcomingGateIndex = 0;
481 upcomingGates.clear();
498 if (qubits.size() >
sizeof(
size_t) * 8)
500 <<
"Warning: The number of qubits to measure is larger than the "
501 "number of bits in the size_t type, the outcome will be undefined"
508 if (simulationType == SimulationType::kStatevector) {
510 for (
size_t qubit : qubits) {
511 if (state->MeasureQubitCollapse(
static_cast<int>(qubit))) res |= mask;
514 }
else if (simulationType == SimulationType::kMatrixProductState) {
516 for (
size_t qubit : qubits) {
517 if (mps->Measure(
static_cast<unsigned int>(qubit))) res |= mask;
520 }
else if (simulationType == SimulationType::kTensorNetwork) {
522 for (
size_t qubit : qubits) {
523 if (tn->Measure(
static_cast<unsigned int>(qubit))) res |= mask;
526 }
else if (simulationType == SimulationType::kPauliPropagator) {
528 for (
size_t qubit : qubits) {
529 if (pp->MeasureQubit(
static_cast<int>(qubit))) res |= mask;
535 NotifyObservers(qubits);
547 std::vector<bool> res(qubits.size(),
false);
550 if (simulationType == SimulationType::kStatevector) {
551 for (
size_t i = 0; i < qubits.size(); ++i)
552 res[i] = state->MeasureQubitCollapse(
static_cast<int>(qubits[i]));
553 }
else if (simulationType == SimulationType::kMatrixProductState) {
554 for (
size_t i = 0; i < qubits.size(); ++i)
555 res[i] = mps->Measure(
static_cast<unsigned int>(qubits[i]));
556 }
else if (simulationType == SimulationType::kTensorNetwork) {
557 for (
size_t i = 0; i < qubits.size(); ++i)
558 res[i] = tn->Measure(
static_cast<unsigned int>(qubits[i]));
559 }
else if (simulationType == SimulationType::kPauliPropagator) {
560 for (
size_t i = 0; i < qubits.size(); ++i)
561 res[i] = pp->MeasureQubit(
static_cast<int>(qubits[i]));
564 NotifyObservers(qubits);
577 if (simulationType == SimulationType::kStatevector) {
578 for (
size_t qubit : qubits)
579 if (state->MeasureQubitCollapse(
static_cast<int>(qubit)))
580 state->ApplyX(
static_cast<int>(qubit));
581 }
else if (simulationType == SimulationType::kMatrixProductState) {
582 for (
size_t qubit : qubits)
583 if (mps->Measure(
static_cast<unsigned int>(qubit)))
584 mps->ApplyX(
static_cast<unsigned int>(qubit));
585 }
else if (simulationType == SimulationType::kTensorNetwork) {
586 for (
size_t qubit : qubits)
587 if (tn->Measure(
static_cast<unsigned int>(qubit)))
588 tn->ApplyX(
static_cast<unsigned int>(qubit));
589 }
else if (simulationType == SimulationType::kPauliPropagator) {
590 for (
size_t qubit : qubits)
591 if (pp->MeasureQubit(
static_cast<int>(qubit)))
592 pp->ApplyX(
static_cast<int>(qubit));
596 NotifyObservers(qubits);
611 if (simulationType == SimulationType::kStatevector)
612 return state->BasisStateProbability(outcome);
613 else if (simulationType == SimulationType::kMatrixProductState ||
614 simulationType == SimulationType::kTensorNetwork) {
616 return std::norm(ampl);
617 }
else if (simulationType == SimulationType::kPauliPropagator) {
618 return pp->Probability(outcome);
638 if (simulationType == SimulationType::kStatevector)
639 state->Amplitude(outcome, &real, &imag);
640 else if (simulationType == SimulationType::kMatrixProductState ||
641 simulationType == SimulationType::kTensorNetwork) {
642 std::vector<long int> fixedValues(nrQubits);
643 for (
size_t i = 0; i < nrQubits; ++i)
644 fixedValues[i] = (outcome & (1ULL << i)) ? 1 : 0;
645 if (simulationType == SimulationType::kMatrixProductState)
646 mps->Amplitude(nrQubits, fixedValues.data(), &real, &imag);
647 else if (simulationType == SimulationType::kTensorNetwork)
648 tn->Amplitude(nrQubits, fixedValues.data(), &real, &imag);
649 }
else if (simulationType == SimulationType::kPauliPropagator) {
651 throw std::runtime_error(
652 "GpuState::Amplitude: Invalid simulation type for amplitude "
656 return std::complex<double>(real, imag);
672 std::complex<double> ProjectOnZero()
override {
673 if (simulationType == SimulationType::kMatrixProductState)
674 return mps->ProjectOnZero();
690 if (nrQubits == 0)
return {};
691 const size_t numStates = 1ULL << nrQubits;
692 std::vector<double> result(numStates);
694 if (simulationType == SimulationType::kStatevector)
695 state->AllProbabilities(result.data());
696 else if (simulationType == SimulationType::kMatrixProductState ||
697 simulationType == SimulationType::kTensorNetwork) {
701 result[i] = std::norm(std::complex<double>(val.real(), val.imag()));
703 }
else if (simulationType == SimulationType::kPauliPropagator) {
706 result[i] = pp->Probability(i);
726 std::vector<double> result(qubits.size());
728 if (simulationType == SimulationType::kStatevector) {
729 for (
size_t i = 0; i < qubits.size(); ++i)
730 result[i] = state->BasisStateProbability(qubits[i]);
731 }
else if (simulationType == SimulationType::kMatrixProductState ||
732 simulationType == SimulationType::kTensorNetwork) {
733 for (
size_t i = 0; i < qubits.size(); ++i) {
735 result[i] = std::norm(ampl);
737 }
else if (simulationType == SimulationType::kPauliPropagator) {
738 for (
size_t i = 0; i < qubits.size(); ++i)
739 result[i] = pp->Probability(qubits[i]);
761 std::unordered_map<Types::qubit_t, Types::qubit_t>
SampleCounts(
763 if (qubits.empty() || shots == 0)
return {};
767 <<
"Warning: The number of qubits to measure is larger than the "
768 "number of bits in the Types::qubit_t type, the outcome will be "
772 std::unordered_map<Types::qubit_t, Types::qubit_t> result;
776 if (simulationType == SimulationType::kStatevector) {
777 std::vector<long int> samples(shots);
778 state->SampleAll(shots, samples.data());
780 for (
auto outcome : samples) {
785 for (
size_t i = 0; i < qubits.size(); ++i) {
786 if (outcome & (1ULL << qubits[i])) translatedOutcome |= mask;
789 ++result[translatedOutcome];
791 }
else if (simulationType == SimulationType::kMatrixProductState) {
792 std::unordered_map<std::vector<bool>, int64_t> *map =
793 mps->GetMapForSample();
795 std::vector<unsigned int> qubitsIndices(qubits.begin(), qubits.end());
797 mps->Sample(shots, qubitsIndices.size(), qubitsIndices.data(), map);
800 for (
const auto &[meas, cnt] : *map) {
804 if (meas[q]) outcome |= mask;
808 result[outcome] += cnt;
811 mps->FreeMapForSample(map);
812 }
else if (simulationType == SimulationType::kTensorNetwork) {
813 std::unordered_map<std::vector<bool>, int64_t> *map =
814 tn->GetMapForSample();
815 std::vector<unsigned int> qubitsIndices(qubits.begin(), qubits.end());
816 tn->Sample(shots, qubitsIndices.size(), qubitsIndices.data(), map);
818 for (
const auto &[meas, cnt] : *map) {
822 if (meas[q]) outcome |= mask;
825 result[outcome] += cnt;
827 tn->FreeMapForSample(map);
828 }
else if (simulationType == SimulationType::kPauliPropagator) {
829 std::vector<int> qb(qubits.begin(), qubits.end());
830 for (
size_t shot = 0; shot < shots; ++shot) {
832 auto res = pp->SampleQubits(qb);
833 for (
size_t i = 0; i < qubits.size(); ++i) {
834 if (res[i]) meas |= (1ULL << i);
841 NotifyObservers(qubits);
859 std::unordered_map<std::vector<bool>,
Types::qubit_t> SampleCountsMany(
861 if (qubits.empty() || shots == 0)
return {};
867 if (simulationType == SimulationType::kStatevector) {
868 std::vector<long int> samples(shots);
869 state->SampleAll(shots, samples.data());
871 std::vector<bool> outcomeVec(qubits.size());
872 for (
auto outcome : samples) {
873 for (
size_t i = 0; i < qubits.size(); ++i)
874 outcomeVec[i] = ((outcome >> qubits[i]) & 1) == 1;
875 ++result[outcomeVec];
877 }
else if (simulationType == SimulationType::kMatrixProductState) {
878 std::unordered_map<std::vector<bool>, int64_t> *map =
879 mps->GetMapForSample();
881 std::vector<unsigned int> qubitsIndices(qubits.begin(), qubits.end());
882 mps->Sample(shots, qubitsIndices.size(), qubitsIndices.data(), map);
885 for (
const auto &[meas, cnt] : *map) result[meas] += cnt;
887 mps->FreeMapForSample(map);
888 }
else if (simulationType == SimulationType::kTensorNetwork) {
889 std::unordered_map<std::vector<bool>, int64_t> *map =
890 tn->GetMapForSample();
891 std::vector<unsigned int> qubitsIndices(qubits.begin(), qubits.end());
892 tn->Sample(shots, qubitsIndices.size(), qubitsIndices.data(), map);
894 for (
const auto &[meas, cnt] : *map) result[meas] += cnt;
895 tn->FreeMapForSample(map);
896 }
else if (simulationType == SimulationType::kPauliPropagator) {
897 std::vector<int> qb(qubits.begin(), qubits.end());
898 for (
size_t shot = 0; shot < shots; ++shot) {
899 const auto res = pp->SampleQubits(qb);
905 NotifyObservers(qubits);
921 double ExpectationValue(
const std::string &pauliString)
override {
924 if (simulationType == SimulationType::kStatevector)
925 result = state->ExpectationValue(pauliString);
926 else if (simulationType == SimulationType::kMatrixProductState)
927 result = mps->ExpectationValue(pauliString);
928 else if (simulationType == SimulationType::kTensorNetwork)
929 result = tn->ExpectationValue(pauliString);
930 else if (simulationType == SimulationType::kPauliPropagator)
931 result = pp->ExpectationValue(pauliString);
933 throw std::runtime_error(
934 "GpuState::ExpectationValue: Invalid simulation type for expectation "
935 "value calculation.");
947 SimulatorType GetType()
const override {
return SimulatorType::kGpuSim; }
967 void Flush()
override {}
980 if (simulationType == SimulationType::kStatevector)
981 state->SaveStateDestructive();
983 throw std::runtime_error(
984 "GpuState::SaveStateToInternalDestructive: Invalid simulation type "
985 "for saving the state destructively.");
995 if (simulationType == SimulationType::kStatevector)
996 state->RestoreStateFreeSaved();
998 throw std::runtime_error(
999 "GpuState::RestoreInternalDestructiveSavedState: Invalid simulation "
1000 "type for restoring the state destructively.");
1012 if (simulationType == SimulationType::kStatevector)
1014 else if (simulationType == SimulationType::kMatrixProductState)
1016 else if (simulationType == SimulationType::kTensorNetwork)
1018 else if (simulationType == SimulationType::kPauliPropagator)
1030 if (simulationType == SimulationType::kStatevector)
1031 state->RestoreStateNoFreeSaved();
1032 else if (simulationType == SimulationType::kMatrixProductState)
1033 mps->RestoreState();
1034 else if (simulationType == SimulationType::kTensorNetwork)
1036 else if (simulationType == SimulationType::kPauliPropagator)
1047 std::complex<double> AmplitudeRaw(
Types::qubit_t outcome)
override {
1082 bool IsQcsim()
const override {
return false; }
1101 if (simulationType == SimulationType::kStatevector)
1102 return state->MeasureAllQubitsNoCollapse();
1103 else if (simulationType == SimulationType::kMatrixProductState ||
1104 simulationType == SimulationType::kTensorNetwork ||
1105 simulationType == SimulationType::kPauliPropagator) {
1108 <<
"Warning: The number of qubits to measure is larger than the "
1109 "number of bits in the Types::qubit_t type, the outcome will be "
1114 std::iota(fixedValues.begin(), fixedValues.end(), 0);
1116 if (res.empty())
return 0;
1121 throw std::runtime_error(
1122 "QCSimState::MeasureNoCollapse: Invalid simulation type for measuring "
1123 "all the qubits without collapsing the state.");
1142 std::vector<bool> MeasureNoCollapseMany()
override {
1143 if (simulationType == SimulationType::kStatevector) {
1144 const auto meas = state->MeasureAllQubitsNoCollapse();
1145 std::vector<bool> result(nrQubits,
false);
1146 for (
size_t i = 0; i < nrQubits; ++i) result[i] = ((meas >> i) & 1) == 1;
1148 }
else if (simulationType == SimulationType::kMatrixProductState ||
1149 simulationType == SimulationType::kTensorNetwork ||
1150 simulationType == SimulationType::kPauliPropagator) {
1152 std::iota(fixedValues.begin(), fixedValues.end(), 0);
1153 const auto res = SampleCountsMany(fixedValues, 1);
1154 if (res.empty())
return std::vector<bool>(nrQubits,
false);
1159 throw std::runtime_error(
1160 "QCSimState::MeasureNoCollapseMany: Invalid simulation type for "
1162 "all the qubits without collapsing the state.");
1164 return std::vector<bool>(nrQubits,
false);
1168 static int64_t FindBestMeetingPosition(
void* thisPtr,
const int64_t* bondDims) {
1169 GpuState* self =
static_cast<GpuState*
>(thisPtr);
1171 return self->FindBestMeetingPositionFunc(bondDims);
1174 int64_t FindBestMeetingPositionFunc(
const int64_t* bondDims)
1178 if (!dummySim || dummySim->getNrQubits() != nQ) {
1179 dummySim = std::make_unique<Simulators::MPSDummySimulator>(nQ);
1180 dummySim->SetMaxBondDimension(
1181 limitSize ?
static_cast<long long int>(chi) : 0);
1182 dummySim->setGrowthFactorGate(growthFactorGate);
1183 dummySim->setGrowthFactorSwap(growthFactorSwap);
1186 dummySim->setTotalSwappingCost(0);
1188 std::vector<double> bondDimsD(bondDims, bondDims + nrQubits - 1);
1189 dummySim->SetCurrentBondDimensions(bondDimsD);
1191 const auto &op = upcomingGates[upcomingGateIndex];
1192 const auto qbits = op->AffectedQubits();
1194 if (qbits.size() != 2) {
1195 std::cerr <<
"Error: Meeting position callback called for a gate "
1196 "that does not have exactly 2 qubits."
1202 double bestCost = std::numeric_limits<double>::infinity();
1203 int64_t res = dummySim->FindBestMeetingPosition(
1204 upcomingGates, upcomingGateIndex, lookaheadDepth,
1205 lookaheadDepthWithHeuristic, 0, bestCost);
1207 dummySim->SwapQubitsToPosition(qbits[0], qbits[1], res);
1208 dummySim->ApplyGate(op);
1213 SimulationType simulationType =
1214 SimulationType::kStatevector;
1216 std::unique_ptr<GpuLibStateVectorSim>
1218 std::unique_ptr<GpuLibMPSSim> mps;
1219 std::unique_ptr<GpuLibTNSim> tn;
1220 std::unique_ptr<GpuPauliPropagator>
1223 size_t nrQubits = 0;
1224 bool limitSize =
false;
1225 bool limitEntanglement =
false;
1226 Eigen::Index chi = 10;
1227 double singularValueThreshold = 0.;
1228 bool useDoublePrecision =
false;
1230 int lookaheadDepth = 0;
1231 int lookaheadDepthWithHeuristic = 0;
1232 bool useOptimalMeetingPosition =
true;
1233 std::vector<std::shared_ptr<Circuits::IOperation<>>> upcomingGates;
1234 long long int upcomingGateIndex = 0;
1235 double growthFactorSwap = 1.;
1236 double growthFactorGate = 0.65;
1238 std::unique_ptr<Simulators::MPSDummySimulator> dummySim;
1241 class GateCounterObserver :
public ISimulatorObserver {
1243 GateCounterObserver(
long long int &indexRef) : index(indexRef) {}
1247 long long int &index;
1249 std::shared_ptr<GateCounterObserver> gateCounterObserver;
double Probability(void *sim, unsigned long long int outcome)
char * GetConfiguration(void *sim, const char *key)
int RestoreState(void *sim)
int ApplyReset(void *sim, const unsigned long int *qubits, unsigned long int nrQubits)
unsigned long int AllocateQubits(void *sim, unsigned long int nrQubits)
unsigned long int GetNumberOfQubits(void *sim)
double * AllProbabilities(void *sim)
unsigned long long int MeasureNoCollapse(void *sim)
int GetMultithreading(void *sim)
unsigned long long int Measure(void *sim, const unsigned long int *qubits, unsigned long int nrQubits)
double * Amplitude(void *sim, unsigned long long int outcome)
double * Probabilities(void *sim, const unsigned long long int *qubits, unsigned long int nrQubits)
int SetMultithreading(void *sim, int multithreading)
int SaveStateToInternalDestructive(void *sim)
int GetSimulationType(void *sim)
unsigned long long int * SampleCounts(void *sim, const unsigned long long int *qubits, unsigned long int nrQubits, unsigned long int shots)
int RestoreInternalDestructiveSavedState(void *sim)
std::vector< qubit_t > qubits_vector
The type of a vector of qubits.
uint_fast64_t qubit_t
The type of a qubit.