Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
Co-authored-by: Steve Wood <40241007+woodsp-ibm@users.noreply.github.com>
  • Loading branch information
t-imamichi and woodsp-ibm committed Dec 6, 2022
1 parent 48c4c0a commit 60a50d1
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 39 deletions.
2 changes: 1 addition & 1 deletion docs/tutorials/04_grover_optimizer.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@
{
"data": {
"text/html": [
"<h3>Version Information</h3><table><tr><th>Qiskit Software</th><th>Version</th></tr><tr><td><code>qiskit-terra</code></td><td>0.23.0</td></tr><tr><td><code>qiskit-aer</code></td><td>0.11.1</td></tr><tr><td><code>qiskit-optimization</code></td><td>0.5.0</td></tr><tr><td><code>qiskit-machine-learning</code></td><td>0.6.0</td></tr><tr><th>System information</th></tr><tr><td>Python version</td><td>3.9.15</td></tr><tr><td>Python compiler</td><td>Clang 14.0.0 (clang-1400.0.29.102)</td></tr><tr><td>Python build</td><td>main, Oct 11 2022 22:27:25</td></tr><tr><td>OS</td><td>Darwin</td></tr><tr><td>CPUs</td><td>4</td></tr><tr><td>Memory (Gb)</td><td>16.0</td></tr><tr><td colspan='2'>Mon Dec 05 22:42:38 2022 JST</td></tr></table>"
"<h3>Version Information</h3><table><tr><th>Qiskit Software</th><th>Version</th></tr><tr><td><code>qiskit-terra</code></td><td>0.23.0</td></tr><tr><td><code>qiskit-aer</code></td><td>0.11.1</td></tr><tr><td><code>qiskit-optimization</code></td><td>0.5.0</td></tr><tr><td><code>qiskit-machine-learning</code></td><td>0.6.0</td></tr><tr><th>System information</th></tr><tr><td>Python version</td><td>3.9.15</td></tr><tr><td>Python compiler</td><td>Clang 14.0.0 (clang-1400.0.29.102)</td></tr><tr><td>Python build</td><td>main, Oct 11 2022 22:27:25</td></tr><tr><td>OS</td><td>Darwin</td></tr><tr><td>CPUs</td><td>4</td></tr><tr><td>Memory (Gb)</td><td>16.0</td></tr><tr><td colspan='2'>Tue Dec 06 21:47:01 2022 JST</td></tr></table>"
],
"text/plain": [
"<IPython.core.display.HTML object>"
Expand Down
6 changes: 3 additions & 3 deletions docs/tutorials/05_admm_optimizer.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
"\n",
"To solve the QUBO problems we can choose between \n",
"\n",
"- `MinimumEigenOptimizer` using different `MinimumEigensolver`, such as `VQE`, `QAOA` or `NumpyMinimumEigensolver` (classical)\n",
"- `MinimumEigenOptimizer` using different `MinimumEigensolver`, such as `SamplingVQE`, `QAOA` or `NumpyMinimumEigensolver` (classical)\n",
"- `GroverOptimizer`\n",
"- `CplexOptimizer` (classical, if CPLEX is installed)\n",
"\n",
Expand Down Expand Up @@ -205,7 +205,7 @@
"source": [
"## Classical Solution\n",
"\n",
"3-ADMM-H needs a QUBO optimizer to solve the QUBO subproblem, and a continuous optimizer to solve the continuous convex constrained subproblem. We first solve the problem classically: we use the `MinimumEigenOptimizer` with the `NumPyMinimumEigenSolver` as a classical and exact QUBO solver and we use the `CobylaOptimizer` as a continuous convex solver. 3-ADMM-H supports any other suitable solver available in Qiskit. For instance, VQE, QAOA, and GroverOptimizer can be invoked as quantum solvers, as demonstrated later.\n",
"3-ADMM-H needs a QUBO optimizer to solve the QUBO subproblem, and a continuous optimizer to solve the continuous convex constrained subproblem. We first solve the problem classically: we use the `MinimumEigenOptimizer` with the `NumPyMinimumEigenSolver` as a classical and exact QUBO solver and we use the `CobylaOptimizer` as a continuous convex solver. 3-ADMM-H supports any other suitable solver available in Qiskit. For instance, `SamplingVQE`, `QAOA`, and `GroverOptimizer` can be invoked as quantum solvers, as demonstrated later.\n",
"If CPLEX is installed, the `CplexOptimizer` can also be used as both, a QUBO and convex solver."
]
},
Expand Down Expand Up @@ -424,7 +424,7 @@
{
"data": {
"text/html": [
"<h3>Version Information</h3><table><tr><th>Qiskit Software</th><th>Version</th></tr><tr><td><code>qiskit-terra</code></td><td>0.23.0</td></tr><tr><td><code>qiskit-aer</code></td><td>0.11.1</td></tr><tr><td><code>qiskit-optimization</code></td><td>0.5.0</td></tr><tr><td><code>qiskit-machine-learning</code></td><td>0.6.0</td></tr><tr><th>System information</th></tr><tr><td>Python version</td><td>3.9.15</td></tr><tr><td>Python compiler</td><td>Clang 14.0.0 (clang-1400.0.29.102)</td></tr><tr><td>Python build</td><td>main, Oct 11 2022 22:27:25</td></tr><tr><td>OS</td><td>Darwin</td></tr><tr><td>CPUs</td><td>4</td></tr><tr><td>Memory (Gb)</td><td>16.0</td></tr><tr><td colspan='2'>Mon Dec 05 22:43:35 2022 JST</td></tr></table>"
"<h3>Version Information</h3><table><tr><th>Qiskit Software</th><th>Version</th></tr><tr><td><code>qiskit-terra</code></td><td>0.23.0</td></tr><tr><td><code>qiskit-aer</code></td><td>0.11.1</td></tr><tr><td><code>qiskit-optimization</code></td><td>0.5.0</td></tr><tr><td><code>qiskit-machine-learning</code></td><td>0.6.0</td></tr><tr><th>System information</th></tr><tr><td>Python version</td><td>3.9.15</td></tr><tr><td>Python compiler</td><td>Clang 14.0.0 (clang-1400.0.29.102)</td></tr><tr><td>Python build</td><td>main, Oct 11 2022 22:27:25</td></tr><tr><td>OS</td><td>Darwin</td></tr><tr><td>CPUs</td><td>4</td></tr><tr><td>Memory (Gb)</td><td>16.0</td></tr><tr><td colspan='2'>Tue Dec 06 21:47:54 2022 JST</td></tr></table>"
],
"text/plain": [
"<IPython.core.display.HTML object>"
Expand Down
32 changes: 12 additions & 20 deletions docs/tutorials/06_examples_max_cut_and_tsp.ipynb

Large diffs are not rendered by default.

10 changes: 4 additions & 6 deletions docs/tutorials/07_examples_vehicle_routing.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,8 @@
"source": [
"## Initialization\n",
"\n",
"First of all we load all the packages that we need. "
"First of all we load all the packages that we need.\n",
"CPLEX is required for the classical computations. You can install it by `pip install 'qiskit-optimization[cplex]'`. "
]
},
{
Expand All @@ -177,7 +178,6 @@
"metadata": {},
"outputs": [],
"source": [
"# Load the packages that are required\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"\n",
Expand All @@ -188,8 +188,6 @@
" print(\"Warning: Cplex not found.\")\n",
"import math\n",
"\n",
"# Qiskit packages\n",
"from qiskit.quantum_info import Pauli\n",
"from qiskit.utils import algorithm_globals\n",
"from qiskit.algorithms.minimum_eigensolvers import SamplingVQE\n",
"from qiskit.algorithms.optimizers import SPSA\n",
Expand Down Expand Up @@ -488,7 +486,7 @@
"\n",
"- `binary_representation` : encodes the problem $(M)$ into a QP terms (that's basically linear algebra);\n",
"- `construct_problem` : constructs a QUBO optimization problem as an instance of `QuadraticProgram`;\n",
"- `solve_problem`: solves the problem $(M)$ constructed at the previous step via `MinimunEigenOptimizer` by using VQE with default parameters;"
"- `solve_problem`: solves the problem $(M)$ constructed at the previous step via `MinimunEigenOptimizer` by using `SamplingVQE` with default parameters;"
]
},
{
Expand Down Expand Up @@ -771,7 +769,7 @@
{
"data": {
"text/html": [
"<h3>Version Information</h3><table><tr><th>Qiskit Software</th><th>Version</th></tr><tr><td><code>qiskit-terra</code></td><td>0.23.0</td></tr><tr><td><code>qiskit-aer</code></td><td>0.11.1</td></tr><tr><td><code>qiskit-optimization</code></td><td>0.5.0</td></tr><tr><td><code>qiskit-machine-learning</code></td><td>0.6.0</td></tr><tr><th>System information</th></tr><tr><td>Python version</td><td>3.9.15</td></tr><tr><td>Python compiler</td><td>Clang 14.0.0 (clang-1400.0.29.102)</td></tr><tr><td>Python build</td><td>main, Oct 11 2022 22:27:25</td></tr><tr><td>OS</td><td>Darwin</td></tr><tr><td>CPUs</td><td>4</td></tr><tr><td>Memory (Gb)</td><td>16.0</td></tr><tr><td colspan='2'>Mon Dec 05 22:42:38 2022 JST</td></tr></table>"
"<h3>Version Information</h3><table><tr><th>Qiskit Software</th><th>Version</th></tr><tr><td><code>qiskit-terra</code></td><td>0.23.0</td></tr><tr><td><code>qiskit-aer</code></td><td>0.11.1</td></tr><tr><td><code>qiskit-optimization</code></td><td>0.5.0</td></tr><tr><td><code>qiskit-machine-learning</code></td><td>0.6.0</td></tr><tr><th>System information</th></tr><tr><td>Python version</td><td>3.9.15</td></tr><tr><td>Python compiler</td><td>Clang 14.0.0 (clang-1400.0.29.102)</td></tr><tr><td>Python build</td><td>main, Oct 11 2022 22:27:25</td></tr><tr><td>OS</td><td>Darwin</td></tr><tr><td>CPUs</td><td>4</td></tr><tr><td>Memory (Gb)</td><td>16.0</td></tr><tr><td colspan='2'>Tue Dec 06 21:53:30 2022 JST</td></tr></table>"
],
"text/plain": [
"<IPython.core.display.HTML object>"
Expand Down
18 changes: 9 additions & 9 deletions docs/tutorials/08_cvar_optimization.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"source": [
"## Introduction\n",
"\n",
"This notebook shows how to use the Conditional Value at Risk (CVaR) objective function introduced in [1] within the variational quantum optimization algorithms provided by Qiskit. Particularly, it is shown how to setup the `MinimumEigenOptimizer` using `SamploingVQE` accordingly. \n",
"This notebook shows how to use the Conditional Value at Risk (CVaR) objective function introduced in [1] within the variational quantum optimization algorithms provided by Qiskit. Particularly, it is shown how to setup the `MinimumEigenOptimizer` using `SamplingVQE` accordingly. \n",
"For a given set of shots with corresponding objective values of the considered optimization problem, the CVaR with confidence level $\\alpha \\in [0, 1]$ is defined as the average of the $\\alpha$ best shots.\n",
"Thus, $\\alpha = 1$ corresponds to the standard expected value, while $\\alpha=0$ corresponds to the minimum of the given shots, and $\\alpha \\in (0, 1)$ is a tradeoff between focusing on better shots, but still applying some averaging to smoothen the optimization landscape.\n",
"\n",
Expand Down Expand Up @@ -153,7 +153,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Minimum Eigen Optimizer using VQE"
"## Minimum Eigen Optimizer using SamplingVQE"
]
},
{
Expand Down Expand Up @@ -219,7 +219,7 @@
"# loop over all given alpha values\n",
"for alpha in alphas:\n",
"\n",
" # initialize VQE using CVaR\n",
" # initialize SamplingVQE using CVaR\n",
" vqe = SamplingVQE(\n",
" sampler=sampler,\n",
" ansatz=ansatz,\n",
Expand All @@ -228,7 +228,7 @@
" callback=lambda i, params, obj, stddev: callback(i, params, obj, stddev, alpha),\n",
" )\n",
"\n",
" # initialize optimization algorithm based on CVaR-VQE\n",
" # initialize optimization algorithm based on CVaR-SamplingVQE\n",
" opt_alg = MinimumEigenOptimizer(vqe)\n",
"\n",
" # solve problem\n",
Expand Down Expand Up @@ -280,9 +280,9 @@
"name": "stdout",
"output_type": "stream",
"text": [
"optimal probabilitiy (alpha = 1.00): 0.0000\n",
"optimal probabilitiy (alpha = 0.50): 0.0000\n",
"optimal probabilitiy (alpha = 0.25): 0.2895\n"
"optimal probability (alpha = 1.00): 0.0000\n",
"optimal probability (alpha = 0.50): 0.0000\n",
"optimal probability (alpha = 0.25): 0.2895\n"
]
}
],
Expand All @@ -301,7 +301,7 @@
" results[alpha].min_eigen_solver_result.eigenstate.binary_probabilities().values(),\n",
" dtype=float,\n",
" )\n",
" print(\"optimal probabilitiy (alpha = %.2f): %.4f\" % (alpha, probabilities[ind][-1:]))"
" print(\"optimal probability (alpha = %.2f): %.4f\" % (alpha, probabilities[ind][-1:]))"
]
},
{
Expand All @@ -312,7 +312,7 @@
{
"data": {
"text/html": [
"<h3>Version Information</h3><table><tr><th>Qiskit Software</th><th>Version</th></tr><tr><td><code>qiskit-terra</code></td><td>0.23.0</td></tr><tr><td><code>qiskit-aer</code></td><td>0.11.1</td></tr><tr><td><code>qiskit-optimization</code></td><td>0.5.0</td></tr><tr><td><code>qiskit-machine-learning</code></td><td>0.6.0</td></tr><tr><th>System information</th></tr><tr><td>Python version</td><td>3.9.15</td></tr><tr><td>Python compiler</td><td>Clang 14.0.0 (clang-1400.0.29.102)</td></tr><tr><td>Python build</td><td>main, Oct 11 2022 22:27:25</td></tr><tr><td>OS</td><td>Darwin</td></tr><tr><td>CPUs</td><td>4</td></tr><tr><td>Memory (Gb)</td><td>16.0</td></tr><tr><td colspan='2'>Mon Dec 05 22:42:37 2022 JST</td></tr></table>"
"<h3>Version Information</h3><table><tr><th>Qiskit Software</th><th>Version</th></tr><tr><td><code>qiskit-terra</code></td><td>0.23.0</td></tr><tr><td><code>qiskit-aer</code></td><td>0.11.1</td></tr><tr><td><code>qiskit-optimization</code></td><td>0.5.0</td></tr><tr><td><code>qiskit-machine-learning</code></td><td>0.6.0</td></tr><tr><th>System information</th></tr><tr><td>Python version</td><td>3.9.15</td></tr><tr><td>Python compiler</td><td>Clang 14.0.0 (clang-1400.0.29.102)</td></tr><tr><td>Python build</td><td>main, Oct 11 2022 22:27:25</td></tr><tr><td>OS</td><td>Darwin</td></tr><tr><td>CPUs</td><td>4</td></tr><tr><td>Memory (Gb)</td><td>16.0</td></tr><tr><td colspan='2'>Tue Dec 06 21:47:02 2022 JST</td></tr></table>"
],
"text/plain": [
"<IPython.core.display.HTML object>"
Expand Down

0 comments on commit 60a50d1

Please sign in to comment.