% Here is an example how to use the matlab subroutines. % step 1) start matlab on your machine. type "pwd". You'll see something % like "ans = c:\matlab\work Remember this because this is where % you'll need to save the three files "LP_setup.m", "pivot.m", and % "LP_disp.m". % step 2) download the three files "LP_setup.m", "pivot.m", and "LP_disp.m" % and save them in the correct directory. (In my case, it's % c:\matlab\work ) % step 3) start matlab. Once it's started, type "ls". Make sure you see % "LP_setup.m", "pivot.m", and "LP_disp.m" listed. % step 4) open your book to page 138 and follow along with the following. % In the following, the ">>" represents the matlab prompt. You % have to type the words after the >> and then hit return. You'll % then be given some questions to answer... % % Example from page 138: % % first we type in the matrix in tableau 2.25 % % make sure you've got your commas and semicolons right. Commas separate % entries in a row, semicolons separate rows... % A =[ 1,2,2,1,1,0,1,0,0,12; 1,2,1,1,2,1,0,1,0,18; 3,6,2,1,3,0,0,0,1,24; -5,-10,-5,-3,-6,-1,0,0,0,-54] % now create the vector "bv" that will have the names of the basic variables >> [A,bv] = LP_setup(A); what is your basic variable? x7 what is your basic variable? x8 what is your basic variable? x9 % note1: you have to input the x7, x8, x9 at the question. % note2: I didn't bother with y1,y2,y3 --- I called them x7, x8, and x9. In fact, if I were to % try calling them y1, y2, y3, the matlab routine would get confused. x1 x2 x3 x4 x5 x6 x7 x8 x9 x7 1 2 2 1 1 0 1 0 0 12 x8 1 2 1 1 2 1 0 1 0 18 x9 3 6 2 1 3 0 0 0 1 24 obj -5 -10 -5 -3 -6 -1 0 0 0 -54 % now we take the first step, going from tableau 2.25 to tableau 2.26: >> [A,bv] = pivot(A,bv); what is the incoming variable? x2 what is the outgoing variable? x9 x1 x2 x3 x4 x5 x6 x7 x8 x9 x7 0 0 1.3333 0.66667 0 0 1 0 -0.33333 4 x8 0 0 0.33333 0.66667 1 1 0 1 -0.33333 10 x2 0.5 1 0.33333 0.16667 0.5 0 0 0 0.16667 4 obj 0 0 -1.6667 -1.3333 -1 -1 0 0 1.6667 -14 % now we take the first step, going from tableau 2.26 to tableau 2.27: >> [A,bv] = pivot(A,bv); what is the incoming variable? x3 what is the outgoing variable? x7 x1 x2 x3 x4 x5 x6 x7 x8 x9 x3 0 0 1 0.5 0 0 0.75 0 -0.25 3 x8 0 0 0 0.5 1 1 -0.25 1 -0.25 9 x2 0.5 1 0 0 0.5 0 -0.25 0 0.25 3 obj 0 0 0 -0.5 -1 -1 1.25 0 1.25 -9 % now we take the first step, going from tableau 2.27 to tableau 2.28: >> [A,bv] = pivot(A,bv); what is the incoming variable? x6 what is the outgoing variable? x8 x1 x2 x3 x4 x5 x6 x7 x8 x9 x3 0 0 1 0.5 0 0 0.75 0 -0.25 3 x6 0 0 0 0.5 1 1 -0.25 1 -0.25 9 x2 0.5 1 0 0 0.5 0 -0.25 0 0.25 3 obj 0 0 0 0 0 0 1 1 1 0 % And phase one terminates! We now have a basic solution for the original linear programing % problem and can continue on to phase two by simply changing the objective row of the % matrix: >> A(4,:) = [-2,0,0,1/2,2,0,-9/4,2,-1/4,3] A = 0 0 1.0000 0.5000 0 0 0.7500 0 -0.2500 3.0000 0 0 0 0.5000 1.0000 1.0000 -0.2500 1.0000 -0.2500 9.0000 0.5000 1.0000 0 0 0.5000 0 -0.2500 0 0.2500 3.0000 -2.0000 0 0 0.5000 2.0000 0 -2.2500 2.0000 -0.2500 3.0000 >> [A,bv] = pivot(A,bv); what is the incoming variable? x1 what is the outgoing variable? x2 x1 x2 x3 x4 x5 x6 x7 x8 x9 x3 0 0 1 0.5 0 0 0.75 0 -0.25 3 x6 0 0 0 0.5 1 1 -0.25 1 -0.25 9 x1 1 2 0 0 1 0 -0.5 0 0.5 6 obj 0 4 0 0.5 4 0 -3.25 2 0.75 15 % Phase two terminates and we're done!