Skip to content

Commit

Permalink
restore outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
rsln-s committed Sep 1, 2023
1 parent de5187d commit 6242421
Showing 1 changed file with 135 additions and 12 deletions.
147 changes: 135 additions & 12 deletions examples/QAOA_LABS_optimization.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": null,
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -27,9 +27,116 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 2,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Maximum p available for N=10 is 8\n"
]
},
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>N</th>\n",
" <th>p</th>\n",
" <th>overlap</th>\n",
" <th>gamma</th>\n",
" <th>beta</th>\n",
" <th>merit factor</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>35</th>\n",
" <td>10</td>\n",
" <td>1</td>\n",
" <td>0.127219</td>\n",
" <td>[0.0788139605]</td>\n",
" <td>[-0.1899602111]</td>\n",
" <td>1.923268</td>\n",
" </tr>\n",
" <tr>\n",
" <th>36</th>\n",
" <td>10</td>\n",
" <td>2</td>\n",
" <td>0.196232</td>\n",
" <td>[0.06896497310000001, 0.1511922366]</td>\n",
" <td>[-0.1966433649, -0.1328573804]</td>\n",
" <td>2.174876</td>\n",
" </tr>\n",
" <tr>\n",
" <th>37</th>\n",
" <td>10</td>\n",
" <td>3</td>\n",
" <td>0.258441</td>\n",
" <td>[0.063816785, 0.1396294913, 0.1538820941]</td>\n",
" <td>[-0.2082662354, -0.1383489014, -0.1215130558]</td>\n",
" <td>2.320238</td>\n",
" </tr>\n",
" <tr>\n",
" <th>38</th>\n",
" <td>10</td>\n",
" <td>4</td>\n",
" <td>0.318326</td>\n",
" <td>[0.0655247286, 0.1319443875, 0.1430007569, 0.1...</td>\n",
" <td>[-0.20560510070000002, -0.1459282952, -0.12584...</td>\n",
" <td>2.445458</td>\n",
" </tr>\n",
" <tr>\n",
" <th>39</th>\n",
" <td>10</td>\n",
" <td>5</td>\n",
" <td>0.362467</td>\n",
" <td>[0.0661013761, 0.1351407309, 0.136539053600000...</td>\n",
" <td>[-0.2261604879, -0.1482192504, -0.1413220406, ...</td>\n",
" <td>2.506400</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" N p overlap gamma \\\n",
"35 10 1 0.127219 [0.0788139605] \n",
"36 10 2 0.196232 [0.06896497310000001, 0.1511922366] \n",
"37 10 3 0.258441 [0.063816785, 0.1396294913, 0.1538820941] \n",
"38 10 4 0.318326 [0.0655247286, 0.1319443875, 0.1430007569, 0.1... \n",
"39 10 5 0.362467 [0.0661013761, 0.1351407309, 0.136539053600000... \n",
"\n",
" beta merit factor \n",
"35 [-0.1899602111] 1.923268 \n",
"36 [-0.1966433649, -0.1328573804] 2.174876 \n",
"37 [-0.2082662354, -0.1383489014, -0.1215130558] 2.320238 \n",
"38 [-0.20560510070000002, -0.1459282952, -0.12584... 2.445458 \n",
"39 [-0.2261604879, -0.1482192504, -0.1413220406, ... 2.506400 "
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"N = 10\n",
"parameters = parameter_utils.get_best_known_parameters_for_LABS_wrt_overlap(N)\n",
Expand All @@ -47,7 +154,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -66,7 +173,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -78,9 +185,17 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 5,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Success probability at p=9 before optimization is 0.49333386759027675\n"
]
}
],
"source": [
"print(f\"Success probability at p={p} before optimization is {1-f(init_freq)}\")"
]
Expand All @@ -96,7 +211,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -105,9 +220,17 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 7,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Success probability at p=9 after optimization is 0.5242896565265064\n"
]
}
],
"source": [
"beta, gamma = parameter_utils.from_fourier_basis(res.x[:p], res.x[p:])\n",
"f_bg = qokit.get_qaoa_labs_objective(N, p, parameterization='gamma beta', objective='overlap')\n",
Expand All @@ -127,9 +250,9 @@
],
"metadata": {
"kernelspec": {
"display_name": "qokit",
"display_name": "py39",
"language": "python",
"name": "qokit"
"name": "py39"
},
"language_info": {
"codemirror_mode": {
Expand Down

0 comments on commit 6242421

Please sign in to comment.