Agents - Codified Alice and Bob

class netQuil.agents.Agent(program=None, qubits=[], cmem=[], name=None)[source]

Bases: threading.Thread

__eq__(other)[source]

Agents are compared for equality by their names.

__hash__()[source]

Agents are hashed by their (unique) names

__init__(program=None, qubits=[], cmem=[], name=None)[source]

Agents are codified versions of Alice and Bob (i.e. single nodes in a quantum network) that can send and receive classical and quantum information over connections. Agents have the following properties:

  • Their run-time logic is in the form of an Agent.run() method

  • Their connections to other agents are by default ingress and egress

  • Agents’ manage their own target and source devices for noise and local time tracking

  • Agents have a network monitor to record the traffic they see

Parameters
  • program (PyQuil<Program>) – program

  • qubits (List<int>) – list of qubits owned by agent

  • cmem (List<int>) – list of cbits owned by agent

  • name (String) – name of agent, defaults to name of class

__ne__(other)[source]

Agents are compared for inequality by their names

add_cmem(cbits)[source]

Add more classical memory in the form of a list of 0s and 1s

Parameters

cbits (List<int>) – classical memory to extend

add_device(device_type, device)[source]

Add a device to an agent.

Parameters
  • device_type (String) – may be either source or target

  • device (Device) – instance of device added

add_source_devices(new_source_devices)[source]

Add source devices. Every qubit sent by Agent will pass through these devices, and, if set, the device’s effect and time-delay will be applied

Parameters

new_source_devices (List<Device>) – list of source devices

add_target_devices(new_target_devices)[source]

Add target devices. Every qubit sent to agent will pass through these devices, and, if set, the device’s effect and time-delay will be applied

Parameters

new_target_devices (List<Device>) – list of target devices

crecv(source)[source]

Get cbits from source.

Parameters

source (String) – name of Agent where cbits originated from.

Returns

list of cbits sent from source

csend(target, cbits)[source]

Sends classical bits from agent to target.

Parameters
  • target (String) – name of target agent

  • cbits (List<int>) – indices of cbits source is sending to target

get_master_time()[source]
Returns

master time

qrecv(source)[source]

Agent receives qubits from source. Adds qubits to agent’s list of qubits and add time delay. Return list of qubits

Parameters

source (String) – name of agent who sent qubits.

Returns

list of qubits sent from source

qsend(target, qubits)[source]

Send qubits from agent to target. Connection will place qubits on queue for target to retrieve.

Parameters
  • target (String) – name of destination for qubits

  • qubits (List<int>) – list of qubits to send to destination

run()[source]

Run-time logic for the Agent; this method should be overridden in child classes.

set_program(program)[source]

Set agent’s program

Parameters

program (PyQuil<Program>) – agent’s program