From 656679f184f82f733c3907d81b5e34ff02a099f4 Mon Sep 17 00:00:00 2001 From: Abhishek Bhatt <46929125+ba2tro@users.noreply.github.com> Date: Wed, 23 Oct 2024 21:29:42 -0400 Subject: [PATCH] =?UTF-8?q?Make=20classical=20and=20quantum=20channel=20de?= =?UTF-8?q?lays=20customizable=20when=20initializ=E2=80=A6=20(#162)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --------- Co-authored-by: Stefan Krastanov Co-authored-by: Stefan Krastanov --- CHANGELOG.md | 1 + src/networks.jl | 18 +++++++++--------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index acaed58c..4a2fba7f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ - Implement protocols: request generator and request tracker for simulation with the above control protocol in an asynchronous way. - Add `PhysicalGraph` struct for storing network metadata as the simulation evolves. - New tags: `EntanglementRequest`,`SwapRequest`, `DistributionRequest` and `RequestCompletion` +- Add `classical_delay` and `quantum_delay` as keyword arguments to the `RegisterNet` constructor to set a default global network edge latency. ## v0.5.0 - 2024-09-05 diff --git a/src/networks.jl b/src/networks.jl index a10dc369..620030b8 100644 --- a/src/networks.jl +++ b/src/networks.jl @@ -13,7 +13,7 @@ struct RegisterNet reverse_lookup::IdDict{Register,Int} end -function RegisterNet(graph::SimpleGraph, registers, vertex_metadata, edge_metadata, directed_edge_metadata) +function RegisterNet(graph::SimpleGraph, registers, vertex_metadata, edge_metadata, directed_edge_metadata; classical_delay=0, quantum_delay=0) env = get_time_tracker(registers[1]) all_are_at_zero = all(iszero(ConcurrentSim.now(get_time_tracker(r))) && isempty(get_time_tracker(r).heap) && isnothing(get_time_tracker(r).active_proc) for r in registers) @@ -42,10 +42,10 @@ function RegisterNet(graph::SimpleGraph, registers, vertex_metadata, edge_metada end for (;src,dst) in edges(graph) - cchannels[src=>dst] = DelayQueue{Tag}(env, 0) - qchannels[src=>dst] = QuantumChannel(env, 0) - cchannels[dst=>src] = DelayQueue{Tag}(env, 0) - qchannels[dst=>src] = QuantumChannel(env, 0) + cchannels[src=>dst] = DelayQueue{Tag}(env, classical_delay) + qchannels[src=>dst] = QuantumChannel(env, quantum_delay) + cchannels[dst=>src] = DelayQueue{Tag}(env, classical_delay) + qchannels[dst=>src] = QuantumChannel(env, quantum_delay) end for (v,r) in zip(vertices(graph), registers) channels = [(;src=w, channel=cchannels[w=>v]) for w in neighbors(graph, v)] @@ -92,9 +92,9 @@ julia> neighbors(net, 1) # from Graphs.jl 3 ``` """ -function RegisterNet(graph::SimpleGraph, registers) +function RegisterNet(graph::SimpleGraph, registers; classical_delay=0, quantum_delay=0) size(graph, 1) == length(registers) || ArgumentError(lazy"You attempted to construct a `RegisterNet` with a graph of $(size(graph, 1)) vertices but provided a list of $(length(registers)) `Registers`. These two numbers have to match.") - RegisterNet(graph, registers, empty_vmd(length(registers)), empty_emd(), empty_demd()) + RegisterNet(graph, registers, empty_vmd(length(registers)), empty_emd(), empty_demd(); classical_delay, quantum_delay) end empty_vmd(n) = [Dict{Symbol,Any}() for _ in 1:n] @@ -113,9 +113,9 @@ julia> neighbors(net,2) # from Graphs.jl 3 ``` """ -function RegisterNet(registers::Vector{Register}) +function RegisterNet(registers::Vector{Register}; classical_delay=0, quantum_delay=0) graph = grid([length(registers)]) - RegisterNet(graph, registers) + RegisterNet(graph, registers; classical_delay, quantum_delay) end function add_register!(net::RegisterNet, r::Register)