Question: Karmarkar's algorithm

I am trying to write a procedure that implements Karmarkar's algorithm for solving linear programming problems.

I am getting a parsing error and I am not sure why. Each of the command in the procedure are working the way I want them to but there is something wrong with the loop controls. The code is attached below:

with(LinearAlgebra);

print(??); # input placeholder
Karmarkar:= proc(A,c)

     n:=ColumnDimension(A);

     x:=ZeroVector(n);

     y:=Vector(n,1/(n));

     r:=1/(sqrt(n*(n-1)));

     for i from 1 to nops(NullSpace(A))do

          x:=x+NullSpace(A)[i];

     end do;

     C:=1.0;

     while C>0.0001 do ;

          Diag := DiagonalMatrix(x/Norm(x, 1));

          B := `<,>`(A.Diag, Vector[row](n, 1));

          p := (IdentityMatrix(n)-Transpose(B).MatrixInverse(B.Transpose(B)).B).Transpose(c.Diag);

          p:=evalf(p/(Norm(p,2)));

          y:=y-0.9*r*p;

          x_new:=evalf((Diag . y)/((Vector[row](n,1) . (Diag . y))));

          C:=evalf((c . x_new-c . x)/(c . x));

          if C>0.0001 then

               x_new:=x;

          end if;

      end do;

end proc;

Any ideas on how to fix this?

 

Please Wait...