├── .nojekyll
├── LICENSE.txt
├── README.md
├── html
├── Beyond_Linear_Programming.html
├── Linear_Programming.html
├── MachineLearning_and_CPLEX.html
└── Scheduling_Tutorial.html
└── jupyter
├── Beyond_Linear_Programming.ipynb
├── Linear_Programming.ipynb
├── MachineLearning_and_CPLEX.ipynb
├── Scheduling_Tutorial.ipynb
└── training
├── 1.png
├── 19.png
├── 1_10.png
├── 1_11.png
├── 1_12.png
├── 1_13.png
├── 1_19.png
├── 1_21.png
├── 1_25.png
├── 1_39.png
├── 1_43.png
├── 1_44.png
├── 1_45.png
├── 1_46.png
├── 1_47.png
├── 1_5.png
├── 1_6.png
├── 1_8.png
├── 20.png
├── 22.png
├── 26.png
├── 32.png
├── 36.png
├── 37.png
├── 38.png
├── 39.png
├── 42.png
└── 52.png
/.nojekyll:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 |
2 | Apache License
3 | Version 2.0, January 2004
4 | http://www.apache.org/licenses/
5 |
6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7 |
8 | 1. Definitions.
9 |
10 | "License" shall mean the terms and conditions for use, reproduction,
11 | and distribution as defined by Sections 1 through 9 of this document.
12 |
13 | "Licensor" shall mean the copyright owner or entity authorized by
14 | the copyright owner that is granting the License.
15 |
16 | "Legal Entity" shall mean the union of the acting entity and all
17 | other entities that control, are controlled by, or are under common
18 | control with that entity. For the purposes of this definition,
19 | "control" means (i) the power, direct or indirect, to cause the
20 | direction or management of such entity, whether by contract or
21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
22 | outstanding shares, or (iii) beneficial ownership of such entity.
23 |
24 | "You" (or "Your") shall mean an individual or Legal Entity
25 | exercising permissions granted by this License.
26 |
27 | "Source" form shall mean the preferred form for making modifications,
28 | including but not limited to software source code, documentation
29 | source, and configuration files.
30 |
31 | "Object" form shall mean any form resulting from mechanical
32 | transformation or translation of a Source form, including but
33 | not limited to compiled object code, generated documentation,
34 | and conversions to other media types.
35 |
36 | "Work" shall mean the work of authorship, whether in Source or
37 | Object form, made available under the License, as indicated by a
38 | copyright notice that is included in or attached to the work
39 | (an example is provided in the Appendix below).
40 |
41 | "Derivative Works" shall mean any work, whether in Source or Object
42 | form, that is based on (or derived from) the Work and for which the
43 | editorial revisions, annotations, elaborations, or other modifications
44 | represent, as a whole, an original work of authorship. For the purposes
45 | of this License, Derivative Works shall not include works that remain
46 | separable from, or merely link (or bind by name) to the interfaces of,
47 | the Work and Derivative Works thereof.
48 |
49 | "Contribution" shall mean any work of authorship, including
50 | the original version of the Work and any modifications or additions
51 | to that Work or Derivative Works thereof, that is intentionally
52 | submitted to Licensor for inclusion in the Work by the copyright owner
53 | or by an individual or Legal Entity authorized to submit on behalf of
54 | the copyright owner. For the purposes of this definition, "submitted"
55 | means any form of electronic, verbal, or written communication sent
56 | to the Licensor or its representatives, including but not limited to
57 | communication on electronic mailing lists, source code control systems,
58 | and issue tracking systems that are managed by, or on behalf of, the
59 | Licensor for the purpose of discussing and improving the Work, but
60 | excluding communication that is conspicuously marked or otherwise
61 | designated in writing by the copyright owner as "Not a Contribution."
62 |
63 | "Contributor" shall mean Licensor and any individual or Legal Entity
64 | on behalf of whom a Contribution has been received by Licensor and
65 | subsequently incorporated within the Work.
66 |
67 | 2. Grant of Copyright License. Subject to the terms and conditions of
68 | this License, each Contributor hereby grants to You a perpetual,
69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70 | copyright license to reproduce, prepare Derivative Works of,
71 | publicly display, publicly perform, sublicense, and distribute the
72 | Work and such Derivative Works in Source or Object form.
73 |
74 | 3. Grant of Patent License. Subject to the terms and conditions of
75 | this License, each Contributor hereby grants to You a perpetual,
76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77 | (except as stated in this section) patent license to make, have made,
78 | use, offer to sell, sell, import, and otherwise transfer the Work,
79 | where such license applies only to those patent claims licensable
80 | by such Contributor that are necessarily infringed by their
81 | Contribution(s) alone or by combination of their Contribution(s)
82 | with the Work to which such Contribution(s) was submitted. If You
83 | institute patent litigation against any entity (including a
84 | cross-claim or counterclaim in a lawsuit) alleging that the Work
85 | or a Contribution incorporated within the Work constitutes direct
86 | or contributory patent infringement, then any patent licenses
87 | granted to You under this License for that Work shall terminate
88 | as of the date such litigation is filed.
89 |
90 | 4. Redistribution. You may reproduce and distribute copies of the
91 | Work or Derivative Works thereof in any medium, with or without
92 | modifications, and in Source or Object form, provided that You
93 | meet the following conditions:
94 |
95 | (a) You must give any other recipients of the Work or
96 | Derivative Works a copy of this License; and
97 |
98 | (b) You must cause any modified files to carry prominent notices
99 | stating that You changed the files; and
100 |
101 | (c) You must retain, in the Source form of any Derivative Works
102 | that You distribute, all copyright, patent, trademark, and
103 | attribution notices from the Source form of the Work,
104 | excluding those notices that do not pertain to any part of
105 | the Derivative Works; and
106 |
107 | (d) If the Work includes a "NOTICE" text file as part of its
108 | distribution, then any Derivative Works that You distribute must
109 | include a readable copy of the attribution notices contained
110 | within such NOTICE file, excluding those notices that do not
111 | pertain to any part of the Derivative Works, in at least one
112 | of the following places: within a NOTICE text file distributed
113 | as part of the Derivative Works; within the Source form or
114 | documentation, if provided along with the Derivative Works; or,
115 | within a display generated by the Derivative Works, if and
116 | wherever such third-party notices normally appear. The contents
117 | of the NOTICE file are for informational purposes only and
118 | do not modify the License. You may add Your own attribution
119 | notices within Derivative Works that You distribute, alongside
120 | or as an addendum to the NOTICE text from the Work, provided
121 | that such additional attribution notices cannot be construed
122 | as modifying the License.
123 |
124 | You may add Your own copyright statement to Your modifications and
125 | may provide additional or different license terms and conditions
126 | for use, reproduction, or distribution of Your modifications, or
127 | for any such Derivative Works as a whole, provided Your use,
128 | reproduction, and distribution of the Work otherwise complies with
129 | the conditions stated in this License.
130 |
131 | 5. Submission of Contributions. Unless You explicitly state otherwise,
132 | any Contribution intentionally submitted for inclusion in the Work
133 | by You to the Licensor shall be under the terms and conditions of
134 | this License, without any additional terms or conditions.
135 | Notwithstanding the above, nothing herein shall supersede or modify
136 | the terms of any separate license agreement you may have executed
137 | with Licensor regarding such Contributions.
138 |
139 | 6. Trademarks. This License does not grant permission to use the trade
140 | names, trademarks, service marks, or product names of the Licensor,
141 | except as required for reasonable and customary use in describing the
142 | origin of the Work and reproducing the content of the NOTICE file.
143 |
144 | 7. Disclaimer of Warranty. Unless required by applicable law or
145 | agreed to in writing, Licensor provides the Work (and each
146 | Contributor provides its Contributions) on an "AS IS" BASIS,
147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148 | implied, including, without limitation, any warranties or conditions
149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150 | PARTICULAR PURPOSE. You are solely responsible for determining the
151 | appropriateness of using or redistributing the Work and assume any
152 | risks associated with Your exercise of permissions under this License.
153 |
154 | 8. Limitation of Liability. In no event and under no legal theory,
155 | whether in tort (including negligence), contract, or otherwise,
156 | unless required by applicable law (such as deliberate and grossly
157 | negligent acts) or agreed to in writing, shall any Contributor be
158 | liable to You for damages, including any direct, indirect, special,
159 | incidental, or consequential damages of any character arising as a
160 | result of this License or out of the use or inability to use the
161 | Work (including but not limited to damages for loss of goodwill,
162 | work stoppage, computer failure or malfunction, or any and all
163 | other commercial damages or losses), even if such Contributor
164 | has been advised of the possibility of such damages.
165 |
166 | 9. Accepting Warranty or Additional Liability. While redistributing
167 | the Work or Derivative Works thereof, You may choose to offer,
168 | and charge a fee for, acceptance of support, warranty, indemnity,
169 | or other liability obligations and/or rights consistent with this
170 | License. However, in accepting such obligations, You may act only
171 | on Your own behalf and on Your sole responsibility, not on behalf
172 | of any other Contributor, and only if You agree to indemnify,
173 | defend, and hold each Contributor harmless for any liability
174 | incurred by, or claims asserted against, such Contributor by reason
175 | of your accepting any such warranty or additional liability.
176 |
177 | END OF TERMS AND CONDITIONS
178 |
179 | APPENDIX: How to apply the Apache License to your work.
180 |
181 | To apply the Apache License to your work, attach the following
182 | boilerplate notice, with the fields enclosed by brackets "[]"
183 | replaced with your own identifying information. (Don't include
184 | the brackets!) The text should be enclosed in the appropriate
185 | comment syntax for the file format. We also recommend that a
186 | file or class name and description of purpose be included on the
187 | same "printed page" as the copyright notice for easier
188 | identification within third-party archives.
189 |
190 | Copyright [2015] [IBM Corporation]
191 |
192 | Licensed under the Apache License, Version 2.0 (the "License");
193 | you may not use this file except in compliance with the License.
194 | You may obtain a copy of the License at
195 |
196 | http://www.apache.org/licenses/LICENSE-2.0
197 |
198 | Unless required by applicable law or agreed to in writing, software
199 | distributed under the License is distributed on an "AS IS" BASIS,
200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201 | See the License for the specific language governing permissions and
202 | limitations under the License.
203 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # IBM® Decision Optimization Tutorials for Python (DOcplex)
2 |
3 | Welcome to the IBM® Decision Optimization Tutorials.
4 | Licensed under the Apache License v2.0.
5 |
6 | With these tutorials, you will learn the concepts of Mathematical Optimization.
7 |
8 | This library is composed of 2 Jupyter notebooks:
9 |
10 | * Linear Programming discovery
11 | * Beyond Linear Programming
12 |
13 | These notebooks are part of **[Prescriptive Analytics for Python](http://ibmdecisionoptimization.github.io/docplex-doc/)**
14 |
15 | They require either an [installation of CPLEX Optimizers](http://ibmdecisionoptimization.github.io/docplex-doc/getting_started.html) or they can be run on [IBM Cloud Pak for Data as a Service](https://www.ibm.com/products/cloud-pak-for-data/as-a-service/) (Sign up for a [free IBM Cloud account](https://dataplatform.cloud.ibm.com/registration/stepone?context=wdp&apps=all>)
16 | and you can start using `IBM Cloud Pak for Data as a Service` right away).
17 |
18 | CPLEX is available on IBM Cloud Pack for Data and IBM Cloud Pak for Data as a Service:
19 | - IBM Cloud Pak for Data as a Service: Depends on the runtime used:
20 | - Python 3.x runtime: Community edition
21 | - Python 3.x + DO runtime: full edition
22 | - Cloud Pack for Data: Community edition is installed by default. Please install the `DO` addon in `Watson Studio Premium` for the full edition
23 |
24 | Additionnaly, you can download [installation of CPLEX Optimizers](http://ibmdecisionoptimization.github.io/docplex-doc/getting_started.html):
25 |
26 | - You can get a free [Community Edition](http://www-01.ibm.com/software/websphere/products/optimization/cplex-studio-community-edition)
27 | of CPLEX Optimization Studio, with limited solving capabilities in term of problem size.
28 |
29 | - Faculty members, research professionals at accredited institutions can get access to an unlimited version of CPLEX through the
30 | [IBM® Academic Initiative](http://www-304.ibm.com/ibm/university/academic/pub/page/ban_ilog_programming).
31 |
32 |
33 | ## License
34 |
35 | This library is delivered under the Apache License Version 2.0, January 2004 (see LICENSE.txt).
36 |
--------------------------------------------------------------------------------
/jupyter/Linear_Programming.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "markdown",
5 | "metadata": {},
6 | "source": [
7 | "# Tutorial: Linear Programming, (CPLEX Part 1)\n",
8 | "\n",
9 | "\n",
10 | "This notebook gives an overview of Linear Programming (or LP). After completing this unit, you should be able to \n",
11 | "- describe the characteristics of an LP in terms of the objective, decision variables and constraints, \n",
12 | "- formulate a simple LP model on paper, \n",
13 | "- conceptually explain some standard terms related to LP, such as dual, feasible region, infeasible, unbounded, slack, reduced cost, and degenerate. \n",
14 | " \n",
15 | "You should also be able to describe some of the algorithms used to solve LPs, explain what presolve does, and recognize the elements of an LP in a basic DOcplex model.\n",
16 | "\n",
17 | "\n",
18 | ">This notebook is part of **[Prescriptive Analytics for Python](http://ibmdecisionoptimization.github.io/docplex-doc/)**\n",
19 | ">\n",
20 | ">It requires either an [installation of CPLEX Optimizers](http://ibmdecisionoptimization.github.io/docplex-doc/getting_started.html) or it can be run on [IBM Cloud Pak for Data as a Service](https://www.ibm.com/products/cloud-pak-for-data/as-a-service/) (Sign up for a [free IBM Cloud account](https://dataplatform.cloud.ibm.com/registration/stepone?context=wdp&apps=all>)\n",
21 | "and you can start using `IBM Cloud Pak for Data as a Service` right away).\n",
22 | ">\n",
23 | "> CPLEX is available on IBM Cloud Pack for Data and IBM Cloud Pak for Data as a Service:\n",
24 | "> - IBM Cloud Pak for Data as a Service: Depends on the runtime used:\n",
25 | "> - Python 3.x runtime: Community edition\n",
26 | "> - Python 3.x + DO runtime: full edition\n",
27 | "> - Cloud Pack for Data: Community edition is installed by default. Please install the `DO` addon in `Watson Studio Premium` for the full edition\n",
28 | "\n",
29 | "\n",
30 | "\n",
31 | "Table of contents:\n",
32 | "\n",
33 | "* [Introduction to Linear Programming](#Introduction-to-Linear-Programming)\n",
34 | "* [Example: a production problem](#Example:-a-production-problem)\n",
35 | "* [CPLEX Modeling for Python](#Use-IBM-Decision-Optimization-CPLEX-Modeling-for-Python)\n",
36 | "* [Algorithms for solving LPs](#Algorithms-for-solving-LPs)\n",
37 | "* [Summary](#Summary)\n",
38 | "* [References](#References)"
39 | ]
40 | },
41 | {
42 | "cell_type": "markdown",
43 | "metadata": {},
44 | "source": [
45 | "# Introduction to Linear Programming\n",
46 | "\n",
47 | "In this topic, you’ll learn what the basic characteristics of a linear program are."
48 | ]
49 | },
50 | {
51 | "cell_type": "markdown",
52 | "metadata": {},
53 | "source": [
54 | "## What is Linear Programming?\n",
55 | "\n",
56 | "Linear programming deals with the maximization (or minimization) of a linear objective function, subject to linear constraints, where all the decision variables are continuous. That is, no discrete variables are allowed. The linear objective and constraints must consist of linear expressions. \n",
57 | "\n",
58 | "## What is a linear expression?\n",
59 | "\n",
60 | "A linear expression is a scalar product, for example, the expression:\n",
61 | "\n",
62 | "$$\n",
63 | "\\sum{a_i x_i}\n",
64 | "$$\n",
65 | "where a_i represents constants (that is, data) and x_i represents variables or unknowns.\n",
66 | "\n",
67 | "Such an expression can also be written in short form as a vector product:\n",
68 | "\n",
69 | "$$^{t}A X\n",
70 | "$$\n",
71 | "\n",
72 | "where $A$ is the vector of constants and $X$ is the vector of variables.\n",
73 | "\n",
74 | "*Note*: Nonlinear terms that involve variables (such as x and y) are not allowed in linear expressions. \n",
75 | "Terms that are not allowed in linear expressions include \n",
76 | "- multiplication of two or more variables (such as x times y), \n",
77 | "- quadratic and higher order terms (such as x squared or x cubed), \n",
78 | "- exponents, \n",
79 | "- logarithms,\n",
80 | "- absolute values.\n"
81 | ]
82 | },
83 | {
84 | "cell_type": "markdown",
85 | "metadata": {},
86 | "source": [
87 | "## What is a linear constraint?\n",
88 | "\n",
89 | "A linear constraint is expressed by an equality or inequality as follows:\n",
90 | "- $linear\\_expression = linear\\_expression$\n",
91 | "- $linear\\_expression \\le linear\\_expression$\n",
92 | "- $linear\\_expression \\ge linear\\_expression$\n",
93 | "\n",
94 | "Any linear constraint can be rewritten as one or two expressions of the type linear expression is less than or equal to zero.\n",
95 | "\n",
96 | "Note that *strict* inequality operators (that is, $>$ and $<$) are not allowed in linear constraints. \n"
97 | ]
98 | },
99 | {
100 | "cell_type": "markdown",
101 | "metadata": {},
102 | "source": [
103 | "## What is a continuous variable?\n",
104 | "\n",
105 | "A variable (or _decision_ variable) is an unknown of the problem. Continuous variables are variables the set of real numbers (or an interval). \n",
106 | "\n",
107 | "Restrictions on their values that create discontinuities, for example a restriction that a variable should take integer values, are not allowed. "
108 | ]
109 | },
110 | {
111 | "cell_type": "markdown",
112 | "metadata": {},
113 | "source": [
114 | "## Symbolic representation of an LP\n",
115 | "\n",
116 | "A typical symbolic representation of a Linear Programming is as follows:\n",
117 | "\n",
118 | "$\n",
119 | "minimize \\sum c_{i} x_{i}\\\\\n",
120 | "\\\\\n",
121 | "subject\\ to:\\\\\n",
122 | "\\ a_{11}x_{1} + a_{12} x_{2} ... + a_{1n} x_{n} \\ge b_{1}\\\\\n",
123 | "\\ a_{21}x_{1} + a_{22} x_{2} ... + a_{2n} x_{n} \\ge b_{2}\\\\\n",
124 | "...\n",
125 | "\\ a_{m1}x_{1} + a_{m2} x_{2} ... + a_{mn} x_{n} \\ge b_{m}\\\\\n",
126 | "x_{1}, x_{2}...x_{n} \\ge 0\n",
127 | "$\n",
128 | "\n",
129 | "This can be written in a concise form using matrices and vectors as:\n",
130 | "\n",
131 | "$\n",
132 | "min\\ C^{t}x\\\\\n",
133 | "s.\\ t.\\ Ax \\ge B\\\\\n",
134 | "x \\ge 0\n",
135 | "$\n",
136 | "\n",
137 | "Where $x$ denotes the vector of variables with size $n$, $A$ denotes the matrix of constraint coefficients, with $m$ rows and $n$ columns and $B$ is a vector of numbers with size $m$.\n"
138 | ]
139 | },
140 | {
141 | "cell_type": "markdown",
142 | "metadata": {},
143 | "source": [
144 | "## Characteristics of a linear program\n",
145 | "
\n",
146 | "
\n",
147 | "
\n",
148 | "
"
149 | ]
150 | },
151 | {
152 | "cell_type": "markdown",
153 | "metadata": {},
154 | "source": [
155 | "# Example: a production problem\n",
156 | "\n",
157 | "In this topic, you’ll analyze a simple production problem in terms of decision variables, the objective function, and constraints. \n",
158 | "You’ll learn how to write an LP formulation of this problem, and how to construct a graphical representation of the model. You’ll also learn what feasible, optimal, infeasible, and unbounded mean in the context of LP.\n",
159 | "\n",
160 | "## Problem description: telephone production\n",
161 | "\n",
162 | "A telephone company produces and sells two kinds of telephones, namely desk phones and cellular phones. \n",
163 | "\n",
164 | "Each type of phone is assembled and painted by the company. The objective is to maximize profit, and the company has to produce at least 100 of each type of phone.\n",
165 | "\n",
166 | "There are limits in terms of the company’s production capacity, and the company has to calculate the optimal number of each type of phone to produce, while not exceeding the capacity of the plant.\n",
167 | "\n",
168 | "## Writing a descriptive model\n",
169 | "\n",
170 | "It is good practice to start with a descriptive model before attempting to write a mathematical model. In order to come up with a descriptive model, you should consider what the decision variables, objectives, and constraints for the business problem are, and write these down in words.\n",
171 | "\n",
172 | "\n",
173 | "In order to come up with a descriptive model, consider the following questions:\n",
174 | "- What are the decision variables? \n",
175 | "- What is the objective? \n",
176 | "- What are the constraints? \n",
177 | "\n"
178 | ]
179 | },
180 | {
181 | "cell_type": "markdown",
182 | "metadata": {},
183 | "source": [
184 | "## Telephone production: a descriptive model\n",
185 | "\n",
186 | "A possible descriptive model of the telephone production problem is as follows:\n",
187 | "- Decision variables:\n",
188 | " - Number of desk phones produced (DeskProduction)\n",
189 | " - Number of cellular phones produced (CellProduction)\n",
190 | "- Objective: Maximize profit\n",
191 | "- Constraints:\n",
192 | " 1. The DeskProduction should be greater than or equal to 100.\n",
193 | " 2. The CellProduction should be greater than or equal to 100.\n",
194 | " 3. The assembly time for DeskProduction plus the assembly time for CellProduction should not exceed 400 hours.\n",
195 | " 4. The painting time for DeskProduction plus the painting time for CellProduction should not exceed 490 hours.\n"
196 | ]
197 | },
198 | {
199 | "cell_type": "markdown",
200 | "metadata": {},
201 | "source": [
202 | "## Writing a mathematical model\n",
203 | "\n",
204 | "Convert the descriptive model into a mathematical model:\n",
205 | "- Use the two decision variables DeskProduction and CellProduction\n",
206 | "- Use the data given in the problem description (remember to convert minutes to hours where appropriate)\n",
207 | "- Write the objective as a mathematical expression\n",
208 | "- Write the constraints as mathematical expressions (use “=”, “<=”, or “>=”, and name the constraints to describe their purpose)\n",
209 | "- Define the domain for the decision variables\n",
210 | "\n",
211 | "### Telephone production: a mathematical model\n",
212 | "\n",
213 | "To express the last two constraints, we model assembly time and painting time as linear combinations of the two productions, resulting in the following mathematical model:\n",
214 | "\n",
215 | "$\n",
216 | "maximize:\\\\\n",
217 | "\\ \\ 12\\ desk\\_production + 20\\ cell\\_production\\\\\n",
218 | "subject\\ to: \\\\\n",
219 | "\\ \\ desk\\_production >= 100 \\\\\n",
220 | "\\ \\ cell\\_production >= 100 \\\\\n",
221 | "\\ \\ 0.2\\ desk\\_production + 0.4\\ cell\\_production <= 400 \\\\\n",
222 | "\\ \\ 0.5\\ desk\\_production + 0.4\\ cell\\_production <= 490 \\\\\n",
223 | "$\n",
224 | "\n",
225 | "### Using DOcplex to formulate the mathematical model in Python\n",
226 | "\n",
227 | "Use the [DOcplex](http://ibmdecisionoptimization.github.io/docplex-doc/) Python library to write the mathematical model in Python.\n",
228 | "This is done in four steps:\n",
229 | "\n",
230 | "- create a instance of docplex.mp.Model to hold all model objects\n",
231 | "- create decision variables,\n",
232 | "- create linear constraints,\n",
233 | "- finally, define the objective.\n",
234 | "\n",
235 | "But first, we have to import the class `Model` from the docplex module."
236 | ]
237 | },
238 | {
239 | "cell_type": "markdown",
240 | "metadata": {},
241 | "source": [
242 | "## Use IBM Decision Optimization CPLEX Modeling for Python\n",
243 | "\n",
244 | "Let's use the DOcplex Python library to write the mathematical model in Python."
245 | ]
246 | },
247 | {
248 | "cell_type": "markdown",
249 | "metadata": {},
250 | "source": [
251 | "### Step 1: Download the library\n",
252 | "\n",
253 | "Install `CPLEX` (Community Edition) and `docplex` if they are not installed.\n",
254 | "\n",
255 | "In `IBM Cloud Pak for Data as a Service` notebooks, `CPLEX` and `docplex` are preinstalled."
256 | ]
257 | },
258 | {
259 | "cell_type": "code",
260 | "execution_count": 1,
261 | "metadata": {},
262 | "outputs": [],
263 | "source": [
264 | "import sys\n",
265 | "try:\n",
266 | " import cplex\n",
267 | "except:\n",
268 | " if hasattr(sys, 'real_prefix'):\n",
269 | " #we are in a virtual env.\n",
270 | " !pip install cplex\n",
271 | " else:\n",
272 | " !pip install --user cplex"
273 | ]
274 | },
275 | {
276 | "cell_type": "markdown",
277 | "metadata": {},
278 | "source": [
279 | "Installs `DOcplex`if needed"
280 | ]
281 | },
282 | {
283 | "cell_type": "code",
284 | "execution_count": 2,
285 | "metadata": {},
286 | "outputs": [],
287 | "source": [
288 | "import sys\n",
289 | "try:\n",
290 | " import docplex.mp\n",
291 | "except:\n",
292 | " if hasattr(sys, 'real_prefix'):\n",
293 | " #we are in a virtual env.\n",
294 | " !pip install docplex\n",
295 | " else:\n",
296 | " !pip install --user docplex"
297 | ]
298 | },
299 | {
300 | "cell_type": "markdown",
301 | "metadata": {},
302 | "source": [
303 | "If either `CPLEX` or `docplex` where installed in the steps above, you will need to restart your jupyter kernel for the changes to be taken into account."
304 | ]
305 | },
306 | {
307 | "cell_type": "markdown",
308 | "metadata": {},
309 | "source": [
310 | "### Step 2: Set up the prescriptive model\n",
311 | "#### Create the model\n",
312 | "\n",
313 | "All objects of the model belong to one model instance."
314 | ]
315 | },
316 | {
317 | "cell_type": "code",
318 | "execution_count": 3,
319 | "metadata": {},
320 | "outputs": [],
321 | "source": [
322 | "# first import the Model class from docplex.mp\n",
323 | "from docplex.mp.model import Model\n",
324 | "\n",
325 | "# create one model instance, with a name\n",
326 | "m = Model(name='telephone_production')"
327 | ]
328 | },
329 | {
330 | "cell_type": "markdown",
331 | "metadata": {},
332 | "source": [
333 | "#### Define the decision variables\n",
334 | "- The continuous variable `desk` represents the production of desk telephones.\n",
335 | "- The continuous variable `cell` represents the production of cell phones."
336 | ]
337 | },
338 | {
339 | "cell_type": "code",
340 | "execution_count": 4,
341 | "metadata": {},
342 | "outputs": [],
343 | "source": [
344 | "# by default, all variables in Docplex have a lower bound of 0 and infinite upper bound\n",
345 | "desk = m.continuous_var(name='desk')\n",
346 | "cell = m.continuous_var(name='cell')"
347 | ]
348 | },
349 | {
350 | "cell_type": "markdown",
351 | "metadata": {},
352 | "source": [
353 | "#### Set up the constraints\n",
354 | "- Desk and cell phone must both be greater than 100\n",
355 | "- Assembly time is limited\n",
356 | "- Painting time is limited."
357 | ]
358 | },
359 | {
360 | "cell_type": "code",
361 | "execution_count": 5,
362 | "metadata": {},
363 | "outputs": [],
364 | "source": [
365 | "# write constraints\n",
366 | "# constraint #1: desk production is greater than 100\n",
367 | "m.add_constraint(desk >= 100)\n",
368 | "\n",
369 | "# constraint #2: cell production is greater than 100\n",
370 | "m.add_constraint(cell >= 100)\n",
371 | "\n",
372 | "# constraint #3: assembly time limit\n",
373 | "ct_assembly = m.add_constraint( 0.2 * desk + 0.4 * cell <= 400)\n",
374 | "\n",
375 | "# constraint #4: paiting time limit\n",
376 | "ct_painting = m.add_constraint( 0.5 * desk + 0.4 * cell <= 490)"
377 | ]
378 | },
379 | {
380 | "cell_type": "markdown",
381 | "metadata": {},
382 | "source": [
383 | "#### Express the objective\n",
384 | "\n",
385 | "We want to maximize the expected revenue."
386 | ]
387 | },
388 | {
389 | "cell_type": "code",
390 | "execution_count": 6,
391 | "metadata": {},
392 | "outputs": [],
393 | "source": [
394 | "m.maximize(12 * desk + 20 * cell)"
395 | ]
396 | },
397 | {
398 | "cell_type": "markdown",
399 | "metadata": {},
400 | "source": [
401 | "A few remarks about how we formulated the mathemtical model in Python using DOcplex:\n",
402 | "- all arithmetic operations (+, \\*, \\-) are done using Python operators\n",
403 | "- comparison operators used in writing linear constraint use Python comparison operators too.\n",
404 | "\n",
405 | "#### Print information about the model\n",
406 | "\n",
407 | "We can print information about the model to see how many objects of each type it holds:"
408 | ]
409 | },
410 | {
411 | "cell_type": "code",
412 | "execution_count": 7,
413 | "metadata": {},
414 | "outputs": [
415 | {
416 | "name": "stdout",
417 | "output_type": "stream",
418 | "text": [
419 | "Model: telephone_production\n",
420 | " - number of variables: 2\n",
421 | " - binary=0, integer=0, continuous=2\n",
422 | " - number of constraints: 4\n",
423 | " - linear=4\n",
424 | " - parameters: defaults\n",
425 | " - objective: maximize\n",
426 | " - problem type is: LP\n"
427 | ]
428 | }
429 | ],
430 | "source": [
431 | "m.print_information()"
432 | ]
433 | },
434 | {
435 | "cell_type": "markdown",
436 | "metadata": {},
437 | "source": [
438 | "### Graphical representation of a Linear Problem\n",
439 | "\n",
440 | "A simple 2-dimensional LP (with 2 decision variables) can be represented graphically using a x- and y-axis. \n",
441 | "\n",
442 | "This is often done to demonstrate optimization concepts. \n",
443 | "\n",
444 | "To do this, follow these steps:\n",
445 | "- Assign one variable to the x-axis and the other to the y-axis.\n",
446 | "- Draw each of the constraints as you would draw any line in 2 dimensions.\n",
447 | "- Use the signs of the constraints (=, <= or >=) to determine which side of each line falls within the feasible region (allowable solutions).\n",
448 | "- Draw the objective function as you would draw any line in 2 dimensions, by substituting any value for the objective (for example, 12 * DeskProduction + 20 * CellProduction = 4000) \n"
449 | ]
450 | },
451 | {
452 | "cell_type": "markdown",
453 | "metadata": {},
454 | "source": [
455 | "#### Feasible set of solutions\n",
456 | "\n",
457 | "\n",
458 | "
\n",
459 | "
\n",
460 | "
\n",
461 | "\n",
462 | "This graphic shows the feasible region for the telephone problem. \n",
463 | "Recall that the feasible region of an LP is the region delimited by the constraints, and it represents all feasible solutions. In this graphic, the variables DeskProduction and CellProduction are abbreviated to be desk and cell instead. Look at this diagram and search intuitively for the optimal solution. That is, which combination of desk and cell phones will yield the highest profit. \n"
464 | ]
465 | },
466 | {
467 | "cell_type": "markdown",
468 | "metadata": {},
469 | "source": [
470 | "#### The optimal solution\n",
471 | "\n",
472 | "\n",
473 | "
\n",
474 | "
\n",
475 | "
\n",
476 | "\n",
477 | " To find the optimal solution to the LP, you must find values for the decision variables, within the feasible region, that maximize profit as defined by the objective function. In this problem, the objective function is to maximize \n",
478 | " $$12 * desk + 20 * cell\n",
479 | " $$\n",
480 | "\n",
481 | "To do this, first draw a line representing the objective by substituting a value for the objective. \n",
482 | "\n",
483 | "Next move the line up (because this is a maximization problem) to find the point where the line last touches the feasible region. Note that all the solutions on one objective line, such as AB, yield the same objective value. Other values of the objective will be found along parallel lines (such as line CD). \n",
484 | "\n",
485 | "In a profit maximizing problem such as this one, these parallel lines are often called isoprofit lines, because all the points along such a line represent the same profit. In a cost minimization problem, they are known as isocost lines. Since all isoprofit lines have the same slope, you can find all other isoprofit lines by pushing the objective value further out, moving in parallel, until the isoprofit lines no longer intersect the feasible region. The last isoprofit line that touches the feasible region defines the largest (therefore maximum) possible value of the objective function. In the case of the telephone production problem, this is found along line EF. \n",
486 | "\n",
487 | "The optimal solution of a linear program always belongs to an extreme point of the feasible region (that is, at a vertex or an edge).\n"
488 | ]
489 | },
490 | {
491 | "cell_type": "markdown",
492 | "metadata": {},
493 | "source": [
494 | "### Solve with the model\n",
495 | "\n",
496 | "If you're using a Community Edition of CPLEX runtimes, depending on the size of the problem, the solve stage may fail and will need a paying subscription or product installation. \n",
497 | "\n",
498 | "In any case, `Model.solve()` returns a solution object in Python, containing the optimal values of decision variables, if the solve succeeds, or else it returns `None`."
499 | ]
500 | },
501 | {
502 | "cell_type": "code",
503 | "execution_count": 8,
504 | "metadata": {},
505 | "outputs": [
506 | {
507 | "name": "stdout",
508 | "output_type": "stream",
509 | "text": [
510 | "objective: 20600.000\n",
511 | " desk=300.000\n",
512 | " cell=850.000\n"
513 | ]
514 | }
515 | ],
516 | "source": [
517 | "s = m.solve()\n",
518 | "m.print_solution()"
519 | ]
520 | },
521 | {
522 | "cell_type": "markdown",
523 | "metadata": {},
524 | "source": [
525 | "In this case, CPLEX has found an optimal solution at (300, 850). You can check that this point is indeed an extreme point of the feasible region."
526 | ]
527 | },
528 | {
529 | "cell_type": "markdown",
530 | "metadata": {},
531 | "source": [
532 | "### Multiple Optimal Solutions\n",
533 | "\n",
534 | "It is possible that an LP has multiple optimal solutions. \n",
535 | "At least one optimal solution will be at a vertex.\n",
536 | "By default, the CPLEX® Optimizer reports the first optimal solution found. \n"
537 | ]
538 | },
539 | {
540 | "cell_type": "markdown",
541 | "metadata": {},
542 | "source": [
543 | "#### Example of multiple optimal solutions\n",
544 | "\n",
545 | "\n",
546 | "
\n",
547 | "
\n",
548 | "
\n",
549 | "\n",
550 | "This graphic shows an example of an LP with multiple optimal solutions. This can happen when the slope of the objective function is the same as the slope of one of the constraints, in this case line AB. All the points on line AB are optimal solutions, with the same objective value, because they are all extreme points within the feasible region.\n"
551 | ]
552 | },
553 | {
554 | "cell_type": "markdown",
555 | "metadata": {},
556 | "source": [
557 | "### Binding and nonbinding constraints\n",
558 | "\n",
559 | "A constraint is binding if the constraint becomes an equality when the solution values are substituted.\n",
560 | "\n",
561 | "Graphically, binding constraints are constraints where the optimal solution lies exactly on the line representing that constraint. \n",
562 | "\n",
563 | "In the telephone production problem, the constraint limiting time on the assembly machine is binding:\n",
564 | "\n",
565 | "$$\n",
566 | "\t0.2desk + 0.4 cell <= 400\\\\\n",
567 | " desk = 300\u000b",
568 | "cell = 850\u000b",
569 | "0.2(300) + 0.4(850) = 400\n",
570 | "$$\n",
571 | "\n",
572 | "The same is true for the time limit on the painting machine:\n",
573 | "\n",
574 | "$$\n",
575 | "\t0.5desk + 0.4cell <= 490\u000b",
576 | "0.5(300) + 0.4(850) = 490 \n",
577 | "$$\n",
578 | "\n",
579 | "On the other hand, the requirement that at least 100 of each telephone type be produced is nonbinding because the left and right hand sides are not equal:\n",
580 | "\n",
581 | "$$\n",
582 | "\tdesk >= 100\\\\\n",
583 | " 300 \\neq 100\n",
584 | "$$\n",
585 | "\n"
586 | ]
587 | },
588 | {
589 | "cell_type": "markdown",
590 | "metadata": {},
591 | "source": [
592 | "### Infeasibility\n",
593 | "\n",
594 | "A model is infeasible when no solution exists that satisfies all the constraints. This may be because:\n",
595 | "The model formulation is incorrect.\n",
596 | "The data is incorrect.\n",
597 | "The model and data are correct, but represent a real-world conflict in the system being modeled.\n",
598 | "\n",
599 | "When faced with an infeasible model, it's not always easy to identify the source of the infeasibility. \n",
600 | "\n",
601 | "DOcplex helps you identify potential causes of infeasibilities, and it will also suggest changes to make the model feasible.\n",
602 | "\n",
603 | "#### An example of infeasible problem\n",
604 | "\n",
605 | "\n",
606 | "
\n",
607 | "
\n",
608 | "
\n",
609 | "\n",
610 | "This graphic shows an example of an infeasible constraint set for the telephone production problem. Assume in this case that the person entering data had accidentally entered lower bounds on the production of 1100 instead of 100. The arrows show the direction of the feasible region with respect to each constraint. This data entry error moves the lower bounds on production higher than the upper bounds from the assembly and painting constraints, meaning that the feasible region is empty and there are no possible solutions. "
611 | ]
612 | },
613 | {
614 | "cell_type": "markdown",
615 | "metadata": {},
616 | "source": [
617 | "#### Infeasible models in DOcplex\n",
618 | "\n",
619 | "Calling `solve()` on an infeasible model returns None. Let's experiment this with DOcplex. First, we take a copy of our model and an extra infeasible constraint which states that desk telephone production must be greater than 1100"
620 | ]
621 | },
622 | {
623 | "cell_type": "code",
624 | "execution_count": 9,
625 | "metadata": {},
626 | "outputs": [
627 | {
628 | "name": "stdout",
629 | "output_type": "stream",
630 | "text": [
631 | "- model is infeasible\n"
632 | ]
633 | }
634 | ],
635 | "source": [
636 | "# create a new model, copy of m\n",
637 | "im = m.copy()\n",
638 | "# get the 'desk' variable of the new model from its name\n",
639 | "idesk = im.get_var_by_name('desk')\n",
640 | "# add a new (infeasible) constraint\n",
641 | "im.add_constraint(idesk >= 1100);\n",
642 | "# solve the new proble, we expect a result of None as the model is now infeasible\n",
643 | "ims = im.solve()\n",
644 | "if ims is None:\n",
645 | " print('- model is infeasible')"
646 | ]
647 | },
648 | {
649 | "cell_type": "markdown",
650 | "metadata": {},
651 | "source": [
652 | "### Correcting infeasible models\n",
653 | "\n",
654 | "To correct an infeasible model, you must use your knowledge of the real-world situation you are modeling.\n",
655 | "If you know that the model is realizable, you can usually manually construct an example of a feasible solution and use it to determine where your model or data is incorrect. For example, the telephone production manager may input the previous month's production figures as a solution to the model and discover that they violate the erroneously entered bounds of 1100.\n",
656 | "\n",
657 | "DOcplex can help perform infeasibility analysis, which can get very complicated in large models. In this analysis, DOcplex may suggest relaxing one or more constraints. \n"
658 | ]
659 | },
660 | {
661 | "cell_type": "markdown",
662 | "metadata": {},
663 | "source": [
664 | "### Relaxing constraints by changing the model\n",
665 | "\n",
666 | "In the case of LP models, the term “relaxation” refers to changing the right hand side of the constraint to allow some violation of the original constraint.\n",
667 | "\n",
668 | "For example, a relaxation of the assembly time constraint is as follows:\n",
669 | "\n",
670 | "$$\n",
671 | "0.2 \\ desk + 0.4\\ cell <= 440\n",
672 | "$$\n",
673 | "\n",
674 | "Here, the right hand side has been relaxed from 400 to 440, meaning that you allow more time for assembly than originally planned. "
675 | ]
676 | },
677 | {
678 | "cell_type": "markdown",
679 | "metadata": {},
680 | "source": [
681 | "#### Relaxing model by converting hard constraints to soft constraints\n",
682 | "\n",
683 | "- A _soft_ constraint is a constraint that can be violated in some circumstances. \n",
684 | "\n",
685 | "- A _hard_ constraint cannot be violated under any circumstances. So far, all constraints we have encountered are hard constraints.\n",
686 | "\n",
687 | "Converting hard constraints to soft is one way to resolve infeasibilities.\n",
688 | "\n",
689 | "The original hard constraint on assembly time is as follows:\n",
690 | "\n",
691 | "$$\n",
692 | "0.2 \\ desk + 0.4 \\ cell <= 400\n",
693 | "$$\n",
694 | "\n",
695 | "You can turn this into a soft constraint if you know that, for example, an additional 40 hours of overtime are available at an additional cost. First add an overtime term to the right-hand side:\n",
696 | "\n",
697 | "$$\n",
698 | "0.2 \\ desk + 0.4 \\ cell <= 400 + overtime\n",
699 | "$$\n",
700 | "\n",
701 | "Next, add a hard limit to the amount of overtime available:\n",
702 | "\n",
703 | "$$\n",
704 | "overtime <= 40\n",
705 | "$$\n",
706 | "\n",
707 | "Finally, add an additional cost to the objective to penalize use of overtime. \n",
708 | "\n",
709 | "Assume that in this case overtime costs an additional $2/hour, then the new objective becomes:\n",
710 | "\n",
711 | "$$\n",
712 | "maximize\\ 12 * desk + 20 * cell — 2 * overtime\n",
713 | "$$\n"
714 | ]
715 | },
716 | {
717 | "cell_type": "markdown",
718 | "metadata": {},
719 | "source": [
720 | "#### Implement the soft constraint model using DOcplex\n",
721 | "\n",
722 | "First add an extra variable for overtime, with an upper bound of 40. This suffices to express the hard limit on overtime."
723 | ]
724 | },
725 | {
726 | "cell_type": "code",
727 | "execution_count": 10,
728 | "metadata": {},
729 | "outputs": [],
730 | "source": [
731 | "overtime = m.continuous_var(name='overtime', ub=40)"
732 | ]
733 | },
734 | {
735 | "cell_type": "markdown",
736 | "metadata": {},
737 | "source": [
738 | "Modify the assembly time constraint by changing its right-hand side by adding overtime. \n",
739 | "\n",
740 | "*Note*: this operation modifies the model by performing a _side-effect_ on the constraint object. DOcplex allows dynamic edition of model elements."
741 | ]
742 | },
743 | {
744 | "cell_type": "code",
745 | "execution_count": 11,
746 | "metadata": {},
747 | "outputs": [],
748 | "source": [
749 | "ct_assembly.rhs = 400 + overtime"
750 | ]
751 | },
752 | {
753 | "cell_type": "markdown",
754 | "metadata": {},
755 | "source": [
756 | "Last, modify the objective expression to add the penalization term.\n",
757 | "Note that we use the Python decrement operator."
758 | ]
759 | },
760 | {
761 | "cell_type": "code",
762 | "execution_count": 12,
763 | "metadata": {},
764 | "outputs": [],
765 | "source": [
766 | "m.maximize(12*desk + 20 * cell - 2 * overtime)"
767 | ]
768 | },
769 | {
770 | "cell_type": "markdown",
771 | "metadata": {},
772 | "source": [
773 | "And solve again using DOcplex:"
774 | ]
775 | },
776 | {
777 | "cell_type": "code",
778 | "execution_count": 13,
779 | "metadata": {},
780 | "outputs": [
781 | {
782 | "name": "stdout",
783 | "output_type": "stream",
784 | "text": [
785 | "objective: 22253.333\n",
786 | " desk=166.667\n",
787 | " cell=1016.667\n",
788 | " overtime=40.000\n"
789 | ]
790 | }
791 | ],
792 | "source": [
793 | "s2 = m.solve()\n",
794 | "m.print_solution()"
795 | ]
796 | },
797 | {
798 | "cell_type": "markdown",
799 | "metadata": {},
800 | "source": [
801 | "### Unbounded Variable vs. Unbounded model\n",
802 | "\n",
803 | "A variable is unbounded when one or both of its bounds is infinite. \n",
804 | "\n",
805 | "A model is unbounded when its objective value can be increased or decreased without limit. \n",
806 | "\n",
807 | "The fact that a variable is unbounded does not necessarily influence the solvability of the model and should not be confused with a model being unbounded. \n",
808 | "\n",
809 | "An unbounded model is almost certainly not correctly formulated. \n",
810 | "\n",
811 | "While infeasibility implies a model where constraints are too limiting, unboundedness implies a model where an important constraint is either missing or not restrictive enough.\n",
812 | "\n",
813 | "By default, DOcplex variables are unbounded: their upper bound is infinite (but their lower bound is zero)."
814 | ]
815 | },
816 | {
817 | "cell_type": "markdown",
818 | "metadata": {},
819 | "source": [
820 | "#### Unbounded feasible region\n",
821 | "\n",
822 | "The telephone production problem would become unbounded if, for example, the constraints on the assembly and painting time were neglected. The feasible region would then look as in this diagram where the objective value can increase without limit, up to infinity, because there is no upper boundary to the region. \n",
823 | "\n",
824 | "\n",
825 | "
\n",
826 | "
\n",
827 | "
\n"
828 | ]
829 | },
830 | {
831 | "cell_type": "markdown",
832 | "metadata": {},
833 | "source": [
834 | "## Algorithms for solving LPs\n",
835 | "\n",
836 | "The IBM® CPLEX® Optimizers to solve LP problems in CPLEX include:\n",
837 | "- Simplex Optimizer\n",
838 | "- Dual-simplex Optimizer\n",
839 | "- Barrier Optimizer\n",
840 | "\n",
841 | "### The Simplex algorithm\n",
842 | "\n",
843 | "The Simplex algorithm, developed by George Dantzig in 1947, was the first generalized algorithm for solving LP problems. It is the basis of many optimization algorithms. The simplex method is an iterative method. It starts with an initial feasible solution, and then tests to see if it can improve the result of the objective function. It continues until the objective function cannot be further improved.\n",
844 | "\n",
845 | "The following diagram illustrates how the simplex algorithm traverses the boundary of the feasible region for the telephone production problem. The algorithm, starts somewhere along the edge of the shaded feasible region, and advances vertex-by-vertex until arriving at the vertex that also intersects the optimal objective line. Assume it starts at the red dot indicated on the diagam.\n",
846 | "\n",
847 | "\n",
848 | "
\n",
849 | "
\n",
850 | "
\n",
851 | "\n",
852 | "\n",
853 | "
\n",
854 | "
\n",
855 | "
\n",
856 | "\n",
857 | "\n",
858 | "
\n",
859 | "
\n",
860 | "
\n",
861 | "\n",
862 | "\n",
863 | "
\n",
864 | "
\n",
865 | "
\n",
866 | "\n",
867 | "\n",
868 | "\n",
869 | "### The Revised Simplex algorithm\n",
870 | "\n",
871 | "To improve the efficiency of the Simplex algorithm, George Dantzig and W. Orchard-Hays revised it in 1953. CPLEX uses the Revised Simplex algorithm, with a number of improvements. The CPLEX Optimizers are particularly efficient and can solve very large problems rapidly. You can tune some CPLEX Optimizer parameters to change the algorithmic behavior according to your needs. \n"
872 | ]
873 | },
874 | {
875 | "cell_type": "markdown",
876 | "metadata": {},
877 | "source": [
878 | "### The Dual Simplex algorithm\n",
879 | "\n",
880 | "#### The dual of a LP\n",
881 | "\n",
882 | "The concept of duality is important in Linear Programming (LP). Every LP problem has an associated LP problem known as its _dual_. The dual of this associated problem is the original LP problem (known as the primal problem). If the primal problem is a minimization problem, then the dual problem is a maximization problem and vice versa.\n",
883 | "\n",
884 | "#### A primal-dual pair\n",
885 | "\n",
886 | "\n",
887 | "
\n",
888 | "
\n",
889 | "
\n",
890 | "\n",
891 | "\n",
892 | "*Primal (P)* \n",
893 | "-------------------- \n",
894 | "\n",
895 | " $max\\ z=\\sum_{i} c_{i}x_{i}$ \n",
896 | " \n",
897 | "*Dual (D)*\n",
898 | "-------------------------------\n",
899 | " $min\\ w= \\sum_{j}b_{j}y_{j}$ \n",
900 | " \n",
901 | "\n",
902 | "- Each constraint in the primal has an associated dual variable, yi.\n",
903 | "- Any feasible solution to D is an upper bound to P, and any feasible solution to P is a lower bound to D.\n",
904 | "- In LP, the optimal objective values of D and P are equivalent, and occurs where these bounds meet.\n",
905 | "- The dual can help solve difficult primal problems by providing a bound that in the best case equals the optimal solution to the primal problem.\n",
906 | "\n",
907 | "#### Dual prices\n",
908 | "\n",
909 | "In any solution to the dual, the values of the dual variables are known as the dual prices, also called shadow prices.\n",
910 | "\n",
911 | "For each constraint in the primal problem, its associated dual price indicates how much the dual objective will change with a unit change in the right hand side of the constraint.\n",
912 | "\n",
913 | "The dual price of a non-binding constraint is zero. That is, changing the right hand side of the constraint will not affect the objective value.\n",
914 | "\n",
915 | "The dual price of a binding constraint can help you make decisions regarding the constraint.\n",
916 | "\n",
917 | "For example, the dual price of a binding resource constraint can be used to determine whether more of the resource should be purchased or not.\n",
918 | "\n",
919 | "#### The Dual Simplex algorithm\n",
920 | "\n",
921 | "The Simplex algorithm works by finding a feasible solution and moving progressively toward optimality. \n",
922 | "\n",
923 | "The Dual Simplex algorithm implicitly uses the dual to try and find an optimal solution to the primal as early as it can, and regardless of whether the solution is feasible or not. \n",
924 | "\n",
925 | "It then moves from one vertex to another, gradually decreasing the infeasibility while maintaining optimality, until an optimal feasible solution to the primal problem is found. \n",
926 | "\n",
927 | "In CPLEX, the Dual-Simplex Optimizer is the first choice for most LP problems.\n"
928 | ]
929 | },
930 | {
931 | "cell_type": "markdown",
932 | "metadata": {
933 | "collapsed": true
934 | },
935 | "source": [
936 | "### Basic solutions and basic variables\n",
937 | "\n",
938 | "You learned earlier that the Simplex algorithm travels from vertex to vertex to search for the optimal solution. \n",
939 | "A solution at a vertex is known as a _basic_ solution. Without getting into too much detail, it's worth knowing that part of the Simplex algorithm involves setting a subset of variables to zero at each iteration. \n",
940 | "These variables are known as non-basic variables. The remaining variables are the _basic_ variables. The concepts of basic solutions and variables are relevant in the definition of reduced costs that follows next. \n"
941 | ]
942 | },
943 | {
944 | "cell_type": "markdown",
945 | "metadata": {},
946 | "source": [
947 | "### Reduced Costs\n",
948 | "\n",
949 | "The reduced cost of a variable gives an indication of the amount the objective will change with a unit increase in the variable value.\n",
950 | "\n",
951 | "Consider the simplest form of an LP:\n",
952 | "\n",
953 | "$\n",
954 | "minimize\\ c^{t}x\\\\\n",
955 | "s.t. \\\\\n",
956 | "Ax = b \\\\\n",
957 | "x \\ge 0\n",
958 | "$\n",
959 | "\n",
960 | "If $y$ represents the dual variables for a given basic solution, then the reduced costs are defined as: \n",
961 | "\n",
962 | "$$\n",
963 | "c - y^{t}A\n",
964 | "$$\n",
965 | "\n",
966 | "Such a basic solution is optimal if: \n",
967 | "\n",
968 | "$$\n",
969 | " c - y^{t}A \\ge 0\n",
970 | "$$\n",
971 | "\n",
972 | "If all reduced costs for this LP are non-negative, it follows that the objective value can only increase with a change in the variable value, and therefore the solution (when minimizing) is optimal.\n",
973 | "\n",
974 | "DOcplex lets you acces sreduced costs of variable, after a successful solve. Let's experiment with the two decision variables of our problem:"
975 | ]
976 | },
977 | {
978 | "cell_type": "markdown",
979 | "metadata": {},
980 | "source": [
981 | "#### Getting reduced cost values with DOcplex\n",
982 | "\n",
983 | "DOcplex lets you access reduced costs of variable, after a successful solve. Let's experiment with the two decision variables of our problem:"
984 | ]
985 | },
986 | {
987 | "cell_type": "code",
988 | "execution_count": 14,
989 | "metadata": {},
990 | "outputs": [
991 | {
992 | "name": "stdout",
993 | "output_type": "stream",
994 | "text": [
995 | "* desk variable has reduced cost: 0\n",
996 | "* cell variable has reduced cost: 0\n"
997 | ]
998 | }
999 | ],
1000 | "source": [
1001 | "print('* desk variable has reduced cost: {0}'.format(desk.reduced_cost))\n",
1002 | "print('* cell variable has reduced cost: {0}'.format(cell.reduced_cost))"
1003 | ]
1004 | },
1005 | {
1006 | "cell_type": "markdown",
1007 | "metadata": {},
1008 | "source": [
1009 | "### Default optimality criteria for CPLEX optimizer\n",
1010 | "\n",
1011 | "Because CPLEX Optimizer operates on finite precision computers, it uses an optimality tolerance to test the reduced costs. \n",
1012 | "\n",
1013 | "The default optimality tolerance is –1e-6, with optimality criteria for the simplest form of an LP then being:\n",
1014 | "\n",
1015 | "$$\n",
1016 | "c — y^{t}A> –10^{-6}\n",
1017 | "$$\n",
1018 | "\n",
1019 | "You can adjust this optimality tolerance, for example if the algorithm takes very long to converge and has already achieved a solution sufficiently close to optimality.\n"
1020 | ]
1021 | },
1022 | {
1023 | "cell_type": "markdown",
1024 | "metadata": {},
1025 | "source": [
1026 | "### Reduced Costs and multiple optimal solutions\n",
1027 | "\n",
1028 | "In the earlier example you saw how one can visualize multiple optimal solutions for an LP with two variables. \n",
1029 | "For larger LPs, the reduced costs can be used to determine whether multiple optimal solutions exist. Multiple optimal solutions exist when one or more non-basic variables with a zero reduced cost exist in an optimal solution (that is, variable values that can change without affecting the objective value). \n",
1030 | "In order to determine whether multiple optimal solutions exist, you can examine the values of the reduced costs with DOcplex. "
1031 | ]
1032 | },
1033 | {
1034 | "cell_type": "markdown",
1035 | "metadata": {},
1036 | "source": [
1037 | "### Slack values\n",
1038 | "\n",
1039 | "For any solution, the difference between the left and right hand sides of a constraint is known as the _slack_ value for that constraint. \n",
1040 | "\n",
1041 | "For example, if a constraint states that f(x) <= 100, and in the solution f(x) = 80, then the slack value of this constraint is 20.\n",
1042 | "\n",
1043 | "In the earlier example, you learned about binding and non-binding constraints. For example, f(x) <= 100 is binding if f(x) = 100, and non-binding if f(x) = 80.\n",
1044 | "\n",
1045 | "The slack value for a binding constraint is always zero, that is, the constraint is met exactly.\n",
1046 | "\n",
1047 | "You can determine which constraints are binding in a solution by examining the slack values with DOcplex. \n",
1048 | "\n",
1049 | "This might help to better interpret the solution and help suggest which constraints may benefit from a change in bounds or a change into a soft constraint.\n"
1050 | ]
1051 | },
1052 | {
1053 | "cell_type": "markdown",
1054 | "metadata": {},
1055 | "source": [
1056 | "#### Accessing slack values with DOcplex\n",
1057 | "\n",
1058 | "As an example, let's examine the slack values of some constraints in our problem, after we revert the change to soft constrants"
1059 | ]
1060 | },
1061 | {
1062 | "cell_type": "code",
1063 | "execution_count": 15,
1064 | "metadata": {},
1065 | "outputs": [
1066 | {
1067 | "name": "stdout",
1068 | "output_type": "stream",
1069 | "text": [
1070 | "* slack value for assembly time constraint is: 0\n",
1071 | "* slack value for painting time constraint is: 0\n"
1072 | ]
1073 | }
1074 | ],
1075 | "source": [
1076 | "# revert soft constraints\n",
1077 | "ct_assembly.rhs = 440\n",
1078 | "s3 = m.solve()\n",
1079 | "\n",
1080 | "# now get slack value for assembly constraint: expected value is 40\n",
1081 | "print('* slack value for assembly time constraint is: {0}'.format(ct_assembly.slack_value))\n",
1082 | "# get slack value for painting time constraint, expected value is 0.\n",
1083 | "print('* slack value for painting time constraint is: {0}'.format(ct_painting.slack_value))"
1084 | ]
1085 | },
1086 | {
1087 | "cell_type": "markdown",
1088 | "metadata": {},
1089 | "source": [
1090 | "### Degeneracy\n",
1091 | "\n",
1092 | "It is possible that multiple non-optimal solutions with the same objective value exist. \n",
1093 | "\n",
1094 | "As the simplex algorithm attempts to move in the direction of an improved objective value, it might happen that the algorithm starts cycling between non-optimal solutions with equivalent objective values. This is known as _degeneracy_. \n",
1095 | "\n",
1096 | "Modern LP solvers, such as CPLEX Simplex Optimizer, have built-in mechanisms to help escape such cycling by using perturbation techniques involving the variable bounds.\n",
1097 | "\n",
1098 | "If the default algorithm does not break the degenerate cycle, it's a good idea to try some other algorithms, for example the Dual-simplex Optimizer. Problem that are primal degenerate, are often not dual degenerate, and vice versa."
1099 | ]
1100 | },
1101 | {
1102 | "cell_type": "markdown",
1103 | "metadata": {},
1104 | "source": [
1105 | "#### Setting a LP algorithm with DOcplex\n",
1106 | "\n",
1107 | "Users can change the algorithm by editing the `lpmethod` parameter of the model.\n",
1108 | "We won't go into details here, it suffices to know this parameter accepts an integer from 0 to 6, where 0 denotes automatic choice of the algorithm, 1 is for primal simplex, 2 is for dual simplex, and 4 is for barrier...\n",
1109 | "\n",
1110 | "For example, choosing the barrier algorithm is done by setting value 4 to this parameter. We access the `parameters` property of the model and from there, assign the `lpmethod` parameter"
1111 | ]
1112 | },
1113 | {
1114 | "cell_type": "code",
1115 | "execution_count": 16,
1116 | "metadata": {},
1117 | "outputs": [
1118 | {
1119 | "name": "stdout",
1120 | "output_type": "stream",
1121 | "text": [
1122 | "Version identifier: 12.10.0.0 | 2019-11-26 | 843d4de2ae\n",
1123 | "CPXPARAM_Read_DataCheck 1\n",
1124 | "CPXPARAM_LPMethod 4\n",
1125 | "Tried aggregator 1 time.\n",
1126 | "LP Presolve eliminated 2 rows and 1 columns.\n",
1127 | "Reduced LP has 2 rows, 2 columns, and 4 nonzeros.\n",
1128 | "Presolve time = 0.02 sec. (0.00 ticks)\n",
1129 | "Parallel mode: using up to 12 threads for barrier.\n",
1130 | "Number of nonzeros in lower triangle of A*A' = 1\n",
1131 | "Using Approximate Minimum Degree ordering\n",
1132 | "Total time for automatic ordering = 0.00 sec. (0.00 ticks)\n",
1133 | "Summary statistics for Cholesky factor:\n",
1134 | " Threads = 12\n",
1135 | " Rows in Factor = 2\n",
1136 | " Integer space required = 2\n",
1137 | " Total non-zeros in factor = 3\n",
1138 | " Total FP ops to factor = 5\n",
1139 | " Itn Primal Obj Dual Obj Prim Inf Upper Inf Dual Inf Inf Ratio\n",
1140 | " 0 9.2499384e+03 -3.2000000e+03 1.14e-13 0.00e+00 6.60e+01 1.00e+00\n",
1141 | " 1 1.7917626e+04 1.0558388e+04 1.61e-13 0.00e+00 1.77e+01 8.37e-01\n",
1142 | " 2 1.9469254e+04 2.1019365e+04 1.25e-10 0.00e+00 3.65e+00 1.60e+04\n",
1143 | " 3 2.2290521e+04 2.2642336e+04 1.36e-11 0.00e+00 2.52e-03 2.41e+04\n",
1144 | " 4 2.2309551e+04 2.2335421e+04 1.61e-11 0.00e+00 1.96e-04 9.91e+04\n",
1145 | " 5 2.2333332e+04 2.2333335e+04 6.10e-14 0.00e+00 1.96e-08 2.38e+07\n",
1146 | " 6 2.2333333e+04 2.2333333e+04 3.11e-12 0.00e+00 1.95e-12 1.51e+11\n",
1147 | " 7 2.2333333e+04 2.2333333e+04 1.04e-12 0.00e+00 1.28e-14 1.51e+15\n",
1148 | "Barrier time = 0.03 sec. (0.01 ticks)\n",
1149 | "Parallel mode: deterministic, using up to 12 threads for concurrent optimization:\n",
1150 | " * Starting dual Simplex on 1 thread...\n",
1151 | " * Starting primal Simplex on 1 thread...\n",
1152 | "\n",
1153 | "Dual crossover.\n",
1154 | " Dual: Fixed no variables.\n",
1155 | " Primal: Fixed no variables.\n",
1156 | "\n",
1157 | "Dual simplex solved model.\n",
1158 | "\n",
1159 | "Total crossover time = 0.00 sec. (0.00 ticks)\n",
1160 | "\n",
1161 | "Total time on 12 threads = 0.05 sec. (0.01 ticks)\n"
1162 | ]
1163 | },
1164 | {
1165 | "data": {
1166 | "text/plain": [
1167 | "docplex.mp.solution.SolveSolution(obj=22333.3,values={desk:166.667,cell:.."
1168 | ]
1169 | },
1170 | "execution_count": 16,
1171 | "metadata": {},
1172 | "output_type": "execute_result"
1173 | }
1174 | ],
1175 | "source": [
1176 | "m.parameters.lpmethod = 4\n",
1177 | "m.solve(log_output=True)"
1178 | ]
1179 | },
1180 | {
1181 | "cell_type": "markdown",
1182 | "metadata": {},
1183 | "source": [
1184 | "### Barrier methods\n",
1185 | "\n",
1186 | "Most of the CPLEX Optimizers for MP call upon the basic simplex method or some variation of it. \n",
1187 | "\n",
1188 | "Some, such as the Barrier Optimizer, use alternative methods.\n",
1189 | "\n",
1190 | "In graphical terms, the Simplex Algorithm starts along the edge of the feasible region and searches for an optimal vertex. \n",
1191 | "\n",
1192 | "The barrier method starts somewhere inside the feasible region – in other words, it avoids the “barrier” that is created by the constraints, and burrows through the feasible region to find the optimal solution.\n",
1193 | "\n",
1194 | "In its search, the method uses what is known as a predictor-corrector algorithm that constantly adjusts its path through the center of the feasible region (the central path). \n",
1195 | "\n",
1196 | "This diagram shows how the barrier method works compared to the simplex method. As you can see, the simplex method traverses the edge of the feasible region, while the barrier method moves through the interior, with a predictor-corrector determining the path. In general, it’s a good idea to experiment with different algorithms in CPLEX when trying to improve performance.\n",
1197 | "\n",
1198 | "\n",
1199 | "
\n",
1200 | "
\n",
1201 | "
"
1202 | ]
1203 | },
1204 | {
1205 | "cell_type": "markdown",
1206 | "metadata": {},
1207 | "source": [
1208 | "### Presolve\n",
1209 | "\n",
1210 | "CPLEX Optimizer provides a _presolve_ procedure.\n",
1211 | "\n",
1212 | "Presolve evaluates the model formulation before solving it, and attempts to reduce the size of the problem that is sent to the solver engine. \n",
1213 | "\n",
1214 | "A reduction in problem size typically translates to a reduction in total run time. \n",
1215 | "\n",
1216 | "For example, a real problem presented to CPLEX Optimizer with approximately 160,000 constraints and 596,000 decision variables, was reduced by presolve to a problem with 27,000 constraints and 150,000 decision variables.\n",
1217 | "\n",
1218 | "The presolve time was only 1.32 seconds and reduced the solution time from nearly half an hour to under 25 seconds.\n",
1219 | "\n",
1220 | "#### An example of presolve operations\n",
1221 | "\n",
1222 | "Let's consider the following Linear problem:\n",
1223 | "\n",
1224 | "$\n",
1225 | "\tmaximize:\\\\\n",
1226 | " [1]\\ 2x_{1}+ 3x_{2} — x_{3} — x_{4}\\\\\n",
1227 | " subject\\ to:\\\\\n",
1228 | " [2]\\ x_{1} + x_{2} + x_{3} — 2x_{4} <= 4\\\\\n",
1229 | " [3]\\ -x_{1} — x_{2} + x_{3} — x_{4} <= 1\\\\\n",
1230 | " [4]\\ x_{1} + x_{4} <= 3\\\\\n",
1231 | " [5]\\ x_{1}, x_{2}, x_{3}, x_{4} >= 0\n",
1232 | "$\n",
1233 | "- Because $x_{3}$ has a negative coefficient in the objective, the optimization will minimize $x_{3}$.\n",
1234 | "- In constraints [2] and [3] $x_{3}$ has positive coefficients, and the constraints are <=. Thus, $x_{3}$ can be reduced to 0, and becomes redundant.\n",
1235 | "- In constraint [3], all the coefficients are now negative. Because the left hand side of [3] can never be positive, any assignment of values will satisfy the constraint. The constraint is redundant and can be removed."
1236 | ]
1237 | },
1238 | {
1239 | "cell_type": "markdown",
1240 | "metadata": {},
1241 | "source": [
1242 | "# Summary\n",
1243 | "\n",
1244 | "Having completed this notebook, you should be able to:\n",
1245 | "- Describe the characteristics of an LP in terms of the objective, decision variables and constraints\n",
1246 | "- Formulate a simple LP model on paper\n",
1247 | "- Conceptually explain the following terms in the context of LP:\n",
1248 | " - dual\n",
1249 | " - feasible region\n",
1250 | " - infeasible\n",
1251 | " - unbounded\n",
1252 | " - slacks\n",
1253 | " - reduced costs\n",
1254 | " - degeneracy\n",
1255 | "- Describe some of the algorithms used to solve LPs\n",
1256 | "- Explain what presolve does\n",
1257 | "- Write a simple LP model with DOcplex\n"
1258 | ]
1259 | },
1260 | {
1261 | "cell_type": "markdown",
1262 | "metadata": {},
1263 | "source": [
1264 | "## References\n",
1265 | "* [CPLEX Modeling for Python documentation](http://ibmdecisionoptimization.github.io/docplex-doc/)\n",
1266 | "* [IBM Decision Optimization](https://www.ibm.com/analytics/decision-optimization)\n",
1267 | "* Need help with DOcplex or to report a bug? Please go [here](https://stackoverflow.com/questions/tagged/docplex).\n",
1268 | "* Contact us at dofeedback@wwpdl.vnet.ibm.com."
1269 | ]
1270 | },
1271 | {
1272 | "cell_type": "code",
1273 | "execution_count": null,
1274 | "metadata": {},
1275 | "outputs": [],
1276 | "source": []
1277 | }
1278 | ],
1279 | "metadata": {
1280 | "anaconda-cloud": {},
1281 | "kernelspec": {
1282 | "display_name": "Python 3",
1283 | "language": "python",
1284 | "name": "python3"
1285 | },
1286 | "language_info": {
1287 | "codemirror_mode": {
1288 | "name": "ipython",
1289 | "version": 3
1290 | },
1291 | "file_extension": ".py",
1292 | "mimetype": "text/x-python",
1293 | "name": "python",
1294 | "nbconvert_exporter": "python",
1295 | "pygments_lexer": "ipython3",
1296 | "version": "3.7.8"
1297 | }
1298 | },
1299 | "nbformat": 4,
1300 | "nbformat_minor": 1
1301 | }
1302 |
--------------------------------------------------------------------------------
/jupyter/training/1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IBMDecisionOptimization/tutorials/730677f141f406a631b25c2fba4bbdb4e5a47b35/jupyter/training/1.png
--------------------------------------------------------------------------------
/jupyter/training/19.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IBMDecisionOptimization/tutorials/730677f141f406a631b25c2fba4bbdb4e5a47b35/jupyter/training/19.png
--------------------------------------------------------------------------------
/jupyter/training/1_10.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IBMDecisionOptimization/tutorials/730677f141f406a631b25c2fba4bbdb4e5a47b35/jupyter/training/1_10.png
--------------------------------------------------------------------------------
/jupyter/training/1_11.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IBMDecisionOptimization/tutorials/730677f141f406a631b25c2fba4bbdb4e5a47b35/jupyter/training/1_11.png
--------------------------------------------------------------------------------
/jupyter/training/1_12.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IBMDecisionOptimization/tutorials/730677f141f406a631b25c2fba4bbdb4e5a47b35/jupyter/training/1_12.png
--------------------------------------------------------------------------------
/jupyter/training/1_13.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IBMDecisionOptimization/tutorials/730677f141f406a631b25c2fba4bbdb4e5a47b35/jupyter/training/1_13.png
--------------------------------------------------------------------------------
/jupyter/training/1_19.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IBMDecisionOptimization/tutorials/730677f141f406a631b25c2fba4bbdb4e5a47b35/jupyter/training/1_19.png
--------------------------------------------------------------------------------
/jupyter/training/1_21.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IBMDecisionOptimization/tutorials/730677f141f406a631b25c2fba4bbdb4e5a47b35/jupyter/training/1_21.png
--------------------------------------------------------------------------------
/jupyter/training/1_25.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IBMDecisionOptimization/tutorials/730677f141f406a631b25c2fba4bbdb4e5a47b35/jupyter/training/1_25.png
--------------------------------------------------------------------------------
/jupyter/training/1_39.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IBMDecisionOptimization/tutorials/730677f141f406a631b25c2fba4bbdb4e5a47b35/jupyter/training/1_39.png
--------------------------------------------------------------------------------
/jupyter/training/1_43.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IBMDecisionOptimization/tutorials/730677f141f406a631b25c2fba4bbdb4e5a47b35/jupyter/training/1_43.png
--------------------------------------------------------------------------------
/jupyter/training/1_44.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IBMDecisionOptimization/tutorials/730677f141f406a631b25c2fba4bbdb4e5a47b35/jupyter/training/1_44.png
--------------------------------------------------------------------------------
/jupyter/training/1_45.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IBMDecisionOptimization/tutorials/730677f141f406a631b25c2fba4bbdb4e5a47b35/jupyter/training/1_45.png
--------------------------------------------------------------------------------
/jupyter/training/1_46.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IBMDecisionOptimization/tutorials/730677f141f406a631b25c2fba4bbdb4e5a47b35/jupyter/training/1_46.png
--------------------------------------------------------------------------------
/jupyter/training/1_47.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IBMDecisionOptimization/tutorials/730677f141f406a631b25c2fba4bbdb4e5a47b35/jupyter/training/1_47.png
--------------------------------------------------------------------------------
/jupyter/training/1_5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IBMDecisionOptimization/tutorials/730677f141f406a631b25c2fba4bbdb4e5a47b35/jupyter/training/1_5.png
--------------------------------------------------------------------------------
/jupyter/training/1_6.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IBMDecisionOptimization/tutorials/730677f141f406a631b25c2fba4bbdb4e5a47b35/jupyter/training/1_6.png
--------------------------------------------------------------------------------
/jupyter/training/1_8.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IBMDecisionOptimization/tutorials/730677f141f406a631b25c2fba4bbdb4e5a47b35/jupyter/training/1_8.png
--------------------------------------------------------------------------------
/jupyter/training/20.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IBMDecisionOptimization/tutorials/730677f141f406a631b25c2fba4bbdb4e5a47b35/jupyter/training/20.png
--------------------------------------------------------------------------------
/jupyter/training/22.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IBMDecisionOptimization/tutorials/730677f141f406a631b25c2fba4bbdb4e5a47b35/jupyter/training/22.png
--------------------------------------------------------------------------------
/jupyter/training/26.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IBMDecisionOptimization/tutorials/730677f141f406a631b25c2fba4bbdb4e5a47b35/jupyter/training/26.png
--------------------------------------------------------------------------------
/jupyter/training/32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IBMDecisionOptimization/tutorials/730677f141f406a631b25c2fba4bbdb4e5a47b35/jupyter/training/32.png
--------------------------------------------------------------------------------
/jupyter/training/36.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IBMDecisionOptimization/tutorials/730677f141f406a631b25c2fba4bbdb4e5a47b35/jupyter/training/36.png
--------------------------------------------------------------------------------
/jupyter/training/37.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IBMDecisionOptimization/tutorials/730677f141f406a631b25c2fba4bbdb4e5a47b35/jupyter/training/37.png
--------------------------------------------------------------------------------
/jupyter/training/38.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IBMDecisionOptimization/tutorials/730677f141f406a631b25c2fba4bbdb4e5a47b35/jupyter/training/38.png
--------------------------------------------------------------------------------
/jupyter/training/39.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IBMDecisionOptimization/tutorials/730677f141f406a631b25c2fba4bbdb4e5a47b35/jupyter/training/39.png
--------------------------------------------------------------------------------
/jupyter/training/42.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IBMDecisionOptimization/tutorials/730677f141f406a631b25c2fba4bbdb4e5a47b35/jupyter/training/42.png
--------------------------------------------------------------------------------
/jupyter/training/52.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IBMDecisionOptimization/tutorials/730677f141f406a631b25c2fba4bbdb4e5a47b35/jupyter/training/52.png
--------------------------------------------------------------------------------