Path: news.mathworks.com!newsfeed-00.mathworks.com!newsfeed2.dallas1.level3.net!news.level3.com!postnews.google.com!news1.google.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local02.nntp.dca.giganews.com!nntp.supernews.com!news.supernews.com.POSTED!not-for-mail
NNTP-Posting-Date: Sat, 03 Jan 2009 09:19:26 -0600
Newsgroups: comp.soft-sys.matlab
Subject: curious problem with sparse matrices that have explicit "0" entries.....
From: "Eric J. Holtman" <ejh@ericholtman.com>
Message-ID: <Xns9B885ED987C87ejhericholtmamcom@216.168.3.30>
User-Agent: Xnews/5.04.25
Date: Sat, 03 Jan 2009 09:19:26 -0600
Lines: 51
X-Trace: sv3-xlvqkfz+0scOowpABvzndHdbdr+48ccs1/YjYZ+VIZK9bQeAtiC0GMsr6/sCFT9v1nUM9p7MlTnQ9dD!6hwzEGItt4UVhTZKLc4ujTxU9vHh+u5tf1xWhnMRyJGSiAxhQ6SUXej/ZDTA9NG7ccMcUF0cBm3w!7c/OkxNhl5g=
X-Complaints-To: www.supernews.com/docs/abuse.html
X-DMCA-Complaints-To: www.supernews.com/docs/dmca.html
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.39
Xref: news.mathworks.com comp.soft-sys.matlab:509647




I've run into a quirky problem with MATLAB having to 
do with sparse matrices built elsewhere (in a C++ program)
and linprog.

The datafile for this can be downloaded at

http://www.ericholtman.com/sparse_error.mat

If you download that file, and then attempt to solve the
linear program with the command:

[x fval exitflag output] = linprog (f, A, b, Aeq, beq, lb, ub);

you get the following error:

Exiting: cannot converge because the primal residual, dual residual,
 or upper-bound feasibility is NaN.

however, if you do

A = sparse(full(A));
Aeq = sparse(full(Aeq));

and then re-run the command, it succeeds, with fval =  1.5185e+003.

I built this problem in C++, and transferred the data into
MATLAB using the mx* and eng* functions.

As an artifact of construction, some of the entries in the
A and Aeq matrices are explicitly 0.

I don't understand why this causes a problem......  why
should there be any difference between a sparse matrix
with say, 17 non-zero entries, and one with the same 17
non-zero entries, and an 18th with an explicit zero?

Note that I can change my C++ program to not store the
explicit zeros, and everything works perfectly, without
having to do the x = sparse(full(x)); conversion.  I've
run it with huge arrays, so am I 100% convinced that I
am setting up the sparse array correctly (so that I know
I'm setting up the offsets in the PR, IR and JC arrays
correctly.)

I'm just curious as to why linprog would fail with a 
sparse matrix that has explicit zeros?