Vous êtes sur la page 1sur 10

Optimization Methods: Linear Programming Applications Software

Module 4 Lecture Notes 1 Use of software for solving linear programming problems Introduction In this class, use of software to solve linear programming problem will be discussed. An MSDos based software, known as MMO, will be discussed. Apart from MMO, simplex method using optimization toolbox of MATLAB will be briefly introduced.

MMO Software This is an MS-Dos based software to solve various types of problems. In this lecture notes, only Graphical method and Simplex method for LP problem using MMO (Dennis and Dennis, 1993) will be discussed. It may be noted that MMO can also solve optimization problems related to integer programming, network flow models, PERT among others. For more details of MMO, refer to INFOFILE.TXT in the folder.

Installation Download the MMO.ZIP file (in the Module_4 folder of the accompanying CD-ROM) and unzip it in a folder in the PC. Open this folder and double click on the application file named as START. It will open the MMO software. Opening screen can be seen as shown in Fig. 1. Press any key to see Main menu screen of MMO as shown in Fig. 2. Use arrow keys from keyboard to select different models.

Fig. 1. Opening Screen of MMO D Nagesh Kumar, IISc, Bangalore M4L1

Optimization Methods: Linear Programming Applications Software

Fig. 2 Main Menu Screen of MMO

Select Linear Programming and press enter. Two options will appear as follows: SOLUTION METHOD: GRAPHIC/ SIMPLEX

Graphical Method using MMO Select GRAPHIC and press enter. You can choose a particular option using arrow keys from the keyboard. It may be noted that graphical method can be used only for two decision variables. After waiting for a few moments screen for data entry method will appear (Fig. 3).

Fig. 3 Screen for Data Entry Method D Nagesh Kumar, IISc, Bangalore M4L1

Optimization Methods: Linear Programming Applications Software

Data entry may be done by either of two different ways. 1. Free Form Entry: You have to write the equation when prompted for input. 2. Tabular Entry: Data can be input in spreadsheet style. Only the coefficients are to be entered, not the variables. Note that all variables must appear in the objective function (even those with a 0 coefficient); if a variable name is repeated in the objective function, an error message will indicate that it is a duplicate and allow you to change the entry. Constraints can be entered in any order; variables with 0 coefficients do not have to be entered; if a constraint contains a variable not found in the objective function, an error message indicates this and allows you to make the correction; constraints may not have negative right-hand-sides (multiply by -1 to convert them before entering); when entering inequalities using < or >, it is not necessary to add the equal sign (=); non-negativity constraints are assumed and do not have to be entered. However, this information can be made available by selecting Information Screen. Let us take following problem Maximize Subject to Z = 2 x1 + 3x 2 x1 5, x1 2 x 2 5, x1 + x 2 6 x1 , x 2 0 Thus, the second constraint is to be multiplied by -1 while entering, i.e., x1 + 2 x 2 5 . In the MMO software, let us select Free Form Entry and max while it asks about TYPE OF PROBLEM and press enter. After entering the problem the screen will appear as Fig. 4. Note that at the last line of the constraints you have to write go and hit the enter key from the keyboard. Next screen will allow checking the proper entry of the problem. If any mistake is found, select NO and correct the mistake. If everything is ok, select YES and press the enter key. The graphics solution will be displayed on the screen. Different handling options will be shown on the right corner of the screen as follows:

D Nagesh Kumar, IISc, Bangalore

M4L1

Optimization Methods: Linear Programming Applications Software F1: Redraw F2: Rescale F3: Move Objective Function Line F4: Shade Feasible Region F5: Show Feasible Points F6: Show Optimal Solution Point F10: Show Graphical LP Menu (GPL)

We can easily make out the commands listed above. For example, F3 function can be used to move the objective function line. Subsequent function keys of F4 and F5 can be used to get the diagram as shown in Fig. 5.

Fig. 4 Screen after Entering the Problem.

D Nagesh Kumar, IISc, Bangalore

M4L1

Optimization Methods: Linear Programming Applications Software

Fig. 5 Feasible Region (highlighted in white), Feasible Points (white) and Optimal Solution Point (cyan)

The function key F10, i.e., Show Graphical LP Menu (GPL) will display the four different options as shown in Fig. 6.

