Solving a Linear Program Using the Excel Solver

The following tutorial describes how to solve the linear program

Max 2x_1 + 3x_2, subject to x_1+2x_2 £ 4, 2x_1-x_2 £ 3, x_1³ 0, x_2³ 0.

 

  1. First choose cells to represent your decision variables. In these example, we shall use cell A1 to represent x_1 and A2 to represent x_2.
  2. Next define the objective function in another cell. For example, we can define cell B1 by click on cell B1 and then typing =2*A1+3*A2 in the formula bar.
  3. Next define each of the explicit constraint functions. For example, define C1 by the expression =A1+2*A2, and define C2 by =2*A1-A2.
  4. Having defined all of the functions, we now need to tell the solver how to use these functions. To do this, use the following procedure:
  1. On the Tools menu, click Solver.
  2. If the Solver command is not on the Tools menu, you need to install the Solver add-in. (See instructions here).

    You should see the following box:

  3. In the Set Target Cell box, enter the cell reference for the objective function. In our case, enter B1. (Shortcut: Click on the Set Target Cell box, then click on cell B1 in the spreadsheet).
  4. To have the value of the target cell be as large as possible, click Max.
  5. To have the value of the target cell be as small as possible, click Min.

    To have the target cell be a certain value, click Value of, and then type the value in the box.

  6. In the By Changing Cells box, enter the cell references for each of the decision variables, separating nonadjacent references with commas. The adjustable cells must be related directly or indirectly to the target cell. You can specify up to 200 adjustable cells. In our example, enter A1:A2
  7. To have Solver automatically propose the adjustable cells based on the target cell, click Guess.

  8. In the Subject to the Constraints box, enter any constraints you want to apply. For each constraint do the following:
    1. Click Add. This will bring up the following dialog box:
    2. In the cell Reference box, enter the cell reference for the constraint.
    3. In the middle box choose one of <=, =, >=.
    4. In the Constraint box, enter the right hand side of the constraint.
    5. So for our first constraint, we would enter C1 in the Cell Reference box, choose <=, and enter 4 in the Constraint box.
    6. Click OK
    7. Repeat for each constraint. (Don't forget the bound constraints!)
  9. When you are done specifying the constraints, the solver parameters box should look as follows:
  10. Click Solve. You will then see the following box:
  11.  

  12. To keep the solution values on the worksheet, click Keep Solver Solution in the Solver Results dialog box. (This means that the values for your decision variables have been altered, with the corresponding changes to the cells defining the objective function and constraint functions.
  13. To restore the original data, click Restore Original Values.

  14. Finally, you can choose the reports you want to generate in the Reports box.