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

Commit 28caf87

Browse files
committed
delete a cell that reads an LP file
1 parent d6fac46 commit 28caf87

1 file changed

Lines changed: 32 additions & 89 deletions

File tree

tutorials/aqua/optimization/1_optimization_problems.ipynb

Lines changed: 32 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"cell_type": "markdown",
55
"metadata": {},
66
"source": [
7-
"# Quadratically Constrained Quadratic Programs"
7+
"# Quadratically Constrained Quadratic Programs\n",
8+
"The latest version of this notebook is available on https://github.com/Qiskit/qiskit/tree/master/docs/tutorials."
89
]
910
},
1011
{
@@ -18,21 +19,17 @@
1819
"cell_type": "markdown",
1920
"metadata": {},
2021
"source": [
21-
"In this tutorial, we briefly introduce how to construct an optimization model with Qiskit Optimization.\n",
22-
"You can find detailed information at [Qiskit Aqua API references](https://qiskit.org/documentation/apidoc/optimization/optimization.html).\n",
23-
"\n",
24-
"Qiskit Optimization introduces `QuadraticProgram` class to make a model of an optimization problem.\n",
22+
"In this tutorial, we briefly introduce how to build optimization problems using Qiskit's optimization module.\n",
23+
"Qiskit introduces the `QuadraticProgram` class to make a model of an optimization problem.\n",
2524
"More precicely, it deals with quadratically constrained quadratic programs given as follows:\n",
26-
"\n",
2725
"$$\n",
2826
"\\begin{align}\n",
29-
"\\text{minimize}\\quad& x^\\top Q_0 x + c^\\top x \\\\\n",
30-
"\\text{subject to}\\quad& A x \\leq b \\\\\n",
31-
"& x^\\top Q_i x + a_i^\\top x \\leq r_i, \\quad 1,\\dots,i,\\dots,q \\\\\n",
27+
"\\text{minimize}\\quad& x^\\top Q_0 x + c^\\top x\\\\\n",
28+
"\\text{subject to}\\quad& A x \\leq b\\\\\n",
29+
"& x^\\top Q_i x + a_i^\\top x \\leq r_i, \\quad 1,\\dots,i,\\dots,q\\\\\n",
3230
"& l_i \\leq x_i \\leq u_i, \\quad 1,\\dots,i,\\dots,n,\n",
3331
"\\end{align}\n",
3432
"$$\n",
35-
"\n",
3633
"where the $Q_i$ are $n \\times n$ matrices, $A$ is a $m \\times n$ matrix , $x$, and $c$ are $n$-dimensional vectors, $b$ is an $m$-dimensional vector, and where $x$ can defined as binary, integer, or continuous variables.\n",
3734
"In addition to \"$\\leq$\" constraints 'QuadraticProgram' also supports \"$\\geq$\" and \"$=$\"."
3835
]
@@ -41,7 +38,7 @@
4138
"cell_type": "markdown",
4239
"metadata": {},
4340
"source": [
44-
"## Loading a Quadratic Program from an LP file"
41+
"## Loading a `Quadratic Program` from an LP file"
4542
]
4643
},
4744
{
@@ -53,18 +50,9 @@
5350
},
5451
{
5552
"cell_type": "code",
56-
"execution_count": 2,
53+
"execution_count": 1,
5754
"metadata": {},
58-
"outputs": [
59-
{
60-
"name": "stderr",
61-
"output_type": "stream",
62-
"text": [
63-
"/opt/miniconda3/lib/python3.7/site-packages/qiskit_aqua-0.7.0-py3.7.egg/qiskit/aqua/operators/primitive_ops/pauli_op.py:25: DeprecationWarning: The module qiskit.extensions.standard is deprecated as of 0.14.0 and will be removed no earlier than 3 months after the release. You should import the standard gates from qiskit.circuit.library.standard_gates instead.\n",
64-
" from qiskit.extensions.standard import RZGate, RYGate, RXGate, XGate, YGate, ZGate, IGate\n"
65-
]
66-
}
67-
],
55+
"outputs": [],
6856
"source": [
6957
"from qiskit.optimization import QuadraticProgram"
7058
]
@@ -73,60 +61,15 @@
7361
"cell_type": "markdown",
7462
"metadata": {},
7563
"source": [
76-
"You start with an empty model or load a problem from LP files.\n",
64+
"You start with an empty model.\n",
7765
"You can display your optimization problem with a method `pprint_as_string` and `print_as_lp_string`."
7866
]
7967
},
80-
{
81-
"cell_type": "code",
82-
"execution_count": 3,
83-
"metadata": {},
84-
"outputs": [
85-
{
86-
"name": "stdout",
87-
"output_type": "stream",
88-
"text": [
89-
"\\ This file has been generated by DOcplex\n",
90-
"\\ ENCODING=ISO-8859-1\n",
91-
"\\Problem name: my problem\n",
92-
"\n",
93-
"Minimize\n",
94-
" obj: x - y + 10 z + [ x^2 - 2 y*z ]/2\n",
95-
"Subject To\n",
96-
" lin_eq: x + 2 y = 1\n",
97-
" lin_leq: x + 2 y <= 1\n",
98-
" lin_geq: x + 2 y >= 1\n",
99-
" quad_eq: [ x^2 - y*z + 2 z^2 ] + x + y = 1\n",
100-
" quad_leq: [ x^2 - y*z + 2 z^2 ] + x + y <= 1\n",
101-
" quad_geq: [ x^2 - y*z + 2 z^2 ] + x + y >= 1\n",
102-
"\n",
103-
"Bounds\n",
104-
" 0 <= x <= 1\n",
105-
" -1 <= y <= 5\n",
106-
" -1 <= z <= 5\n",
107-
"\n",
108-
"Binaries\n",
109-
" x\n",
110-
"\n",
111-
"Generals\n",
112-
" y\n",
113-
"End\n",
114-
"\n"
115-
]
116-
}
117-
],
118-
"source": [
119-
"# load an LP file\n",
120-
"mod = QuadraticProgram()\n",
121-
"mod.read_from_lp_file('aux_files/sample.lp')\n",
122-
"print(mod.export_as_lp_string())"
123-
]
124-
},
12568
{
12669
"cell_type": "markdown",
12770
"metadata": {},
12871
"source": [
129-
"Qiskit Optimization supports the conversion from Docplex model. You can easily make a model of an optimization problem with Docplex.\n",
72+
"Qiskit's optimization module supports the conversion from Docplex model. You can easily make a model of an optimization problem with Docplex.\n",
13073
"You can find the documentation of Docplex at https://ibmdecisionoptimization.github.io/docplex-doc/mp/index.html\n",
13174
"\n",
13275
"You can load a Docplex model to `QuadraticProgram` by invoking `from_docplex`."
@@ -136,12 +79,12 @@
13679
"cell_type": "markdown",
13780
"metadata": {},
13881
"source": [
139-
"## Loading a QuadraticProgram from a docplex model"
82+
"## Loading a `QuadraticProgram` from a docplex model"
14083
]
14184
},
14285
{
14386
"cell_type": "code",
144-
"execution_count": 4,
87+
"execution_count": 2,
14588
"metadata": {},
14689
"outputs": [
14790
{
@@ -187,7 +130,7 @@
187130
},
188131
{
189132
"cell_type": "code",
190-
"execution_count": 5,
133+
"execution_count": 3,
191134
"metadata": {},
192135
"outputs": [
193136
{
@@ -229,7 +172,7 @@
229172
"cell_type": "markdown",
230173
"metadata": {},
231174
"source": [
232-
"## Directly constructing a QuadraticProgram"
175+
"## Directly constructing a `QuadraticProgram`"
233176
]
234177
},
235178
{
@@ -242,7 +185,7 @@
242185
},
243186
{
244187
"cell_type": "code",
245-
"execution_count": 6,
188+
"execution_count": 4,
246189
"metadata": {},
247190
"outputs": [
248191
{
@@ -273,7 +216,7 @@
273216
"cell_type": "markdown",
274217
"metadata": {},
275218
"source": [
276-
"Qiskit Optimization stack supports three types of variables:\n",
219+
"The `QuadraticProgram` supports three types of variables:\n",
277220
"- Binary varible\n",
278221
"- Integer variable\n",
279222
"- Continuous variable\n",
@@ -288,7 +231,7 @@
288231
},
289232
{
290233
"cell_type": "code",
291-
"execution_count": 7,
234+
"execution_count": 5,
292235
"metadata": {},
293236
"outputs": [
294237
{
@@ -339,7 +282,7 @@
339282
},
340283
{
341284
"cell_type": "code",
342-
"execution_count": 8,
285+
"execution_count": 6,
343286
"metadata": {},
344287
"outputs": [
345288
{
@@ -377,7 +320,7 @@
377320
},
378321
{
379322
"cell_type": "code",
380-
"execution_count": 9,
323+
"execution_count": 7,
381324
"metadata": {},
382325
"outputs": [
383326
{
@@ -427,7 +370,7 @@
427370
},
428371
{
429372
"cell_type": "code",
430-
"execution_count": 10,
373+
"execution_count": 8,
431374
"metadata": {},
432375
"outputs": [
433376
{
@@ -487,7 +430,7 @@
487430
},
488431
{
489432
"cell_type": "code",
490-
"execution_count": 11,
433+
"execution_count": 9,
491434
"metadata": {},
492435
"outputs": [
493436
{
@@ -537,7 +480,7 @@
537480
},
538481
{
539482
"cell_type": "code",
540-
"execution_count": 12,
483+
"execution_count": 10,
541484
"metadata": {},
542485
"outputs": [
543486
{
@@ -590,7 +533,7 @@
590533
},
591534
{
592535
"cell_type": "code",
593-
"execution_count": 13,
536+
"execution_count": 11,
594537
"metadata": {},
595538
"outputs": [
596539
{
@@ -618,7 +561,7 @@
618561
},
619562
{
620563
"cell_type": "code",
621-
"execution_count": 14,
564+
"execution_count": 12,
622565
"metadata": {},
623566
"outputs": [
624567
{
@@ -678,7 +621,7 @@
678621
},
679622
{
680623
"cell_type": "code",
681-
"execution_count": 15,
624+
"execution_count": 13,
682625
"metadata": {},
683626
"outputs": [
684627
{
@@ -719,7 +662,7 @@
719662
},
720663
{
721664
"cell_type": "code",
722-
"execution_count": 16,
665+
"execution_count": 14,
723666
"metadata": {},
724667
"outputs": [
725668
{
@@ -752,7 +695,7 @@
752695
},
753696
{
754697
"cell_type": "code",
755-
"execution_count": 17,
698+
"execution_count": 15,
756699
"metadata": {},
757700
"outputs": [
758701
{
@@ -773,14 +716,14 @@
773716
},
774717
{
775718
"cell_type": "code",
776-
"execution_count": 18,
719+
"execution_count": 16,
777720
"metadata": {},
778721
"outputs": [
779722
{
780723
"data": {
781724
"text/html": [
782-
"<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.14.0</td></tr><tr><td>Aer</td><td>0.6.0</td></tr><tr><td>Ignis</td><td>0.3.0</td></tr><tr><td>Aqua</td><td>0.7.0</td></tr><tr><td>IBM Q Provider</td><td>0.6.1</td></tr><tr><th>System information</th></tr><tr><td>Python</td><td>3.7.7 (default, Mar 26 2020, 10:32:53) \n",
783-
"[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'>Wed Apr 29 12:59:03 2020 EDT</td></tr></table>"
725+
"<h3>Version Information</h3><table><tr><th>Qiskit Software</th><th>Version</th></tr><tr><td>Qiskit</td><td>0.18.3</td></tr><tr><td>Terra</td><td>0.14.1</td></tr><tr><td>Aer</td><td>0.5.1</td></tr><tr><td>Ignis</td><td>0.3.0</td></tr><tr><td>Aqua</td><td>0.8.0.dev0+7056f9b</td></tr><tr><td>IBM Q Provider</td><td>0.6.1</td></tr><tr><th>System information</th></tr><tr><td>Python</td><td>3.7.7 (default, Apr 18 2020, 02:59:53) \n",
726+
"[GCC 9.3.0]</td></tr><tr><td>OS</td><td>Linux</td></tr><tr><td>CPUs</td><td>4</td></tr><tr><td>Memory (Gb)</td><td>15.143501281738281</td></tr><tr><td colspan='2'>Wed May 06 22:35:12 2020 JST</td></tr></table>"
784727
],
785728
"text/plain": [
786729
"<IPython.core.display.HTML object>"

0 commit comments

Comments
 (0)