Skip to content

Commit

Permalink
add documentation files
Browse files Browse the repository at this point in the history
  • Loading branch information
DeborahVolpe committed Jun 3, 2024
1 parent 84b5ee7 commit 79c4766
Showing 1 changed file with 93 additions and 25 deletions.
118 changes: 93 additions & 25 deletions docs/Quickstart.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -13,93 +13,160 @@
"execution_count": null,
"id": "697e4c2b",
"metadata": {},
"outputs": [],
"outputs": [
{
"ename": "",
"evalue": "",
"output_type": "error",
"traceback": [
"\u001b[1;31mRunning cells with 'c:\\Users\\39333\\miniconda3\\envs\\MyEnvironmentName\\python.exe' requires the ipykernel package.\n",
"\u001b[1;31mRun the following command to install 'ipykernel' into the Python environment. \n",
"\u001b[1;31mCommand: 'conda install -p c:\\Users\\39333\\miniconda3\\envs\\MyEnvironmentName ipykernel --update-deps --force-reinstall'"
]
}
],
"source": [
"from mqt.bench import get_benchmark\n",
"from mqt.predictor import qcompile"
"from mqt.qao import Constraints, ObjectiveFunction, Problem, Solver, Variables"
]
},
{
"cell_type": "markdown",
"id": "02841c4f-a865-452d-a5ca-085a64eccf00",
"metadata": {},
"source": [
"## Generate Uncompiled Quantum Circuit"
"## Declare the variables of the problem"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "73c0a2f9-adbd-4f85-8843-b6ab2ef53da8",
"metadata": {},
"outputs": [],
"outputs": [
{
"ename": "",
"evalue": "",
"output_type": "error",
"traceback": [
"\u001b[1;31mRunning cells with 'c:\\Users\\39333\\miniconda3\\envs\\MyEnvironmentName\\python.exe' requires the ipykernel package.\n",
"\u001b[1;31mRun the following command to install 'ipykernel' into the Python environment. \n",
"\u001b[1;31mCommand: 'conda install -p c:\\Users\\39333\\miniconda3\\envs\\MyEnvironmentName ipykernel --update-deps --force-reinstall'"
]
}
],
"source": [
"var = Variables()\n",
"a = var.add_binary_variable(\"a\")\n",
"b = var.add_discrete_variable(\"b\", [-1, 1, 3])\n",
"c = var.add_continuous_variable(\"c\", -2, 2, 0.25)"
]
},
{
"cell_type": "markdown",
"id": "dc5b2a05-c062-46d8-b75e-2bfde4795a19",
"metadata": {},
"source": [
"qc = get_benchmark(\"ghz\", level=\"indep\", circuit_size=5)\n",
"qc.draw()"
"## Declare the objective functions"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "6ebf087c-b03f-4050-b452-ecf9d698f5e7",
"id": "b3f643db-f833-433c-87f8-65cdc5355304",
"metadata": {},
"outputs": [],
"outputs": [
{
"ename": "",
"evalue": "",
"output_type": "error",
"traceback": [
"\u001b[1;31mRunning cells with 'c:\\Users\\39333\\miniconda3\\envs\\MyEnvironmentName\\python.exe' requires the ipykernel package.\n",
"\u001b[1;31mRun the following command to install 'ipykernel' into the Python environment. \n",
"\u001b[1;31mCommand: 'conda install -p c:\\Users\\39333\\miniconda3\\envs\\MyEnvironmentName ipykernel --update-deps --force-reinstall'"
]
}
],
"source": [
"qc_compiled, compilation_information, quantum_device = qcompile(qc)"
"obj_func = ObjectiveFunction()\n",
"obj_func.add_objective_function(a + b * c + c**2)"
]
},
{
"cell_type": "markdown",
"id": "dc5b2a05-c062-46d8-b75e-2bfde4795a19",
"id": "7b823498-55e1-47df-9b7b-f5f462f38c50",
"metadata": {},
"source": [
"## Predicted Device"
"## Declare the constraints"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "b3f643db-f833-433c-87f8-65cdc5355304",
"id": "0c327466-7905-45b9-980a-f96ca8cffadb",
"metadata": {},
"outputs": [],
"outputs": [
{
"ename": "",
"evalue": "",
"output_type": "error",
"traceback": [
"\u001b[1;31mRunning cells with 'c:\\Users\\39333\\miniconda3\\envs\\MyEnvironmentName\\python.exe' requires the ipykernel package.\n",
"\u001b[1;31mRun the following command to install 'ipykernel' into the Python environment. \n",
"\u001b[1;31mCommand: 'conda install -p c:\\Users\\39333\\miniconda3\\envs\\MyEnvironmentName ipykernel --update-deps --force-reinstall'"
]
}
],
"source": [
"print(quantum_device)"
"cst = Constraints()\n",
"cst.add_constraint(\"b + c >= 2\", variable_precision=True)"
]
},
{
"cell_type": "markdown",
"id": "7b823498-55e1-47df-9b7b-f5f462f38c50",
"id": "53953b24-353e-465e-b4f4-d7c0f2f0f0bf",
"metadata": {},
"source": [
"## Predicted and Conducted Compilation Passes"
"## Declaration of the problem"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "0c327466-7905-45b9-980a-f96ca8cffadb",
"id": "fe643f31-9d3e-4b7f-875a-af27e3dab5ed",
"metadata": {},
"outputs": [],
"outputs": [
{
"ename": "",
"evalue": "",
"output_type": "error",
"traceback": [
"\u001b[1;31mRunning cells with 'c:\\Users\\39333\\miniconda3\\envs\\MyEnvironmentName\\python.exe' requires the ipykernel package.\n",
"\u001b[1;31mRun the following command to install 'ipykernel' into the Python environment. \n",
"\u001b[1;31mCommand: 'conda install -p c:\\Users\\39333\\miniconda3\\envs\\MyEnvironmentName ipykernel --update-deps --force-reinstall'"
]
}
],
"source": [
"print(compilation_information)"
"prb = Problem()\n",
"prb.create_problem(var, cst, obj_func)"
]
},
{
"cell_type": "markdown",
"id": "53953b24-353e-465e-b4f4-d7c0f2f0f0bf",
"id": "93392cb4",
"metadata": {},
"source": [
"## Compiled Circuit"
"## Solve with Quantum Annealing"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "fe643f31-9d3e-4b7f-875a-af27e3dab5ed",
"id": "010ab172",
"metadata": {},
"outputs": [],
"source": [
"qc_compiled.draw()"
"solution = Solver().solve_Dwave_quantum_annealer(prb, token=token)"
]
}
],
Expand All @@ -118,7 +185,8 @@
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3"
"pygments_lexer": "ipython3",
"version": "3.9.7"
}
},
"nbformat": 4,
Expand Down

0 comments on commit 79c4766

Please sign in to comment.