Maestro 0.1.0
Unified interface for quantum circuit simulation
Loading...
Searching...
No Matches
Network::SimpleController< Time > Class Template Reference

The simple controller host implementation. More...

#include <SimpleController.h>

Inheritance diagram for Network::SimpleController< Time >:
Network::IController< Types::time_type > Network::IHost< Types::time_type >

Public Member Functions

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.
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.
size_t GetId () const override
 Get the host id.
size_t GetNumQubits () const override
 Get the number of qubits.
size_t GetNumNetworkEntangledQubits () const override
 Get the number of network entangled qubits.
size_t GetNumClassicalBits () const override
 Get the number of classical bits.
bool IsQubitOnHost (size_t qubitId) const override
 Check if a qubit is in the host.
bool IsClassicalBitOnHost (size_t qubitId) const override
 Check if a classical bit is in the host.
bool IsEntangledQubitOnHost (size_t qubitId) const override
 Check if a qubit used for entanglement between hosts is in the host.
bool AreQubitsOnSameHost (size_t qubitId1, size_t qubitId2) const override
 Check if two qubits are in the same host.
bool AreCbitsOnSameHost (size_t qubitId1, size_t qubitId2) const override
 Check if two classical bits are in the same host.
std::vector< size_t > GetQubitsIds () const override
 Get the ids of the qubits in the host.
std::vector< size_t > GetNetworkEntangledQubitsIds () const override
 Get the ids of the qubits used for entanglement between hosts in the host.
std::vector< size_t > GetClassicalBitsIds () const override
 Get the ids of the classical bits 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 hosts present in the 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.
std::shared_ptr< Distribution::IRemapper< Time > > GetRemapper () const override
 Gets the remapper that is used for remapping a circuit to a distributed one.
bool SendPacketToHost (size_t hostId, const std::vector< uint8_t > &packet) override
 Send a packet to a host.
bool RecvPacketFromHost (size_t hostId, const std::vector< uint8_t > &packet) override
 Receive a packet from a host.
size_t GetStartQubitId () const override
 Get the id of the first qubit assigned to the host.
size_t GetStartClassicalBitId () const override
 Get the id of the first classical bit assigned to the host.
std::shared_ptr< Graphs::IOptimiser< Time > > GetOptimiser () const override
 Returns the optimiser used.
void CreateOptimiser (Graphs::OptimiserType type) override
 Creates an optimiser.
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.
void CreateScheduler (const std::shared_ptr< INetwork< Time > > &network, SchedulerType schType=SchedulerType::kNoEntanglementQubitsParallel) override
 Create the scheduler for the network.
std::shared_ptr< Schedulers::IScheduler< Time > > GetScheduler () const override
 Get the scheduler for the network.
bool GetOptimizeRotationGates () const override
void SetOptimizeRotationGates (bool val=true) override
void SetOptimizeCircuit (bool o=true) override
 Set circuit optimization.
bool GetOptimizeCircuit () const override
 Get circuit optimization.
Public Member Functions inherited from Network::IController< Types::time_type >
virtual std::shared_ptr< Circuits::Circuit< Types::time_type > > DistributeCircuit (const std::shared_ptr< INetwork< Types::time_type > > &network, const std::shared_ptr< Circuits::Circuit< Types::time_type > > &circuit)=0
 Distributes the circuit on the hosts.
virtual std::shared_ptr< Circuits::Circuit< Types::time_type > > SplitCompositeOperations (const std::shared_ptr< INetwork< Types::time_type > > &network, const std::shared_ptr< Circuits::Circuit< Types::time_type > > &circuit)=0
 Splits the composite operations from the circuit.
virtual void SetRemapper (const std::shared_ptr< Distribution::IRemapper< Types::time_type > > &remapper)=0
 Changes the remapper that is used for remapping a circuit to a distributed one.
virtual std::shared_ptr< Circuits::Circuit< Types::time_type > > DoNetworkSpecificConversionsForDistribution (const std::shared_ptr< INetwork< Types::time_type > > &network, const std::shared_ptr< Circuits::Circuit< Types::time_type > > &circuit)=0
 Convert the circuit for distribution for specific networks.
virtual void CreateScheduler (const std::shared_ptr< INetwork< Types::time_type > > &network, SchedulerType schType=SchedulerType::kNoEntanglementQubitsParallel)=0
 Create the scheduler for the network.
