Skip to content

Commit

Permalink
Make classical and quantum channel delays customizable when initializ… (
Browse files Browse the repository at this point in the history
#162)


---------

Co-authored-by: Stefan Krastanov <[email protected]>
Co-authored-by: Stefan Krastanov <[email protected]>
  • Loading branch information
3 people authored Oct 24, 2024
1 parent 9ace582 commit 3ccd676
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# News

## v0.5.1-dev

- 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-10-16

- Develop `CutoffProt` to deal with deadlocks in a simulation
Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "QuantumSavory"
uuid = "2de2e421-972c-4cb5-a0c3-999c85908079"
authors = ["Stefan Krastanov <[email protected]>"]
version = "0.5"
version = "0.5.1-dev"

[deps]
Combinatorics = "861a8166-3701-5b0c-9a16-15d98fcdc6aa"
Expand Down
18 changes: 9 additions & 9 deletions src/networks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)]
Expand Down Expand Up @@ -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]
Expand All @@ -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)
Expand Down

0 comments on commit 3ccd676

Please sign in to comment.