opener-opinion-detector-basic 2.0.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (148) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -0
  3. data/ext/hack/Rakefile +0 -2
  4. data/lib/opener/opinion_detector_basic/version.rb +1 -1
  5. data/opener-opinion-detector-basic.gemspec +0 -1
  6. data/task/compile.rake +1 -1
  7. data/task/requirements.rake +0 -1
  8. metadata +2 -142
  9. data/core/vendor/src/crfsuite/AUTHORS +0 -1
  10. data/core/vendor/src/crfsuite/COPYING +0 -27
  11. data/core/vendor/src/crfsuite/ChangeLog +0 -103
  12. data/core/vendor/src/crfsuite/INSTALL +0 -236
  13. data/core/vendor/src/crfsuite/Makefile.am +0 -19
  14. data/core/vendor/src/crfsuite/Makefile.in +0 -783
  15. data/core/vendor/src/crfsuite/README +0 -183
  16. data/core/vendor/src/crfsuite/aclocal.m4 +0 -9018
  17. data/core/vendor/src/crfsuite/autogen.sh +0 -38
  18. data/core/vendor/src/crfsuite/compile +0 -143
  19. data/core/vendor/src/crfsuite/config.guess +0 -1502
  20. data/core/vendor/src/crfsuite/config.h.in +0 -198
  21. data/core/vendor/src/crfsuite/config.sub +0 -1714
  22. data/core/vendor/src/crfsuite/configure +0 -14273
  23. data/core/vendor/src/crfsuite/configure.in +0 -149
  24. data/core/vendor/src/crfsuite/crfsuite.sln +0 -42
  25. data/core/vendor/src/crfsuite/depcomp +0 -630
  26. data/core/vendor/src/crfsuite/example/chunking.py +0 -49
  27. data/core/vendor/src/crfsuite/example/crfutils.py +0 -179
  28. data/core/vendor/src/crfsuite/example/ner.py +0 -270
  29. data/core/vendor/src/crfsuite/example/pos.py +0 -78
  30. data/core/vendor/src/crfsuite/example/template.py +0 -88
  31. data/core/vendor/src/crfsuite/frontend/Makefile.am +0 -29
  32. data/core/vendor/src/crfsuite/frontend/Makefile.in +0 -640
  33. data/core/vendor/src/crfsuite/frontend/dump.c +0 -116
  34. data/core/vendor/src/crfsuite/frontend/frontend.vcxproj +0 -129
  35. data/core/vendor/src/crfsuite/frontend/iwa.c +0 -273
  36. data/core/vendor/src/crfsuite/frontend/iwa.h +0 -65
  37. data/core/vendor/src/crfsuite/frontend/learn.c +0 -439
  38. data/core/vendor/src/crfsuite/frontend/main.c +0 -137
  39. data/core/vendor/src/crfsuite/frontend/option.c +0 -93
  40. data/core/vendor/src/crfsuite/frontend/option.h +0 -86
  41. data/core/vendor/src/crfsuite/frontend/readdata.h +0 -38
  42. data/core/vendor/src/crfsuite/frontend/reader.c +0 -136
  43. data/core/vendor/src/crfsuite/frontend/tag.c +0 -427
  44. data/core/vendor/src/crfsuite/genbinary.sh.in +0 -15
  45. data/core/vendor/src/crfsuite/include/Makefile.am +0 -11
  46. data/core/vendor/src/crfsuite/include/Makefile.in +0 -461
  47. data/core/vendor/src/crfsuite/include/crfsuite.h +0 -1063
  48. data/core/vendor/src/crfsuite/include/crfsuite.hpp +0 -555
  49. data/core/vendor/src/crfsuite/include/crfsuite_api.hpp +0 -400
  50. data/core/vendor/src/crfsuite/include/os.h +0 -61
  51. data/core/vendor/src/crfsuite/install-sh +0 -520
  52. data/core/vendor/src/crfsuite/lib/cqdb/COPYING +0 -28
  53. data/core/vendor/src/crfsuite/lib/cqdb/Makefile.am +0 -21
  54. data/core/vendor/src/crfsuite/lib/cqdb/Makefile.in +0 -549
  55. data/core/vendor/src/crfsuite/lib/cqdb/cqdb.vcxproj +0 -86
  56. data/core/vendor/src/crfsuite/lib/cqdb/include/cqdb.h +0 -524
  57. data/core/vendor/src/crfsuite/lib/cqdb/src/cqdb.c +0 -587
  58. data/core/vendor/src/crfsuite/lib/cqdb/src/lookup3.c +0 -976
  59. data/core/vendor/src/crfsuite/lib/crf/Makefile.am +0 -46
  60. data/core/vendor/src/crfsuite/lib/crf/Makefile.in +0 -721
  61. data/core/vendor/src/crfsuite/lib/crf/crf.vcxproj +0 -216
  62. data/core/vendor/src/crfsuite/lib/crf/src/crf1d.h +0 -353
  63. data/core/vendor/src/crfsuite/lib/crf/src/crf1d_context.c +0 -705
  64. data/core/vendor/src/crfsuite/lib/crf/src/crf1d_encode.c +0 -943
  65. data/core/vendor/src/crfsuite/lib/crf/src/crf1d_feature.c +0 -352
  66. data/core/vendor/src/crfsuite/lib/crf/src/crf1d_model.c +0 -994
  67. data/core/vendor/src/crfsuite/lib/crf/src/crf1d_tag.c +0 -550
  68. data/core/vendor/src/crfsuite/lib/crf/src/crfsuite.c +0 -492
  69. data/core/vendor/src/crfsuite/lib/crf/src/crfsuite_internal.h +0 -236
  70. data/core/vendor/src/crfsuite/lib/crf/src/crfsuite_train.c +0 -272
  71. data/core/vendor/src/crfsuite/lib/crf/src/dataset.c +0 -106
  72. data/core/vendor/src/crfsuite/lib/crf/src/dictionary.c +0 -118
  73. data/core/vendor/src/crfsuite/lib/crf/src/holdout.c +0 -80
  74. data/core/vendor/src/crfsuite/lib/crf/src/logging.c +0 -91
  75. data/core/vendor/src/crfsuite/lib/crf/src/logging.h +0 -48
  76. data/core/vendor/src/crfsuite/lib/crf/src/params.c +0 -335
  77. data/core/vendor/src/crfsuite/lib/crf/src/params.h +0 -80
  78. data/core/vendor/src/crfsuite/lib/crf/src/quark.c +0 -172
  79. data/core/vendor/src/crfsuite/lib/crf/src/quark.h +0 -46
  80. data/core/vendor/src/crfsuite/lib/crf/src/rumavl.c +0 -1107
  81. data/core/vendor/src/crfsuite/lib/crf/src/rumavl.h +0 -160
  82. data/core/vendor/src/crfsuite/lib/crf/src/train_arow.c +0 -408
  83. data/core/vendor/src/crfsuite/lib/crf/src/train_averaged_perceptron.c +0 -242
  84. data/core/vendor/src/crfsuite/lib/crf/src/train_l2sgd.c +0 -507
  85. data/core/vendor/src/crfsuite/lib/crf/src/train_lbfgs.c +0 -338
  86. data/core/vendor/src/crfsuite/lib/crf/src/train_passive_aggressive.c +0 -435
  87. data/core/vendor/src/crfsuite/lib/crf/src/vecmath.h +0 -341
  88. data/core/vendor/src/crfsuite/ltmain.sh +0 -8413
  89. data/core/vendor/src/crfsuite/missing +0 -376
  90. data/core/vendor/src/crfsuite/swig/Makefile.am +0 -13
  91. data/core/vendor/src/crfsuite/swig/Makefile.in +0 -365
  92. data/core/vendor/src/crfsuite/swig/crfsuite.cpp +0 -2
  93. data/core/vendor/src/crfsuite/swig/export.i +0 -32
  94. data/core/vendor/src/crfsuite/swig/python/README +0 -92
  95. data/core/vendor/src/crfsuite/swig/python/crfsuite.py +0 -329
  96. data/core/vendor/src/crfsuite/swig/python/export_wrap.cpp +0 -14355
  97. data/core/vendor/src/crfsuite/swig/python/export_wrap.h +0 -63
  98. data/core/vendor/src/crfsuite/swig/python/prepare.sh +0 -9
  99. data/core/vendor/src/crfsuite/swig/python/sample_tag.py +0 -52
  100. data/core/vendor/src/crfsuite/swig/python/sample_train.py +0 -68
  101. data/core/vendor/src/crfsuite/swig/python/setup.py +0 -44
  102. data/core/vendor/src/crfsuite/win32/stdint.h +0 -679
  103. data/core/vendor/src/liblbfgs/AUTHORS +0 -1
  104. data/core/vendor/src/liblbfgs/COPYING +0 -22
  105. data/core/vendor/src/liblbfgs/ChangeLog +0 -120
  106. data/core/vendor/src/liblbfgs/INSTALL +0 -231
  107. data/core/vendor/src/liblbfgs/Makefile.am +0 -10
  108. data/core/vendor/src/liblbfgs/Makefile.in +0 -638
  109. data/core/vendor/src/liblbfgs/NEWS +0 -0
  110. data/core/vendor/src/liblbfgs/README +0 -71
  111. data/core/vendor/src/liblbfgs/aclocal.m4 +0 -6985
  112. data/core/vendor/src/liblbfgs/autogen.sh +0 -38
  113. data/core/vendor/src/liblbfgs/config.guess +0 -1411
  114. data/core/vendor/src/liblbfgs/config.h.in +0 -64
  115. data/core/vendor/src/liblbfgs/config.sub +0 -1500
  116. data/core/vendor/src/liblbfgs/configure +0 -21146
  117. data/core/vendor/src/liblbfgs/configure.in +0 -107
  118. data/core/vendor/src/liblbfgs/depcomp +0 -522
  119. data/core/vendor/src/liblbfgs/include/lbfgs.h +0 -745
  120. data/core/vendor/src/liblbfgs/install-sh +0 -322
  121. data/core/vendor/src/liblbfgs/lbfgs.sln +0 -26
  122. data/core/vendor/src/liblbfgs/lib/Makefile.am +0 -24
  123. data/core/vendor/src/liblbfgs/lib/Makefile.in +0 -499
  124. data/core/vendor/src/liblbfgs/lib/arithmetic_ansi.h +0 -133
  125. data/core/vendor/src/liblbfgs/lib/arithmetic_sse_double.h +0 -294
  126. data/core/vendor/src/liblbfgs/lib/arithmetic_sse_float.h +0 -298
  127. data/core/vendor/src/liblbfgs/lib/lbfgs.c +0 -1371
  128. data/core/vendor/src/liblbfgs/lib/lib.vcxproj +0 -95
  129. data/core/vendor/src/liblbfgs/ltmain.sh +0 -6426
  130. data/core/vendor/src/liblbfgs/missing +0 -353
  131. data/core/vendor/src/liblbfgs/sample/Makefile.am +0 -15
  132. data/core/vendor/src/liblbfgs/sample/Makefile.in +0 -433
  133. data/core/vendor/src/liblbfgs/sample/sample.c +0 -81
  134. data/core/vendor/src/liblbfgs/sample/sample.cpp +0 -126
  135. data/core/vendor/src/liblbfgs/sample/sample.vcxproj +0 -105
  136. data/core/vendor/src/svm_light/LICENSE.txt +0 -59
  137. data/core/vendor/src/svm_light/Makefile +0 -105
  138. data/core/vendor/src/svm_light/kernel.h +0 -40
  139. data/core/vendor/src/svm_light/svm_classify.c +0 -197
  140. data/core/vendor/src/svm_light/svm_common.c +0 -985
  141. data/core/vendor/src/svm_light/svm_common.h +0 -301
  142. data/core/vendor/src/svm_light/svm_hideo.c +0 -1062
  143. data/core/vendor/src/svm_light/svm_learn.c +0 -4147
  144. data/core/vendor/src/svm_light/svm_learn.h +0 -169
  145. data/core/vendor/src/svm_light/svm_learn_main.c +0 -397
  146. data/core/vendor/src/svm_light/svm_loqo.c +0 -211
  147. data/task/c.rake +0 -36
  148. data/task/submodules.rake +0 -5
