-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
update the lbfgs optimizer #2337
Merged
Merged
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -391,6 +391,31 @@ typedef int (*lbfgs_progress_t)( | |
int ls | ||
); | ||
|
||
/** | ||
* Callback interface to adjust step size based on constrains. | ||
* | ||
* If the function pointer is not NULL, the lbfgs() function call | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "calls" with s |
||
* this function to adjust its step size. A client program can implement this function | ||
* to adjust the step size used in lbfgs update based on user-defined constrains. | ||
* Note that the update is x_new = x + step * d, where step is positive. | ||
* | ||
* @param instance The user data sent for lbfgs() function by the client. | ||
* @param x The current values of variables. | ||
* @param d The direction vector of variables. | ||
* @param n The number of variables. | ||
* @param step The current step of the line search routine. | ||
* | ||
* @retval float64_t The value of adjusted step size | ||
*/ | ||
|
||
typedef float64_t (*lbfgs_adjust_step_t)( | ||
void *instance, | ||
const float64_t *x, | ||
const float64_t *d, | ||
const int n, | ||
const float64_t step | ||
); | ||
|
||
/* | ||
A user must implement a function compatible with ::lbfgs_evaluate_t (evaluation | ||
callback) and pass the pointer to the callback function to lbfgs() arguments. | ||
|
@@ -445,6 +470,9 @@ In this formula, ||.|| denotes the Euclidean norm. | |
* parameter to \c NULL to use the default parameters. | ||
* Call lbfgs_parameter_init() function to fill a | ||
* structure with the default values. | ||
* @param proc_adjust_step The callback function to adjust step size based on constrains. | ||
* This argument can be set to \c NULL if there is not constrain. | ||
* | ||
* @retval int The status code. This function returns zero if the | ||
* minimization process terminates without an error. A | ||
* non-zero value indicates an error. | ||
|
@@ -456,7 +484,8 @@ int lbfgs( | |
lbfgs_evaluate_t proc_evaluate, | ||
lbfgs_progress_t proc_progress, | ||
void *instance, | ||
lbfgs_parameter_t *param | ||
lbfgs_parameter_t *param, | ||
lbfgs_adjust_step_t proc_adjust_step=NULL | ||
); | ||
|
||
/** | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo "constraints"