## Author: M. Turhan ÇOBAN
## Created: 2021-11-10
## simpl2ex1
function [x,y]=simplex2(a,n_variable)
[n,m]=size(a);
n1=n-1;
## n line m column
critical_column=1;
critical_row=0;
y_critical=0.0;
## |  i
## V
##
## find critical column j -->
jj=1;
##while a(1,jj)<0
for jj=1:n
  xmax=9.99e30;
  ymax=9.99e30;
for j=1:m
    if a(1,j)<xmax
      xmax=a(1,j);
      critical_column=j;
    endif
endfor
critical_column
for i=2:n
  ratio=a(i,m)/a(i,critical_column);
  if ratio<ymax
    ymax=ratio;
    critical_row=i;
    y_critical=a(critical_row,critical_column);
  endif
endfor
critical_row
#  normalise critical row by using y_critical
a(critical_row,:)=a(critical_row,:)/y_critical;
## Gauss elimination like process
for i=1:n
   if i!=critical_row
     c=a(i,critical_column);
     for j=1:m
       a(i,j)=a(i,j)-c*a(critical_row,j);
     endfor
   endif
endfor
jj
a
jj=jj+1;
endfor
y=a(1,m);
for j=n_variable+1:m-1
  for i=1:n
    a(i,j)=0.0;
  endfor
endfor
a
for i=1:n
  for j=1:n
    if a(i,j)==1
      x(j)=a(i,m);
    endif
  endfor
endfor
endfunction