Fig. 6 Graphical LP Menu Display Graphical Solution will return to the graphical diagram, List Solution Values will show the solution, which is Z = 15.67 with x1 = 2.33 and x 2 = 3.67 . Show Extreme Points will show either All or Feasible extreme points as per the choice (Fig. 7)

D Nagesh Kumar, IISc, Bangalore

M4L1

Optimization Methods: Linear Programming Applications Software

Fig. 7 List of Extreme Points and Feasible Extreme Points SIMPLEX Method using MMO As we know, the graphical solution is is limited to two decision variables. However, simplex method can be used for any number of variables, which is discussed in this section. Select SIMPLEX in Linear Programming option of MMO software. As before, screen for data entry method will appear (Fig. 3). The data entry is exactly same as discussed before. Let us consider the earlier problem for discussion and easy comparison. However, we could have taken a problem with more than two decision variables also. Maximize Subject to Z = 2 x1 + 3x 2 x1 5, x1 2 x 2 5, x1 + x 2 6 x1 , x 2 0 Once you run the problem, it will show the list of slack, surplus and artificial variables as shown in Fig. 8. Note that there are three additional slack variables in the above problem. Press any key to continue.

Fig. 8 List of slack, surplus and artificial variables D Nagesh Kumar, IISc, Bangalore M4L1

Optimization Methods: Linear Programming Applications Software It will show three different options (Fig. 9): 1. No Tableau: Shows direct solutions 2. All Tableau: Shows all simplex tableau one by one 3. Final Tableau: Shows only the final simplex tableau directly

Fig. 9 Different Options for Simplex Solution

Final simplex tableau for the present problem is shown in Fig. 10 and the final solution is obtained as: Optimal Z = 15.667 with x1 = 2.333 and x 2 = 3.667 .

There is an additional option for Sensitivity Analysis. However, it is beyond the scope of this lecture notes.

D Nagesh Kumar, IISc, Bangalore

M4L1

Optimization Methods: Linear Programming Applications Software

Fig. 10 Final Simplex Tableau

MATLAB Toolbox for Linear Programming

Optimization toolbox of MATLAB (2001) is very popular and efficient. It includes different types of optimization techniques. In this lecture notes, we will briefly introduce the use of MATLAB toolbox for Simplex Algorithm. However, it is assumed that the users are aware of basics of MATLAB.

To use the simplex method, you have to set the option as 'LargeScale' to 'off' and 'Simplex' to 'on' in the following way.

options = optimset('LargeScale', 'off', 'Simplex', 'on')

Then a function called linprog is to be used. A brief MATLAB documentation is shown in Fig. 11 for linear programming (linprog).

D Nagesh Kumar, IISc, Bangalore

M4L1

Optimization Methods: Linear Programming Applications Software

Fig. 11 MATLAB Documentation for Linear Programming

Further details may be referred from the toolbox. However, with this basic knowledge, simple LP problems can be solved. Let us consider the same problem as considered earlier. Maximize Subject to Z = 2 x1 + 3 x 2 x1 5, x1 2 x 2 5, x1 + x 2 6 x1 , x 2 0 D Nagesh Kumar, IISc, Bangalore M4L1

Optimization Methods: Linear Programming Applications Software Following MATLAB code will give the solution using simplex algorithm.
clear all f=[-2 -3]; %Converted to minimization problem A=[1 0;-1 2;1 1]; b=[5 5 6]; lb=[0 0]; options = optimset('LargeScale', 'off', 'Simplex', 'on'); [x,fval]=linprog(f,A,b,[],[],lb); z=-fval %Multiplied by -1 x

10

Note that objective function should be converted to a minimization problem before entering as done in line 2 of the code. Finally, solution should be multiplied by -1 to the optimized (maximum) solution as done in last but one line. Solution will be obtained as Z = 15.667 with x1 = 2.333 and x 2 = 3.667 as in the earlier case.

References

Dennis T.L. and L.B. Dennis, Microcomputer Models for Management Decision Making, West Publishing Company, 1993. MATLAB Users Manual, The Math Works Inc., 2001.

D Nagesh Kumar, IISc, Bangalore

M4L1

Vous aimerez peut-être aussi