Monday, September 12, 2011

How to Set Up a Linear Program in Excel 2007


Linear Program Setup
1. Enter a title for your linear program in cell A1. Enter labels for your variables in cells C3 and D3.
2. Type your variable coefficients in cells C5 and D5. List each coefficient in the column that corresponds to its respective variable.
3. Create a border around cells C6, D6 and B7. Cells C6 and D6 will be used to display the optimal solutions for your variables, and cell B7 will be used to show the value of the objective function given the optimal variable values.
4. List your constraints beginning with cell C9 and continuing down one row for each constraint. Use a different cell for each element of your constraints, including the inequality symbols, but excluding the operator symbols, such as the plus or minus symbol.For example, if one of your constraints is 3x1 6x2
5. Type the heading 'LHS' under your constraints in column C, and type the heading 'RHS' beside it in column D. List the right-hand-side values of your constraints vertically under the RHS heading, and create borders for each corresponding cell under the LHS heading. The LHS cells will be used to display the actual left-hand-side values of your constraints for the optimal solution.
6. Enter the formula '=SUMPRODUCT(C5:D5,C6:D6)' in cell B7, the optimal solution output cell. This formula will calculate the value of the objective function given the optimal values of the variables.
7. Enter the formula '=SUMPRODUCT(C9:D9,$C$6:$D$6)' in the first cell under your LHS heading, and copy the formula into each additional left-hand-side value output cell under the LHS heading. This formula will calculate the actual value of your constraints given the optimal values of the variables.
Linear Program Solution
8. Click 'Data -> Solver' to bring up the 'solver parameters' dialog box. Set the target cell to '$B$7,' the objective function value output cell. Set the solver to maximize or minimize the function, based on the purpose of your linear program.
9. Enter the constraints into the solver parameters dialog box. Begin by clicking 'Add' for each individual constraint. For each constraint, enter the cell reference for the corresponding cell under your LHS heading in the cell reference box, choose the proper inequality symbol from the drop-down box in the center, and enter the cell reference for the corresponding cell under your RHS heading.
10. Back in the solver parameters dialog box, click 'Options' to open the solver options dialog box. Click 'Assume Linear Model' and 'Assume Non-Negative,' then click 'OK.'
11. Click 'Solve' in the solver parameters dialog box, and Excel 2007 will fill in the optimal solution, the value of the objective function, and the actual left-hand-side values of your constraints.

Blogger news