%lpgen: Generate random solvable lp: min c'x s.t. Ax =< b; A:m-by-n
%Input: m,n,d(ensity); Output: A,b,c; (x,u): primal-dual solution
pl=inline('(abs(x)+x)/2');%pl(us) function 
tic;A=sprand(m,n,d);A=100*(A-0.5*spones(A));
u=sparse(10*pl(rand(m,1)-(m-3*n)/m));
x=10*spdiags((sign(pl(rand(n,1)-rand(n,1)))),0,n,n)*(rand(n,1)-rand(n,1));
c=-A'*u;b=A*x+spdiags((ones(m,1)-sign(pl(u))),0,m,m)*10*ones(m,1);toc0=toc;
format short e;[m n d toc0]
