-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial changes for different control plane simulations
- Loading branch information
Showing
13 changed files
with
795 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
include("setup.jl") | ||
|
||
succ_prob = Observable(0.001) | ||
for (;src, dst) in edges(net) | ||
eprot = EntanglerProt(sim, net, src, dst; rounds=-1, randomize=true, success_prob=succ_prob[]) | ||
@process eprot() | ||
end | ||
|
||
local_busy_time = Observable(0.0) | ||
retry_lock_time = Observable(0.1) | ||
for node in 2:7 | ||
swapper = SwapperProt(sim, net, node; nodeL = <(node), nodeH = >(node), chooseL = argmin, chooseH = argmax, rounds=-1, local_busy_time=local_busy_time[], | ||
retry_lock_time=retry_lock_time[]) | ||
@process swapper() | ||
end | ||
|
||
for v in vertices(net) | ||
tracker = EntanglementTracker(sim, net, v) | ||
@process tracker() | ||
end | ||
|
||
period_cons = Observable(0.1) | ||
consumer = EntanglementConsumer(sim, net, 1, 8; period=period_cons[]) | ||
@process consumer() | ||
|
||
period_dec = Observable(0.1) | ||
for v in vertices(net) | ||
cutoff = CutoffProt(sim, net, v; period=period_dec[]) | ||
@process cutoff() | ||
end | ||
params = [succ_prob, local_busy_time, retry_lock_time, period_cons, period_dec] | ||
sim, net, obs, entlog, entlogaxis, fid_axis, histaxis, num_epr_axis, fig = prepare_vis(consumer, params) | ||
|
||
step_ts = range(0.0, 1000.0, step=0.1) | ||
record(fig, "sim.mp4", step_ts; framerate=10, visible=true) do t | ||
run(sim, t) | ||
notify.((obs,entlog)) | ||
notify.(params) | ||
ylims!(entlogaxis, (-1.04,1.04)) | ||
xlims!(entlogaxis, max(0,t-50), 1+t) | ||
ylims!(fid_axis, (0, 1.04)) | ||
xlims!(fid_axis, max(0, t-50), 1+t) | ||
autolimits!(histaxis) | ||
ylims!(num_epr_axis, (0, 4)) | ||
xlims!(num_epr_axis, max(0, t-50), 1+t) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
using WGLMakie | ||
WGLMakie.activate!() | ||
import Bonito | ||
using Markdown | ||
|
||
include("setup.jl") | ||
|
||
|
||
const custom_css = Bonito.DOM.style("ul {list-style: circle !important;}") # TODO remove after fix of bug in JSServe https://github.com/SimonDanisch/JSServe.jl/issues/178 | ||
|
||
succ_prob = Observable(0.001) | ||
for (;src, dst) in edges(net) | ||
eprot = EntanglerProt(sim, net, src, dst; rounds=-1, randomize=true, success_prob=succ_prob[]) | ||
@process eprot() | ||
end | ||
|
||
local_busy_time = Observable(0.0) | ||
retry_lock_time = Observable(0.1) | ||
for node in 2:7 | ||
swapper = SwapperProt(sim, net, node; nodeL = <(node), nodeH = >(node), chooseL = argmin, chooseH = argmax, rounds=-1, local_busy_time=local_busy_time[], | ||
retry_lock_time=retry_lock_time[]) | ||
@process swapper() | ||
end | ||
|
||
for v in vertices(net) | ||
tracker = EntanglementTracker(sim, net, v) | ||
@process tracker() | ||
end | ||
|
||
period_cons = Observable(0.1) | ||
consumer = EntanglementConsumer(sim, net, 1, 8; period=period_cons[]) | ||
@process consumer() | ||
|
||
period_dec = Observable(0.1) | ||
for v in vertices(net) | ||
cutoff = CutoffProt(sim, net, v; period=period_dec[]) | ||
@process cutoff() | ||
end | ||
params = [succ_prob, local_busy_time, retry_lock_time, period_cons, period_dec] | ||
|
||
# All the calls that happen in the main event loop of the simulation, | ||
# encapsulated here so that we can conveniently pause the simulation from the WGLMakie app. | ||
function continue_singlerun!(sim, obs, entlog, params, entlogaxis, fid_axis, histaxis, num_epr_axis, running) | ||
step_ts = range(0, 1000, step=0.1) | ||
for t in step_ts | ||
run(sim, t) | ||
notify.((obs,entlog)) | ||
notify.(params) | ||
ylims!(entlogaxis, (-1.04,1.04)) | ||
xlims!(entlogaxis, max(0,t-50), 1+t) | ||
ylims!(fid_axis, (0, 1.04)) | ||
xlims!(fid_axis, max(0, t-50), 1+t) | ||
autolimits!(histaxis) | ||
ylims!(num_epr_axis, (0, 4)) | ||
xlims!(num_epr_axis, max(0, t-50), 1+t) | ||
end | ||
running[] = nothing | ||
end | ||
|
||
# | ||
landing = Bonito.App() do | ||
|
||
sim, net, obs, entlog, entlogaxis, fid_axis, histaxis, num_epr_axis, fig = prepare_vis(consumer, params) | ||
|
||
running = Observable{Any}(false) | ||
fig[5,1] = buttongrid = GridLayout(tellwidth = false) | ||
buttongrid[1,1] = b = Makie.Button(fig, label = @lift(isnothing($running) ? "Done" : $running ? "Running..." : "Run once"), height=30, tellwidth=false) | ||
|
||
on(b.clicks) do _ | ||
if !running[] | ||
running[] = true | ||
end | ||
end | ||
on(running) do r | ||
if r | ||
Threads.@spawn begin | ||
continue_singlerun!( | ||
sim, obs, entlog, params, entlogaxis, fid_axis, histaxis, num_epr_axis, running) | ||
end | ||
end | ||
end | ||
|
||
|
||
content = md""" | ||
Pick simulation settings and hit run (see below for technical details). | ||
$(fig.scene) | ||
# Connectionless, Distributed and Decentralized Control Plane for Entanglement Distribution | ||
The above simulation visualizes entanglement distribution between Alice and Bob on an arbitrary network topology | ||
given by the adjacency matrix of the graph. The control plane architecture used for this simulation is connectionless, | ||
distributed and decentralized. The node representing Alice is the node on the top left and the bottom right is Bob. | ||
The actual connectivity of the physical graph isn't fully captured by the visualization above as we use edges only to | ||
show the virtual graph. | ||
[See and modify the code for this simulation on github.](https://github.com/QuantumSavory/QuantumSavory.jl/tree/master/examples/controlplane/1b_cdd_wglmakie.jl) | ||
""" | ||
return Bonito.DOM.div(Bonito.MarkdownCSS, Bonito.Styling, custom_css, content) | ||
end; | ||
|
||
# | ||
# Serve the Makie app | ||
|
||
isdefined(Main, :server) && close(server); | ||
port = parse(Int, get(ENV, "CDD_PORT", "8888")) | ||
interface = get(ENV, "CDD_IP", "127.0.0.1") | ||
proxy_url = get(ENV, "CDD_PROXY", "") | ||
server = Bonito.Server(interface, port; proxy_url); | ||
Bonito.HTTPServer.start(server) | ||
Bonito.route!(server, "/" => landing); | ||
|
||
## | ||
|
||
wait(server) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
include("setup.jl") | ||
|
||
controller = NetController(sim, net, 3, 6, 0.2) | ||
@process controller() | ||
|
||
consumer = EntanglementConsumer(sim, net, 1, 8; period=0.2) | ||
@process consumer() | ||
|
||
for node in 1:7 | ||
tracker = RequestTracker(sim, net, node, 0.3) | ||
@process tracker() | ||
end | ||
|
||
for v in 1:8 | ||
tracker = EntanglementTracker(sim, net, v) | ||
@process tracker() | ||
end | ||
|
||
for v in 1:8 | ||
c_prot = CutoffProt(sim, net, v) | ||
@process c_prot() | ||
end | ||
|
||
sim, net, obs, entlog, entlogaxis, fid_axis, histaxis, num_epr_axis, fig = prepare_vis(consumer) | ||
|
||
step_ts = range(0.0, 1000.0, step=0.1) | ||
record(fig, "sim.mp4", step_ts; framerate=10, visible=true) do t | ||
run(sim, t) | ||
notify.((obs,entlog)) | ||
ylims!(entlogaxis, (-1.04,1.04)) | ||
xlims!(entlogaxis, max(0,t-50), 1+t) | ||
ylims!(fid_axis, (0, 1.04)) | ||
xlims!(fid_axis, max(0, t-50), 1+t) | ||
autolimits!(histaxis) | ||
ylims!(num_epr_axis, (0, 4)) | ||
xlims!(num_epr_axis, max(0, t-50), 1+t) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
using WGLMakie | ||
WGLMakie.activate!() | ||
import Bonito | ||
using Markdown | ||
|
||
include("setup.jl") | ||
|
||
const custom_css = Bonito.DOM.style("ul {list-style: circle !important;}") # TODO remove after fix of bug in JSServe https://github.com/SimonDanisch/JSServe.jl/issues/178 | ||
|
||
controller = NetController(sim, net, 3, 6, 0.2) | ||
@process controller() | ||
|
||
consumer = EntanglementConsumer(sim, net, 1, 8; period=0.2) | ||
@process consumer() | ||
|
||
for node in 1:7 | ||
tracker = RequestTracker(sim, net, node, 0.3) | ||
@process tracker() | ||
end | ||
|
||
for v in 1:8 | ||
tracker = EntanglementTracker(sim, net, v) | ||
@process tracker() | ||
end | ||
|
||
for v in 1:8 | ||
c_prot = CutoffProt(sim, net, v) | ||
@process c_prot() | ||
end | ||
|
||
# All the calls that happen in the main event loop of the simulation, | ||
# encapsulated here so that we can conveniently pause the simulation from the WGLMakie app. | ||
function continue_singlerun!(sim, obs, entlog, entlogaxis, fid_axis, histaxis, num_epr_axis, running) | ||
step_ts = range(0, 1000, step=0.1) | ||
for t in step_ts | ||
run(sim, t) | ||
notify.((obs,entlog)) | ||
ylims!(entlogaxis, (-1.04,1.04)) | ||
xlims!(entlogaxis, max(0,t-50), 1+t) | ||
ylims!(fid_axis, (0, 1.04)) | ||
xlims!(fid_axis, max(0, t-50), 1+t) | ||
autolimits!(histaxis) | ||
ylims!(num_epr_axis, (0, 4)) | ||
xlims!(num_epr_axis, max(0, t-50), 1+t) | ||
end | ||
running[] = nothing | ||
end | ||
|
||
# | ||
landing = Bonito.App() do | ||
|
||
sim, net, obs, entlog, entlogaxis, fid_axis, histaxis, num_epr_axis, fig = prepare_vis(consumer) | ||
|
||
running = Observable{Any}(false) | ||
fig[5,1] = buttongrid = GridLayout(tellwidth = false) | ||
buttongrid[1,1] = b = Makie.Button(fig, label = @lift(isnothing($running) ? "Done" : $running ? "Running..." : "Run once"), height=30, tellwidth=false) | ||
|
||
on(b.clicks) do _ | ||
if !running[] | ||
running[] = true | ||
end | ||
end | ||
on(running) do r | ||
if r | ||
Threads.@spawn begin | ||
continue_singlerun!( | ||
sim, obs, entlog, entlogaxis, fid_axis, histaxis, num_epr_axis, running) | ||
end | ||
end | ||
end | ||
|
||
|
||
content = md""" | ||
Pick simulation settings and hit run (see below for technical details). | ||
$(fig.scene) | ||
# Connection-Oriented, Non-Distributed and Centralized Control Plane for Entanglement Distribution | ||
The above simulation visualizes entanglement distribution between Alice and Bob on an arbitrary network topology | ||
given by the adjacency matrix of the graph. The control plane architecture used for this simulation is connection-oriented, | ||
non-distributed and centralized. The node representing Alice is the node on the top left and the bottom right is Bob. | ||
The actual connectivity of the physical graph isn't fully captured by the visualization above as we use edges only to | ||
show the virtual graph. | ||
[See and modify the code for this simulation on github.](https://github.com/QuantumSavory/QuantumSavory.jl/tree/master/examples/controlplane/2b_cnc_wglmakie.jl) | ||
""" | ||
return Bonito.DOM.div(Bonito.MarkdownCSS, Bonito.Styling, custom_css, content) | ||
end; | ||
|
||
# | ||
# Serve the Makie app | ||
|
||
isdefined(Main, :server) && close(server); | ||
port = parse(Int, get(ENV, "CNC_PORT", "8888")) | ||
interface = get(ENV, "CNC_IP", "127.0.0.1") | ||
proxy_url = get(ENV, "CNC_PROXY", "") | ||
server = Bonito.Server(interface, port; proxy_url); | ||
Bonito.HTTPServer.start(server) | ||
Bonito.route!(server, "/" => landing); | ||
|
||
## | ||
|
||
wait(server) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[deps] | ||
Bonito = "824d6782-a2ef-11e9-3a09-e5662e0c26f8" | ||
ConcurrentSim = "6ed1e86c-fcaf-46a9-97e0-2b26a2cdb499" | ||
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f" | ||
Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6" | ||
Markdown = "d6f4376e-aef5-505a-96c1-9c027394607a" | ||
QuantumOptics = "6e0679c1-51ea-5a7c-ac74-d61b76210b0c" | ||
QuantumSavory = "2de2e421-972c-4cb5-a0c3-999c85908079" | ||
QuantumSymbolics = "efa7fd63-0460-4890-beb7-be1bbdfbaeae" | ||
ResumableFunctions = "c5292f4c-5179-55e1-98c5-05642aab7184" | ||
Revise = "295af30f-e4ad-537b-8983-00126c2a3abe" | ||
WGLMakie = "276b4fcb-3e11-5398-bf8b-a0c2d153d008" | ||
|
||
[compat] | ||
Bonito = "3.1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
Different control plane architectures with arbitrary network topologies can be simulated using QuantumSavory. The `setup.jl` contains basic functionality required by the simulations. The other files are described below: | ||
|
||
1a. A simulation that generates an interactive visualization for a connectionless, distributed and decentralized entanglement distribution network | ||
|
||
1b. An interactive web app with the same simulation as 1a | ||
|
||
2a. A simulation that generates an interactive visualization for a connection-oriented, non-distributed and centralized entanglement distribution network | ||
|
||
2b. An interactive web app with the same simulation as 2a |
Oops, something went wrong.