Public Member Functions inherited from Network::IHost< Types::time_type >
virtual ~IHost ()=default
 The destructor.
std::shared_ptr< IHost< Types::time_type > > getptr ()
 Get a shared pointer to this object.

Protected Attributes

std::shared_ptr< Distribution::IRemapper< Time > > remapper
 The remapper used to remap a circuit to a distributed one.
std::shared_ptr< Graphs::IOptimiser< Time > > optimiser
std::shared_ptr< Schedulers::IScheduler< Time > > scheduler
 < The optimiser used to optimise the circuit.

Detailed Description

template<typename Time = Types::time_type>
class Network::SimpleController< Time >

The simple controller host implementation.

The controller is a special kind of host, it is the one that distributes the circuit to the other hosts. The simple controller just converts a local circuit to a distributed one.

Template Parameters
TimeThe time representation to use for execution times.
See also
IController
INetwork
SimpleNetwork
Circuits::Circuit

Definition at line 42 of file SimpleController.h.

Member Function Documentation

◆ AreCbitsOnSameHost()

template<typename Time = Types::time_type>
bool Network::SimpleController< Time >::AreCbitsOnSameHost ( size_t qubitId1,
size_t qubitId2 ) const
inlineoverridevirtual

Check if two classical bits are in the same host.

Checks if two classical bits with the specified ids are in the same host. The controller is a special host, it's not a quantum computer, so it returns false.

Returns
True if the classical bits are on the same host, false otherwise.

Implements Network::IHost< Types::time_type >.

Definition at line 224 of file SimpleController.h.

◆ AreQubitsOnSameHost()

template<typename Time = Types::time_type>
bool Network::SimpleController< Time >::AreQubitsOnSameHost ( size_t qubitId1,
size_t qubitId2 ) const
inlineoverridevirtual

Check if two qubits are in the same host.

Checks if two qubits with the specified ids are in the same host, excluding the one(s) used only for entanglement with other hosts. The controller is a special host, it's not a quantum computer, so it returns false.

Returns
True if the qubits are on the same host, false otherwise.

Implements Network::IHost< Types::time_type >.

Definition at line 212 of file SimpleController.h.

◆ CreateOptimiser()

template<typename Time = Types::time_type>
void Network::SimpleController< Time >::CreateOptimiser ( Graphs::OptimiserType type)
inlineoverridevirtual

Creates an optimiser.

Creates an optimiser of the specified type.

Parameters
typeThe type of optimiser to create.

Implements Network::IController< Types::time_type >.

Definition at line 382 of file SimpleController.h.

◆ CreateScheduler()

template<typename Time = Types::time_type>
void Network::SimpleController< Time >::CreateScheduler ( const std::shared_ptr< INetwork< Time > > & network,
SchedulerType schType = SchedulerType::kNoEntanglementQubitsParallel )
inlineoverride

Create the scheduler for the network.

Creates the scheduler for the network. Call this only after the network topology has been set up. Should create the scheduler and set the network for it and any other necessary parameters.

Parameters
simTypeThe type of the scheduler to create.
See also
SchedulerType

Definition at line 419 of file SimpleController.h.

◆ DistributeCircuit()

template<typename Time = Types::time_type>
std::shared_ptr< Circuits::Circuit< Time > > Network::SimpleController< Time >::DistributeCircuit ( const std::shared_ptr< INetwork< Time > > & network,
const std::shared_ptr< Circuits::Circuit< Time > > & circuit )
inlineoverride

Distributes the circuit on the hosts.

The network will call this, the conversion and distribution should happen before execution.

Parameters
networkThe network to distribute the circuit for.
circuitThe circuit to distribute.
Returns
The distributed circuit.

Definition at line 54 of file SimpleController.h.

◆ DoNetworkSpecificConversionsForDistribution()

template<typename Time = Types::time_type>
std::shared_ptr< Circuits::Circuit< Time > > Network::SimpleController< Time >::DoNetworkSpecificConversionsForDistribution ( const std::shared_ptr< INetwork< Time > > & network,
const std::shared_ptr< Circuits::Circuit< Time > > & circuit )
inlineoverride

Convert the circuit for distribution for specific networks.

Convert the circuit for distribution for specific networks. Particular networks might need additional circuit conversions before distribution. They should override this implementation. By default, it does nothing.

Parameters
networkThe network to convert the circuit for.
circuitThe circuit to convert.
Returns
The converted circuit.
See also
Circuits::Circuit

