MIP 1: Solvers and Branch-and-Bound

Packages Used: Functions from the following packages are used in this notebook for the first time:

Mixed-integer programming is used when some of the decision variables need to be integer-valued and/or, more importantly, decisions need to be made as part of the solution procedure, and these "internal decisions" can only be implemented using discrete (typically binary) decision variables.

Mixed-integer program MIP NLP + some integer variables
Mixed-integer linear program MILP LP + some integer variables
Integer linear program ILP LP + all integer variables
Binary integer program BIP LP + all binary variables

In the following, the focus will be on MILP because it has the widest range of applications. Due to the difficultly in implementing effective procedures, MIP with NLP is usually restricted to only a handful of special NLP models like quadratic programming (QP).

1. Solving a MILP

Branch and Bound Steps

$ \begin{eqnarray} \quad \mbox{Maximize} \quad 6x_1 + 8x_2 \\ \quad \mbox{subject to} \quad 2x_1 + 3x_2 &\le& 11 \\ 2x_1 &\le& 7 \\ x_1, x_2 \ge 0 \mbox{, integer} \\ \end{eqnarray} $

image.png

image.png

image.png

For a maximization problem, solving the problem as an LP without integer variable constraints provides an upper bound on the integer-restricted solution. Initially, the lower bound on the solution is zero because the variables are restricted to being nonnegative. Once the first integer feasible solution is found (termed the incumbent solution), it then becomes the current lower bound. The difference between the UB and LB defines the gap, and the search continues through the branch and bound tree until the gap falls below a threshold. Solutions that are not feasible are fathomed, that is, eliminated from the search tree.

First, solve as an LP (branch node 0 in tree):

Next, select one of the fractional decision variables and add two integer constraints to the tree. Selection of the variable can be based on the most fractional, least fractional, and many other criteria.

At node 6, the absolute value of the gap was less than one, and as a result, the procedure could stop. In practice, only the relative percentage gap is determined, and the search continues until the gap approaches zero or the complete tree has been searched; as a result, in practice, nodes 7 and 8 might be evaluated before being fathomed. Since the branch and bound tree can grow exponentially, in many applications, the search can be stopped when the relative gap falls below a value of 1%, for example.

Solve as an ILP

Solve as an ILP (integer linear program) directly:

Here, the GLPK message level GLPK.GLP_MSG_DBG is being used instead of GLPK.GLP_MSG_ALL so that details of the brand and bound procedure are output:

MIP Solvers

JuMP supports a large number of solvers (full list). The following table lists the most well-known commercial and open-source MIP solvers:

Cplex IBM, first commercial solver
Gurobi Developed by Robert Bixby
FICO Xpress Used by LLamasoft
SAS/OR Part of SAS system (not supported in JuMP)
Cbc COIN-OR open-source solver
GLPK Free Software Foundation GNU open-source solver

The OR Software Stack:

image.png

Solver Features:

image.png

Internal Decisions

In an LP, no decision variable can be restricted to being integer-valued, and no decisions can be made (internally) as part of the solution procedure. In practice, what usually necessitates representing a problem as a MILP is that that one or more discrete decisions need to be made as part of the solution procedure. This leads to the following uses of discrete decision variables in a MILP:

  1. Integer variable: Variable is inherently discrete
  1. Direct decision: Internal decision variables are used to indicate a choice between two or more alternatives
  1. Indirect control: Internal decision variables used to control other continuous and discrete variables

2. Integer Variables

In a MILP, some of the decision variables can be restricted to being integer-valued so that they can better represent model entities that are inherently discrete.

Ex 1: Employee Staffing

In Ex 4 in LP 3, although the number of employees is inherently a discrete value, the total number of employees was high enough that just rounding the continuous LP solution was reasonable. In this example, the number of employees is small enough that just rounding results in significant error in the solution and, instead, the number of employees is treated as an integer value:

Rounded-up continuous-valued variables:

Integer-valued variables:

Ex 2: Bagged Coffee and Peppers Arbitrage Opportunity

In Ex 1 in LP 2, the size of individual coffee beans and peppers are small enough relative to the size of the knapsack that representing the quantities of both as continuous variables seems reasonable:

If only a few units of each item are being considered, then just rounding a continuous variable may lead to a nonoptimal result; instead, integer-valued variables could be used to represent the quantities of each item. For example, if the coffee and peppers only could be purchased in 4-pound bags, then rounding the continuous result to get the number of 4-bags would give a result that exceeds the 30-pound weight limit:

In order to correcly account for the 4-pound bags, the model can include integer restrictions on the $x_i$, which makes it a MILP and where the quantities $x_i$ now represent the numbers of bags instead of pounds purchased, which reduces the total profit from \$195 to \\$192:

3. Gurobi Solver Installation

Gurobi is a commercial MIP solver that is free for students. It is able to solve some MIPs that might be difficult for the open-source GLPK solver that we have been using. You will not need to use Gurobi for any of the assignments in this class, but you may want to use it for your other needs if you find GLPK not able to solve your MILP model.

To install, you will need to download a copy of the Individual Academic License of Gurobi to your local machine. You will need to create an account using your @ncsu.edu email and then access your free named-user academic license while connected to the NCSU network on campus. If you are off-campus and want to connect to the NCSU network using AnyConnect VPN), you will need to first request full tunnel VPN access via this form - https://ncsu.service-now.com/oit_help?id=sc_cat_item_no_crumbs&sys_id=d58ac9b9db47ef00564ef9051d9619b8 (the normal VPN is split tunnel). On Windows, Gurobi can be installed in the default c:\gurobi912 folder, and the license file guorbi.lic should be stored in this location. After registering the software with the license, you will be able to use Gurobi anywhere (you only need to be on the NCSU network for your initial download).

After closing the window, you can then add Gurobi and build Gurobi in the Julia REPL in order to access it in Jupyter and allow JuMP to use it as its solver. You can test your installation by running the following: