SHOGUN  4.2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
lbfgs.h
Go to the documentation of this file.
1 /*
2  * C library of Limited memory BFGS (L-BFGS).
3  *
4  * Copyright (c) 1990, Jorge Nocedal
5  * Copyright (c) 2007-2010 Naoaki Okazaki
6  * All rights reserved.
7  *
8  * Permission is hereby granted, free of charge, to any person obtaining a copy
9  * of this software and associated documentation files (the "Software"), to deal
10  * in the Software without restriction, including without limitation the rights
11  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12  * copies of the Software, and to permit persons to whom the Software is
13  * furnished to do so, subject to the following conditions:
14  *
15  * The above copyright notice and this permission notice shall be included in
16  * all copies or substantial portions of the Software.
17  *
18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24  * THE SOFTWARE.
25  */
26 
27 #ifndef __LBFGS_H__
28 #define __LBFGS_H__
29 
30 #include <shogun/lib/config.h>
31 
32 #include <shogun/lib/common.h>
34 
35 namespace shogun
36 {
49 enum {
56 
124 };
125 
126 
127 
131 enum {
170 };
171 
177 typedef struct {
186  int m;
187 
197 
205  int past;
206 
218 
228 
235 
242 
251 
260 
267 
278 
290 
299 
314 
328 
338 
339 
358  void *instance,
359  const float64_t *x,
360  float64_t *g,
361  const int n,
362  const float64_t step
363  );
364 
385 typedef int (*lbfgs_progress_t)(
386  void *instance,
387  const float64_t *x,
388  const float64_t *g,
389  const float64_t fx,
390  const float64_t xnorm,
391  const float64_t gnorm,
392  const float64_t step,
393  int n,
394  int k,
395  int ls
396  );
397 
416  void *instance,
417  const float64_t *x,
418  const float64_t *d,
419  const int n,
420  const float64_t step
421  );
422 
423 /*
424 A user must implement a function compatible with ::lbfgs_evaluate_t (evaluation
425 callback) and pass the pointer to the callback function to lbfgs() arguments.
426 Similarly, a user can implement a function compatible with ::lbfgs_progress_t
427 (progress callback) to obtain the current progress (e.g., variables, function
428 value, ||G||, etc) and to cancel the iteration process if necessary.
429 Implementation of a progress callback is optional: a user can pass \c NULL if
430 progress notification is not necessary.
431 
432 In addition, a user must preserve two requirements:
433  - The number of variables must be multiples of 16 (this is not 4).
434  - The memory block of variable array ::x must be aligned to 16.
435 
436 This algorithm terminates an optimization
437 when:
438 
439  ||G|| < \epsilon \cdot \max(1, ||x||) .
440 
441 In this formula, ||.|| denotes the Euclidean norm.
442 */
443 
484 int lbfgs(
485  int n,
486  float64_t *x,
487  float64_t *ptr_fx,
488  lbfgs_evaluate_t proc_evaluate,
489  lbfgs_progress_t proc_progress,
490  void *instance,
491  lbfgs_parameter_t *param,
492  lbfgs_adjust_step_t proc_adjust_step=NULL
493  );
494 
504 
507 } // namespace shogun
508 
509 #endif/*__LBFGS_H__*/
int32_t lbfgs(int32_t n, float64_t *x, float64_t *ptr_fx, lbfgs_evaluate_t proc_evaluate, lbfgs_progress_t proc_progress, void *instance, lbfgs_parameter_t *_param, lbfgs_adjust_step_t proc_adjust_step)
Definition: lbfgs.cpp:208
float64_t orthantwise_c
Definition: lbfgs.h:313
double float64_t
Definition: common.h:50
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:18
float64_t(* lbfgs_adjust_step_t)(void *instance, const float64_t *x, const float64_t *d, const int n, const float64_t step)
Definition: lbfgs.h:415
float64_t(* lbfgs_evaluate_t)(void *instance, const float64_t *x, float64_t *g, const int n, const float64_t step)
Definition: lbfgs.h:357
int(* lbfgs_progress_t)(void *instance, const float64_t *x, const float64_t *g, const float64_t fx, const float64_t xnorm, const float64_t gnorm, const float64_t step, int n, int k, int ls)
Definition: lbfgs.h:385
void lbfgs_parameter_init(lbfgs_parameter_t *param)
Definition: lbfgs.cpp:203

SHOGUN Machine Learning Toolbox - Documentation