Definition at line 401 of file SimpleController.h.

◆ GetClassicalBitsIds()

template<typename Time = Types::time_type>
std::vector< size_t > Network::SimpleController< Time >::GetClassicalBitsIds ( ) const
inlineoverridevirtual

Get the ids of the classical bits in the host.

Obtain the ids of the classical bits in the host. The controller is a special host, it's not a quantum computer, so it returns an empty vector.

Returns
The ids of the classical bits in the host.

Implements Network::IHost< Types::time_type >.

Definition at line 260 of file SimpleController.h.

◆ GetEntangledQubitMeasurementBitIds()

template<typename Time = Types::time_type>
std::vector< size_t > Network::SimpleController< Time >::GetEntangledQubitMeasurementBitIds ( ) const
inlineoverridevirtual

Get the ids of the classical bits used for measurement of the qubits used for entanglement between hosts present in the host.

Obtain the ids of the classical bits used for measurement of the qubits used for entanglement between hosts present in the host. The controller is a special host, it's not a quantum computer, so it returns an empty vector.

Returns
The ids of the classical bits used for measurement of the qubits used for entanglement between hosts present in the host.

Implements Network::IHost< Types::time_type >.

Definition at line 272 of file SimpleController.h.

◆ GetId()

template<typename Time = Types::time_type>
size_t Network::SimpleController< Time >::GetId ( ) const
inlineoverridevirtual

Get the host id.

Obtain a host id used to identify the host in the network. Since this is a special host, it returns the maximum value of size_t.

Returns
The host id.

Implements Network::IHost< Types::time_type >.

Definition at line 140 of file SimpleController.h.

◆ GetNetworkEntangledQubitsIds()

template<typename Time = Types::time_type>
std::vector< size_t > Network::SimpleController< Time >::GetNetworkEntangledQubitsIds ( ) const
inlineoverridevirtual

Get the ids of the qubits used for entanglement between hosts in the host.

Obtain the ids of the qubits used for entanglement between hosts in the host. The controller is a special host, it's not a quantum computer, so it returns an empty vector.

Returns
The ids of the qubits used for entanglement between hosts in the host.

Implements Network::IHost< Types::time_type >.

Definition at line 248 of file SimpleController.h.

◆ GetNumClassicalBits()

template<typename Time = Types::time_type>
size_t Network::SimpleController< Time >::GetNumClassicalBits ( ) const
inlineoverridevirtual

Get the number of classical bits.

Obtain the number of classical bits in the host. The controller is a special host, it's not a quantum computer, so it returns 0.

Returns
The number of classical bits.

Implements Network::IHost< Types::time_type >.

Definition at line 171 of file SimpleController.h.

◆ GetNumNetworkEntangledQubits()

template<typename Time = Types::time_type>
size_t Network::SimpleController< Time >::GetNumNetworkEntangledQubits ( ) const
inlineoverridevirtual

Get the number of network entangled qubits.

Obtain the number of qubits in the host used for entanglement with other hosts. The controller is a special host, it's not a quantum computer, so it returns 0.

Returns
The number of network entangled qubits.

Implements Network::IHost< Types::time_type >.

Definition at line 161 of file SimpleController.h.

◆ GetNumQubits()

template<typename Time = Types::time_type>
size_t Network::SimpleController< Time >::GetNumQubits ( ) const
inlineoverridevirtual

Get the number of qubits.

Obtain the number of qubits in the host, excluding the one(s) used only for entanglement with other hosts. The controller is a special host, it's not a quantum computer, so it returns 0.

Returns
The number of qubits.

Implements Network::IHost< Types::time_type >.

Definition at line 150 of file SimpleController.h.

◆ GetOptimiser()

template<typename Time = Types::time_type>
std::shared_ptr< Graphs::IOptimiser< Time > > Network::SimpleController< Time >::GetOptimiser ( ) const
inlineoverridevirtual

Returns the optimiser used.

Returns the optimiser used. Could be nullptr, that is, no optimiser.

Returns
The optimiser used.

Implements Network::IController< Types::time_type >.

Definition at line 371 of file SimpleController.h.

◆ GetOptimizeCircuit()

template<typename Time = Types::time_type>
bool Network::SimpleController< Time >::GetOptimizeCircuit ( ) const
inlineoverridevirtual

Get circuit optimization.

Returns true if the circuit will be optimized, false otherwise.

Returns
True if the circuit will be optimized, false otherwise.

