Computer Application for business (CS202) Term 093 Excel Solver Using Excel Solvers for Optimization You can solve the step-by-step an optimization problem below using Excel alone -- but if you need to solve problems with more than 200 variables, consider to use Excel Solver. What are Solvers Good For? Solvers, or optimizers, are software tools that help users find the best way to allocate scarce resources. The resources may be raw materials, machine time or people time, money, or anything else in limited supply. The "best" or optimal solution may mean maximizing profits, minimizing costs, or achieving the best possible quality. An almost infinite variety of problems can be tackled this way, but here are some typical examples: Finance and Investment Working capital management involves allocating cash to different purposes (accounts receivable, inventory, etc.) across multiple time periods, to maximize interest earnings. Capital budgeting involves allocating funds to projects that initially consume cash but later generate cash, to maximize a firm's return on capital. Portfolio optimization -- creating "efficient portfolios" -- involves allocating funds to stocks or bonds to maximize return for a given level of risk, or to minimize risk for a target rate of return. Manufacturing Job shop scheduling involves allocating time for work orders on different types of production equipment, to minimize delivery time or maximize equipment utilization. Blending (of petroleum products, ores, animal feed, etc.) involves allocating and combining raw materials of different types and grades, to meet demand while minimizing costs. Cutting stock (for lumber, paper, etc.) involves allocating space on large sheets or timbers to be cut into smaller pieces, to meet demand while minimizing waste. Distribution and Networks Routing (of goods, natural gas, electricity, digital data, etc.) involves allocating something to different paths through which it can move to various destinations, to minimize costs or maximize throughput. Loading (of trucks, rail cars, etc.) involves allocating space in vehicles to items of different sizes so as to minimize wasted or unused space. Computer Application for business (CS202) Term 093 Excel Solver Scheduling of everything from workers to vehicles and meeting rooms involves allocating capacity to various tasks in order to meet demand while minimizing overall costs. Example PROBLEM DEFINITION: minimize f(X) s.t. h1(X) g1(X) g2(X) f(X) X1,X2 h1 g1 g2 = = = = 0 0 2*X1 X1 X1 2*X1 < X1 < X2 + + < < X2 2*X2 - 2 = 0 X2 - 2 > 0 3*X2 - 12 < 0 10 infinity : objective function (OBJ) : decision variables : equality constraint : first inequality constraint : second inequality constraint EXCEL WORKSHEET: Examine the worksheet shown in Fig.1 below. Only the cells with cyan-colored background contain formulas; other cells are all text enteries used to facilitate readibility of the worksheet. Cell B20 contains the formula of the objective function: =(2*B15-B1), Cell B23 contains the formula of the equality constraint: =B15-2*B16-2, Cell B26 contains the formula of the first inequality constraint: =B15+B16-2, Cell B29 contains the formula of the second inequality constraint: =2*B15+3*B16-12. The cells B15 and B16 contain the initial guesses for the decision variables. These can be set to zero or to any other good starting values (if you do not enter any number to these cells, Excel`s Solver will take them as zero). Before calling the Solver (as in Fig.1), the cells B20, B23, B26, and B29, corresponding to the functions entered (objective and constraints) are evaluated with the initial-guess values (check!). As you see, with this initial guesses, the equality constraint and the first inequality constraint are violated. Computer Application for business (CS202) Term 093 Excel Solver Now, we will call the Solver to find the values of the decision variables that give minimum value to the objective function and, at the same time, satisfy the three constraints. FIGURE-1: HOW TO CALL & ENTER THE SOLVER PARAMETERS: To activate the SOLVER, select Solver from the Tools menu with mouse. A dialog box will appear as shown in Fig.2 below. FIGURE-2: Computer Application for business (CS202) Term 093 Excel Solver Set Target Cell: Highlight the target-cell box by selecting the cell contents with mouse, then click on the cell B20 in the worksheet (i.e., cell to the right of "F ="; the objective function). $B$20 should appear in the target-cell box. This target-cell box contains your objective function. Equal to: Select the "Min" option for minimization. The "Value of" option is generally used to solve a single algebraic equation (or set of equations, in which case the residual norm of the right-hand sides of the set of functions in the form f(x)=0 is set to zero). See the ChE_110 Home Page for applications of Excel`s Solver in solution of linear/nonlinear set of mass-balance equations. By Changing Cells: Highlight this box by selecting the cell contents with mouse, then select the cells B15 and B16 in the worksheet with mouse (i.e., the cell to the right of "x1=" and "x2="). $B$15:$B$16 should appear in the box. This box identifies the location of the decision variable (or the vector of decision variables) in the worksheet. Subject to Constraints: Click on the "Add..." button. A new dialog box will appear as shown in Fig.3 below. FIGURE-3: Cell Reference (left box): This cell should contain the cell reference corresponding to the variable (e.g., side constraints --lower/upper bounds-) or function (e.g., equality/inequality constraint) which is constrained. Make sure that the cursor is in this box, then, click on the cell B23 in the Computer Application for business (CS202) Term 093 Excel Solver worksheet to enter the equality constraint. $B$23 should appear in the left box. Constraint (middle box): Select the constraint type as "=" for the equality constraint (options are: equal, less than or equal, greater than or equal, integer). Constraint (right box): This cell should contain the right-hand-side value of the constraint (or, the cell reference that contains the value of the righthand side). Since we are entering the equality constraint in the standard form as h1(x)=x1-2*x2-2=0 enter 0 (zero). When you complete the fields, click on the "Add" button. Then you are ready to repeat the steps to enter the next constraint. For our problem, next enter the first inequality constraint (left box: B26, middle box: =>, right box: 0), second inequality constraint (left box: B29, middle box: <=, right box: 0), lower bound on decision variable X1 (left box: B15, middle box: =>, right box: 0), lower bound on decision variable X2 (left box: B16, middle box: =>, right box: 0), and uper bound on decision variable X1 (left box: B15, middle box: <=, right box: 10). When you entered the last constraint, this time click on the "OK" button. You will return automatically to the first dialog pane of the Solver. Options: To modify the Solver`s Options used in its numerical algorithms, click the "Options" button; a dialog box will appear as shown in Fig.4 below. The selected options in the figure are for general nonlinear optimization problems (NLPs). For our example problem which is a linear programing problem (LP), it is best to check the "Assume Linear Model". Click on the "Help" button to learn more on each option`s functionality. Do not check the box "Assume Linear Model" if your objective function and/or constraint functions are not linear ! To see the results of the major iterations on the worksheet, check the box "Show iteration results". Click on the "OK" button to return to main Solver menu (Fig.2). FIGURE-4: Computer Application for business (CS202) Term 093 Excel Solver CLOSING REMARKS: When you complete everthing, the "Solver Parameters" dialog pane should look like Fig.5 given below (for our example LP problem). FIGURE-5: Click on the "Solve" button. If you have checked the box "Show Iteration Results", you will be prompted with "Continue" dialog box after each major iteration. You may see the progress of optimization by looking at the worksheet and the bottom of the window. When you come to "Solver Results" dialog pane, please read its Help (see Fig.6 below). By default "Keep Solver Solution" box will be checked. If you press the Computer Application for business (CS202) Term 093 Excel Solver "OK" button, your worksheet variables will be replaced by their values at the optimum solution found by the Solver. Remember that, in Fig.1, the cells B15 and B16 contained the initial gusses of the decision variables. Now, as you see in Fig.6 below, the cells B15 and B16 contain the optimal values of the decision variables with which the objective function is minimized and the constraints are satisfied. Double click on "Answer" to see an Answer Report (see the sheet tabs at the bottom of the worksheet). After the final iteration your worksheet will look like Fig.6 given below. FIGURE-6: Computer Application for business (CS202) Term 093 Excel Solver Check the optimal solution suggested by the Solver! Are all the constraints satisfied?