From 45441b3eb6a0eb3bec8cec3c4b423fa1423edf60 Mon Sep 17 00:00:00 2001 From: Caitao Zhan Date: Sun, 15 Dec 2024 02:05:38 -0600 Subject: [PATCH] [minor] update the random_request_network.ipynb demo --- example/random_request_network.ipynb | 40 ++++++++++++++++------------ 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/example/random_request_network.ipynb b/example/random_request_network.ipynb index a46da867..110b16bd 100644 --- a/example/random_request_network.ipynb +++ b/example/random_request_network.ipynb @@ -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", @@ -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", @@ -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", @@ -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)" ] @@ -171,7 +176,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 17, "metadata": {}, "outputs": [], "source": [ @@ -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", @@ -239,7 +244,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 18, "metadata": { "scrolled": false }, @@ -247,7 +252,7 @@ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "3696019279184c42bc92a3ba929865fa", + "model_id": "5e612eb5a1d049c78a37e17ecd8b5a85", "version_major": 2, "version_minor": 0 }, @@ -261,16 +266,17 @@ { "data": { "text/plain": [ - "" + "" ] }, - "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" ] }, { @@ -297,7 +303,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.12.7" + "version": "3.12.8" } }, "nbformat": 4,