Implements Network::IController< Types::time_type >.

Definition at line 463 of file SimpleController.h.

◆ GetOptimizeRotationGates()

template<typename Time = Types::time_type>
bool Network::SimpleController< Time >::GetOptimizeRotationGates ( ) const
inlineoverridevirtual

Implements Network::IController< Types::time_type >.

Definition at line 438 of file SimpleController.h.

◆ GetQubitsIds()

template<typename Time = Types::time_type>
std::vector< size_t > Network::SimpleController< Time >::GetQubitsIds ( ) const
inlineoverridevirtual

Get the ids of the qubits in the host.

Obtain the ids of the qubits in the host, excluding the one(s) used only for entanglement with other hosts. The controller is a special host, it's not a quantum computer, so it returns an empty vector.

Returns
The ids of the qubits in the host.

Implements Network::IHost< Types::time_type >.

Definition at line 236 of file SimpleController.h.

◆ GetRemapper()

template<typename Time = Types::time_type>
std::shared_ptr< Distribution::IRemapper< Time > > Network::SimpleController< Time >::GetRemapper ( ) const
inlineoverridevirtual

Gets the remapper that is used for remapping a circuit to a distributed one.

The remapper is used to remap the circuit to a distributed one.

Returns
The remapper.
See also
Distribution::IRemapper

Implements Network::IController< Types::time_type >.

Definition at line 300 of file SimpleController.h.

◆ GetScheduler()

template<typename Time = Types::time_type>
std::shared_ptr< Schedulers::IScheduler< Time > > Network::SimpleController< Time >::GetScheduler ( ) const
inlineoverridevirtual

Get the scheduler for the network.

Get the scheduler for the network.

Returns
The scheduler for the network.
See also
Schedulers::IScheduler

Implements Network::IController< Types::time_type >.

Definition at line 434 of file SimpleController.h.

◆ GetStartClassicalBitId()

template<typename Time = Types::time_type>
size_t Network::SimpleController< Time >::GetStartClassicalBitId ( ) const
inlineoverridevirtual

Get the id of the first classical bit assigned to the host.

Obtain the id of the first classical bit assigned to the host, the other ones are assigned contiquously.

Returns
The id of the first classical bit assigned to the host.

Implements Network::IHost< Types::time_type >.

Definition at line 362 of file SimpleController.h.

◆ GetStartQubitId()

template<typename Time = Types::time_type>
size_t Network::SimpleController< Time >::GetStartQubitId ( ) const
inlineoverridevirtual

Get the id of the first qubit assigned to the host.

Obtain the id of the first qubit assigned to the host, the other ones are assigned contiquously.

Returns
The id of the first qubit assigned to the host.

Implements Network::IHost< Types::time_type >.

Definition at line 352 of file SimpleController.h.

◆ IsClassicalBitOnHost()

template<typename Time = Types::time_type>
bool Network::SimpleController< Time >::IsClassicalBitOnHost ( size_t qubitId) const
inlineoverridevirtual

Check if a classical bit is in the host.

Checks if a classical bit with the specified id is in the host. The controller is a special host, it's not a quantum computer, so it returns false.

Returns
True if the classical bit is on this host, false otherwise.

Implements Network::IHost< Types::time_type >.

Definition at line 191 of file SimpleController.h.

◆ IsEntangledQubitOnHost()

template<typename Time = Types::time_type>
bool Network::SimpleController< Time >::IsEntangledQubitOnHost ( size_t qubitId) const
inlineoverridevirtual

Check if a qubit used for entanglement between hosts is in the host.

Checks if a qubit used for entanglement between hosts with the specified id is in the host. The controller is a special host, it's not a quantum computer, so it returns false.

Returns
True if the network entangled qubit is on this host, false otherwise.

Implements Network::IHost< Types::time_type >.

Definition at line 202 of file SimpleController.h.

◆ IsQubitOnHost()

template<typename Time = Types::time_type>
bool Network::SimpleController< Time >::IsQubitOnHost ( size_t qubitId) const
inlineoverridevirtual

Check if a qubit is in the host.

Checks if a qubit with the specified id is in the host, excluding the one(s) used only for entanglement with other hosts. The controller is a special host, it's not a quantum computer, so it returns false.

Returns
True if the qubit is on this host, false otherwise.

Implements Network::IHost< Types::time_type >.

Definition at line 181 of file SimpleController.h.

