eigen3-nnls icon indicating copy to clipboard operation
eigen3-nnls copied to clipboard

Infinite loop?

Open giordi91 opened this issue 8 years ago • 3 comments

Hi, I gave a try to the header and gave somewhat good result. One of the problem is that sometimes it just goes into an infinite loop and hangs it there. I am not an expert at all in LS or NNLS implementation so my question is, if that kind of behaviour is common? If not can be solved ? I think my data set was roughly correct, covering enough samples to have a good span. So even if with relative big error a result should have been found?

Best Regards and thanks for your effort.

giordi91 avatar Aug 24 '16 23:08 giordi91

Although this behavior is not common, it may happen. The NNLS algorithm uses a heuristic to determine the next parameter to optimize. Any heuristic may cause an infinite loop under certain conditions that depend on the particular heuristic. Currently there is only one heuristic implemented, the maximum descent heuristic. Hence the problem cannot be solved by resorting to another heuristic that may succeed for your specific problem.

If, however, you are interested in an approx. solution, you may set the max_iter argument to the NNLS constructor to a positive value. This will cause the optimization to abort after the specified number of iterations and returning a partial (possibly bad) solution.

hmatuschek avatar Aug 25 '16 10:08 hmatuschek

Thank you that was most helpful, although I had trouble providing all the proper arguments for the second signature, I hacked it in making _max_iters public, just as a test. I get an assertion k<rows, although the very same system works with the lest square in eigen.

Here is my matrix:

image

It is a series of R^3 points, one for each column, and I am solving with a point moving in space and trying to find the least square. The point is R^3 too.

Do you have any idea why the assertion is triggering? I do understand those being silly question as stated above I am not confident (yet) with the details of the math itself.

Regards

M.

giordi91 avatar Aug 25 '16 21:08 giordi91

It appears that you have to pass the transposed matrix. The matrix shown in the image contains more columns than rows. The NNLS (as well as a LS) problem is of the form

argmin ||y - Ab ||^2

where y is some given n vector, A is a given n x m Matrix and b (the solution) will be a m-vector. where n>=m (usually n>m).

Am 25.08.2016 um 23:00 schrieb Marco Giordano [email protected]:

Thank you that was most helpful, although I had trouble providing all the proper arguments for the second signature, I hacked it in making _max_iters public, just as a test. I get an assertion k<rows, although the very same system works with the lest square in eigen.

Here is my matrix:

It is a series of R^3 points, one for each column, and I am solving with a point moving in space and trying to find the least square. The point is R^3 too.

Do you have any idea why the assertion is triggering? I do understand those being silly question as stated above I am not confident (yet) with the details of the math itself.

Regards

M.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

hmatuschek avatar Aug 26 '16 16:08 hmatuschek