function [t, x, lambda] = newlpxt(c,A,b,alg,vlb,vub,x0,numeq,itermx);
%lp     Linear programming (using CPLEX).
%       t=lpxt(c,A,b) solves the linear programming problem:
%        
%            min c'x    subject to:   Ax <= b 
%             x
%   
%       [t,x,s]=lpxt(c,A,b,alg) returns lambda = -u, where u are the Lagrange
%       multipliers for the problem; that is, u solves the dual problem
%            max -b'u subject to: -A'u=c, u >= 0
%             u
%
%       [t,x,s]=lpxt(c,A,b,alg) indicates user sets preferred algorithm in alg
%         choice of alg:
%         0 for primal simplex
%         1 for dual simplex
%         2 for network
%         3 for barrier method
%       
%       x=lpxt(c,A,b,alg,vlb,vub) defines a set of lower and upper
%       bounds on the design variables, x, so that the solution is always in
%       the range vlb <= x <= vub.
%       
%       x=lpxt(c,A,b,alg,vlb,vub,x0,numeq) indicates that the first 
%       numeq constraints defined by A and b are equality constraints.
%
%       x=lpxt(c,A,b,alg,vlb,vub,x0,numeq,itermx) sets the maximum number of 
%       iterations to itermx
%
%       (x0 is completely ignored, but preserved for API compatibility
%       with the LP function on the UNIX boxes
% 
%       ( M-file &  mex-interface modified feb 2002 by (Gino)Jinho Lim)

  if (( nargin < 3) | (nargin > 9) )
    error('Wrong # of input parameters');
  end;

  n=length(c);
  m = size(A,1);

  if nargin == 9
    opts = struct('itlim',itermx);
  else
    opts = struct('itlim',10000);
  end
  if nargin >= 8
    Aeq = A(1:numeq,:); beq = b(1:numeq);
    le = [numeq+1:m];
    A = A(le,:); b = b(le); 
  else 
    Aeq = []; beq = [];
  end
  if nargin >=6
    if ( length(vub) ~= n )
      error('Wrong # of upper bounds.');
    end;
  else
    vub = inf*ones(n,1);
  end
  if nargin >=5
    if ( length(vlb) ~= n )
      error('Wrong # of upper bounds.');
    end;
  else
    vlb = -inf*ones(n,1);
  end
  options = cplexoptimset('cplex');
  if nargin >=4
    if ( alg>4 | alg<0 )
      error('Wrong choice of algorithm entered');
    end;
    options.lpmethod = alg+1;
  end
  options.Diagnostics = 'off';
% USE CPLEX VERSION OF MATLAB INTERFACE NOT MCF VERSION  
  t = cputime;
  [x,obj,exitflag,output,alllam]=cplexlp(c,A,b,Aeq,beq,vlb,vub,[],options);
%  [obj,x,lambda,stat]=cplexlp(c,A,b,vlb,vub,le,[],opts);
  if (exitflag <= 0)
    stat=output.cplexstatus,output.message,output.iterations,
    error('problem fails to solve - probably infeasible or unbounded');
  end
  lambda = [alllam.ineqlin; alllam.eqlin];
  t = cputime - t;