◆ RecvPacketFromHost()

template<typename Time = Types::time_type>
bool Network::SimpleController< Time >::RecvPacketFromHost ( size_t hostId,
const std::vector< uint8_t > & packet )
inlineoverridevirtual

Receive a packet from a host.

Receive a packet from a host. Usually called by the network implementation. For the simple network, receiving classical packets is not simulated, so this function does nothing and returns false. Most of network implementations do not simulate sending packets from the controller or receiving packets by the controller, only sending/receiving packets between quantum computers.

Parameters
hostIdThe id of the host to receive the packet from.
packetThe packet to receive.
Returns
False.

Implements Network::IHost< Types::time_type >.

Definition at line 339 of file SimpleController.h.

◆ SendPacketToHost()

template<typename Time = Types::time_type>
bool Network::SimpleController< Time >::SendPacketToHost ( size_t hostId,
const std::vector< uint8_t > & packet )
inlineoverridevirtual

Send a packet to a host.

Send a packet to a host. Usually called by the host implementation or perhaps in some cases by the network implementation. For the simple network, sending classical packets is not simulated, so this function does nothing and returns false. Most of network implementations do not simulate sending packets from the controller or receiving packets by the controller, only sending/receiving packets between quantum computers.

Parameters
hostIdThe id of the host to send the packet to.
packetThe packet to send.
Returns
False.

Implements Network::IHost< Types::time_type >.

Definition at line 319 of file SimpleController.h.

◆ SetOptimizeCircuit()

template<typename Time = Types::time_type>
void Network::SimpleController< Time >::SetOptimizeCircuit ( bool o = true)
inlineoverridevirtual

Set circuit optimization.

If the parameter is true, the circuit will be optimized, otherwise it will not be optimized.

Parameters
optimizeTrue if the circuit should be optimized, false otherwise.

Implements Network::IController< Types::time_type >.

Definition at line 454 of file SimpleController.h.

◆ SetOptimizeRotationGates()

template<typename Time = Types::time_type>
void Network::SimpleController< Time >::SetOptimizeRotationGates ( bool val = true)
inlineoverridevirtual

Implements Network::IController< Types::time_type >.

Definition at line 442 of file SimpleController.h.

◆ SetRemapper()

template<typename Time = Types::time_type>
void Network::SimpleController< Time >::SetRemapper ( const std::shared_ptr< Distribution::IRemapper< Time > > & r)
inlineoverride

Changes the remapper that is used for remapping a circuit to a distributed one.

The remapper is used to remap a circuit to a distributed one. A default remapper is already set, so calling this function is optional.

Parameters
rThe new remapper.
See also
Distribution::IRemapper

Definition at line 286 of file SimpleController.h.

◆ SplitCompositeOperations()

template<typename Time = Types::time_type>
std::shared_ptr< Circuits::Circuit< Time > > Network::SimpleController< Time >::SplitCompositeOperations ( const std::shared_ptr< INetwork< Time > > & network,
const std::shared_ptr< Circuits::Circuit< Time > > & circuit )
inlineoverride

Splits the composite operations from the circuit.

Splits some composite operations. There are composite operations - other than multiple qubits quantum gates - that act on multiple qubits/classical bits that might act on qubits that are not local. This function splits those operations into ones that act on a single qubit/classical bit. For example measurements on several qubits are split into several measurements on a single qubit.

Parameters
networkThe network to execute the circuit for.
circuitThe circuit to execute.
Returns
A shared pointer to the modified circuit.
See also
Circuits::Circuit
INetwork

Definition at line 123 of file SimpleController.h.

Member Data Documentation

◆ optimiser

template<typename Time = Types::time_type>
std::shared_ptr<Graphs::IOptimiser<Time> > Network::SimpleController< Time >::optimiser
protected

Definition at line 477 of file SimpleController.h.

◆ remapper

template<typename Time = Types::time_type>
std::shared_ptr<Distribution::IRemapper<Time> > Network::SimpleController< Time >::remapper
protected

The remapper used to remap a circuit to a distributed one.

Definition at line 467 of file SimpleController.h.

◆ scheduler

template<typename Time = Types::time_type>
std::shared_ptr<Schedulers::IScheduler<Time> > Network::SimpleController< Time >::scheduler
protected

< The optimiser used to optimise the circuit.

The scheduler used to schedule the circuits.

Definition at line 482 of file SimpleController.h.


The documentation for this class was generated from the following file: