-
Notifications
You must be signed in to change notification settings - Fork 267
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cholmod_solve2() with Bset reports a too-sparse Xset and thus an incomplete solution (edit: this is not a bug, but feature of Xset / Bset) #892
Comments
This is not a bug, but a design feature in how Bset and Xset work. With Bset and Xset, CHOLMOD is giving you a requested subset of the solution, not the whole solution. That's the purpose of Xset and Bset. Xset is not saying "the solution is sparse; here is the pattern of X". It is saying "here are the entries of X that I computed; the other entries outside of Xset have not been computed, even if they are present". The user guide states:
and also
In general, for most linear systems, X is a full vector. The goal of the Bset / Xset method is that a subset of X can be computed quickly, without computing all of X. With the Xset output, I tell you which components of X I have computed. Xset is determined via a traversal of the elimination tree, starting from nodes in Bset. Xset always includes Bset, so if you want X(3) in this case, you need to set Bset(3). In otherwords, if you want a subset of X, put the list of entries in X you want to compute into the set Bset. Then Xset will be guaranteed to include all those entries. Xset is larger than Bset because to compute all entries requested (all X(i) for i in Bset), I have to compute some entries in X outside of Bset. The entries I compute in X are all X(i) for all i in Xset. I can try to clarify the User Guide to make this more clear. |
Hi. Thank you very much for clarifying. So then there's no obvious way to solve Thanks. |
If the graph of JtJ consists of a single connected component, then x = JtJ \ b is dense, whatever the sparsity pattern of b. Do you know if that is the case for your JtJ matrix? If so, then there's nothing you can do; x will be dense. The only thing possible is to not solve for all of x (if that's useful), which is what the goal of the Xset / Bset process is. |
I'll leave this issue open, by the way, until I revise the user guide. |
Hi. In my case x is definitely dense. But I was hoping I could still get a much faster solve because
Thank you for updating the docs. This will be helpful for people in the future. |
If x = JtJ \ b, then you need y = bt * x, where bt is a sparse row vector, correct? So if Bset is the sparsity of bt, don't you only need x(i) for all i in Bset? If so, then cholmod_solve2 will compute that. It will compute more of x, as it needs to (and returns that set in Xset), but it will compute all x(i) for all i in Bset. |
Yes... That is absolutely correct, and should work ok. Thanks for the suggestion! I think once I discovered this "bug", I lost faith that I understood what cholmod was doing, and stopped investigating. Thanks you very much! |
Awesome! This use case is exactly what I put the Xset / Bset method in place for. I think this has to be the best "bug" I've seen .. the fix is "This is not a bug, but a specific feature you want to exploit to greatly speed up your code." |
Hi. I worked on this a bit just now, and have another related question if that's ok. Before using Bset, I could make my computation much faster by solving So now I'm trying to use Bset with Thanks. |
So to answer my own question, this is possible, but
I can give you patches to implement some of this, if you let me know what the preferred approach is. Is there a better forum for this discussion? Should I move this back to the "github discussions"? Thanks. |
Hi. This is a clearer discussion of #891.
I'm solving a very small linear system
JtJ x = b
whereb = [5,0,0]
. I do this twice with acholmod_solve2(CHOLMOD_A)
call: once withoutBset
(telling CHOLMOD to use the whole denseb
vector) and again withBset
(telling CHOLMOD that the first element ofb
is the only non-zero element).Without
Bset
this works properly: in the attached sample this produces a vectorx
with all non-zero entries. But withBset
the reported vectorx
is only correct in the first two entries; the reportedXset
vector says thatx
is sparse with the 3rd entry 0. But this is wrong: all entries should be non-zero.Now the reproducer. Here's a tiny Python program to densely solve this problem as a reference:
This reports the correct solution:
Here's a C program solving the same problem with
cholmod_solve2()
: cholmod-solve2-with-bset.c.txtI build it like this:
I run it without arguments to solve with a dense
b
(noBset
):Note that it computed the correct answer. And I run it again with an argument, to solve with a sparse
b
:Note that the last value of 5.7143 is missing.
This is on Debian with libcholmod5=1:7.8.3+dfsg-2
Thanks.
The text was updated successfully, but these errors were encountered: