Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Show simplex tableau
- # Prereq: matrix A, vectors b,c, basis
- printf("Current basis:"); printf(" %2i", basis); disp("");
- B = A(:,basis); cB = c(basis);
- Bm1A = B\A; x_B = B\b; zrow = cB'*Bm1A-c'; zval = cB'*x_B;
- nv = find(zrow==min(zrow(zrow<=0)))(1);
- r = x_B./Bm1A(:,nv);
- T = [basis' Bm1A x_B r; 0 zrow zval 0]
- if length(r(r>=0)) >= 1
- ovp = find(r==min(r(r>=0)))(1);
- printf("Leaving variable: %i\nEntering variable: %i\n", basis(ovp), nv);
- basis(ovp) = nv;
- else
- disp("Simplex ended");
- endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement