00001
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #ifndef __LBFGS_H__
00032 #define __LBFGS_H__
00033
00034 #ifdef __cplusplus
00035 extern "C" {
00036 #endif
00037
00038
00039
00040
00041 #ifndef LBFGS_FLOAT
00042 #define LBFGS_FLOAT 64
00043 #endif
00044
00045
00046
00047
00048 #ifndef LBFGS_IEEE_FLOAT
00049 #define LBFGS_IEEE_FLOAT 1
00050 #endif
00051
00052 #if LBFGS_FLOAT == 32
00053 typedef float lbfgsfloatval_t;
00054
00055 #elif LBFGS_FLOAT == 64
00056 typedef double lbfgsfloatval_t;
00057
00058 #else
00059 #error "liblbfgs supports single (float; LBFGS_FLOAT = 32) or double (double; LBFGS_FLOAT=64) precision only."
00060
00061 #endif
00062
00063
00074 enum {
00076 LBFGSFALSE = 0,
00078 LBFGSTRUE,
00079
00081 LBFGSERR_UNKNOWNERROR = -1024,
00083 LBFGSERR_LOGICERROR = -1023,
00085 LBFGSERR_OUTOFMEMORY = -1022,
00087 LBFGSERR_CANCELED = -1021,
00089 LBFGSERR_INVALID_N = -1020,
00091 LBFGSERR_INVALID_N_SSE = -1019,
00093 LBFGSERR_INVALID_MINSTEP = -1018,
00095 LBFGSERR_INVALID_MAXSTEP = -1017,
00097 LBFGSERR_INVALID_FTOL = -1016,
00099 LBFGSERR_INVALID_GTOL = -1015,
00101 LBFGSERR_INVALID_XTOL = -1014,
00103 LBFGSERR_INVALID_MAXLINESEARCH = -1013,
00105 LBFGSERR_INVALID_ORTHANTWISE = -1012,
00107 LBFGSERR_OUTOFINTERVAL = -1011,
00110 LBFGSERR_INCORRECT_TMINMAX = -1010,
00113 LBFGSERR_ROUNDING_ERROR = -1009,
00115 LBFGSERR_MINIMUMSTEP = -1008,
00117 LBFGSERR_MAXIMUMSTEP = -1007,
00119 LBFGSERR_MAXIMUMLINESEARCH = -1006,
00121 LBFGSERR_MAXIMUMITERATION = -1005,
00124 LBFGSERR_WIDTHTOOSMALL = -1004,
00126 LBFGSERR_INVALIDPARAMETERS = -1003,
00128 LBFGSERR_INCREASEGRADIENT = -1002,
00129 };
00130
00136 typedef struct {
00145 int m;
00146
00155 lbfgsfloatval_t epsilon;
00156
00165 int max_iterations;
00166
00172 int max_linesearch;
00173
00181 lbfgsfloatval_t min_step;
00182
00190 lbfgsfloatval_t max_step;
00191
00197 lbfgsfloatval_t ftol;
00198
00209 lbfgsfloatval_t gtol;
00210
00218 lbfgsfloatval_t xtol;
00219
00231 lbfgsfloatval_t orthantwise_c;
00232 } lbfgs_parameter_t;
00233
00234
00252 typedef lbfgsfloatval_t (*lbfgs_evaluate_t)(
00253 void *instance,
00254 const lbfgsfloatval_t *x,
00255 lbfgsfloatval_t *g,
00256 const int n,
00257 const lbfgsfloatval_t step
00258 );
00259
00280 typedef int (*lbfgs_progress_t)(
00281 void *instance,
00282 const lbfgsfloatval_t *x,
00283 const lbfgsfloatval_t *g,
00284 const lbfgsfloatval_t fx,
00285 const lbfgsfloatval_t xnorm,
00286 const lbfgsfloatval_t gnorm,
00287 const lbfgsfloatval_t step,
00288 int n,
00289 int k,
00290 int ls
00291 );
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313
00347 int lbfgs(
00348 const int n,
00349 lbfgsfloatval_t *x,
00350 lbfgsfloatval_t *ptr_fx,
00351 lbfgs_evaluate_t proc_evaluate,
00352 lbfgs_progress_t proc_progress,
00353 void *instance,
00354 lbfgs_parameter_t *param
00355 );
00356
00365 void lbfgs_parameter_init(lbfgs_parameter_t *param);
00366
00369 #ifdef __cplusplus
00370 }
00371 #endif
00372
00373
00374
00510 #endif
00511