LBFGSpp icon indicating copy to clipboard operation
LBFGSpp copied to clipboard

[PR Suggestion] Remove runtime exceptions

Open Svalorzen opened this issue 4 years ago • 1 comments

I was wondering whether you would be interested in a patch that removed runtime exceptions, opting instead for returning either a boolean, enumeration or some sort of std::optional value to report whether a minimization went well or not.

I am not proposing removing exception related to erroneous parameters (so all std::invalid_arguments make sense for me).

I ask as exceptions can be relatively costly computationally when used as a failure status report, and given that one has no way to know in advance whether the provided inputs will result in failure or not, throwing an exception seems unduly harsh on the caller. In my current usage, for example, I am simply wrapping minimize calls in a try/except block that simply logs failures.

Please let me know if you would be interested in this, and I can try to provide a PR :)

Svalorzen avatar Nov 20 '20 18:11 Svalorzen

+1

GPrathap avatar Feb 16 '21 12:02 GPrathap

This commit has removed major runtime exceptions when maximum number of line searches is reached, which should resolve most of the common issues.

There remain some exceptions in the code, which are mostly "serious" issues that are hard to proceed.

Let me first mark this as closed. Feel free to reopen if further issues occur.

yixuan avatar May 25 '23 06:05 yixuan