{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Tutorial: Beyond Linear Programming, (CPLEX Part2)\n", "\n", "This notebook describes some special cases of LP, as well as some other non-LP techniques, and also under which conditions they should be used. \n", "\n", "Before continuing, you should ensure that you followed the CPLEX Tutorial Part 1.\n", "\n", "After completing this unit, you should be able to describe what a network model is, and the benefits of using network models, explain the concepts of nonlinearity and convexity, describe what a piecewise linear function is, and describe the differences between Linear Programming (LP), Integer Programming (IP), Mixed-Integer Programming (MIP), and Quadratic Programming (QP). You should also be able to construct a simple MIP model. \n", "\n", ">This notebook is part of **[Prescriptive Analytics for Python](http://ibmdecisionoptimization.github.io/docplex-doc/)**\n", ">\n", ">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", "and you can start using `IBM Cloud Pak for Data as a Service` right away).\n", ">\n", "> CPLEX is available on IBM Cloud Pack for Data and IBM Cloud Pak for Data as a Service:\n", "> - IBM Cloud Pak for Data as a Service: Depends on the runtime used:\n", "> - Python 3.x runtime: Community edition\n", "> - Python 3.x + DO runtime: full edition\n", "> - Cloud Pack for Data: Community edition is installed by default. Please install the `DO` addon in `Watson Studio Premium` for the full edition\n", "\n", "\n", "\n", "Table of contents:\n", "\n", "* [CPLEX Modeling for Python](#Use-IBM-Decision-Optimization-CPLEX-Modeling-for-Python)\n", "* [Network models](#Network-models)\n", "* [Non-linearity and Convexity](#Non-linearity-and-Convexity)\n", "* [Integer Optimization](#Integer-Optimization)\n", "* [Quadratic Programming](#Quadratic-Programming)\n", "\n", "We will use DOcplex to write small samples to illustrate the topics" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Use IBM Decision Optimization CPLEX Modeling for Python\n", "\n", "Let's use the [DOcplex](http://ibmdecisionoptimization.github.io/docplex-doc/) Python library to write sample models in Python." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Download the library\n", "\n", "Install `CPLEX` (Community Edition) and `docplex` if they are not installed.\n", "\n", "In `IBM Cloud Pak for Data as a Service` notebooks, `CPLEX` and `docplex` are preinstalled." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import sys\n", "try:\n", " import cplex\n", "except:\n", " if hasattr(sys, 'real_prefix'):\n", " #we are in a virtual env.\n", " !pip install cplex\n", " else:\n", " !pip install --user cplex" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Installs `DOcplex`if needed" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "import sys\n", "try:\n", " import docplex.mp\n", "except:\n", " if hasattr(sys, 'real_prefix'):\n", " #we are in a virtual env.\n", " !pip install docplex\n", " else:\n", " !pip install --user docplex" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "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." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Network models\n", "\n", "In this topic, you’ll learn what a network model is, and how its structure can be exploited for more efficient solutions." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Networks in real life\n", "\n", "Several problems encountered in Operations Research (OR) involve networks, such as:\n", "Distribution problems (for example, transportation networks)\n", "Assignment problems (for example, networks of workers and jobs they could be assigned to)\n", "Planning problems (for example, critical path analysis for project planning)\n", "\n", "Many network models are special LP problems for which specialized solution algorithms exist. \n", "\n", "It is important to know whether a problem can be formulated as a network model to exploit the special structure.\n", "\n", "This topic introduces networks in general, as well as some well-known instances of network models.\n", "\n", "## Network modeling concepts\n", "\n", "Any network structure can be described using two types of objects:\n", "\n", "- Nodes: Defined points in the network, for example warehouses.\n", "- Arcs: An arc connects two nodes, for example a road connecting two warehouses. \n", "\n", "An arc can be _directed_, which means than an arc $a_{ij}$ from node $i$ to node $j$ is different from arc $a_ji$ that begins at node $j$ and ends at node $i$.\n", "\n", "

\n", "

\n", "\n", " A sequence of arcs connecting two nodes is called a chain. Each arc in a chain shares exactly one node with the preceding arc.\n", "\n", " When all the arcs in a chain are directed such that it is possible to traverse the chain in the directions of the arcs from the start node to the end node, it is called a path.\n", "\n", "

\n", "

\n", "\n", "## Different types of network problems\n", "\n", "The following are some well-known types of network problems:\n", "- Transportation problem\n", "- Transshipment problem\n", "- Assignment problem\n", "- Shortest path problem\n", "- Critical path analysis\n", "\n", "Next, you'll learn how to recognize each of these, and how their special structure can be exploited." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### The Transportation Problem\n", "\n", "One of the most common real-world network problems is the transportation problem. This type of problem involves a set of supply nodes and a set of demand nodes. The objective is to minimize the transportation cost from the supply nodes to the demand nodes, so as to satisfy the demand, and without exceeding the suppliers’ capacities. \n", "\n", "Such a problem can be depicted in a graph, with supply nodes, demand nodes, and connecting arcs. The supply capacity is indicated with the supply nodes, while the demand is indicated with the demand nodes, and the transportation costs are indicated on the arcs. \n", "\n", "

\n", "

\n", "\n", "The LP formulation involves one type of variable, namely x(i,j) representing the quantity transported from supply node i to demand node j. The objective is to minimize the total transportation cost across all arcs. The constraints are flow conservation constraints. The first two constraints state that the outflow from each supply node should be less than or equal to the supply capacity. The next three constraints state that the inflow into each demand node should equal the demand at that node. The domain for the shipments on the allowable arcs is set to be greater than or equal to zero, while the shipment quantities on the disallowed arcs are set to zero. \n", "\n", "Even though arcs (1,4) and (2,3) do not exist in the graph, the variables are included in the slide to show the special structure of the transportation problem. If you were to formulate such a model in practice, you’d simply exclude these variables. " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Formulating a simple transportation problem with DOcplex\n", "\n", "In the next section, we formulate the problem described above using DOcplex." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### What data for the transpotation problem?\n", "\n", "Input nodes are integers ranging in {1, 2}; output nodes are integers ranging from 3 to 5.\n", "\n", "The data consists in three Python dictionaries:\n", "\n", "- one dictionary gives capacity values for all input nodes\n", "- one dictionary contains demands for all target nodes\n", "- one last dictionary holds cost values for some (source, target) pair of nodes." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "capacities = {1: 15, 2: 20}\n", "demands = {3: 7, 4: 10, 5: 15}\n", "costs = {(1,3): 2, (1,5):4, (2,4):5, (2,5):3}\n", "\n", "# Python ranges will be used to iterate on source, target nodes.\n", "source = range(1, 3) # {1, 2}\n", "target = range(3, 6) # {3,4,5}" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Create a model instance" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "from docplex.mp.model import Model\n", "\n", "tm = Model(name='transportation')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Define the decision variables\n", "- The continuous variable `x(i,j)` is the flow going out of node i to node j\n" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "# create flow variables for each couple of nodes\n", "# x(i,j) is the flow going out of node i to node j\n", "x = {(i,j): tm.continuous_var(name='x_{0}_{1}'.format(i,j)) for i,j in costs}" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Set up the constraints\n", "\n", "- For each source node, the total outbound flow must be smaller than available quantity.\n", "- For each target node, total inbound flow must be greater thand demand" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "# for each node, total outgoing flow must be smaller than available quantity\n", "for i in source:\n", " tm.add_constraint(tm.sum(x[i,j] for j in target if (i,j) in costs) <= capacities[i])\n", " \n", "# for each target node, total ingoing flow must be greater than demand\n", "for j in target:\n", " tm.add_constraint(tm.sum(x[i,j] for i in source if (i,j) in costs) >= demands[j])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Express the business objective: minimize total flow cost\n", "\n", "Each arc has a unit cost and we want to minimize the total cost. " ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Model: transportation\n", " - number of variables: 4\n", " - binary=0, integer=0, continuous=4\n", " - number of constraints: 5\n", " - linear=5\n", " - parameters: defaults\n", " - objective: minimize\n", " - problem type is: LP\n" ] } ], "source": [ "# each arc comes with a cost. Minimize all costed flows\n", "tm.minimize(tm.sum(x[i,j]*costs[i,j] for i, j in costs))\n", "tm.print_information()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Solve the model\n", "\n", "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", "\n", "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`." ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "solution for: transportation\n", "objective: 114.000\n", "x_1_3 = 7.000\n", "x_1_5 = 5.000\n", "x_2_4 = 10.000\n", "x_2_5 = 10.000\n" ] } ], "source": [ "tms = tm.solve()\n", "assert tms\n", "tms.display()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Special structure of network problem\n", "\n", "The special structure of the transportation problem, as well as many other types of network problems, allows the use of specialized algorithms that lead to significant reductions in solution time.\n", "\n", "Another important characteristic of transportation problems (and also some other network problems) is that if all the capacities and demands are integer, then the decision variables will take integer values.\n", "\n", "This is important to know, because it means that you do not have to use integer variables in such cases. \n", "\n", "As you'll learn in a later topic, integer variables often lead to problems that require much more computational effort compared to problems with only continuous variables.\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## The Transshipment Problem\n", "\n", "The transshipment problem is similar to the transportation problem, except that intermediate nodes exist in addition to the supply and demand nodes. \n", "\n", "

\n", "

\n", "\n", "\n", "In this example, nodes 3 and 4 are intermediate nodes. \n", "\n", "The LP formulation is also similar, in the sense that it involves an objective to minimize the transportation cost across all arcs, and a set of flow conservation constraints. The first two constraints are for the supply nodes, and state that the outflow from each supply node should equal the capacity of that node, plus any inflow into that same node. The next two constraints are for the intermediate nodes, and state that the inflow into an intermediate node should equal the outflow out of that node. The last two constraints are for the demand nodes, and state that the inflow into each demand node should equal the demand at that node. The domain for the variables is to be greater than or equal to zero. \n", "\n", "It is possible to write the transshipment problem as a transportation problem in order to use specialized algorithms that exploit the structure of transportation problem. This conversion is not covered as part of this course because CPLEX Optimizer does this conversion automatically, but you can find details in the textbooks listed at the end of this course\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## The Assignment Problem\n", "\n", "The Assignment Problem is the problem of assigning one set of items to another, while optimizing a given objective. For example, the problem of assigning workers to jobs so as to minimize the hiring costs. \n", "\n", "

\n", "

\n", "\n", "In this example, the workers are represented by nodes 1 through 3, while the jobs are represented with nodes A, B and C. The cost of assigning a worker to a job is shown on each arc. The objective is to minimize the total assignment cost. Again, the constraints can be seen as flow conservation constraints. The first three constraints state that each job is filled by exactly one person, while the last three constraints state that each person is assigned to exactly one job. The variables should now take a value of 1 if worker i is assigned to job j, and zero otherwise. \n", "\n", "This problem is a special case of the transportation problem, with each supply node capacity set to one, and each demand set to 1. What’s also important to know is that even though the variables must take 0-1 values, they can be declared as continuous variables due to the integrality property, namely that if all capacity and demand quantities are integer, the variables will take integer values." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## The Shortest Path Problem\n", "\n", "The Shortest Path Problem is the problem of finding the shortest path through a network. For example, to find the minimum travel time between two cities in a network of cities. The shortest path problem is a special case of the transshipment problem, where there is exactly one supply node and one demand node, and the supply and demand are both equal to 1. \n", "\n", "

\n", "

\n", "\n", "In this example, each node represents a city, and each arc represents the road connecting two cities. The travel time is indicated on each arc. The variable x(i, j) takes a value of 1 if the arc between i and j is included in the shortest path, and zero otherwise. The objective is to minimize the total travel time. As with the other network problems, the constraints can be seen as flow conservation constraints. A constraint exists for each node (or each city) and the constraints state that exactly one arc should be chosen into each city, and exactly one arc should be chosen out of each city. \n", "\n", "Again, even though the x variables must take 0-1 values, they can be declared as continuous due to the integrality property (that is, all the capacity and demand quantities are integer). \n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Critical Path Analysis\n", "\n", "Critical path analysis is a technique used in project planning to find the set of critical activities where a delay in one of the critical activities will lead to an overall project delay. The critical path is the longest path in the network. It represents the minimum completion time of the project, and if any task on the critical path is delayed, the entire project will be delayed. \n", "\n", "Tasks that do not lie on the critical path may be delayed to some extent without impacting the final completion date of the project. The critical path will change if a non-critical task is delayed to a point where it becomes critical. \n", "\n", "For example, consider a kitchen remodeling project where the home owners are remodeling their kitchen with the eventual goal of hosting a party. Some of the tasks can be done simultaneously, such as plumbing and electricity, while others can only be started once a previous task is complete, for example the sink can only be installed once the plumbing is complete. The critical path will indicate the minimum time for completing this project, so that they know when they can have their party. \n", "\n", "

\n", "

\n", "\n", "Here, the arcs show the task durations, while the nodes show the task start times. For modeling purposes, let t(i) be the start time of the tasks originating at node i. The objective is to minimize the project completion time, namely t7. The constraints indicate the task duration and precedence. For example, the third constraint indicates that the minimum time between starting the sink installation (that is, node 3), and starting the plumbing (that is, node 1) is 3 days. Arcs 3-2 and 4-2 are dummy tasks required to complete the model. Such dummy tasks have no minimum time associated with them, but are used to model precedence involving more than one preceding tasks of varying duration, in this case that the plumbing, electricity, and appliance order time must be complete before appliances can be installed. \n", "\n", "In this graph, it’s easy to see that the critical path lies on nodes 0 – 2 – 6 – 7, with a total length of 19 days. Therefore, any delay in the appliance ordering or installation will delay the party date. \n", "\n", "Large projects can lead to very complex networks, and specialized algorithms exist for critical path analysis.\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## CPLEX Network Optimizer\n", "\n", "As you’ve now seen, many network problems are special types of LP problems. In many cases, using the Simplex or Dual-simplex Optimizers is the most efficient way to solve them. In some cases, specialized algorithms can solve such problems more efficiently. \n", "\n", "CPLEX automatically invokes the Network Optimizer when it's likely that it would improve solution time compared to the other algorithms. \n", "\n", "It is also possible to force the use (or not) of the Network Optimizer by setting the `lpopt` parameter of\n", "a DOcplex model to 3 (remember 1 was primal simplex, 2 was dual simplex, and 4 is for barrier). " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Non-linearity and Convexity\n", "\n", "In this topic, you’ll learn about the concepts of nonlinearity and convexity, and their significance in relation to mathematical programming.\n", "\n", "## Non-linearity\n", "\n", "In many problems, the relationships between decision variables are not linear. Examples of industries where nonlinear optimization problems are often encountered are:\n", "The chemical process industry, for example oil refining or pipeline design\n", "The finance sector, for example stock portfolio optimization\n", "\n", "- Nonlinear Programming (NLP) is often used to solve such optimization problems. One of the NLP techniques available through DOcplex is Quadratic Programming (QP), used especially for portfolio optimization. \n", "\n", "- Sometimes it is possible to approximate a nonlinear function with a set of linear functions and then solve the problem using LP techniques. The success of this depends on whether the nonlinear function is convex or nonconvex. \n", "\n", "## Convexity\n", "\n", "A region of the space is _convex_ if any point lying on a straight line between any two points in the region is also in the region.\n", "\n", "All LPs are convex, because an LP involves the minimization of a linear function over a feasible region defined by a set of linear functions, and linear functions are convex.\n", "\n", "

\n", "

\n", "\n", "## Approximating a non-linear program with piecewise-linear functions\n", "\n", "A convex nonlinear function can be approximated by a set of linear functions, as shown in the next figure. This could be used to allow solution with LP techniques. \n", "\n", "Such an approximate function consisting of several linear line segments is called a _piecewise linear_ function. \n", "\n", "

\n", "

\n", "\n", "We will start by discussing this approximation.\n", "\n", "Piecewise linear programming is used when dealing with functions consisting of several linear segments. Examples of where this might be appropriate are piecewise linear approximations of convex nonlinear functions, and piecewise linear functions representing economies of scale (for example a unit cost that changes when a certain number of units are ordered.) \n", "\n", "## An example of piecewise linear programming: economies of scale\n", "\n", "\n", "Consider a transportation problem in which the transportation cost between an origin,$i$, and a destination, $j$, depends on the size of the shipment, $ship_{ij}$:\n", "- The first 1000 items have a shipping cost of \\$0.40 per item\n", "- For the next 2000 items (i.e. items 1001-3000) the cost is \\$ 0.20 per item\n", "- From item 3001 on, the cost decreases to \\$ 0.10 per item.\n", "\n", "The cost of each quantity bracket remains intact (that is, the cost per unit changes only for additional units, and remains unchanged for the previous quantity bracket). \n", "\n", "Within each bracket there is a linear relationship between cost and quantity, but at each breakpoint the rate of linear variation changes. \n", "\n", "If you graph this function, you see that at each breakpoint, the slope of the line changes. The section of the graph between two breakpoints is a linear piece.\n", "\n", "

\n", "

\n", "\n", "The diagram shows that the total shipping cost is evaluated by 3 different linear functions, each determined by the quantity shipped $Q$:\n", "\n", "- 0.40 * items when $Q \\le 1000$,\n", "- 0.40 * 1000 + 0.20 * (Q - 1000) when $1000 <= Q = 3000$,\n", "- 0.40 * 1000 + 0.20 * 2000 + 0.10 * (Q - 3000) when $Q \\ge 3000$.\n", "\n", "This is an example of a piecewise linear function. Note that this function is _continuous_, that is has no 'jump' in its values, but this not mandatory for piecewise linear functions.\n", "\n", "### Piecewise linear functions with DOcplex\n", "\n", "DOcplex lets you define piecewise linear functions in two styles: either with a set of points, or with a set of values and slopes. As the problem is formulated with slopes, we'll start with this formulation.\n", "\n", "The `Model.piecewise_with_slopes` method takes a sequence of $(x_{i}, slope_{i})$ values where $slope_{i}$ is the slope of the function between $x_{i-1}$ and $x_{i}$." ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXcAAAD4CAYAAAAXUaZHAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8QZhcZAAAfO0lEQVR4nO3df5yWc77H8den0g+lGpmtJMrqoJOQ0bJZByGVI4f1Y+1ap2Vbe1g/2pActrUssTayNlqiyJLaVUusFrFsaCJJnZREKTVLv6hUM9/zx+eavaeappm67/u67+t+Px+Pecz1q7k/c8307tv3vq7PZSEEREQkWerFXYCIiKSfwl1EJIEU7iIiCaRwFxFJIIW7iEgCNYi7AIB99tkndOjQIe4yRETyysyZM/8ZQiiubl9OhHuHDh0oLS2NuwwRkbxiZh/vaJ+mZUREEkjhLiKSQAp3E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r/Ov1o/0t8Om5bNR1WjS9FUIIXwMPk/3z1QM4w8wW41NiJ+Ej+eyer9190yCuD/wRgYvwNxoq3zT69yy+flNgryrL/8Dn6e5k6zfl7oiW+7L1mzlvpbmeDmz9xmWd6sBHOB/hbygVRct7Z6CutlWWr8bnFAH+na3fPFqEvzGY9p9z9L2PBe7eZnus56yGumI9Z0Ax0DJabgL8HTgdeIqt3yD8n2j5MrZ+g3B8TfVmoK62Vc7n3cDtcfzuR1/7BFJvqGb1fKUtXOL4wN/9/gCf/7shy699YHTi3wXer3x9fK7sRWBB9HnvKr9o90W1vgeUpLGWP+L/Xd+M/2t/8a7UAfwIf9NmIdA/Q3U9Gr3ubGAyWwfXDVFd84Hemfo5A8fh/72dDcyKPvrEfc5qqCvWcwZ0Bd6JXn8OcFOVvwNvRd/7U0CjaHvjaH1htP/AndWb5rpeis7XHOAxUlfUZO13v8rXPYFUuGf1fKn9gIhIAuXznLuIiOyAwl1EJIEU7iIiCaRwFxFJIIW7iEgCKdxFRBJI4S4ikkD/D3BcbtZ11tYCAAAAAElFTkSuQmCC", "text/plain": [ "
" ] }, "metadata": { "needs_background": "light" }, "output_type": "display_data" } ], "source": [ "# Display matplotlib plots in the notebook\n", "%matplotlib inline\n", "\n", "# create a new model to attach piecewise\n", "pm = Model(name='pwl')\n", "pwf1 = pm.piecewise_as_slopes([(0, 0), (0.4, 1000), (0.2, 3000)], lastslope=0.1)\n", "# plot the function\n", "pwf1.plot(lx=-1, rx=4000, k=1, color='b', marker='s', linewidth=2)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Defining a piecewise linear functions from break points\n", "\n", "DOcplex also allows to define a piecewise linear function from the set of its _break_ points, that is a sequence of $(x_{i}, y_{i})$ values, plus the final slope towards $+\\infty$. Here the sequence of breakpoints is:\n", "\n", "- (0,0)\n", "- (1000, 400): computed with 0.4 marginal cost\n", "- (3000, 800): computed as 400 + 0.2 * (3000 - 1000)\n", "- final slope is 0.1" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXcAAAD4CAYAAAAXUaZHAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8QZhcZAAAgAElEQVR4nO3de5yWc/7H8den0lkHaZN0svqhX6KMlg2LkGp/smxY1vq1a9NiHdok+bGxWueNLBGiGEtk1RKrRSwbKpLUpkQHzdYsnejcfH9/fK7ZeybTNFP3fV/34f18POYx12nm/sw19e7b976uz2UhBEREJLfUiLsAERFJPoW7iEgOUriLiOQghbuISA5SuIuI5KBacRcAsO+++4Z27drFXYaISFaZNWvWv0MIzSvalxHh3q5dO2bOnBl3GSIiWcXMluxsn6ZlRERykMJdRCQHKdxFRHKQwl1EJAcp3EVEcpDCXUQkDoWF0K4d1KjhnwsLk/rtM+JSSBGRvFJYCAMGwIYNvr5kia8DnH9+Ul5CI3cRkXQKAa6+OhHspTZsgOuuS9rLKNxFRFJt/Xp4/nkfnbduDUVFFR+3dGnSXlLTMiIiyRYCLFgAU6b4x5tvwtatif01akBJybe/rk2bpJWgcBcRSYYNG2DatESgf/ZZYl+NGvD970Pv3v7x8cdw8cXlp2bq14cRI5JWjsJdRGR3ffppIsynTYNNmxL79t0XTjvNw/zUU6FZs8S+Ll3AzOfYly71EfuIEUl7MxUU7iIiVbd5s0+xlAb6J5+U33/UUdCrlwd6QQHUrLnz73X++UkN8x0p3EVEKrN0Kbz0kof53/5WfiqlSRPo2dPDvGdPaNEivjp3oHAXESlr61Z4++3E6Pzjj8vvP/zwxNz50UdDrcyM0cysSkQknYqKEqPzqVNh3brEvr33hpNP9jDv1QtatYqvzmpQuItI/tm+Hd59NzE6/+CD8vs7dkyMzrt3h9q146lzDyjcRSQ/FBfDyy97mL/yCnz1VWJfvXrQo0didJ4Dj/1Uu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xQWb0pqKtlmfN5N3BrHH/2o+99Aok3VNN6vpIWLnF84O9+f4LP/12X5tc+MDrxHwIfl74+Plf2KrAw+rxPmT9o90W1fgQUJLGWP+H/Xd+K/2v/i92pA/g5/qbNIqB/iup6PHrdOcBkygfXdVFdC4Beqfo9A8fi/72dA8yOPnrHfc4qqSvWcwZ0Bj6IXn8ucEOZvwPvRT/7M0CdaHvdaH1RtP/AXdWb5Lpei87XXOAJElfUpO3PfpnvewKJcE/r+VL7ARGRHJTNc+4iIrITCncRkRykcEtPTVoAAAAgSURBVBcRyUEKdxGRHKRwFxHJQQp3EZEcpHAXEclB/w8Vjs5h0tgZWwAAAABJRU5ErkJggg==", "text/plain": [ "
" ] }, "metadata": { "needs_background": "light" }, "output_type": "display_data" } ], "source": [ "pwf2 = pm.piecewise(preslope=0, breaksxy=[(0, 0), (1000, 400), (3000, 800)], postslope=0.1)\n", "# plot the function\n", "pwf2.plot(lx=-1, rx=4000, k=1, color='r', marker='o', linewidth=2)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "To bind a variable $y$ to the result of applying the peicewise linear function to another variable $x$, you just have to add the following constraint to the model:" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [], "source": [ "x = pm.continuous_var(name='x')\n", "y = pm.continuous_var(name='y')\n", "pm.add_constraint(y == pwf2(x)); # y is constrained to be equal to f(x)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Integer Optimization\n", "\n", "In this topic, you’ll learn how to deal with integer decision variables by using Integer Programming and Mixed-Integer Programming, and how these techniques differ from LP.\n", "\n", "## Problems requiring integers\n", "\n", "For some optimization problems the decision variables should take integer values. \n", "\n", "- One example is problems involving the production of large indivisible items, such as airplanes or cars. It usually does not make sense to use a continuous variable to represent the number of airplanes to produce, because there is no point in manufacturing a partial airplane, and each finished airplane involves a large cost. \n", "\n", "- Another example of where one would use integer variables is to model a particular state, such as on or off. For example, a unit commitment problem where integer variables are used to represent the state of a particular unit being either on or off. \n", "\n", "- Planning of investments also requires integer variables, for example a variable that takes a value of 1 to invest in a warehouse, and 0 to ignore it. \n", "\n", "Finally, integer variables are often used to model logic between different decision, for example that a given tax break is only applicable if a certain investment is made.\n", "\n", "## Different types of integer decisions\n", "\n", "Many types of decisions can be modeled by using integer variables. \n", "\n", "One example is yes/no decisions, with a value of 1 for yes, and 0 for no. For example, if x equals 1, new manufacturing equipment should be installed, and if x equals 0, it should not. \n", "\n", "Integer variables are also used to model state or mode decisions. For example, if z1 equals 1 the machine operates in mode 1, if z2 equals 1, the machine operates in mode 2, and if z3 equals 1 the machine operates in mode 3. The same integer is often used to express both yes/no decisions and logic. For example, y1 equals 1 could in this case also be used to indicate that machine 1 is installed, and 0 otherwise. \n", "\n", "Finally, integer variables are used tomodel cases where a value can take only integer values: for example: how many flights should a company operate between two airports.\n", "\n", "## Types of integer variables\n", "\n", "In general, integer variables can take any integer value, such as 0, 1, 2, 3, and so forth. Integers that should only take the values of 1 or 0 are known as binary (or Boolean) variables. Binary variables are also often referred to as Boolean variables because the Boolean values of true and false are analogous to 1 and 0. \n", "\n", "To ensure that an integer variable can only take the values 0 and 1, one can give it an upper bound of 1 or declare it to be of type binary. In a DOcplex model, decision variables are assumed to be nonnegative unless otherwise specified and the lower bound of 0 does not need to be declared explicitly. " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Declaring integer decision variables in DOcplex\n", "\n", "DOcplex has specific methods to create integer and binary variables." ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Model: integer_programming\n", " - number of variables: 2\n", " - binary=1, integer=1, continuous=0\n", " - number of constraints: 0\n", " - linear=0\n", " - parameters: defaults\n", " - objective: none\n", " - problem type is: MILP\n" ] } ], "source": [ "im = Model(name='integer_programming')\n", "b = im.binary_var(name='boolean_var')\n", "ijk = im.integer_var(name='int_var')\n", "im.print_information()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Modeling techniques with integer and binary variables\n", "\n", "Integer and binary variables are very useful to express logical constraints. Here are a few examples of\n", "such constraints.\n", "\n", "### Indicator variables\n", "\n", "Indicator variables are binary variables used to indicate whether a certain set of conditions is valid (with the variable equal to 1) or not (with the variable equal to 0). For example, consider a production problem where you want to distinguish between two states, namely production above a minimum threshold, and no production. \n", "\n", "To model this, define a binary variable $y$ to take a value of 1 if the production is above the minimum threshold (called minProd), and 0 if there is no production. Assume $production$ is a continuous variable containing the produced quantity. \n", "This leads to these two constraints.\n", "\n", "$$\n", "production \\ge minProd * y\\\\\n", "production \\le maxProd * y\n", "$$\n", "\n", "Here, maxProd is an upper bound on the production quantity. Thus, if y = 1, the minimum and maximum production bounds hold, and if y = 0, the production is set to zero. \n", "\n", "\n", "### Logical constraints - an example\n", "\n", "For example, consider an investment decision involving a production plant and two warehouses. \n", "\n", "- If the production plant is invested in, then either warehouse 1 or warehouse 2 may be invested in (not both).\n", "\n", "- If the production plant is not invested in, then neither of the two warehouses may be invested in.\n", "\n", "Let $yPlant$ be 1 if you decide to invest in the production plant, and 0 otherwise. \n", "Similar for $yWarehouse1$ and $yWarehouse2$.\n", "Then this example can be modeled as follows:\n", "\n", "$$\n", "yWarehouse1 + yWarehouse2 <= yPlant\n", "$$\n", "\n", "If $yPlant$ is 0 then both $yWarehouse1$ and $yWarehouse2$ are set to zero. \n", "\n", "On the opposite, if one warehouse variable is set to 1, then $yPlant$ is also set to 1. Finally, this constraint also states that warehouse variables cannot be both equal to 1.\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## IP versus MIP\n", "\n", "When all the decision variables in a linear model should take integer values, the model is an Integer Program (or **IP**). \n", "\n", "When some of the decision variables may also take continuous values, the model is a Mixed Integer Program (or **MIP**). \n", "\n", "MIPs are very common in, for example, some supply chain applications where investment decisions may be represented by integers and production quantities are represented by continuous variables.\n", "\n", "IPs and MIPs are generally much more difficult to solve than LPs.\n", "\n", "The solution complexity increases with the number of possible combinations of the integer variables, and such problems are often referred to as being “combinatorial”.\n", "\n", "In the worst case, the solution complexity increases exponentially with the number of integer decision variables.\n", "\n", "Many advanced algorithms can solve complex IPs and MIPs in reasonable time\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### An integer programming example\n", "\n", "In the telephone production problem where the optimal solution found in chapter 2 'Linear programming' had integer values, it is possible that the solution becomes non-integer under certain circumstances, for example:\n", "\n", "- Change the availability of the assembly machine to 401 hours\n", "- Change the painting machine availability to 492 hours\n", "- Change the profit for a desk phone to 12.4\n", "- Change the profit for a cell phone to 20.2\n", "\n", "The fractional values for profit are quite realistic. Even though the fractional times for availability are not entirely realistic, these are used here to illustrate how fractional solutions may occur. \n", "\n", "Let's solve again the telephone production problem with these new data. A detailed explanation of the model is found in notebook 2: 'Linear Programming'" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "objective: 20948.167\n", " desk=303.333\n", " cell=850.833\n" ] } ], "source": [ "lm = Model(name='lp_telephone_production')\n", "desk = lm.continuous_var(name='desk')\n", "cell = lm.continuous_var(name='cell')\n", "# write constraints\n", "# constraint #1: desk production is greater than 100\n", "lm.add_constraint(desk >= 100)\n", "\n", "# constraint #2: cell production is greater than 100\n", "lm.add_constraint(cell >= 100)\n", "\n", "# constraint #3: assembly time limit\n", "ct_assembly = lm.add_constraint( 0.2 * desk + 0.4 * cell <= 401)\n", "\n", "# constraint #4: painting time limit\n", "ct_painting = lm.add_constraint( 0.5 * desk + 0.4 * cell <= 492)\n", "lm.maximize(12.4 * desk + 20.2 * cell)\n", "\n", "ls = lm.solve()\n", "lm.print_solution()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "As we can see the optimal solution contains fractional values for number of telephones, which are not realistic.\n", "To ensure we get integer values in the solution, we can use integer decision variables.\n", "\n", "Let's solve a new model, identical except that its two decision variables are declared as _integer_ variables." ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "objective: 20947.400\n", " desk=303\n", " cell=851\n" ] } ], "source": [ "im = Model(name='ip_telephone_production')\n", "desk = im.integer_var(name='desk')\n", "cell = im.integer_var(name='cell')\n", "# write constraints\n", "# constraint #1: desk production is greater than 100\n", "im.add_constraint(desk >= 100)\n", "\n", "# constraint #2: cell production is greater than 100\n", "im.add_constraint(cell >= 100)\n", "\n", "# constraint #3: assembly time limit\n", "im.add_constraint( 0.2 * desk + 0.4 * cell <= 401)\n", "\n", "# constraint #4: painting time limit\n", "im.add_constraint( 0.5 * desk + 0.4 * cell <= 492)\n", "im.maximize(12.4 * desk + 20.2 * cell)\n", "\n", "si = im.solve()\n", "im.print_solution()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "As expected, the IP model returns integer values as optimal solution.\n", "\n", "

\n", "

\n", "\n", "This graphic shows the new feasible region where the dots indicate the feasible solutions. That is, solutions where the variables take only integer values. This graphic is not according to scale, because it’s not possible to indicate all the integer points graphically for this example. What you should take away from this graphic, is that the feasible region is now a collection of points, as opposed to a solid area. Because, in this example, the integer solution does not lie on an extreme point of the continuous feasible region, LP techniques would not find the integer optimum. To find the integer optimum, you should use an integer programming technique. \n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Rouding a fractional solution\n", "\n", "An idea that often comes up to deal with fractional solutions is to solve an LP and then round the fractional numbers in order to find an integer solution. However, because the optimal solution is always on the edge of the feasible region, rounding can lead to an infeasible solution, that is, a solution that lies outside the feasible region. In the case of the telephone problem, rounding would produce infeasible results for both types of phones. \n", "\n", "When large quantities of items are produced, for example thousands of phones, rounding may be still be a good approach to avoid integer variables.\n", "In general, you should use an integer programming algorithm to solve IPs. The most well-known of these is the branch-and-bound algorithm. \n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## The branch and bound method\n", "\n", "The _branch and bound_ method, implemented in CPLEX Mixed-Integer Optimizer, provides an efficient way to solve IP and MIP problems. This method begins by relaxing the integer requirement and treating the problem as an LP. If all the variables take integer values, the solution is complete. If not, the algorithm begins a tree search. You’ll now see an example of this tree search. \n", "\n", "Consider this integer programming problem, involving an objective to maximize, three constraints, and three non-negative integer variables (this is the default for DOcplex variables).\n", "\n", "$\n", "maximize\\ x + y + 2 z\\\\\n", "subject\\ to: 7x + 2y + 3z <= 36\\\\\n", "\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ 5x + 4y + 7z <= 42\\\\\n", "\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ 2x + 3y + 5z <= 28\\\\\n", "\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ x,y,z \\ge 0\n", "$\n", "\n", "### Branch and Bound: the root node\n", "\n", "The first node of the branch and bound tree is the LP relaxation of the original IP model. \n", "LP relaxation means that the integer variables have been relaxed to be continuous variables. \n", "The solution to the LP relaxation of a maximization IP, such as this, provides an upper bound to the original problem, in this case that bound is eleven and five elevenths. \n", "The current lower bound is minus infinity. \n", "\n", "

\n", "

\n", "\n", "In this case, the solution is fractional and the tree search continues in order to try and find an integer solution.\n", "\n", "### Branch and Bound: branching on a variable\n", "\n", "The algorithm next chooses one of the variables to branch on, in this case $x$, and adds two constraints to create two subproblems. \n", "These two constraints are based on the relaxed value of x, namely one and three elevenths. In the one subproblem, $x$ is required to be less than or equal to one, and in the other problem, $x$ is required to be greater than or equal to two, in order to eliminate the fractional solution found. \n", "IP2 gives another fractional solution, but IP3 gives an integer solution. This integer solution of 10 is the new lower bound to the original maximization problem, because it is the best current solution to the maximization problem. \n", "\n", "

\n", "

\n", "\n", "The algorithm will terminate when the gap between the upper and lower bounds is sufficiently small, but at this point there is still more of the tree to explore.\n", "\n", "### Branch and Bound: iteration\n", "\n", "

\n", "

\n", "\n", "Two new subproblems are now generated from IP2, and these constraints are determined by the fractional value of z in IP2. In IP4, z must be less than or equal to 5, and in IP3 z must be greater than or equal to 6. IP4 gives another fractional solution, while IP3 is infeasible and can be pruned. When a node is pruned, the node is not explored further in the tree.\n", "\n", "

\n", "

\n", "\n", "Next, two more subproblems are created from IP4, namely one with y less than or equal to zero in IP6, and one with y greater than or equal to 1 in IP5. IP6 yields an integer solution of 11, which is an improvement of the previously found lower bound of 10. IP5 gives a fractional solution and can be explored further.\n", "\n", "

\n", "

\n", "\n", "So another two subproblems are created from IP5, namely IP8 with z less than or equal to 4, and IP7 with z greater than or equal to 5. However, the constraint added for IP4 specifies that z must be less than or equal to 5, so node IP7 immediately yields an integer solution with an objective value of 11, which is the same objective as for IP6. IP8 yields an integer solution with objective value of 9, which is a worse solution than those previously found and IP8 can therefore be discarded. \n", "\n", "The optimal solution reported is the integer solution with the best objective value that was found first, namely the solution to IP6." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The progess of the Branch & Bound algorithm can be monitored by looking at the CPLEX the _log_. Adding the keyword argument `log_output=True` to the `Model.solve()` method will print the log on the standard output.\n", "You can see the best bound going down until the gap closes and the final solution of 11 is returned.\n", "By default the CPLEX log is not printed." ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Version identifier: 12.10.0.0 | 2019-11-26 | 843d4de2ae\n", "CPXPARAM_Read_DataCheck 1\n", "Found incumbent of value 0.000000 after 0.00 sec. (0.00 ticks)\n", "Tried aggregator 1 time.\n", "Reduced MIP has 3 rows, 3 columns, and 9 nonzeros.\n", "Reduced MIP has 0 binaries, 3 generals, 0 SOSs, and 0 indicators.\n", "Presolve time = 0.00 sec. (0.00 ticks)\n", "Tried aggregator 1 time.\n", "Reduced MIP has 3 rows, 3 columns, and 9 nonzeros.\n", "Reduced MIP has 0 binaries, 3 generals, 0 SOSs, and 0 indicators.\n", "Presolve time = 0.02 sec. (0.00 ticks)\n", "MIP emphasis: balance optimality and feasibility.\n", "MIP search method: dynamic search.\n", "Parallel mode: deterministic, using up to 12 threads.\n", "Root relaxation solution time = 0.00 sec. (0.00 ticks)\n", "\n", " Nodes Cuts/\n", " Node Left Objective IInf Best Integer Best Bound ItCnt Gap\n", "\n", "* 0+ 0 0.0000 24.0000 --- \n", " 0 0 11.4286 2 0.0000 11.4286 2 --- \n", "* 0+ 0 11.0000 11.4286 3.90%\n", " 0 0 cutoff 11.0000 11.4286 2 3.90%\n", "Elapsed time = 0.02 sec. (0.03 ticks, tree = 0.01 MB, solutions = 2)\n", "\n", "Root node processing (before b&c):\n", " Real time = 0.02 sec. (0.03 ticks)\n", "Parallel b&c, 12 threads:\n", " Real time = 0.00 sec. (0.00 ticks)\n", " Sync time (average) = 0.00 sec.\n", " Wait time (average) = 0.00 sec.\n", " ------------\n", "Total (root+branch&cut) = 0.02 sec. (0.03 ticks)\n" ] } ], "source": [ "bbm = Model(name='b&b')\n", "x, y, z = bbm.integer_var_list(3, name=['x', 'y', 'z'])\n", "bbm.maximize(x + y + 2*z)\n", "bbm.add_constraint(7*x + 2*y + 3*z <= 36)\n", "bbm.add_constraint(5*x + 4*y + 7*z <= 42)\n", "bbm.add_constraint(2*x + 3*y + 5*z <= 28)\n", "bbm.solve(log_output=True);" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Modeling yes/no decisions with binary variables: an example\n", "\n", "Binary variables are often used to model yes/no decisions. \n", "Consider again the telephone production problem, but ignore the lower bounds of 100 on production for simplicity. The company is considering replacing the assembly machine with a newer machine that requires less time for cell phones, namely 18 minutes per phone, but more time for desk phones, namely 15 minutes per phone. This machine is available for 430 hours, as opposed to the 400 hours of the existing assembly machine, because it requires less downtime. \n", "\n", "We will design and write a model that uses binary variables to help the company choose between the two machines. \n", "\n", "The steps to formulate the mixed-integer model are:\n", "- Add four new variables (desk1, desk2, cell1, and cell2, to indicate the production on assembly machines 1 and 2, respectively.\n", "- Add two constraints to define the total production of desk and cell to equal the sum of production from the two assembly machines.\n", "- Rewrite the constraint for assembly machine 1 to use the new variables for that machine (desk1 and cell1).\n", "- Add a similar constraint for the production on assembly machine 2.\n", "- Define a Boolean variable, y, to take a value of 1 if assembly machine 1 is chosen, and 0 if assembly machine 2 is chosen.\n", "- Use the z variable to set the production to zero for the machine that is not chosen.\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Implementing the yes/no decision model with DOcplex\n", "\n", "First, create a model instance." ] }, { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [], "source": [ "tm2 = Model('decision_phone')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Setup decision variables\n", "\n", "we create two sets of (desk, cell) integer variables, one per machine type, plus the total production variables.\n", "Note that the total production variables do not need to be declared if the four typed productions are integers.\n", "As the sum of two integers, they will always be integers; the less we have of integer variables, the easier CPLEX willsolve the problem.\n", "\n", "In addition, we define an extra binary variable $z$ to model the choice we are facing: use machine #1 or machine #2." ] }, { "cell_type": "code", "execution_count": 17, "metadata": {}, "outputs": [], "source": [ "# variables for total production\n", "desk = tm2.integer_var(name='desk', lb=100)\n", "cell = tm2.continuous_var(name='cell', lb=100)\n", "\n", "# two variables per machine type:\n", "desk1 = tm2.integer_var(name='desk1')\n", "cell1 = tm2.integer_var(name='cell1')\n", "\n", "desk2 = tm2.integer_var(name='desk2')\n", "cell2 = tm2.integer_var(name='cell2')\n", "\n", "# yes no variable\n", "z = tm2.binary_var(name='z')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Setup constraints\n", "\n", "- The constraint for painting machine limit is identical to the basic telephone model\n", "- Two extra constraints express the total production as the sum of productions on the two assembly machines.\n", "- Each assembly machine type has its own constraint, in which variable $z$ expresses the exclusive choice between the two." ] }, { "cell_type": "code", "execution_count": 18, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Model: decision_phone\n", " - number of variables: 7\n", " - binary=1, integer=5, continuous=1\n", " - number of constraints: 5\n", " - linear=5\n", " - parameters: defaults\n", " - objective: none\n", " - problem type is: MILP\n" ] } ], "source": [ "\n", "# total production is sum of type1 + type 2\n", "tm2.add_constraint(desk == desk1 + desk2)\n", "tm2.add_constraint(cell == cell1 + cell2)\n", "\n", "# production on assembly machine of type 1 must be less than 400 if z is 1, else 0\n", "tm2.add_constraint(0.2 * desk1 + 0.4 * cell1 <= 400 * z)\n", "# production on assembly machine of type 2 must be less than 430 if z is 0, else 0\n", "tm2.add_constraint(0.25 * desk2 + 0.3 * cell2 <= 430 * (1-z))\n", "\n", "# painting machine limit is identical\n", "# constraint #4: painting time limit\n", "tm2.add_constraint( 0.5 * desk + 0.4 * cell <= 490)\n", "\n", "tm2.print_information()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Expressing the objective\n", "\n", "The objective is identical: maximize total profit, using total productions." ] }, { "cell_type": "code", "execution_count": 19, "metadata": {}, "outputs": [], "source": [ "tm2.maximize(12 * desk + 20 * cell)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Solve with the Decision Optimization solve service" ] }, { "cell_type": "code", "execution_count": 20, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Version identifier: 12.10.0.0 | 2019-11-26 | 843d4de2ae\n", "CPXPARAM_Read_DataCheck 1\n", "Found incumbent of value 12800.000000 after 0.00 sec. (0.00 ticks)\n", "Tried aggregator 1 time.\n", "MIP Presolve modified 2 coefficients.\n", "Reduced MIP has 5 rows, 7 columns, and 14 nonzeros.\n", "Reduced MIP has 1 binaries, 5 generals, 0 SOSs, and 0 indicators.\n", "Presolve time = 0.00 sec. (0.01 ticks)\n", "Probing fixed 0 vars, tightened 1 bounds.\n", "Probing time = 0.00 sec. (0.00 ticks)\n", "Tried aggregator 1 time.\n", "Detecting symmetries...\n", "MIP Presolve modified 1 coefficients.\n", "Reduced MIP has 5 rows, 7 columns, and 14 nonzeros.\n", "Reduced MIP has 1 binaries, 6 generals, 0 SOSs, and 0 indicators.\n", "Presolve time = 0.02 sec. (0.01 ticks)\n", "Probing time = 0.00 sec. (0.00 ticks)\n", "MIP emphasis: balance optimality and feasibility.\n", "MIP search method: dynamic search.\n", "Parallel mode: deterministic, using up to 12 threads.\n", "Root relaxation solution time = 0.00 sec. (0.01 ticks)\n", "\n", " Nodes Cuts/\n", " Node Left Objective IInf Best Integer Best Bound ItCnt Gap\n", "\n", "* 0+ 0 12800.0000 32800.0000 156.25%\n", "* 0 0 integral 0 23200.0000 23200.0000 1 0.00%\n", "Elapsed time = 0.02 sec. (0.05 ticks, tree = 0.00 MB, solutions = 2)\n", "\n", "Root node processing (before b&c):\n", " Real time = 0.02 sec. (0.05 ticks)\n", "Parallel b&c, 12 threads:\n", " Real time = 0.00 sec. (0.00 ticks)\n", " Sync time (average) = 0.00 sec.\n", " Wait time (average) = 0.00 sec.\n", " ------------\n", "Total (root+branch&cut) = 0.02 sec. (0.05 ticks)\n", "objective: 23200.000\n", " desk=100\n", " cell=1100.000\n", " desk2=100\n", " cell2=1100\n" ] } ], "source": [ "tm2s= tm2.solve(log_output=True)\n", "assert tm2s\n", "tm2.print_solution()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Conclusion\n", "\n", "This model demonstrates that the optimal solution is to use machine #2 , producing 100 desk phones and 1100 cell phones." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Using binary variables for logical decisions\n", "\n", "What if the company had to choose between 3 possible candidates for the assembly machine, as opposed to two?\n", "\n", "The above model can be generalized with three binary variables $z1$, $z2$, $z3$ each of which is equal to 1 only if machine type 1,2, or 3 is used. But then we need to express that _exactly_ one of those variables must be equal to 1. How can we achive this?\n", "\n", "The answer is to add the following constraint to the model:\n", "\n", "$$\n", "z_{1} + z_{2} + z_{3} = 1\n", "$$\n", "\n", "Thus, if one of zs variables is equal to 0, the two other areequal to zero (remember binary variables can take value 0 or 1)." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Quadratic Programming\n", "\n", "In this topic, you’ll learn what a quadratic program (or QP) is, and learn how quadratic programming applies to portfolio management.\n", "\n", "## Quadratic Functions\n", "\n", "Mathematically, a function is quadratic if: \n", "- The variables are only first or second degree (that is, one variable may be multiplied by another variable, and any of the variables may be squared) and\n", "- The coefficients of the variables are constant numeric values (that is, integers or real numbers). \n", "\n", "A quadratic function is also known as a second degree polynomial function. \n", "\n", "Geometrically, a quadratic function is a curve or curved surface. For example, a quadratic function in two dimensions is a curved line, such as a parabola, hyperbola, ellipse, or circle. \n", "\n", "## What is a Quadratic Program?\n", "\n", "\n", "Quadratic Programs (or QPs) have quadratic objectives and linear constraints. A model that has quadratic functions in the constraints is a Quadratically Constrained Program (or QCP). The objective function of a QCP may be quadratic or linear. \n", "A simple formulation of a QP is:\n", "\n", "$$\n", "\t{minimize}\\ \\frac{1}{2}{x^{t}Qx + c^{t}x}\\\\ \n", "subject\\ to \\\\\n", "\\ \\ \tAx \\ge b \\\\\n", "\\ \\ \tlb \\le x \\le ub \\\\\n", "$$\n", "\n", "The first objective term is quadratic, with Q being the matrix of objective function coefficients of the quadratic terms. The second term and the constraints are linear. CPLEX Optimizer can solve convex QP and QCP problems. Quadratic programming is used in several real-world situations, for example portfolio management or chemical process modeling. In the next two slides, you’ll see how QP applies to portfolio management. \n", "\n", "A model that has quadratic functions in the constraints is a Quadratically Constrained Program (QCP). The objective function of a QCP problem may be quadratic or linear. " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Portfolio management\n", "\n", "In order to mitigate risk while ensuring a reasonable level of return, investors purchase a variety of securities and combine these into an investment portfolio. Each security has an expected return and an associated level of risk (or variance). \n", "\n", "Securities sometimes covary, that is, they change together with some classes of securities, and in the opposite direction of other classes of securities. An example of positive covariance is when shares in technology companies follow similar patterns of increases and decreases in value. On the other hand, as the price of oil rises, shares in oil companies may increase in value, but plastics manufacturers, who depend on petroleum as a major primary resource, may see their shares decline in value as their costs go up and vice versa. This is negative covariance. \n", "\n", "To optimize a portfolio in terms of risk and return, an investor will evaluate the sum of expected returns of the securities, the total variances of the securities, and the covariances of the securities. A portfolio that contains a large number of positively covariant securities is more risky (and potentially more rewarding) than one that contains a mix of positively and negatively covariant securities. \n", "\n", "### Potfolio optimization: what use?\n", "\n", "Portfolio optimization is used to select securities to maximize the rate of return, while managing the volatility of the portfolio and remaining within the investment budget. \n", "\n", "As the securities covary with one another, selecting the right mix of securities can change or even reduce the volatility of the portfolio with the same expected return. \n", "\n", "At a given expected rate of return, there is one portfolio which has the lowest risk. If you plot each lowest-risk portfolio for each expected rate of return, the result is a convex graph, called the efficient frontier. \n", "\n", "The risk-return characteristics of a portfolio change in a nonlinear fashion, and quadratic expressions are used to model them." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Data comes in two parts:\n", "\n", "- Basic data on shares: activity sector, expected return rate, and whether or not activity is based in North America\n", "- The covariance square matrix for all pairs of shares.\n", "\n", "The `pandas` Python data analysis library is used to store the data. Let's set up and declare the data." ] }, { "cell_type": "code", "execution_count": 21, "metadata": {}, "outputs": [], "source": [ "import pandas as pd\n", "from pandas import DataFrame" ] }, { "cell_type": "code", "execution_count": 22, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
returnarea
sector
treasury5N-Am.
hardware17N-Am.
theater26N-Am.
telecom12N-Am.
brewery8ww
highways9ww
cars7ww
bank6ww
software31ww
electronics21ww
\n", "
" ], "text/plain": [ " return area\n", "sector \n", "treasury 5 N-Am.\n", "hardware 17 N-Am.\n", "theater 26 N-Am.\n", "telecom 12 N-Am.\n", "brewery 8 ww\n", "highways 9 ww\n", "cars 7 ww\n", "bank 6 ww\n", "software 31 ww\n", "electronics 21 ww" ] }, "execution_count": 22, "metadata": {}, "output_type": "execute_result" } ], "source": [ "sec_data = {\n", " 'sector': ['treasury', 'hardware', 'theater', 'telecom', 'brewery', 'highways', 'cars', 'bank', 'software',\n", " 'electronics'],\n", " 'return': [5, 17, 26, 12, 8, 9, 7, 6, 31, 21],\n", " 'area': ['N-Am.', 'N-Am.', 'N-Am.', 'N-Am.', \"ww\", 'ww', 'ww', 'ww', 'ww', 'ww']\n", "}\n", "\n", "df_secs = DataFrame(sec_data, columns=['sector', 'return', 'area'])\n", "df_secs.set_index(['sector'], inplace=True)\n", "\n", "# store set of share names\n", "securities = df_secs.index\n", "df_secs" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### The covariance matrix\n", "\n", "Covraiance matrix is a square matrix (its size is the nu,ber of shares). The covariance matrix is also stored in a pandas DataFrame." ] }, { "cell_type": "code", "execution_count": 23, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
sectortreasuryhardwaretheatertelecombreweryhighwayscarsbanksoftwareelectronics
sector
treasury0.10.0000.00.00.00.00.00.0
hardware0.019.0-241.01.01.00.510.05.0
theater0.0-2.02812.01.01.00.0-2.0-1.0
telecom0.04.01220.01.02.00.03.04.0
brewery0.01.0204.0-1.5-2.0-1.01.01.0
highways0.01.011-1.53.52.00.51.01.5
cars0.01.012-2.02.05.00.51.02.5
bank0.00.500-1.00.50.51.00.50.5
software0.010.0-231.01.01.00.525.08.0
electronics0.05.0-141.01.52.50.58.016.0
\n", "
" ], "text/plain": [ "sector treasury hardware theater telecom brewery highways cars \\\n", "sector \n", "treasury 0.1 0.0 0 0 0.0 0.0 0.0 \n", "hardware 0.0 19.0 -2 4 1.0 1.0 1.0 \n", "theater 0.0 -2.0 28 1 2.0 1.0 1.0 \n", "telecom 0.0 4.0 1 22 0.0 1.0 2.0 \n", "brewery 0.0 1.0 2 0 4.0 -1.5 -2.0 \n", "highways 0.0 1.0 1 1 -1.5 3.5 2.0 \n", "cars 0.0 1.0 1 2 -2.0 2.0 5.0 \n", "bank 0.0 0.5 0 0 -1.0 0.5 0.5 \n", "software 0.0 10.0 -2 3 1.0 1.0 1.0 \n", "electronics 0.0 5.0 -1 4 1.0 1.5 2.5 \n", "\n", "sector bank software electronics \n", "sector \n", "treasury 0.0 0.0 0.0 \n", "hardware 0.5 10.0 5.0 \n", "theater 0.0 -2.0 -1.0 \n", "telecom 0.0 3.0 4.0 \n", "brewery -1.0 1.0 1.0 \n", "highways 0.5 1.0 1.5 \n", "cars 0.5 1.0 2.5 \n", "bank 1.0 0.5 0.5 \n", "software 0.5 25.0 8.0 \n", "electronics 0.5 8.0 16.0 " ] }, "execution_count": 23, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# the variance matrix\n", "var = {\n", " \"treasury\": [0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n", " \"hardware\": [0, 19, -2, 4, 1, 1, 1, 0.5, 10, 5],\n", " \"theater\": [0, -2, 28, 1, 2, 1, 1, 0, -2, -1],\n", " \"telecom\": [0, 4, 1, 22, 0, 1, 2, 0, 3, 4],\n", " \"brewery\": [0, 1, 2, 0, 4, -1.5, -2, -1, 1, 1],\n", " \"highways\": [0, 1, 1, 1, -1.5, 3.5, 2, 0.5, 1, 1.5],\n", " \"cars\": [0, 1, 1, 2, -2, 2, 5, 0.5, 1, 2.5],\n", " \"bank\": [0, 0.5, 0, 0, -1, 0.5, 0.5, 1, 0.5, 0.5],\n", " \"software\": [0, 10, -2, 3, 1, 1, 1, 0.5, 25, 8],\n", " \"electronics\": [0, 5, -1, 4, 1, 1.5, 2.5, 0.5, 8, 16]\n", "}\n", "\n", "dfv = pd.DataFrame(var, index=securities, columns=securities)\n", "dfv" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "There is a constraint that the total fraction of wealth invested in North American securities must be greater than some minimum value. To implement this constraint, we add a new column to df_secs, that is equal to 1 if and only if the area column equals \"N.-Am.\", else is equal to 0 (see later how we use this column to implemen the constraint)." ] }, { "cell_type": "code", "execution_count": 24, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
returnareais_na
sector
treasury5N-Am.1
hardware17N-Am.1
theater26N-Am.1
telecom12N-Am.1
brewery8ww0
highways9ww0
cars7ww0
bank6ww0
software31ww0
electronics21ww0
\n", "
" ], "text/plain": [ " return area is_na\n", "sector \n", "treasury 5 N-Am. 1\n", "hardware 17 N-Am. 1\n", "theater 26 N-Am. 1\n", "telecom 12 N-Am. 1\n", "brewery 8 ww 0\n", "highways 9 ww 0\n", "cars 7 ww 0\n", "bank 6 ww 0\n", "software 31 ww 0\n", "electronics 21 ww 0" ] }, "execution_count": 24, "metadata": {}, "output_type": "execute_result" } ], "source": [ "def is_nam(s):\n", " return 1 if s == 'N-Am.' else 0\n", "\n", "df_secs['is_na'] = df_secs['area'].apply(is_nam)\n", "df_secs" ] }, { "cell_type": "code", "execution_count": 25, "metadata": {}, "outputs": [], "source": [ "from docplex.mp.model import Model\n", "\n", "mdl = Model(name='portfolio_miqp')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We model variables as the _fraction_ of wealth to invest in each share. Each variable is a continuous variable between 0 and 1. Variables are stored in a column of the dataframe." ] }, { "cell_type": "code", "execution_count": 26, "metadata": {}, "outputs": [], "source": [ "# create variables\n", "df_secs['frac'] = mdl.continuous_var_list(securities, name='frac', ub=1)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Express the business constraints\n", "\n", "The business constraints are the following:\n", "\n", "- the sum of allocated fractions equal 100%\n", "- each security cannot exceed a certain percentage of the initial allocated wealth (here 30%)\n", "- there must be at least 40% of wealth invested in securities hosted in North America\n", "- compound return on investment must be less than or equal to a minimum target (say 9%)" ] }, { "cell_type": "code", "execution_count": 27, "metadata": {}, "outputs": [], "source": [ "# max fraction\n", "frac_max = 0.3\n", "for row in df_secs.itertuples():\n", " mdl.add_constraint(row.frac <= 0.3)\n", " \n", "# sum of fractions equal 100%\n", "mdl.add_constraint(mdl.sum(df_secs.frac) == 1);\n", "\n", "# north america constraint:\n", "# - add a 1-0 column equal to 1 \n", "# compute the scalar product of frac variables and the 1-0 'is_na' column and set a minimum\n", "mdl.add_constraint(mdl.dot(df_secs.frac, df_secs.is_na) >= .4);\n", "\n", "# ensure minimal return on investment\n", "target_return = 9 # return data is expressed in percents\n", "# again we use scalar product to compute compound return rate\n", "# keep the expression to use as a kpi.\n", "actual_return = mdl.dot(df_secs.frac, df_secs['return'])\n", "mdl.add_kpi(actual_return, 'ROI')\n", "\n", "# keep the constraint for later use (more on this later)\n", "ct_return = mdl.add_constraint(actual_return >= 9);" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Express the objective\n", "\n", "The objective or goal is to minimize risk, here computed as the variance of the allocation, given a minimum return rate is guaranteed.\n", "Variance is computed as a _quadratic_ expression, which makes this model a Quadratic Programming (QP) model" ] }, { "cell_type": "code", "execution_count": 28, "metadata": {}, "outputs": [], "source": [ "# KPIs\n", "fracs = df_secs.frac\n", "variance = mdl.sum(float(dfv[sec1][sec2]) * fracs[sec1] * fracs[sec2] for sec1 in securities for sec2 in securities)\n", "mdl.add_kpi(variance, 'Variance')\n", "\n", "# finally the objective\n", "mdl.minimize(variance)" ] }, { "cell_type": "markdown", "metadata": { "collapsed": true }, "source": [ "##### Solve the model\n", "\n", "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", "\n", "We display the objective and KPI values after the solve by calling the method report() on the model." ] }, { "cell_type": "code", "execution_count": 29, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "* model portfolio_miqp solved with objective = 0.406\n", "* KPI: ROI = 9.000\n", "* KPI: Variance = 0.406\n" ] } ], "source": [ "assert mdl.solve(), \"Solve failed\"\n", "mdl.report()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The model has solved with a target return of 9% and a variance of 0.406." ] }, { "cell_type": "code", "execution_count": 30, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "-- fraction allocated in: treasury : 30.00%\n", "-- fraction allocated in: hardware : 2.08%\n", "-- fraction allocated in: theater : 5.46%\n", "-- fraction allocated in: telecom : 2.46%\n", "-- fraction allocated in: brewery : 15.35%\n", "-- fraction allocated in: highways : 8.60%\n", "-- fraction allocated in: cars : 1.61%\n", "-- fraction allocated in: bank : 29.00%\n", "-- fraction allocated in: software : 4.34%\n", "-- fraction allocated in: electronics : 1.10%\n" ] } ], "source": [ "all_fracs = {}\n", "for row in df_secs.itertuples():\n", " pct = 100 * row.frac.solution_value\n", " all_fracs[row[0]] = pct\n", " print('-- fraction allocated in: {0:<12}: {1:.2f}%'.format(row[0], pct))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Let's display these fractions in a pie chart using the Python package [*matplotlib*](http://matplotlib.org/)." ] }, { "cell_type": "code", "execution_count": 31, "metadata": {}, "outputs": [ { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAAV0AAAD3CAYAAAC+eIeLAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8QZhcZAAAgAElEQVR4nOydd5iU1fXHP2dme28snV16XXoVQQSjiViSGDVRE00sQRNTfpqImkSMDWuMCpbEgi32vrYEFFC69F6XvsD2vjvl/P5434Vl2WXblIW9n+eZh5n3ve+95x1mv3Pn3HPPEVXFYDAYDIHBEWwDDAaDoS1hRNdgMBgCiBFdg8FgCCBGdA0GgyGAGNE1GAyGAGJE12AwGAKIEd02ioi8JCL32s8nici+YNt0MlqrjSJyh4j8O9h2GE4djOie5ojI1yKSLyLhQbbjqMj7qX8VkVIRKbEfBX4Y4wThV9X7VfU6X49lOH0xonsaIyLpwARAgYuCakxgGKKqMfYjoa4GIhISaKMMhpoY0T29+QWwBHgJuLqxF4lIf3uGXCAiG0TkohrnIkXkURHZLSKFIvKNiETa594WkWz7+AIRGWgfvwG4EvizPQv92D7eSUTeFZEjIrJLRH5Xa5yX7Fn6RmBUc96A6tmpiNwmItnAiyKSKCKf2OPm28+71LgmSUReFJED9vkPRCQa+AzoVGM23UlEZojIqzWuvch+zwrs97B/jXNZInKriKy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1heOz+KXKjwU/L70dAw455w4O/BEZ0zsLXTNoOecEH77ZzrmPwvpcERkLxFT1N67wfR4Cpqrq4ykoywwSOYk3MSY9OecUaIu6DmP6wuZeMKZ/ckTk30WkVkQ2icg1IvKkiNSIyPsiskZEBEBEXheRp0TkbRH5QES6LXcvIr8vIltFpDD8QzFhstA1pn/GAWtU9VagGXgUP0HR7UG3wyeA+V22z1HV38JfSv2trm8kIp8HngDmqWpDKNWbyFj3gjH9c0hVtwT31wNfAw6IyNeBa4Dh+FUiXgq2eSH4uR0/AX2nmcBU4G5VbR7ook30rKVrTP9cegZagX8G7gum41zLxdNxdvY9x7m4sbMfGMrgvIjE9IOFrjH9M0ZEpgX3y4A3gvsNInItcF+S73MQfwn1c8EUnybDWega0z97gAdFpBbflbAS37p9D3gRf+FFUlR1L37S8x+JyE0DUKtJIzZO1xhjQmQtXWOMCZGFrjHGhMhC1xhjQmSha4wxIbLQNcaYEFnoGmNMiCx0jTEmRBa6xhgTIgtdY4wJkYWuMcaEyELXGGNCZKFrjDEhstA1xpgQWegaY0yILHSNMSZEFrrGGBMiC11jjAmRha4xxoTIQtcYY0JkoWuMMSH6fwZKkTnIXHFGAAAAAElFTkSuQmCC", "text/plain": [ "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "%matplotlib inline\n", "import matplotlib.pyplot as plt\n", "\n", "def display_pie(pie_values, pie_labels, colors=None,title=''):\n", " plt.axis(\"equal\")\n", " plt.pie(pie_values, labels=pie_labels, colors=colors, autopct=\"%1.1f%%\")\n", " plt.title(title)\n", " plt.show()\n", " \n", "display_pie( list(all_fracs.values()), list(all_fracs),title='Allocated Fractions')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## What-if analysis: trying different values for target return\n", "\n", "The above model was solved with a 'hard coded' value of 9% for the target. \n", "Now, one can wonder how variance would vary if we changed this target return value.\n", "\n", "In this part, we will leverage DOcplex model edition capabilities to explore different scenarios with different target return values.\n", "We will run the model for target return values betwen 4% and 20%. For each possible target return value,\n", "we modify the right-hand side (or _rhs_) of the `ct_target` constraint we kept as a variable, and solve again,\n", "keeping the values in a list.\n" ] }, { "cell_type": "code", "execution_count": 32, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "- for a target return of: 5%, variance=0.28105252209449944\n", "- for a target return of: 6%, variance=0.28105252214416476\n", "- for a target return of: 7%, variance=0.28105252225011274\n", "- for a target return of: 8%, variance=0.30818590869638357\n", "- for a target return of: 9%, variance=0.40557734940356227\n", "- for a target return of: 10%, variance=0.5503435250054378\n", "- for a target return of: 11%, variance=0.7417945731282698\n", "- for a target return of: 12%, variance=0.9798459646928664\n", "- for a target return of: 13%, variance=1.2598935443762442\n", "- for a target return of: 14%, variance=1.5813755540443808\n", "- for a target return of: 15%, variance=1.9442235946080064\n", "- for a target return of: 16%, variance=2.3469592331334908\n", "- for a target return of: 17%, variance=2.7889850545628727\n", "- for a target return of: 18%, variance=3.2707284094234224\n", "- for a target return of: 19%, variance=3.792503995389222\n", "- for a target return of: 20%, variance=4.3543118101284675\n" ] } ], "source": [ "target_returns = range(5,21) # from 5 to 20, included\n", "variances = []\n", "for target in target_returns:\n", " # modify the constraint's right hand side.\n", " ct_return.rhs = target\n", " cur_s = mdl.solve()\n", " assert cur_s # solve is OK\n", " cur_variance = variance.solution_value\n", " print('- for a target return of: {0}%, variance={1}'.format(target, cur_variance))\n", " variances.append(cur_variance)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Again we use `matplotlib` to print variances vs. target returns." ] }, { "cell_type": "code", "execution_count": 33, "metadata": {}, "outputs": [ { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYIAAAEWCAYAAABrDZDcAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8QZhcZAAAgAElEQVR4nO3deZyVZfnH8c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IM1fcHa5nsMqm1sE1l78QtJ4UvfGf0hzRLQHV7LsWEA5dAIuLvNzWAVzi8DMrMq5RWBmVuWcCMzMqpwTgZlZlXMiMDOrck4EZmZV7v8BuHfAElFzvI0AAAAASUVORK5CYII=", "text/plain": [ "
" ] }, "metadata": { "needs_background": "light" }, "output_type": "display_data" } ], "source": [ "plt.plot(target_returns, variances, 'bo-')\n", "plt.title('Variance vs. Target Return')\n", "plt.xlabel('target return (in %)')\n", "plt.ylabel('variance')\n", "plt.show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Not surprisingly, variance is increasing with target return." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "# Summary\n", "\n", "Having completed this notebook, you should be able to:\n", "\n", "- Describe what a network model is, and the benefits of using network models\n", "\n", "- Explain the concepts of nonlinearity and convexity\n", "\n", "- Describe what a piecewise linear function is\n", "\n", "- Describe the differences between:\n", " - Linear Programming (LP)\n", " - Integer Programming (IP)\n", " - Mixed-Integer Programming (MIP)\n", " - Quadratic Programming (QP)\n", "\n", "- Construct a simple MIP model" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## References\n", "* [CPLEX Modeling for Python documentation](http://ibmdecisionoptimization.github.io/docplex-doc/)\n", "* [IBM Decision Optimization](https://www.ibm.com/analytics/decision-optimization)\n", "* Need help with DOcplex or to report a bug? Please go [here](https://stackoverflow.com/questions/tagged/docplex).\n", "* Contact us at dofeedback@wwpdl.vnet.ibm.com." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "anaconda-cloud": {}, "interpreter": { "hash": "20aa0f211a07fbaa9d391b57d605bb1f7be15b53be5598b8bf3e5eb62b0c712b" }, "kernelspec": { "display_name": "Python 3.8.8 ('py388')", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.8" } }, "nbformat": 4, "nbformat_minor": 1 }