Skip to content
This repository was archived by the owner on Aug 21, 2023. It is now read-only.

Commit 63f6d52

Browse files
authored
Merge pull request #850 from manoelmarques/json_remove
Remove Aqua Declarative API, Update import paths, Change to Machine Learning
2 parents 51144fe + bfe2200 commit 63f6d52

45 files changed

Lines changed: 2276 additions & 11797 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

qiskit/1_start_here.ipynb

Lines changed: 9 additions & 4 deletions
Large diffs are not rendered by default.

qiskit/advanced/aqua/Aqua_how_to_build_a_pluggable_algorithm_components.ipynb

Lines changed: 23 additions & 168 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,15 @@
1616
"cell_type": "markdown",
1717
"metadata": {},
1818
"source": [
19-
"# Qiskit Aqua: Tutorial to build a pluggable algorithm/component\n"
19+
"# _*Qiskit Aqua: Tutorial to build a pluggable algorithm/component*_ \n",
20+
"\n",
21+
"The latest version of this notebook is available on https://github.com/Qiskit/qiskit-tutorial.\n",
22+
"\n",
23+
"***\n",
24+
"### Contributors\n",
25+
"Richard Chen<sup>[1]</sup>, Shaohan Hu<sup>[1]</sup>, Antonio Mezzacapo<sup>[1]</sup>, Peng Liu<sup>[1]</sup>, Marco Pistoia<sup>[1]</sup>, Stephen Wood<sup>[1]</sup>\n",
26+
"### Affiliation\n",
27+
"- <sup>[1]</sup>IBMQ"
2028
]
2129
},
2230
{
@@ -28,120 +36,36 @@
2836
"This notebook is part of the simple example of an algorithm for `Qiskit Aqua`. This sample, called `Evolution Fidelity`, illustrates how to implement an algorithm and what steps to take to configure and run it. The implementation of the algorithm itself is located in the `evolutionfidelity` directory."
2937
]
3038
},
31-
{
32-
"cell_type": "markdown",
33-
"metadata": {},
34-
"source": [
35-
"### Register a pluggable algorithm/components\n",
36-
"After you complete the algorithm implementation, there are two approaches to register your pluggable algorithm/components.\n",
37-
"\n",
38-
"**Note: you can use the developed algorithm directly in Python without any issue.**\n",
39-
"\n",
40-
"1. Register it permanently. \n",
41-
"2. Register it on-the-fly.\n",
42-
"\n",
43-
"\n",
44-
"#### Register it permanently\n",
45-
"If you complete the pluggable algorithm/components as a Python package, you can refer to this [instruction](https://qiskit.org/documentation/aqua/extending.html#extending-aqua) to prepare the `setup.py` file to register the pluggable algorithm/component, which will be discovered in Qiskit-Aqua. We prepared a [setup.py](evolutionfidelity/setup.py) example for this tutorial. \n",
46-
"\n",
47-
"Go to the `qiskit/advanced/aqua/evolutionfidelity` folder, and then do `python3 setup.py install` to install the package.\n",
48-
"\n",
49-
"#### Register it on-the-fly\n",
50-
"You can also register it on-the-fly. Aqua provides a function to register your pluggable algorithm/component easily. The following cell shows how to do that."
51-
]
52-
},
53-
{
54-
"cell_type": "code",
55-
"execution_count": 1,
56-
"metadata": {
57-
"ExecuteTime": {
58-
"end_time": "2019-12-12T15:16:11.185336Z",
59-
"start_time": "2019-12-12T15:16:08.136942Z"
60-
}
61-
},
62-
"outputs": [],
63-
"source": [
64-
"from qiskit.aqua import register_pluggable\n",
65-
"from evolutionfidelity.evolutionfidelity import EvolutionFidelity\n",
66-
"try:\n",
67-
" register_pluggable(EvolutionFidelity)\n",
68-
"except Exception as e:\n",
69-
" print(e)"
70-
]
71-
},
72-
{
73-
"cell_type": "code",
74-
"execution_count": 2,
75-
"metadata": {
76-
"ExecuteTime": {
77-
"end_time": "2019-12-12T15:16:11.201460Z",
78-
"start_time": "2019-12-12T15:16:11.198572Z"
79-
}
80-
},
81-
"outputs": [],
82-
"source": [
83-
"from qiskit import BasicAer\n",
84-
"import numpy as np\n",
85-
"from qiskit.aqua.operators import MatrixOperator, op_converter\n",
86-
"from qiskit.aqua import local_pluggables, PluggableType"
87-
]
88-
},
89-
{
90-
"cell_type": "markdown",
91-
"metadata": {},
92-
"source": [
93-
"List all registered algorithms, and we will find `EvolutionFidelity` in the list if you registered it."
94-
]
95-
},
96-
{
97-
"cell_type": "code",
98-
"execution_count": 3,
99-
"metadata": {
100-
"ExecuteTime": {
101-
"end_time": "2019-12-12T15:16:11.217871Z",
102-
"start_time": "2019-12-12T15:16:11.214681Z"
103-
}
104-
},
105-
"outputs": [
106-
{
107-
"name": "stdout",
108-
"output_type": "stream",
109-
"text": [
110-
"['QAOA.Variational', 'QGAN', 'VQC', 'VQE', 'ExactEigensolver', 'ExactLSsolver', 'SVM', 'EOH', 'QSVM', 'AmplitudeEstimation', 'MaximumLikelihoodAmplitudeEstimation', 'BernsteinVazirani', 'DeutschJozsa', 'Grover', 'HHL', 'IQPE', 'QPE', 'Shor', 'Simon', 'QEomEE', 'QEomVQE', 'EvolutionFidelity']\n"
111-
]
112-
}
113-
],
114-
"source": [
115-
"print(local_pluggables(PluggableType.ALGORITHM))"
116-
]
117-
},
11839
{
11940
"cell_type": "markdown",
12041
"metadata": {},
12142
"source": [
12243
"### Use the algorithm directly\n",
123-
"Without registration, you can still use the designed algorithm/components as is."
44+
"You can use the designed algorithm/components as is."
12445
]
12546
},
12647
{
12748
"cell_type": "code",
128-
"execution_count": 4,
49+
"execution_count": 1,
12950
"metadata": {
13051
"ExecuteTime": {
131-
"end_time": "2019-12-12T15:16:11.402263Z",
132-
"start_time": "2019-12-12T15:16:11.283486Z"
52+
"end_time": "2019-08-22T01:38:45.795524Z",
53+
"start_time": "2019-08-22T01:38:45.524414Z"
13354
}
13455
},
13556
"outputs": [
13657
{
13758
"name": "stdout",
13859
"output_type": "stream",
13960
"text": [
140-
"0.9420934576187111\n"
61+
"0.7182824381334073\n"
14162
]
14263
}
14364
],
14465
"source": [
66+
"from qiskit import BasicAer\n",
67+
"import numpy as np\n",
68+
"from qiskit.aqua.operators import MatrixOperator, op_converter\n",
14569
"from evolutionfidelity.evolutionfidelity import EvolutionFidelity\n",
14670
"from qiskit.aqua.components.initial_states import Zero\n",
14771
"from qiskit.aqua import QuantumInstance\n",
@@ -160,90 +84,21 @@
16084
"print(result['score'])"
16185
]
16286
},
163-
{
164-
"cell_type": "markdown",
165-
"metadata": {},
166-
"source": [
167-
"### Use the algorithm via a declarative approach\n",
168-
"After you register the package, you will be able to discover the algorithm declaratively."
169-
]
170-
},
171-
{
172-
"cell_type": "code",
173-
"execution_count": 5,
174-
"metadata": {
175-
"ExecuteTime": {
176-
"end_time": "2019-12-12T15:16:12.488671Z",
177-
"start_time": "2019-12-12T15:16:12.483037Z"
178-
}
179-
},
180-
"outputs": [],
181-
"source": [
182-
"from qiskit.aqua.input import EnergyInput\n",
183-
"from qiskit.aqua import run_algorithm\n",
184-
"\n",
185-
"params = {\n",
186-
" 'problem': {\n",
187-
" 'name': 'eoh'\n",
188-
" },\n",
189-
" 'algorithm': {\n",
190-
" 'name': 'EvolutionFidelity',\n",
191-
" 'expansion_order': 1\n",
192-
" },\n",
193-
" 'initial_state': {\n",
194-
" 'name': 'ZERO'\n",
195-
" }\n",
196-
"}\n",
197-
"\n",
198-
"algo_input = EnergyInput(qubit_op)"
199-
]
200-
},
201-
{
202-
"cell_type": "code",
203-
"execution_count": 6,
204-
"metadata": {
205-
"ExecuteTime": {
206-
"end_time": "2019-12-12T15:16:24.808291Z",
207-
"start_time": "2019-12-12T15:16:13.001536Z"
208-
}
209-
},
210-
"outputs": [
211-
{
212-
"name": "stderr",
213-
"output_type": "stream",
214-
"text": [
215-
"/Users/paul/opt/anaconda3/envs/qiskit/lib/python3.7/site-packages/qiskit/providers/models/backendconfiguration.py:337: UserWarning: `dt` and `dtm` now have units of seconds(s) rather than nanoseconds(ns).\n",
216-
" warnings.warn('`dt` and `dtm` now have units of seconds(s) rather '\n"
217-
]
218-
},
219-
{
220-
"name": "stdout",
221-
"output_type": "stream",
222-
"text": [
223-
"0.9420934576187111\n"
224-
]
225-
}
226-
],
227-
"source": [
228-
"result = run_algorithm(params, algo_input, backend=backend)\n",
229-
"print(result['score'])"
230-
]
231-
},
23287
{
23388
"cell_type": "code",
234-
"execution_count": 7,
89+
"execution_count": 2,
23590
"metadata": {
23691
"ExecuteTime": {
237-
"end_time": "2019-12-12T15:16:24.898534Z",
238-
"start_time": "2019-12-12T15:16:24.823965Z"
92+
"end_time": "2019-08-22T01:38:34.386128Z",
93+
"start_time": "2019-08-22T01:38:34.375938Z"
23994
}
24095
},
24196
"outputs": [
24297
{
24398
"data": {
24499
"text/html": [
245-
"<h3>Version Information</h3><table><tr><th>Qiskit Software</th><th>Version</th></tr><tr><td>Qiskit</td><td>0.14.0</td></tr><tr><td>Terra</td><td>0.11.0</td></tr><tr><td>Aer</td><td>0.3.4</td></tr><tr><td>Ignis</td><td>0.2.0</td></tr><tr><td>Aqua</td><td>0.6.1</td></tr><tr><td>IBM Q Provider</td><td>0.4.4</td></tr><tr><th>System information</th></tr><tr><td>Python</td><td>3.7.5 (default, Oct 25 2019, 10:52:18) \n",
246-
"[Clang 4.0.1 (tags/RELEASE_401/final)]</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'>Thu Dec 12 10:16:24 2019 EST</td></tr></table>"
100+
"<h3>Version Information</h3><table><tr><th>Qiskit Software</th><th>Version</th></tr><tr><td>Qiskit</td><td>None</td></tr><tr><td>Terra</td><td>0.11.0.dev0+4164568</td></tr><tr><td>Aer</td><td>0.4.0</td></tr><tr><td>Ignis</td><td>0.3.0.dev0+6145a4e</td></tr><tr><td>Aqua</td><td>0.7.0.dev0+2d7a26f</td></tr><tr><td>IBM Q Provider</td><td>0.4.0rc1</td></tr><tr><th>System information</th></tr><tr><td>Python</td><td>3.7.4 (default, Aug 13 2019, 15:17:50) \n",
101+
"[Clang 4.0.1 (tags/RELEASE_401/final)]</td></tr><tr><td>OS</td><td>Darwin</td></tr><tr><td>CPUs</td><td>2</td></tr><tr><td>Memory (Gb)</td><td>8.0</td></tr><tr><td colspan='2'>Mon Nov 11 17:29:56 2019 EST</td></tr></table>"
247102
],
248103
"text/plain": [
249104
"<IPython.core.display.HTML object>"
@@ -295,7 +150,7 @@
295150
"name": "python",
296151
"nbconvert_exporter": "python",
297152
"pygments_lexer": "ipython3",
298-
"version": "3.7.5"
153+
"version": "3.7.4"
299154
},
300155
"varInspector": {
301156
"cols": {

qiskit/advanced/aqua/amplitude_estimation.ipynb

Lines changed: 44 additions & 36 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)