View Full Version : JMSL BoundedLeastSquares termination and output.

10-16-2007, 12:00 PM
Hi there.

I have a couple of questions about the JMSL BoundedLeastSquares behaviour. The first question involves the solve() method. Is there a way to stop it while it's running? I'm looking for a way to signal BoundedLeastSquares to stop before it hits any of its termination conditions (basically to cancel the solve() because it is taking a long time).

The second question involves output lines like:

com.imsl.math.BoundedLeastSquares: Maximum number of iterations exceeded.

Is there a way to turn this output off? The output actually looks similar to logging output, but I don't see any logging in the BoundedLeastSquares API.



10-17-2007, 06:56 AM
This message actually comes from the static com.imsl.Warning class. You can use Warning.setOut(PrintStream out) to redirect the output. You can also use Warning.setWarning(WarningObject obj) to customize how the warnings are handled.

Note that the PrintStream cannot be null, but the WarningObject can be -- so use the latter method to completely ignore error and warning messages.

EDIT: Sorry, forgot to address the first part of your question. I don't think there is a way to stop solve() once it's started. You could spin this off in another thread and then try to use interrupt(), but I'm not sure that would work. If you're doing ad-hoc work, you could tweak the max iterations or tolerances to make it stop sooner.

EDIT 2: A colleague suggested another approach here which I think could work pretty well. If you have a set MaxTime you want the function to run, you can add a time check (System.currentTimeMillis()) to your BoundedLeastSquares.Jacobian function. When it has exceeded MaxTime, return a residual value of zero and this should cause the code to quit computing. If you want the answer so far, you can record x in a separate location.

10-17-2007, 10:07 AM
Ah, the Warning class is what I was looking for. Setting the WarningObject to null worked like I wanted.

The interrupt() solution to stopping solve() was a possible unfriendly solution I was looking at, but the Jacobian residual approach sounds like the better way to do it.

Thanks for the help.