SHOGUN  3.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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>
33 
34 namespace shogun
35 {
36 
49 enum {
56 
122 };
123 
127 enum {
166 };
167 
173 typedef struct {
182  int m;
183 
193 
201  int past;
202 
214 
224 
231 
238 
247 
256 
263 
274 
286 
295 
310 
324 
334 
335 
354  void *instance,
355  const float64_t *x,
356  float64_t *g,
357  const int n,
358  const float64_t step
359  );
360 
381 typedef int (*lbfgs_progress_t)(
382  void *instance,
383  const float64_t *x,
384  const float64_t *g,
385  const float64_t fx,
386  const float64_t xnorm,
387  const float64_t gnorm,
388  const float64_t step,
389  int n,
390  int k,
391  int ls
392  );
393 
394 /*
395 A user must implement a function compatible with ::lbfgs_evaluate_t (evaluation
396 callback) and pass the pointer to the callback function to lbfgs() arguments.
397 Similarly, a user can implement a function compatible with ::lbfgs_progress_t
398 (progress callback) to obtain the current progress (e.g., variables, function
399 value, ||G||, etc) and to cancel the iteration process if necessary.
400 Implementation of a progress callback is optional: a user can pass \c NULL if
401 progress notification is not necessary.
402 
403 In addition, a user must preserve two requirements:
404  - The number of variables must be multiples of 16 (this is not 4).
405  - The memory block of variable array ::x must be aligned to 16.
406 
407 This algorithm terminates an optimization
408 when:
409 
410  ||G|| < \epsilon \cdot \max(1, ||x||) .
411 
412 In this formula, ||.|| denotes the Euclidean norm.
413 */
414 
452 int lbfgs(
453  int n,
454  float64_t *x,
455  float64_t *ptr_fx,
456  lbfgs_evaluate_t proc_evaluate,
457  lbfgs_progress_t proc_progress,
458  void *instance,
459  lbfgs_parameter_t *param
460  );
461 
471 
474 } // namespace shogun
475 
476 #endif/*__LBFGS_H__*/

SHOGUN Machine Learning Toolbox - Documentation