Skip to content

Commit

Permalink
[minor] update the random_request_network.ipynb demo
Browse files Browse the repository at this point in the history
  • Loading branch information
caitaozhan committed Dec 15, 2024
1 parent 8d77ddb commit 45441b3
Showing 1 changed file with 23 additions and 17 deletions.
40 changes: 23 additions & 17 deletions example/random_request_network.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,12 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 16,
"metadata": {},
"outputs": [],
"source": [
"from sequence.constants import SECOND\n",
"\n",
"def test(sim_time, qc_atten):\n",
" \"\"\"\n",
" sim_time: duration of simulation time (ms)\n",
Expand Down Expand Up @@ -111,8 +113,8 @@
" # a seed for the random number generator, and\n",
" # several arguments for request parameters.\n",
" app = RandomRequestApp(node, other_nodes, i,\n",
" min_dur=1e13, max_dur=2e13, min_size=10,\n",
" max_size=25, min_fidelity=0.8, max_fidelity=1.0)\n",
" min_dur=0.1e12, max_dur=0.2e12, min_size=1,\n",
" max_size=5, min_fidelity=0.8, max_fidelity=0.85)\n",
" apps.append(app)\n",
" app.start()\n",
" \n",
Expand All @@ -126,14 +128,15 @@
" \n",
" for app in apps:\n",
" print(\"node \" + app.node.name)\n",
" print(\"\\tnumber of wait times: \", len(app.get_wait_time()))\n",
" print(\"\\twait times:\", app.get_wait_time())\n",
" # print(\"\\tnumber of wait times: \", len(app.get_wait_time()))\n",
" # print(\"\\twait times:\", app.get_wait_time())\n",
" print(\"\\treservations: \", app.reserves)\n",
" print(\"\\tthroughput: \", app.get_throughput())\n",
" print(\"\\tthroughput: \", app.all_throughput)\n",
" \n",
" # create a table to showcase information about the reservations\n",
" print(\"\\nReservations Table:\\n\")\n",
" node_names = []\n",
" paths = []\n",
" start_times = []\n",
" end_times = []\n",
" memory_sizes = []\n",
Expand All @@ -144,10 +147,12 @@
" if reservation.initiator != node.name and reservation.responder != node.name:\n",
" size *= 2\n",
" node_names.append(node_name)\n",
" start_times.append(s_t)\n",
" end_times.append(e_t)\n",
" paths.append(tuple(reservation.path))\n",
" start_times.append(s_t / SECOND)\n",
" end_times.append(e_t / SECOND)\n",
" memory_sizes.append(size)\n",
" log = {\"Node\": node_names, \"Start_time\": start_times, \"End_time\": end_times, \"Memory_size\": memory_sizes}\n",
" # log = {\"Node\": node_names, \"Path\": paths, \"Start_time\": start_times, \"End_time\": end_times, \"Memory_size\": memory_sizes}\n",
" log = {\"Node\": node_names, \"Path\": paths, \"Start_time (s)\": start_times, \"End_time (s)\": end_times}\n",
" df = pd.DataFrame(log)\n",
" print(df)"
]
Expand All @@ -171,7 +176,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 17,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -190,7 +195,7 @@
" MEMO_FREQ = 2e3\n",
" MEMO_EXPIRE = 0\n",
" MEMO_EFFICIENCY = 1\n",
" MEMO_FIDELITY = 0.9349367588934053\n",
" MEMO_FIDELITY = 0.95\n",
" for node in topology.get_nodes_by_type(RouterNetTopo.QUANTUM_ROUTER):\n",
" memory_array = node.get_components_by_type(\"MemoryArray\")[0]\n",
" memory_array.update_memory_params(\"frequency\", MEMO_FREQ)\n",
Expand Down Expand Up @@ -239,15 +244,15 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 18,
"metadata": {
"scrolled": false
},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "3696019279184c42bc92a3ba929865fa",
"model_id": "5e612eb5a1d049c78a37e17ecd8b5a85",
"version_major": 2,
"version_minor": 0
},
Expand All @@ -261,16 +266,17 @@
{
"data": {
"text/plain": [
"<function __main__.test(sim_time, qc_atten)>"
"<ipywidgets.widgets.interaction._InteractFactory at 0x111365910>"
]
},
"execution_count": 8,
"execution_count": 18,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"interact(test, sim_time=(2000, 4000, 500), qc_atten=[0, 1e-5, 2e-5])"
"interact(test, sim_time=(2000, 4000, 500), qc_atten=[1e-5, 5e-5, 1e-4])\n",
"interact\n"
]
},
{
Expand All @@ -297,7 +303,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.7"
"version": "3.12.8"
}
},
"nbformat": 4,
Expand Down

0 comments on commit 45441b3

Please # to comment.