@@ -1,745 +0,0 @@
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
- /* $Id$ */
28
-
29
- #ifndef __LBFGS_H__
30
- #define __LBFGS_H__
31
-
32
- #ifdef __cplusplus
33
- extern "C" {
34
- #endif/*__cplusplus*/
35
-
36
- /*
37
- * The default precision of floating point values is 64bit (double).
38
- */
39
- #ifndef LBFGS_FLOAT
40
- #define LBFGS_FLOAT 64
41
- #endif/*LBFGS_FLOAT*/
42
-
43
- /*
44
- * Activate optimization routines for IEEE754 floating point values.
45
- */
46
- #ifndef LBFGS_IEEE_FLOAT
47
- #define LBFGS_IEEE_FLOAT 1
48
- #endif/*LBFGS_IEEE_FLOAT*/
49
-
50
- #if LBFGS_FLOAT == 32
51
- typedef float lbfgsfloatval_t;
52
-
53
- #elif LBFGS_FLOAT == 64
54
- typedef double lbfgsfloatval_t;
55
-
56
- #else
57
- #error "libLBFGS supports single (float; LBFGS_FLOAT = 32) or double (double; LBFGS_FLOAT=64) precision only."
58
-
59
- #endif
60
-
61
-
62
- /**
63
- * \addtogroup liblbfgs_api libLBFGS API
64
- * @{
65
- *
66
- * The libLBFGS API.
67
- */
68
-
69
- /**
70
- * Return values of lbfgs().
71
- *
72
- * Roughly speaking, a negative value indicates an error.
73
- */
74
- enum {
75
- /** L-BFGS reaches convergence. */
76
- LBFGS_SUCCESS = 0,
77
- LBFGS_CONVERGENCE = 0,
78
- LBFGS_STOP,
79
- /** The initial variables already minimize the objective function. */
80
- LBFGS_ALREADY_MINIMIZED,
81
-
82
- /** Unknown error. */
83
- LBFGSERR_UNKNOWNERROR = -1024,
84
- /** Logic error. */
85
- LBFGSERR_LOGICERROR,
86
- /** Insufficient memory. */
87
- LBFGSERR_OUTOFMEMORY,
88
- /** The minimization process has been canceled. */
89
- LBFGSERR_CANCELED,
90
- /** Invalid number of variables specified. */
91
- LBFGSERR_INVALID_N,
92
- /** Invalid number of variables (for SSE) specified. */
93
- LBFGSERR_INVALID_N_SSE,
94
- /** The array x must be aligned to 16 (for SSE). */
95
- LBFGSERR_INVALID_X_SSE,
96
- /** Invalid parameter lbfgs_parameter_t::epsilon specified. */
97
- LBFGSERR_INVALID_EPSILON,
98
- /** Invalid parameter lbfgs_parameter_t::past specified. */
99
- LBFGSERR_INVALID_TESTPERIOD,
100
- /** Invalid parameter lbfgs_parameter_t::delta specified. */
101
- LBFGSERR_INVALID_DELTA,
102
- /** Invalid parameter lbfgs_parameter_t::linesearch specified. */
103
- LBFGSERR_INVALID_LINESEARCH,
104
- /** Invalid parameter lbfgs_parameter_t::max_step specified. */
105
- LBFGSERR_INVALID_MINSTEP,
106
- /** Invalid parameter lbfgs_parameter_t::max_step specified. */
107
- LBFGSERR_INVALID_MAXSTEP,
108
- /** Invalid parameter lbfgs_parameter_t::ftol specified. */
109
- LBFGSERR_INVALID_FTOL,
110
- /** Invalid parameter lbfgs_parameter_t::wolfe specified. */
111
- LBFGSERR_INVALID_WOLFE,
112
- /** Invalid parameter lbfgs_parameter_t::gtol specified. */
113
- LBFGSERR_INVALID_GTOL,
114
- /** Invalid parameter lbfgs_parameter_t::xtol specified. */
115
- LBFGSERR_INVALID_XTOL,
116
- /** Invalid parameter lbfgs_parameter_t::max_linesearch specified. */
117
- LBFGSERR_INVALID_MAXLINESEARCH,
118
- /** Invalid parameter lbfgs_parameter_t::orthantwise_c specified. */
119
- LBFGSERR_INVALID_ORTHANTWISE,
120
- /** Invalid parameter lbfgs_parameter_t::orthantwise_start specified. */
121
- LBFGSERR_INVALID_ORTHANTWISE_START,
122
- /** Invalid parameter lbfgs_parameter_t::orthantwise_end specified. */
123
- LBFGSERR_INVALID_ORTHANTWISE_END,
124
- /** The line-search step went out of the interval of uncertainty. */
125
- LBFGSERR_OUTOFINTERVAL,
126
- /** A logic error occurred; alternatively, the interval of uncertainty
127
- became too small. */
128
- LBFGSERR_INCORRECT_TMINMAX,
129
- /** A rounding error occurred; alternatively, no line-search step
130
- satisfies the sufficient decrease and curvature conditions. */
131
- LBFGSERR_ROUNDING_ERROR,
132
- /** The line-search step became smaller than lbfgs_parameter_t::min_step. */
133
- LBFGSERR_MINIMUMSTEP,
134
- /** The line-search step became larger than lbfgs_parameter_t::max_step. */
135
- LBFGSERR_MAXIMUMSTEP,
136
- /** The line-search routine reaches the maximum number of evaluations. */
137
- LBFGSERR_MAXIMUMLINESEARCH,
138
- /** The algorithm routine reaches the maximum number of iterations. */
139
- LBFGSERR_MAXIMUMITERATION,
140
- /** Relative width of the interval of uncertainty is at most
141
- lbfgs_parameter_t::xtol. */
142
- LBFGSERR_WIDTHTOOSMALL,
143
- /** A logic error (negative line-search step) occurred. */
144
- LBFGSERR_INVALIDPARAMETERS,
145
- /** The current search direction increases the objective function value. */
146
- LBFGSERR_INCREASEGRADIENT,
147
- };
148
-
149
- /**
150
- * Line search algorithms.
151
- */
152
- enum {
153
- /** The default algorithm (MoreThuente method). */
154
- LBFGS_LINESEARCH_DEFAULT = 0,
155
- /** MoreThuente method proposd by More and Thuente. */
156
- LBFGS_LINESEARCH_MORETHUENTE = 0,
157
- /**
158
- * Backtracking method with the Armijo condition.
159
- * The backtracking method finds the step length such that it satisfies
160
- * the sufficient decrease (Armijo) condition,
161
- * - f(x + a * d) <= f(x) + lbfgs_parameter_t::ftol * a * g(x)^T d,
162
- *
163
- * where x is the current point, d is the current search direction, and
164
- * a is the step length.
165
- */
166
- LBFGS_LINESEARCH_BACKTRACKING_ARMIJO = 1,
167
- /** The backtracking method with the defualt (regular Wolfe) condition. */
168
- LBFGS_LINESEARCH_BACKTRACKING = 2,
169
- /**
170
- * Backtracking method with regular Wolfe condition.
171
- * The backtracking method finds the step length such that it satisfies
172
- * both the Armijo condition (LBFGS_LINESEARCH_BACKTRACKING_ARMIJO)
173
- * and the curvature condition,
174
- * - g(x + a * d)^T d >= lbfgs_parameter_t::wolfe * g(x)^T d,
175
- *
176
- * where x is the current point, d is the current search direction, and
177
- * a is the step length.
178
- */
179
- LBFGS_LINESEARCH_BACKTRACKING_WOLFE = 2,
180
- /**
181
- * Backtracking method with strong Wolfe condition.
182
- * The backtracking method finds the step length such that it satisfies
183
- * both the Armijo condition (LBFGS_LINESEARCH_BACKTRACKING_ARMIJO)
184
- * and the following condition,
185
- * - |g(x + a * d)^T d| <= lbfgs_parameter_t::wolfe * |g(x)^T d|,
186
- *
187
- * where x is the current point, d is the current search direction, and
188
- * a is the step length.
189
- */
190
- LBFGS_LINESEARCH_BACKTRACKING_STRONG_WOLFE = 3,
191
- };
192
-
193
- /**
194
- * L-BFGS optimization parameters.
195
- * Call lbfgs_parameter_init() function to initialize parameters to the
196
- * default values.
197
- */
198
- typedef struct {
199
- /**
200
- * The number of corrections to approximate the inverse hessian matrix.
201
- * The L-BFGS routine stores the computation results of previous \ref m
202
- * iterations to approximate the inverse hessian matrix of the current
203
- * iteration. This parameter controls the size of the limited memories
204
- * (corrections). The default value is \c 6. Values less than \c 3 are
205
- * not recommended. Large values will result in excessive computing time.
206
- */
207
- int m;
208
-
209
- /**
210
- * Epsilon for convergence test.
211
- * This parameter determines the accuracy with which the solution is to
212
- * be found. A minimization terminates when
213
- * ||g|| < \ref epsilon * max(1, ||x||),
214
- * where ||.|| denotes the Euclidean (L2) norm. The default value is
215
- * \c 1e-5.
216
- */
217
- lbfgsfloatval_t epsilon;
218
-
219
- /**
220
- * Distance for delta-based convergence test.
221
- * This parameter determines the distance, in iterations, to compute
222
- * the rate of decrease of the objective function. If the value of this
223
- * parameter is zero, the library does not perform the delta-based
224
- * convergence test. The default value is \c 0.
225
- */
226
- int past;
227
-
228
- /**
229
- * Delta for convergence test.
230
- * This parameter determines the minimum rate of decrease of the
231
- * objective function. The library stops iterations when the
232
- * following condition is met:
233
- * (f' - f) / f < \ref delta,
234
- * where f' is the objective value of \ref past iterations ago, and f is
235
- * the objective value of the current iteration.
236
- * The default value is \c 0.
237
- */
238
- lbfgsfloatval_t delta;
239
-
240
- /**
241
- * The maximum number of iterations.
242
- * The lbfgs() function terminates an optimization process with
243
- * ::LBFGSERR_MAXIMUMITERATION status code when the iteration count
244
- * exceedes this parameter. Setting this parameter to zero continues an
245
- * optimization process until a convergence or error. The default value
246
- * is \c 0.
247
- */
248
- int max_iterations;
249
-
250
- /**
251
- * The line search algorithm.
252
- * This parameter specifies a line search algorithm to be used by the
253
- * L-BFGS routine.
254
- */
255
- int linesearch;
256
-
257
- /**
258
- * The maximum number of trials for the line search.
259
- * This parameter controls the number of function and gradients evaluations
260
- * per iteration for the line search routine. The default value is \c 20.
261
- */
262
- int max_linesearch;
263
-
264
- /**
265
- * The minimum step of the line search routine.
266
- * The default value is \c 1e-20. This value need not be modified unless
267
- * the exponents are too large for the machine being used, or unless the
268
- * problem is extremely badly scaled (in which case the exponents should
269
- * be increased).
270
- */
271
- lbfgsfloatval_t min_step;
272
-
273
- /**
274
- * The maximum step of the line search.
275
- * The default value is \c 1e+20. This value need not be modified unless
276
- * the exponents are too large for the machine being used, or unless the
277
- * problem is extremely badly scaled (in which case the exponents should
278
- * be increased).
279
- */
280
- lbfgsfloatval_t max_step;
281
-
282
- /**
283
- * A parameter to control the accuracy of the line search routine.
284
- * The default value is \c 1e-4. This parameter should be greater
285
- * than zero and smaller than \c 0.5.
286
- */
287
- lbfgsfloatval_t ftol;
288
-
289
- /**
290
- * A coefficient for the Wolfe condition.
291
- * This parameter is valid only when the backtracking line-search
292
- * algorithm is used with the Wolfe condition,
293
- * ::LBFGS_LINESEARCH_BACKTRACKING_STRONG_WOLFE or
294
- * ::LBFGS_LINESEARCH_BACKTRACKING_WOLFE .
295
- * The default value is \c 0.9. This parameter should be greater
296
- * the \ref ftol parameter and smaller than \c 1.0.
297
- */
298
- lbfgsfloatval_t wolfe;
299
-
300
- /**
301
- * A parameter to control the accuracy of the line search routine.
302
- * The default value is \c 0.9. If the function and gradient
303
- * evaluations are inexpensive with respect to the cost of the
304
- * iteration (which is sometimes the case when solving very large
305
- * problems) it may be advantageous to set this parameter to a small
306
- * value. A typical small value is \c 0.1. This parameter shuold be
307
- * greater than the \ref ftol parameter (\c 1e-4) and smaller than
308
- * \c 1.0.
309
- */
310
- lbfgsfloatval_t gtol;
311
-
312
- /**
313
- * The machine precision for floating-point values.
314
- * This parameter must be a positive value set by a client program to
315
- * estimate the machine precision. The line search routine will terminate
316
- * with the status code (::LBFGSERR_ROUNDING_ERROR) if the relative width
317
- * of the interval of uncertainty is less than this parameter.
318
- */
319
- lbfgsfloatval_t xtol;
320
-
321
- /**
322
- * Coeefficient for the L1 norm of variables.
323
- * This parameter should be set to zero for standard minimization
324
- * problems. Setting this parameter to a positive value activates
325
- * Orthant-Wise Limited-memory Quasi-Newton (OWL-QN) method, which
326
- * minimizes the objective function F(x) combined with the L1 norm |x|
327
- * of the variables, {F(x) + C |x|}. This parameter is the coeefficient
328
- * for the |x|, i.e., C. As the L1 norm |x| is not differentiable at
329
- * zero, the library modifies function and gradient evaluations from
330
- * a client program suitably; a client program thus have only to return
331
- * the function value F(x) and gradients G(x) as usual. The default value
332
- * is zero.
333
- */
334
- lbfgsfloatval_t orthantwise_c;
335
-
336
- /**
337
- * Start index for computing L1 norm of the variables.
338
- * This parameter is valid only for OWL-QN method
339
- * (i.e., \ref orthantwise_c != 0). This parameter b (0 <= b < N)
340
- * specifies the index number from which the library computes the
341
- * L1 norm of the variables x,
342
- * |x| := |x_{b}| + |x_{b+1}| + ... + |x_{N}| .
343
- * In other words, variables x_1, ..., x_{b-1} are not used for
344
- * computing the L1 norm. Setting b (0 < b < N), one can protect
345
- * variables, x_1, ..., x_{b-1} (e.g., a bias term of logistic
346
- * regression) from being regularized. The default value is zero.
347
- */
348
- int orthantwise_start;
349
-
350
- /**
351
- * End index for computing L1 norm of the variables.
352
- * This parameter is valid only for OWL-QN method
353
- * (i.e., \ref orthantwise_c != 0). This parameter e (0 < e <= N)
354
- * specifies the index number at which the library stops computing the
355
- * L1 norm of the variables x,
356
- */
357
- int orthantwise_end;
358
- } lbfgs_parameter_t;
359
-
360
-
361
- /**
362
- * Callback interface to provide objective function and gradient evaluations.
363
- *
364
- * The lbfgs() function call this function to obtain the values of objective
365
- * function and its gradients when needed. A client program must implement
366
- * this function to evaluate the values of the objective function and its
367
- * gradients, given current values of variables.
368
- *
369
- * @param instance The user data sent for lbfgs() function by the client.
370
- * @param x The current values of variables.
371
- * @param g The gradient vector. The callback function must compute
372
- * the gradient values for the current variables.
373
- * @param n The number of variables.
374
- * @param step The current step of the line search routine.
375
- * @retval lbfgsfloatval_t The value of the objective function for the current
376
- * variables.
377
- */
378
- typedef lbfgsfloatval_t (*lbfgs_evaluate_t)(
379
- void *instance,
380
- const lbfgsfloatval_t *x,
381
- lbfgsfloatval_t *g,
382
- const int n,
383
- const lbfgsfloatval_t step
384
- );
385
-
386
- /**
387
- * Callback interface to receive the progress of the optimization process.
388
- *
389
- * The lbfgs() function call this function for each iteration. Implementing
390
- * this function, a client program can store or display the current progress
391
- * of the optimization process.
392
- *
393
- * @param instance The user data sent for lbfgs() function by the client.
394
- * @param x The current values of variables.
395
- * @param g The current gradient values of variables.
396
- * @param fx The current value of the objective function.
397
- * @param xnorm The Euclidean norm of the variables.
398
- * @param gnorm The Euclidean norm of the gradients.
399
- * @param step The line-search step used for this iteration.
400
- * @param n The number of variables.
401
- * @param k The iteration count.
402
- * @param ls The number of evaluations called for this iteration.
403
- * @retval int Zero to continue the optimization process. Returning a
404
- * non-zero value will cancel the optimization process.
405
- */
406
- typedef int (*lbfgs_progress_t)(
407
- void *instance,
408
- const lbfgsfloatval_t *x,
409
- const lbfgsfloatval_t *g,
410
- const lbfgsfloatval_t fx,
411
- const lbfgsfloatval_t xnorm,
412
- const lbfgsfloatval_t gnorm,
413
- const lbfgsfloatval_t step,
414
- int n,
415
- int k,
416
- int ls
417
- );
418
-
419
- /*
420
- A user must implement a function compatible with ::lbfgs_evaluate_t (evaluation
421
- callback) and pass the pointer to the callback function to lbfgs() arguments.
422
- Similarly, a user can implement a function compatible with ::lbfgs_progress_t
423
- (progress callback) to obtain the current progress (e.g., variables, function
424
- value, ||G||, etc) and to cancel the iteration process if necessary.
425
- Implementation of a progress callback is optional: a user can pass \c NULL if
426
- progress notification is not necessary.
427
-
428
- In addition, a user must preserve two requirements:
429
- - The number of variables must be multiples of 16 (this is not 4).
430
- - The memory block of variable array ::x must be aligned to 16.
431
-
432
- This algorithm terminates an optimization
433
- when:
434
-
435
- ||G|| < \epsilon \cdot \max(1, ||x||) .
436
-
437
- In this formula, ||.|| denotes the Euclidean norm.
438
- */
439
-
440
- /**
441
- * Start a L-BFGS optimization.
442
- *
443
- * @param n The number of variables.
444
- * @param x The array of variables. A client program can set
445
- * default values for the optimization and receive the
446
- * optimization result through this array. This array
447
- * must be allocated by ::lbfgs_malloc function
448
- * for libLBFGS built with SSE/SSE2 optimization routine
449
- * enabled. The library built without SSE/SSE2
450
- * optimization does not have such a requirement.
451
- * @param ptr_fx The pointer to the variable that receives the final
452
- * value of the objective function for the variables.
453
- * This argument can be set to \c NULL if the final
454
- * value of the objective function is unnecessary.
455
- * @param proc_evaluate The callback function to provide function and
456
- * gradient evaluations given a current values of
457
- * variables. A client program must implement a
458
- * callback function compatible with \ref
459
- * lbfgs_evaluate_t and pass the pointer to the
460
- * callback function.
461
- * @param proc_progress The callback function to receive the progress
462
- * (the number of iterations, the current value of
463
- * the objective function) of the minimization
464
- * process. This argument can be set to \c NULL if
465
- * a progress report is unnecessary.
466
- * @param instance A user data for the client program. The callback
467
- * functions will receive the value of this argument.
468
- * @param param The pointer to a structure representing parameters for
469
- * L-BFGS optimization. A client program can set this
470
- * parameter to \c NULL to use the default parameters.
471
- * Call lbfgs_parameter_init() function to fill a
472
- * structure with the default values.
473
- * @retval int The status code. This function returns zero if the
474
- * minimization process terminates without an error. A
475
- * non-zero value indicates an error.
476
- */
477
- int lbfgs(
478
- int n,
479
- lbfgsfloatval_t *x,
480
- lbfgsfloatval_t *ptr_fx,
481
- lbfgs_evaluate_t proc_evaluate,
482
- lbfgs_progress_t proc_progress,
483
- void *instance,
484
- lbfgs_parameter_t *param
485
- );
486
-
487
- /**
488
- * Initialize L-BFGS parameters to the default values.
489
- *
490
- * Call this function to fill a parameter structure with the default values
491
- * and overwrite parameter values if necessary.
492
- *
493
- * @param param The pointer to the parameter structure.
494
- */
495
- void lbfgs_parameter_init(lbfgs_parameter_t *param);
496
-
497
- /**
498
- * Allocate an array for variables.
499
- *
500
- * This function allocates an array of variables for the convenience of
501
- * ::lbfgs function; the function has a requreiemt for a variable array
502
- * when libLBFGS is built with SSE/SSE2 optimization routines. A user does
503
- * not have to use this function for libLBFGS built without SSE/SSE2
504
- * optimization.
505
- *
506
- * @param n The number of variables.
507
- */
508
- lbfgsfloatval_t* lbfgs_malloc(int n);
509
-
510
- /**
511
- * Free an array of variables.
512
- *
513
- * @param x The array of variables allocated by ::lbfgs_malloc
514
- * function.
515
- */
516
- void lbfgs_free(lbfgsfloatval_t *x);
517
-
518
- /** @} */
519
-
520
- #ifdef __cplusplus
521
- }
522
- #endif/*__cplusplus*/
523
-
524
-
525
-
526
- /**
527
- @mainpage libLBFGS: a library of Limited-memory Broyden-Fletcher-Goldfarb-Shanno (L-BFGS)
528
-
529
- @section intro Introduction
530
-
531
- This library is a C port of the implementation of Limited-memory
532
- Broyden-Fletcher-Goldfarb-Shanno (L-BFGS) method written by Jorge Nocedal.
533
- The original FORTRAN source code is available at:
534
- http://www.ece.northwestern.edu/~nocedal/lbfgs.html
535
-
536
- The L-BFGS method solves the unconstrainted minimization problem,
537
-
538
- <pre>
539
- minimize F(x), x = (x1, x2, ..., xN),
540
- </pre>
541
-
542
- only if the objective function F(x) and its gradient G(x) are computable. The
543
- well-known Newton's method requires computation of the inverse of the hessian
544
- matrix of the objective function. However, the computational cost for the
545
- inverse hessian matrix is expensive especially when the objective function
546
- takes a large number of variables. The L-BFGS method iteratively finds a
547
- minimizer by approximating the inverse hessian matrix by information from last
548
- m iterations. This innovation saves the memory storage and computational time
549
- drastically for large-scaled problems.
550
-
551
- Among the various ports of L-BFGS, this library provides several features:
552
- - <b>Optimization with L1-norm (Orthant-Wise Limited-memory Quasi-Newton
553
- (OWL-QN) method)</b>:
554
- In addition to standard minimization problems, the library can minimize
555
- a function F(x) combined with L1-norm |x| of the variables,
556
- {F(x) + C |x|}, where C is a constant scalar parameter. This feature is
557
- useful for estimating parameters of sparse log-linear models (e.g.,
558
- logistic regression and maximum entropy) with L1-regularization (or
559
- Laplacian prior).
560
- - <b>Clean C code</b>:
561
- Unlike C codes generated automatically by f2c (Fortran 77 into C converter),
562
- this port includes changes based on my interpretations, improvements,
563
- optimizations, and clean-ups so that the ported code would be well-suited
564
- for a C code. In addition to comments inherited from the original code,
565
- a number of comments were added through my interpretations.
566
- - <b>Callback interface</b>:
567
- The library receives function and gradient values via a callback interface.
568
- The library also notifies the progress of the optimization by invoking a
569
- callback function. In the original implementation, a user had to set
570
- function and gradient values every time the function returns for obtaining
571
- updated values.
572
- - <b>Thread safe</b>:
573
- The library is thread-safe, which is the secondary gain from the callback
574
- interface.
575
- - <b>Cross platform.</b> The source code can be compiled on Microsoft Visual
576
- Studio 2010, GNU C Compiler (gcc), etc.
577
- - <b>Configurable precision</b>: A user can choose single-precision (float)
578
- or double-precision (double) accuracy by changing ::LBFGS_FLOAT macro.
579
- - <b>SSE/SSE2 optimization</b>:
580
- This library includes SSE/SSE2 optimization (written in compiler intrinsics)
581
- for vector arithmetic operations on Intel/AMD processors. The library uses
582
- SSE for float values and SSE2 for double values. The SSE/SSE2 optimization
583
- routine is disabled by default.
584
-
585
- This library is used by:
586
- - <a href="http://www.chokkan.org/software/crfsuite/">CRFsuite: A fast implementation of Conditional Random Fields (CRFs)</a>
587
- - <a href="http://www.chokkan.org/software/classias/">Classias: A collection of machine-learning algorithms for classification</a>
588
- - <a href="http://www.public.iastate.edu/~gdancik/mlegp/">mlegp: an R package for maximum likelihood estimates for Gaussian processes</a>
589
- - <a href="http://infmath.uibk.ac.at/~matthiasf/imaging2/">imaging2: the imaging2 class library</a>
590
- - <a href="http://search.cpan.org/~laye/Algorithm-LBFGS-0.16/">Algorithm::LBFGS - Perl extension for L-BFGS</a>
591
- - <a href="http://www.cs.kuleuven.be/~bernd/yap-lbfgs/">YAP-LBFGS (an interface to call libLBFGS from YAP Prolog)</a>
592
-
593
- @section download Download
594
-
595
- - <a href="https://github.com/downloads/chokkan/liblbfgs/liblbfgs-1.10.tar.gz">Source code</a>
596
- - <a href="https://github.com/chokkan/liblbfgs">GitHub repository</a>
597
-
598
- libLBFGS is distributed under the term of the
599
- <a href="http://opensource.org/licenses/mit-license.php">MIT license</a>.
600
-
601
- @section changelog History
602
- - Version 1.10 (2010-12-22):
603
- - Fixed compiling errors on Mac OS X; this patch was kindly submitted by
604
- Nic Schraudolph.
605
- - Reduced compiling warnings on Mac OS X; this patch was kindly submitted
606
- by Tamas Nepusz.
607
- - Replaced memalign() with posix_memalign().
608
- - Updated solution and project files for Microsoft Visual Studio 2010.
609
- - Version 1.9 (2010-01-29):
610
- - Fixed a mistake in checking the validity of the parameters "ftol" and
611
- "wolfe"; this was discovered by Kevin S. Van Horn.
612
- - Version 1.8 (2009-07-13):
613
- - Accepted the patch submitted by Takashi Imamichi;
614
- the backtracking method now has three criteria for choosing the step
615
- length:
616
- - ::LBFGS_LINESEARCH_BACKTRACKING_ARMIJO: sufficient decrease (Armijo)
617
- condition only
618
- - ::LBFGS_LINESEARCH_BACKTRACKING_WOLFE: regular Wolfe condition
619
- (sufficient decrease condition + curvature condition)
620
- - ::LBFGS_LINESEARCH_BACKTRACKING_STRONG_WOLFE: strong Wolfe condition
621
- - Updated the documentation to explain the above three criteria.
622
- - Version 1.7 (2009-02-28):
623
- - Improved OWL-QN routines for stability.
624
- - Removed the support of OWL-QN method in MoreThuente algorithm because
625
- it accidentally fails in early stages of iterations for some objectives.
626
- Because of this change, <b>the OW-LQN method must be used with the
627
- backtracking algorithm (::LBFGS_LINESEARCH_BACKTRACKING)</b>, or the
628
- library returns ::LBFGSERR_INVALID_LINESEARCH.
629
- - Renamed line search algorithms as follows:
630
- - ::LBFGS_LINESEARCH_BACKTRACKING: regular Wolfe condition.
631
- - ::LBFGS_LINESEARCH_BACKTRACKING_LOOSE: regular Wolfe condition.
632
- - ::LBFGS_LINESEARCH_BACKTRACKING_STRONG: strong Wolfe condition.
633
- - Source code clean-up.
634
- - Version 1.6 (2008-11-02):
635
- - Improved line-search algorithm with strong Wolfe condition, which was
636
- contributed by Takashi Imamichi. This routine is now default for
637
- ::LBFGS_LINESEARCH_BACKTRACKING. The previous line search algorithm
638
- with regular Wolfe condition is still available as
639
- ::LBFGS_LINESEARCH_BACKTRACKING_LOOSE.
640
- - Configurable stop index for L1-norm computation. A member variable
641
- ::lbfgs_parameter_t::orthantwise_end was added to specify the index
642
- number at which the library stops computing the L1 norm of the
643
- variables. This is useful to prevent some variables from being
644
- regularized by the OW-LQN method.
645
- - A sample program written in C++ (sample/sample.cpp).
646
- - Version 1.5 (2008-07-10):
647
- - Configurable starting index for L1-norm computation. A member variable
648
- ::lbfgs_parameter_t::orthantwise_start was added to specify the index
649
- number from which the library computes the L1 norm of the variables.
650
- This is useful to prevent some variables from being regularized by the
651
- OWL-QN method.
652
- - Fixed a zero-division error when the initial variables have already
653
- been a minimizer (reported by Takashi Imamichi). In this case, the
654
- library returns ::LBFGS_ALREADY_MINIMIZED status code.
655
- - Defined ::LBFGS_SUCCESS status code as zero; removed unused constants,
656
- LBFGSFALSE and LBFGSTRUE.
657
- - Fixed a compile error in an implicit down-cast.
658
- - Version 1.4 (2008-04-25):
659
- - Configurable line search algorithms. A member variable
660
- ::lbfgs_parameter_t::linesearch was added to choose either MoreThuente
661
- method (::LBFGS_LINESEARCH_MORETHUENTE) or backtracking algorithm
662
- (::LBFGS_LINESEARCH_BACKTRACKING).
663
- - Fixed a bug: the previous version did not compute psuedo-gradients
664
- properly in the line search routines for OWL-QN. This bug might quit
665
- an iteration process too early when the OWL-QN routine was activated
666
- (0 < ::lbfgs_parameter_t::orthantwise_c).
667
- - Configure script for POSIX environments.
668
- - SSE/SSE2 optimizations with GCC.
669
- - New functions ::lbfgs_malloc and ::lbfgs_free to use SSE/SSE2 routines
670
- transparently. It is uncessary to use these functions for libLBFGS built
671
- without SSE/SSE2 routines; you can still use any memory allocators if
672
- SSE/SSE2 routines are disabled in libLBFGS.
673
- - Version 1.3 (2007-12-16):
674
- - An API change. An argument was added to lbfgs() function to receive the
675
- final value of the objective function. This argument can be set to
676
- \c NULL if the final value is unnecessary.
677
- - Fixed a null-pointer bug in the sample code (reported by Takashi Imamichi).
678
- - Added build scripts for Microsoft Visual Studio 2005 and GCC.
679
- - Added README file.
680
- - Version 1.2 (2007-12-13):
681
- - Fixed a serious bug in orthant-wise L-BFGS.
682
- An important variable was used without initialization.
683
- - Version 1.1 (2007-12-01):
684
- - Implemented orthant-wise L-BFGS.
685
- - Implemented lbfgs_parameter_init() function.
686
- - Fixed several bugs.
687
- - API documentation.
688
- - Version 1.0 (2007-09-20):
689
- - Initial release.
690
-
691
- @section api Documentation
692
-
693
- - @ref liblbfgs_api "libLBFGS API"
694
-
695
- @section sample Sample code
696
-
697
- @include sample.c
698
-
699
- @section ack Acknowledgements
700
-
701
- The L-BFGS algorithm is described in:
702
- - Jorge Nocedal.
703
- Updating Quasi-Newton Matrices with Limited Storage.
704
- <i>Mathematics of Computation</i>, Vol. 35, No. 151, pp. 773--782, 1980.
705
- - Dong C. Liu and Jorge Nocedal.
706
- On the limited memory BFGS method for large scale optimization.
707
- <i>Mathematical Programming</i> B, Vol. 45, No. 3, pp. 503-528, 1989.
708
-
709
- The line search algorithms used in this implementation are described in:
710
- - John E. Dennis and Robert B. Schnabel.
711
- <i>Numerical Methods for Unconstrained Optimization and Nonlinear
712
- Equations</i>, Englewood Cliffs, 1983.
713
- - Jorge J. More and David J. Thuente.
714
- Line search algorithm with guaranteed sufficient decrease.
715
- <i>ACM Transactions on Mathematical Software (TOMS)</i>, Vol. 20, No. 3,
716
- pp. 286-307, 1994.
717
-
718
- This library also implements Orthant-Wise Limited-memory Quasi-Newton (OWL-QN)
719
- method presented in:
720
- - Galen Andrew and Jianfeng Gao.
721
- Scalable training of L1-regularized log-linear models.
722
- In <i>Proceedings of the 24th International Conference on Machine
723
- Learning (ICML 2007)</i>, pp. 33-40, 2007.
724
-
725
- Special thanks go to:
726
- - Yoshimasa Tsuruoka and Daisuke Okanohara for technical information about
727
- OWL-QN
728
- - Takashi Imamichi for the useful enhancements of the backtracking method
729
- - Kevin S. Van Horn, Nic Schraudolph, and Tamas Nepusz for bug fixes
730
-
731
- Finally I would like to thank the original author, Jorge Nocedal, who has been
732
- distributing the effieicnt and explanatory implementation in an open source
733
- licence.
734
-
735
- @section reference Reference
736
-
737
- - <a href="http://www.ece.northwestern.edu/~nocedal/lbfgs.html">L-BFGS</a> by Jorge Nocedal.
738
- - <a href="http://research.microsoft.com/en-us/downloads/b1eb1016-1738-4bd5-83a9-370c9d498a03/default.aspx">Orthant-Wise Limited-memory Quasi-Newton Optimizer for L1-regularized Objectives</a> by Galen Andrew.
739
- - <a href="http://chasen.org/~taku/software/misc/lbfgs/">C port (via f2c)</a> by Taku Kudo.
740
- - <a href="http://www.alglib.net/optimization/lbfgs.php">C#/C++/Delphi/VisualBasic6 port</a> in ALGLIB.
741
- - <a href="http://cctbx.sourceforge.net/">Computational Crystallography Toolbox</a> includes
742
- <a href="http://cctbx.sourceforge.net/current_cvs/c_plus_plus/namespacescitbx_1_1lbfgs.html">scitbx::lbfgs</a>.
743
- */
744
-
745
- #endif/*__LBFGS_H__*/