Skip to content
This repository has been archived by the owner on Nov 16, 2023. It is now read-only.

Commit

Permalink
Move cplex import to last section
Browse files Browse the repository at this point in the history
This way, the all parts of the tutorial _except_ the cplex
section will work, even on systems where cplex is unavailable.
  • Loading branch information
garrison committed Jul 15, 2022
1 parent 9531ff1 commit 6e6079e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions docs/tutorials/01_getting_started.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
"metadata": {},
"source": [
"Next, we import\n",
"- CPLEX — an exact classical optimizer we use to evaluate QRAO's approximation.\n",
"- QRAO — an approximate quantum optimizer to solve combinatorial optimization problems — through a series of 3 classes:\n",
" - the encoding class (`QuantumRandomAccessEncoding`), which encodes our problem into a relaxed problem that requires fewer resources to solve\n",
" - one rounding scheme (`SemideterministicRounding`), which rounds the solution for the relaxed problem back to a solution of the original problem.\n",
Expand All @@ -50,8 +49,6 @@
"metadata": {},
"outputs": [],
"source": [
"from qiskit_optimization.algorithms import CplexOptimizer\n",
"\n",
"from qrao import (\n",
" QuantumRandomAccessEncoding,\n",
" QuantumRandomAccessOptimizer,\n",
Expand Down Expand Up @@ -447,7 +444,7 @@
"source": [
"## Solve the problem exactly using the `CplexOptimizer`\n",
"\n",
"To evaluate the performance of QRAO in approximating the optimal solution, we can use CPLEX to solve for the exact optimal solution as follows:"
"To evaluate the performance of QRAO in approximating the optimal solution, we can use CPLEX, an exact classical optimizer, to solve for the exact optimal solution as follows:"
]
},
{
Expand All @@ -469,6 +466,9 @@
}
],
"source": [
"# pylint: disable=wrong-import-order\n",
"from qiskit_optimization.algorithms import CplexOptimizer\n",
"\n",
"cplex_optimizer = CplexOptimizer()\n",
"cplex_results = cplex_optimizer.solve(problem)\n",
"exact_fval = cplex_results.fval\n",
Expand Down

0 comments on commit 6e6079e

Please sign in to comment.