-
Notifications
You must be signed in to change notification settings - Fork 198
Description
I noticed that when a callback function returns non-zero value, the value is used as a return value of lbfgs().
Lines 495 to 500 in 5ad02fb
| /* Report the progress. */ | |
| if (cd.proc_progress) { | |
| if ((ret = cd.proc_progress(cd.instance, x, g, fx, xnorm, gnorm, step, cd.n, k, ls))) { | |
| goto lbfgs_exit; | |
| } | |
| } |
But this behavior is not documented, e.g. at
Lines 403 to 404 in 5ad02fb
| * @retval int Zero to continue the optimization process. Returning a | |
| * non-zero value will cancel the optimization process. |
or
Lines 461 to 465 in 5ad02fb
| * @param proc_progress The callback function to receive the progress | |
| * (the number of iterations, the current value of | |
| * the objective function) of the minimization | |
| * process. This argument can be set to \c NULL if | |
| * a progress report is unnecessary. |
The current situation is not desirable as a user might write a callback function that returns a value that is not intended to be used as the return value of lbfgs().
I think it's better to either:
- document the current behavior (Document that non-zero return value of a callback is used as return value of lbfgs() #37), or
- make
lbfgs()always returnLBFGSERR_CANCELEDon cancel, ignoring the actual return value of the callback (Make lbfgs() to return LBFGSERR_CANCELED when callback function returns non-zero value #38)
Metadata
Metadata
Assignees
Labels
No labels