17#ifndef _SIMPLE_CONTROLLER_H_
18#define _SIMPLE_CONTROLLER_H_
20#include "../Distribution/Remapper.h"
21#include "../Scheduler/Scheduler.h"
22#include "../graph/Optimiser.h"
41template <
typename Time = Types::time_type>
60 std::shared_ptr<Circuits::Circuit<Time>> distCirc =
61 std::static_pointer_cast<Circuits::Circuit<Time>>(circuit->Clone());
72 if (optimize) distCirc->Optimize(optimizeRotationGates);
76 distCirc->ConvertForDistribution();
86 optimiser->SetNetworkAndCircuit(network, distCirc);
88 const auto &qubitsMap =
optimiser->GetQubitsMap();
89 distCirc = std::dynamic_pointer_cast<Circuits::Circuit<Time>>(
90 distCirc->Remap(qubitsMap, qubitsMap));
102 return remapper->Remap(network, distCirc);
126 return remapper->SplitCompositeOperations(network, circuit);
137 size_t GetId()
const override {
return std::numeric_limits<size_t>::max(); }
297 std::shared_ptr<Distribution::IRemapper<Time>>
GetRemapper()
const override {
317 const std::vector<uint8_t> &packet)
override {
337 const std::vector<uint8_t> &packet)
override {
368 std::shared_ptr<Graphs::IOptimiser<Time>>
GetOptimiser()
const override {
380 throw std::runtime_error(
381 "SimpleController::CreateOptimiser: not "
382 "implemented for this type of network controller");
398 std::shared_ptr<Circuits::Circuit<Time>>
420 throw std::runtime_error(
421 "SimpleController::CreateScheduler: not "
422 "implemented for this type of network controller");
433 std::shared_ptr<Schedulers::IScheduler<Time>>
GetScheduler()
const override {
438 return optimizeRotationGates;
442 optimizeRotationGates = val;
465 std::shared_ptr<Distribution::IRemapper<Time>>
475 std::shared_ptr<Graphs::IOptimiser<Time>>
480 std::shared_ptr<Schedulers::IScheduler<Time>>
484 bool optimize =
true;
485 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 scheduler used to schedule the circuits.
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.
SchedulerType
The type of the network scheduler for scheduling execution of multiple circuits.
@ kNoEntanglementQubitsParallel