17#ifndef _SIMPLE_CONTROLLER_H_
18#define _SIMPLE_CONTROLLER_H_
41template <
typename Time = Types::time_type>
61 std::shared_ptr<Circuits::Circuit<Time>> distCirc =
62 std::static_pointer_cast<Circuits::Circuit<Time>>(circuit->Clone());
74 distCirc->Optimize(optimizeRotationGates);
78 distCirc->ConvertForDistribution();
88 optimiser->SetNetworkAndCircuit(network, distCirc);
90 const auto &qubitsMap =
optimiser->GetQubitsMap();
91 distCirc = std::dynamic_pointer_cast<Circuits::Circuit<Time>>(
92 distCirc->Remap(qubitsMap, qubitsMap));
104 return remapper->Remap(network, distCirc);
129 return remapper->SplitCompositeOperations(network, circuit);
140 size_t GetId()
const override {
return std::numeric_limits<size_t>::max(); }
300 std::shared_ptr<Distribution::IRemapper<Time>>
GetRemapper()
const override {
320 const std::vector<uint8_t> &packet)
override {
340 const std::vector<uint8_t> &packet)
override {
371 std::shared_ptr<Graphs::IOptimiser<Time>>
GetOptimiser()
const override {
383 throw std::runtime_error(
"SimpleController::CreateOptimiser: not "
384 "implemented for this type of network controller");
400 std::shared_ptr<Circuits::Circuit<Time>>
422 throw std::runtime_error(
"SimpleController::CreateScheduler: not "
423 "implemented for this type of network controller");
434 std::shared_ptr<Schedulers::IScheduler<Time>>
GetScheduler()
const override {
439 return optimizeRotationGates;
443 optimizeRotationGates = val;
466 std::shared_ptr<Distribution::IRemapper<Time>>
476 std::shared_ptr<Graphs::IOptimiser<Time>>
481 std::shared_ptr<Schedulers::IScheduler<Time>>
485 bool optimize =
true;
486 bool optimizeRotationGates =
Circuit class for holding the sequence of operations.
The controller host interface.
The simple controller host implementation.
bool IsQubitOnHost(size_t qubitId) const override
Check if a qubit is in the host.
std::vector< size_t > GetEntangledQubitMeasurementBitIds() const override
Get the ids of the classical bits used for measurement of the qubits used for entanglement between ho...
std::shared_ptr< Circuits::Circuit< Time > > SplitCompositeOperations(const std::shared_ptr< INetwork< Time > > &network, const std::shared_ptr< Circuits::Circuit< Time > > &circuit) override
Splits the composite operations from the circuit.
void CreateOptimiser(Graphs::OptimiserType type) override
Creates an optimiser.
size_t GetNumClassicalBits() const override
Get the number of classical bits.
std::shared_ptr< Circuits::Circuit< Time > > DistributeCircuit(const std::shared_ptr< INetwork< Time > > &network, const std::shared_ptr< Circuits::Circuit< Time > > &circuit) override
Distributes the circuit on the hosts.
bool RecvPacketFromHost(size_t hostId, const std::vector< uint8_t > &packet) override
Receive a packet from a host.
void SetRemapper(const std::shared_ptr< Distribution::IRemapper< Time > > &r) override
Changes the remapper that is used for remapping a circuit to a distributed one.
void SetOptimizeRotationGates(bool val=true) override
size_t GetStartQubitId() const override
Get the id of the first qubit assigned to the host.
void SetOptimizeCircuit(bool o=true) override
Set circuit optimization.
std::shared_ptr< Schedulers::IScheduler< Time > > GetScheduler() const override
Get the scheduler for the network.
std::shared_ptr< Graphs::IOptimiser< Time > > optimiser
std::shared_ptr< Graphs::IOptimiser< Time > > GetOptimiser() const override
Returns the optimiser used.
std::shared_ptr< Distribution::IRemapper< Time > > remapper
The remapper used to remap a circuit to a distributed one.
bool IsEntangledQubitOnHost(size_t qubitId) const override
Check if a qubit used for entanglement between hosts is in the host.
bool GetOptimizeCircuit() const override
Get circuit optimization.
std::shared_ptr< Distribution::IRemapper< Time > > GetRemapper() const override
Gets the remapper that is used for remapping a circuit to a distributed one.
std::vector< size_t > GetQubitsIds() const override
Get the ids of the qubits in the host.
bool IsClassicalBitOnHost(size_t qubitId) const override
Check if a classical bit is in the host.
std::vector< size_t > GetNetworkEntangledQubitsIds() const override
Get the ids of the qubits used for entanglement between hosts in the host.
bool AreCbitsOnSameHost(size_t qubitId1, size_t qubitId2) const override
Check if two classical bits are in the same host.
std::shared_ptr< Circuits::Circuit< Time > > DoNetworkSpecificConversionsForDistribution(const std::shared_ptr< INetwork< Time > > &network, const std::shared_ptr< Circuits::Circuit< Time > > &circuit) override
Convert the circuit for distribution for specific networks.
size_t GetNumQubits() const override
Get the number of qubits.
bool AreQubitsOnSameHost(size_t qubitId1, size_t qubitId2) const override
Check if two qubits are in the same host.
size_t GetId() const override
Get the host id.
size_t GetNumNetworkEntangledQubits() const override
Get the number of network entangled qubits.
std::shared_ptr< Schedulers::IScheduler< Time > > scheduler
< The optimiser used to optimise the circuit.
bool GetOptimizeRotationGates() const override
std::vector< size_t > GetClassicalBitsIds() const override
Get the ids of the classical bits in the host.
void CreateScheduler(const std::shared_ptr< INetwork< Time > > &network, SchedulerType schType=SchedulerType::kNoEntanglementQubitsParallel) override
Create the scheduler for the network.
size_t GetStartClassicalBitId() const override
Get the id of the first classical bit assigned to the host.
bool SendPacketToHost(size_t hostId, const std::vector< uint8_t > &packet) override
Send a packet to a host.
OptimiserType
The type of optimiser.
SchedulerType
The type of the network scheduler for scheduling execution of multiple circuits.
@ kNoEntanglementQubitsParallel