330 likes | 347 Views
Learn how to model complex problems using 0-1 variables and integers with optimization techniques in Excel's Solver for IP models.
E N D
Chapter 6 Optimization Models with Integer Variables
Introduction • In this chapter, we show how many complex problems can be modeled using 0–1 variables and other variables that are constrained to have integer values. • A 0–1 variable is a decision variable that must equal 0 or 1. Usually a 0–1 variable corresponds to an activity that either is or is not undertaken. • If the 0–1 variable corresponding to the activity equals 1, the activity is undertaken; if it equals 0, the activity is not undertaken. A 0–1 variable is also called a binaryvariable.
Introduction continued • Optimization models in which some or all of the variables must be integers are known as integer programming (IP) models. • In this chapter, we illustrate many of the modeling techniques that are needed to formulate IP models of complex situations. • You should be aware that any optimization software, including Excel’s Solver, typically has a much harder time solving an IP problem than an LP problem.
Overview of optimization with integer variables • When Excel’s Solver solves a linear model without integer constraints, it uses a very efficient algorithm, the simplex method, to perform the optimization. • The simplex method is efficient because it typically examines only a very small fraction of the hundreds, thousands, or even millions of possible corner points before determining the best corner point. • The main difference between LP and IP models is that LP models allow fractional values, such as 0.137 and 5.3246, in the changing cells, whereas IP models allow only integer values in integer-constrained changing cells.
Overview of optimization with integer variables continued • Although several solution methods have been suggested by researchers - and new methods for specialized problems are still being developed - the solution procedure used by Solver is called branch and bound.
Branch and bound algorithm • Consider a model with 100 changing cells, all constrained to be binary. Because there are only two values for each binary variable - 0 and 1 - there are potentially 2100 feasible solutions, although many of these might not satisfy all of the constraints. • Unfortunately, 2100is an extremely large number, so it would take even a very fast computer a long time to check each one of them. Therefore, the naive method of complete enumeration of all possible solutions - look at each solution and select the best - is usually impractical.
Branch and bound algorithm continued • However, implicit enumeration is often very practical. This approach examines only a fraction of all 2100potential solutions and guarantees that solutions not examined have no chance of being optimal. • Ageneral idea is the essence of the branch and bound method used by Solver in IP models. • The branching part means that the algorithm systematically searches through the set of all feasible integer solutions, creating branches, or subsets, of solutions as it goes.
Branch and bound algorithm continued • The key, however, is the bounding part of the algorithm. Every time the best feasible solution is found, it is called the incumbent solution – the best so far. It is the easy part of the bounding procedure, and the solution represents a lower bound on the optimal solution (for a maximize objective). • The upper bound is more difficult to find, and the procedures used to find upper bounds are beyond the level of this book.
Solver Tolerance setting • The Solver Options dialog box contains a Tolerance setting, which is relevant for integer-constrained models. • Excel’s default tolerance is 5%. In Excel 2010, this setting, listed as Integer Optimality (%), is found under Solver Options in the dialog box shown here.
Solver Tolerance setting continued • To explain the Tolerance option, we must first define the LP relaxation of an IP model. • This is the same model as the IP model, except that all integer constraints are omitted. • In particular, cells that are originally constrained to be binary are allowed under the LP relaxation to have any fractional values between 0 and 1 (including 0 and 1). • The LP relaxation is typically easy to solve (using the simplex method), and it provides a bound for the IP model.
Solver Tolerance setting continued • A tolerance setting of 5% means that Solver stops as soon as it finds a feasible (integer) solution to the IP model that is within 5% of the current upper bound. • Initially, the optimal objective value of the LP relaxation serves as the upper bound. As Solver proceeds to find solutions that satisfy the integer constraints, it keeps updating the upper bound. • The important point is that when Solver stops, it guarantees an integer solution that is within at least 5% of the optimal integer solution.
Solver Tolerance setting continued • The implication is that if you set the tolerance to 0%, Solver will (in theory) run until it finds the optimal integer solution. So why isn’t a tolerance setting of 0% always used? • The reason is that for many IP models, especially large models, it can take Solver a long time to find the optimal solution (or guarantee that the best solution found so far is optimal). • On the other hand, a solution that is close to optimal - within 5%, say - can often be found quickly.
Solver messages • When you run Solver on some of the difficult problems in this chapter, you might get different messages, shown below. • You have two options: • Change the options in Solver settings • Click on Continue to let Solver run longer. We recommend the second option.
Capital budgeting models • Perhaps the simplest binary IP model is the following capital budgeting example, which illustrates the go/no-go nature of many IP models. • Example 6.1 demonstrates a typical capital budgeting model.
Fixed-cost models • In many situations, a cost is incurred if an activity is undertaken at any positive level. This cost is independent of the level of the activity and is known as a fixed cost (or fixed charge). • Here are three examples of fixed costs: • The construction of a warehouse incurs a fixed cost that is the same whether the warehouse is built with a low- or a high-capacity level. • A cash withdrawal from a bank incurs a fixed cost, independent of the size of the withdrawal. • A machine that is used to produce several products must be set up for the production of each product. Regardless of the batch size produced, the same fixed cost (lost production due to the setup time) is incurred.
Fixed-cost models continued • In these examples, a fixed cost is incurred if an activity is undertaken at any positive level, whereas no fixed cost is incurred if the activity is not undertaken at all. • Although it might not be obvious, this feature makes the problem inherently nonlinear, which means that a straightforward application of LP is not possible. • However, a clever use of 0–1 variables can result in a model with linear constraints and a linear objective.
Fixed-cost models continued • It is important to realize that you do not simply create an LP model and then add integer constraints. • Instead, you use 0-1 variable to model the logic. • The logic in this section is that if a certain activity is done on any positive level, a fixed cost is incurred. • No fixed cost is incurred if the activity is not done at all. • Solver is able to handle linear models with binary variables, so this is the approach you should take whenever possible. • Example 6.2 is used to demonstrate this type of model.
A model with IF functions • In case you are still not convinced that the binary variable approach is required, and you think IF functions could be used instead, take a look at the finished version of the file. • The resulting model looks the same, but it incorporates the following changes: • We no longer use the binary range as part of the changing cells range. Instead, we enter the formula =IF(B16>0,1,0) in cell B14 and copy it across to cell F14. • We model the effective capacities in row 18 with IF functions. Specifically, we enter the formula =IF(B16>0,MIN($D$22/B5,$D$23/B6),0)in cell B18 and copy it across to cell F18.
A model with IF functions continued • We change the Solver dialog box so that it appears as shown below. The Rent_equipmentrange is not part of the changing cells range, and there is no binary constraint.
A model with IF functions continued • When we ran Solver on this modified model, we found inconsistent results, depending on the initial production quantities entered in row 16. • However, when we entered initial production quantities all equal to 100, Solver found the correct optimal solution. • The moral is that the IF-function approach is not the way to go. Its success depends strongly on the initial values we enter in the changing cells, and this requires us to make very good guesses. The binary approach ensures that we get the correct solution.
Either-or constraints • The following example is similar to the Great Threads example in that there is a fixed cost for any positive level of production of a given product. • However, an additional requirement states that if the company produces any of a given product, then (possibly because of economies of scale) it must produce at least some minimal level such as 1000. • This is a typical example of a problem with either-or constraints: The company’s level of production must either be 0 or at least 1000. • In the next example, we show how the use of binary variables allows you to model the either-or constraints in a linear manner.
Set-covering and location-assignment models • Many companies have geographically dispersed customers that they must service in some way. • To do this, they create service center facilities at selected locations and then assign each customer to one of the service centers. • Various costs are incurred, including: • Fixed costs of locating service centers in particular locations; • Operating costs, depending on the service centers’ locations; and • Transportation costs, depending on the distances between customers and their assigned service centers.
Set-covering and location-assignment models continued • We first examine a particular type of location model called a set-covering model. • In a set-covering model, each member of a given set (set 1) must be “covered” by an acceptable member of another set (set 2). • The usual objective in a set-covering problem is to minimize the number of members in set 2 that are needed to cover all the members in set 1. • Set-covering models have been applied to areas as diverse as airline crew scheduling, truck dispatching, political redistricting, and capital investment. Example 6.4 presents a typical set-covering model.
Assignment models • Example 6.5 is similar to a set-covering model, but it also has an assignment model.
Cutting stock models • The final model we discuss in this chapter has found many real-world applications, especially in manufacturing. • The model is relevant in situations where a product is produced in a standard size, which must then be cut into one of several patterns to satisfy customer orders. • In contrast to the other models in this chapter, this cutting stock model does not have binary variables, but it does have integer variables. The problem is relatively easy to model, but it can be very time-consuming for Solver to solve. • IP models are inherently more difficult to solve than general LP problems. • The model in example 6.7 illustrates that this is definitely the case.
Solver Tolerance setting • Until now, we have suggested setting the Solver tolerance to 0%. • This guarantees the optimal solution. However, this example illustrates why the default tolerance setting is 5%. • When we set the tolerance to 0% and click on Solve, the Solver quickly got to a solution that requires 47 rolls, but then ran and ran and ran. • After some experimenting, we found that with the tolerance set at 2% or above, the solution was obtained almost instantaneously, but with the tolerance set at 1% or 0%, it ran seemingly forever.
Solver Tolerance setting continued • This behavior is not at all uncommon in IP models. • The Solver often finds a very good or even optimal solution very quickly, but it takes a long time to verify that it is optimal. • The moral is clear. • If you set the tolerance to a low value and find that the Solver is taking forever without getting anywhere, press Ctrl-Break to get out. By that time, you probably already have a very good or even optimal solution.
Conclusion • Three important points emerge from this chapter. • A wide variety of important problems can be modeled as IP problems with binary variables. These can generally be identified as problems where at least some of the activities (such as making a particular investment, opening a particular plant, or supplying a customer from a particular plant) must be done or not done; there is no in-between. • Regular LP models cannot handle these problems; IP models with binary variables often can.
Conclusion continued • Some IP models are simply LP models with integer constraints on the variables. • These problems can often be solved by solving the associated LP model and then rounding the solution to integer values. • Although there is no guarantee that the rounded solution is optimal, it is often close enough. • In contrast, most of the problems discussed in this chapter introduce binary decision variables that specify whether an activity is done or not. If you ignore the binary constraints and only constrain these variables to be between 0 and 1, it is generally impossible to find the optimal solution by rounding.
Conclusion continued • The solution approach required for IP problems, especially those with 0-1 variables, is inherently more difficult than the simplex method for LP problems. • Analysts typically employ heuristic methods on these really difficult problems.