clf
clear all
A0=[
1 -2 -1 0 0 0 0
0 1 1 1 0 0 5
0 -1 1 0 1 0 0
0 6 2 0 0 1 21
]
hold on
axis square
axis equal
x=0:1:6;
y=0*x;
plot(x,y,'k-')
y=0:1:6;
x=0*y;
plot(x,y,'k-')
pause(.5)

x=0:1:5;
y=5-x;
plot(x,y,'b-')
pause(.5)
y=0+x;
plot(x,y,'g-')
pause(.5)
x=1.8:.2:3.7;
y=(21-6*x)/2;
plot(x,y,'r-')
pause(.5)
plot(11/4,9/4,'ko')
disp('now display the lattice points')
pause
for i=0:1:4,
for j=0:1:3,
plot(i,j,'kx')
end
end

disp('now start to pivot')
pause
A=A0;
A=piv(A,2,2)
A=piv(A,3,3)
A=piv(A,4,5)

%%%%%%%%%%%%%%%%%%%%%%%%%%%
disp('add cut from x_4 row ')
pause
A1=A;
A=[ A(:,1:6) zeros(4,1) A(:,7)
    0 0 0 0 0 -.5 1 -.5]
disp('apply dual simplex - s_1 leaves and x_5 enters')
A=piv(A,5,6)
A2=A;
disp('temporary pivot for plot')
pause
A=piv(A,2,4)
pause
A=piv(A,3,7)
disp('plot the cut')
pause
x=1.2:.1:3.4;
y=(10-3*x);
plot(x,y,'k-')
A=A2


%%%%%%%%%%%%%%%%%%%%%%%%%%%
disp('now add cut from x_1 row ')
pause
A3=A;
A=[ A(:,1:7) zeros(5,1) A(:,8)
    0 0 0 -.5 0 0  -.5 1 -.5]
disp('apply dual simplex - s_1 leaves and x_3 enters')
A=piv(A,6,4)
plot(3,1,'mo')
disp('we have an optimal ILP tableau')
A4=A;
disp('temporary pivot for plot')
pause
A=piv(A,2,7)
pause
A=piv(A,3,8)
disp('plot the cut')
pause
x=1.2:.1:3.4;
y=(7-2*x);
plot(x,y,'m-')
A=A4



hold off
