Skip to content

Commit

Permalink
final
Browse files Browse the repository at this point in the history
  • Loading branch information
clb168 committed Feb 4, 2024
1 parent 1e0fa68 commit 442011c
Show file tree
Hide file tree
Showing 8 changed files with 2,545 additions and 84 deletions.
924 changes: 912 additions & 12 deletions .ipynb_checkpoints/QuCloud_InvList-checkpoint.ipynb

Large diffs are not rendered by default.

144 changes: 116 additions & 28 deletions .ipynb_checkpoints/SimulationSetup-checkpoint.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 1,
"id": "47c972b1-2332-4759-83df-274233289989",
"metadata": {
"tags": []
Expand All @@ -12,7 +12,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"measurement results: Counter({'00': 414, '11': 403, '10': 95, '01': 88})\n"
"measurement results: Counter({'00': 429, '11': 406, '01': 94, '10': 71})\n"
]
}
],
Expand Down Expand Up @@ -111,7 +111,7 @@
},
{
"cell_type": "code",
"execution_count": 71,
"execution_count": 21,
"id": "46fc4347-b388-4319-ba2e-20cfc2cdd3aa",
"metadata": {
"tags": []
Expand All @@ -121,69 +121,157 @@
"name": "stdout",
"output_type": "stream",
"text": [
"CNot('qubit_count': 2)\n",
"{'GateSet0': [QubitSet([Qubit(6), Qubit(7)]), QubitSet([Qubit(0), Qubit(1)])], 'GateSet1': [QubitSet([Qubit(1), Qubit(2)]), QubitSet([Qubit(3), Qubit(4)])], 'GateSet2': [QubitSet([Qubit(6), Qubit(7)])]}\n"
"{'GateSet0': [QubitSet([Qubit(0), Qubit(1)]), QubitSet([Qubit(4), Qubit(3)])], 'GateSet1': [QubitSet([Qubit(0), Qubit(1)]), QubitSet([Qubit(4), Qubit(3)])], 'GateSet2': [QubitSet([Qubit(0), Qubit(1)]), QubitSet([Qubit(2), Qubit(3)])]}\n"
]
}
],
"source": [
"bell = Circuit().h(0).cnot(0, 1).cnot(1, 2).cnot(3,4).h(5).cnot(6, 7)\n",
"\n",
"#bell = Circuit().cnot(0, 1).cnot(0, 1).cnot(0,2).cnot(0, 2).cnot(1, 2).cnot(0,3).cnot(1, 2).cnot(0, 3).cnot(1,3).cnot(1, 3).cnot(2,3).cnot(2,3)\n",
"bell = Circuit().cnot(0, 1).cnot(4, 3).cnot(0,1).cnot(2, 3)\n",
"inst_list = bell.instructions\n",
"print(inst_list[1].operator)\n",
"\n",
"CNOT = {}\n",
"GateSet = {}\n",
"cnot_count = 0\n",
"tempArray = []\n",
" \n",
"temp = 0\n",
"distance = 1\n",
"cnot_count = 0\n",
"cnot_count_prev = -1\n",
"cycle_num = 0\n",
"\n",
"\n",
"#might need a get function for getting the CNOT gates\n",
"for instruction in inst_list:\n",
" #print(instruction.operator)\n",
" if prevInstruction:\n",
" \n",
" \n",
" # try:\n",
" if temp == 1:\n",
" if str(prevInstruction.operator) != \"CNot('qubit_count': 2)\":\n",
" if cnot_count != 0:\n",
" cnot_count+=1\n",
" \n",
"\n",
" else:\n",
" for i in prevInstruction.target:\n",
" for j in instruction.target:\n",
" if i == j:\n",
" \n",
" cnot_count+=1\n",
" \n",
" temp2 = 0\n",
" for i in range(cnot_count, cnot_count+distance):\n",
" \n",
" for j in inst_list[i].target:\n",
" for k in instruction.target:\n",
" \n",
" if str(instruction.operator) == \"CNot('qubit_count': 2)\":\n",
" if k == j and temp2 == 0:\n",
" \n",
" cnot_count+=1\n",
" temp2 = 1\n",
" \n",
" \n",
" \n",
" \n",
" # for i in prevInstruction.target:\n",
" # for j in instruction.target:\n",
" # if i == j:\n",
" # cnot_count+=1\n",
" \n",
" if str(instruction.operator) == \"CNot('qubit_count': 2)\":\n",
"\n",
" key = f'GateSet{cnot_count}'\n",
" if cnot_count == cnot_count_prev:\n",
" tempArray.append(instruction.target)\n",
" CNOT[key] = tempArray\n",
" GateSet[key] = tempArray\n",
" distance+=1\n",
" \n",
" \n",
" \n",
" \n",
" else:\n",
" GateSet[key] = tempArray\n",
" tempArray = []\n",
" \n",
" tempArray.append(instruction.target)\n",
" CNOT[key] = tempArray\n",
" # cnot_count+=1\n",
" #CNOT[key] = instruction.target\n",
" if distance > 1:\n",
" cnot_count+=1\n",
" \n",
" \n",
" distance = 1\n",
" \n",
" \n",
" \n",
" \n",
" #NEW\n",
" # else:\n",
" # key = f'GateSet{cnot_count}'\n",
" # tempArray = []\n",
" # tempArray.append(instruction.target)\n",
" # GateSet[key] = tempArray\n",
" #NEW_END\n",
" \n",
" prevInstruction = instruction\n",
" temp = 1\n",
" \n",
" cnot_count_prev = cnot_count\n",
" \n",
"\n",
"print(CNOT)"
"print(GateSet)"
]
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 19,
"id": "34e20239-4ce5-474f-bb07-607eae5146e7",
"metadata": {},
"outputs": [],
"source": []
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Qubit(0)\n",
"Qubit(1)\n",
"Qubit(4)\n",
"Qubit(3)\n",
"Qubit(0)\n",
"Qubit(1)\n",
"Qubit(2)\n",
"Qubit(3)\n",
"Qubit(0)\n",
"Qubit(1)\n",
"Qubit(2)\n",
"Qubit(3)\n"
]
}
],
"source": [
"IL = [[], []]\n",
"for gateSet in GateSet:\n",
" # print(gateSet)\n",
" temp = GateSet[gateSet]\n",
" for set in temp:\n",
" for qbit in set:\n",
" print(qbit)\n",
" \n",
" \n",
"\n",
" \n",
" "
]
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 8,
"id": "0df4d882-c06c-43ee-8739-1bec70b2e1d5",
"metadata": {},
"outputs": [],
"source": []
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{'GateSet3': [QubitSet([Qubit(0), Qubit(1)]), QubitSet([Qubit(4), Qubit(3)]), QubitSet([Qubit(0), Qubit(1)]), QubitSet([Qubit(2), Qubit(3)])]}\n"
]
}
],
"source": [
"\n"
]
},
{
"cell_type": "code",
Expand Down
6 changes: 6 additions & 0 deletions .ipynb_checkpoints/Untitled1-checkpoint.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"cells": [],
"metadata": {},
"nbformat": 4,
"nbformat_minor": 5
}
6 changes: 6 additions & 0 deletions .ipynb_checkpoints/postfailure-checkpoint.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"cells": [],
"metadata": {},
"nbformat": 4,
"nbformat_minor": 5
}
Loading

0 comments on commit 442011c

Please sign in to comment.