lbfgsb 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.github/workflows/build.yml +21 -0
- data/.gitignore +17 -0
- data/.rspec +3 -0
- data/.yardopts +1 -0
- data/Gemfile +8 -0
- data/LICENSE.txt +27 -0
- data/README.md +110 -0
- data/Rakefile +15 -0
- data/ext/lbfgsb/extconf.rb +35 -0
- data/ext/lbfgsb/lbfgsbext.c +164 -0
- data/ext/lbfgsb/lbfgsbext.h +12 -0
- data/ext/lbfgsb/src/License.txt +71 -0
- data/ext/lbfgsb/src/blas.c +287 -0
- data/ext/lbfgsb/src/blas.h +12 -0
- data/ext/lbfgsb/src/lbfgsb.c +4096 -0
- data/ext/lbfgsb/src/lbfgsb.h +122 -0
- data/ext/lbfgsb/src/linpack.c +236 -0
- data/ext/lbfgsb/src/linpack.h +9 -0
- data/lbfgsb.gemspec +29 -0
- data/lib/lbfgsb.rb +84 -0
- data/lib/lbfgsb/version.rb +7 -0
- metadata +82 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 10f6e681a7b2d60d8915837bc7001a79d9ea796237d9907651481eeb96618213
|
4
|
+
data.tar.gz: d95ab1a0f2ac0e5d3f040de8309e4c3a9e3b3babe057c02fe553a3702dd3e75c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7eae04f38bb591a1a2b13b18c2be747cfccd28551c5ff3cdc5095442f00044d6489407abc1b6db33425cedd5368cff0efc88202b76c5ca27ba3a9a98094ed60d
|
7
|
+
data.tar.gz: e75187c9e10cd4e9670c5f3c3a795509d35307515dbe98c951eb8059fde47eec4e7dc4190fdf80dbbf45104b2d0a4306caee050a3e0b485b30c8451bfc50ad3f
|
@@ -0,0 +1,21 @@
|
|
1
|
+
name: build
|
2
|
+
|
3
|
+
on: [push]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
build:
|
7
|
+
runs-on: ubuntu-latest
|
8
|
+
strategy:
|
9
|
+
matrix:
|
10
|
+
ruby: [ '2.5', '2.6', '2.7' ]
|
11
|
+
steps:
|
12
|
+
- uses: actions/checkout@v2
|
13
|
+
- name: Set up Ruby ${{ matrix.ruby }}
|
14
|
+
uses: actions/setup-ruby@v1
|
15
|
+
with:
|
16
|
+
ruby-version: ${{ matrix.ruby }}
|
17
|
+
- name: Build and test with Rake
|
18
|
+
run: |
|
19
|
+
gem install bundler
|
20
|
+
bundle install --jobs 4 --retry 3
|
21
|
+
bundle exec rake
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.yardopts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--exclude ext/lbfgsb/src/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
Copyright (c) 2020 Atsushi Tatsuma
|
2
|
+
All rights reserved.
|
3
|
+
|
4
|
+
Redistribution and use in source and binary forms, with or without
|
5
|
+
modification, are permitted provided that the following conditions are met:
|
6
|
+
|
7
|
+
* Redistributions of source code must retain the above copyright notice, this
|
8
|
+
list of conditions and the following disclaimer.
|
9
|
+
|
10
|
+
* Redistributions in binary form must reproduce the above copyright notice,
|
11
|
+
this list of conditions and the following disclaimer in the documentation
|
12
|
+
and/or other materials provided with the distribution.
|
13
|
+
|
14
|
+
* Neither the name of the copyright holder nor the names of its
|
15
|
+
contributors may be used to endorse or promote products derived from
|
16
|
+
this software without specific prior written permission.
|
17
|
+
|
18
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
19
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
20
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
21
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
22
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
23
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
24
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
25
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
26
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
27
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/README.md
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
# Lbfgsb.rb
|
2
|
+
|
3
|
+
[](https://github.com/yoshoku/lbfgsb.rb/actions?query=workflow%3Abuild)
|
4
|
+
[](https://badge.fury.io/rb/lbfgsb)
|
5
|
+
[](https://github.com/yoshoku/suika/blob/master/LICENSE.txt)
|
6
|
+
|
7
|
+
Lbfgsb.rb is a Ruby binding for [L-BFGS-B](http://users.iems.northwestern.edu/~nocedal/lbfgsb.html)
|
8
|
+
that is a limited-memory algorithm for solving large nonlinear optimization problems
|
9
|
+
subject to simple bounds on the variables.
|
10
|
+
L-BFGS-B is written in FORTRAN. Author converted the codes into C-lang
|
11
|
+
and call that with Ruby native exntesion.
|
12
|
+
|
13
|
+
## Installation
|
14
|
+
|
15
|
+
Add this line to your application's Gemfile:
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
gem 'lbfgsb'
|
19
|
+
```
|
20
|
+
|
21
|
+
And then execute:
|
22
|
+
|
23
|
+
$ bundle install
|
24
|
+
|
25
|
+
Or install it yourself as:
|
26
|
+
|
27
|
+
$ gem install lbfgsb
|
28
|
+
|
29
|
+
## Usage
|
30
|
+
Example 1. Logistic Regression
|
31
|
+
|
32
|
+
```ruby
|
33
|
+
require 'numo/narray'
|
34
|
+
require 'lbfgsb'
|
35
|
+
require 'rumale'
|
36
|
+
|
37
|
+
|
38
|
+
## Training:
|
39
|
+
# Define objective function and its derivative.
|
40
|
+
obj_fnc = proc do |w, x, y|
|
41
|
+
Numo::NMath.log(1 + Numo::NMath.exp(-y * x.dot(w))).sum
|
42
|
+
end
|
43
|
+
|
44
|
+
d_obj_fnc = proc do |w, x, y|
|
45
|
+
(y / (1 + Numo::NMath.exp(-y * x.dot(w))) - y).dot(x)
|
46
|
+
end
|
47
|
+
|
48
|
+
# Load dataset.
|
49
|
+
x, y = Rumale::Dataset.load_libsvm_file('svmguide3')
|
50
|
+
|
51
|
+
# Extend variable for intercept.
|
52
|
+
xb = Numo::DFloat.hstack([x, Numo::DFloat.ones(x.shape[0]).expand_dims(1)])
|
53
|
+
|
54
|
+
# Initialize weight vector.
|
55
|
+
w0 = xb.mean(0)
|
56
|
+
|
57
|
+
# Optimize weight vector.
|
58
|
+
res = Lbfgsb.minimize(fnc: obj_fnc, jcb: d_obj_fnc, x_init: w0, args: [xb, y])
|
59
|
+
pp res
|
60
|
+
w = res[:x]
|
61
|
+
|
62
|
+
|
63
|
+
## Testing:
|
64
|
+
# Load dataset.
|
65
|
+
x_test, y_test = Rumale::Dataset.load_libsvm_file('svmguide3.t')
|
66
|
+
xb_test = Numo::DFloat.hstack([x_test, Numo::DFloat.ones(x_test.shape[0]).expand_dims(1)])
|
67
|
+
|
68
|
+
# Predict class label.
|
69
|
+
probs = 1.0 / (Numo::NMath.exp(-xb_test.dot(w)) + 1.0)
|
70
|
+
predicted = Numo::Int32.zeros(x_test.shape[0])
|
71
|
+
predicted[probs >= 0.5] = 1
|
72
|
+
predicted[probs < 0.5] =-1
|
73
|
+
|
74
|
+
# Evaluate result.
|
75
|
+
evaluator = Rumale::EvaluationMeasure::Accuracy.new
|
76
|
+
puts("Accuracy: %.1f%%" % (100.0 * evaluator.score(predicted, y_test)))
|
77
|
+
```
|
78
|
+
|
79
|
+
```sh
|
80
|
+
$ gem install rumale
|
81
|
+
$ wget https://www.csie.ntu.edu.tw/~cjlin/libsvmtools/datasets/binary/svmguide3
|
82
|
+
$ wget https://www.csie.ntu.edu.tw/~cjlin/libsvmtools/datasets/binary/svmguide3.t
|
83
|
+
$ ruby example1.rb
|
84
|
+
{:task=>"CONVERGENCE: REL_REDUCTION_OF_F_<=_FACTR*EPSMCH",
|
85
|
+
:x=>
|
86
|
+
Numo::DFloat#shape=[23]
|
87
|
+
[6.36634, -86.6413, -18.9489, -11.4564, -16.6738, -23.9111, -6.19714, ...],
|
88
|
+
:fnc=>512.3210359536802,
|
89
|
+
:jcb=>
|
90
|
+
Numo::DFloat#shape=[23]
|
91
|
+
[8.01782e-05, -0.000226254, -0.00144915, 4.26451e-05, 0.000677138, ...],
|
92
|
+
:n_iter=>623,
|
93
|
+
:n_fev=>716,
|
94
|
+
:n_jev=>716,
|
95
|
+
:success=>true}
|
96
|
+
Accuracy: 61.0%
|
97
|
+
```
|
98
|
+
|
99
|
+
## Contributing
|
100
|
+
|
101
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/yoshoku/lbfgsb.
|
102
|
+
|
103
|
+
## License
|
104
|
+
|
105
|
+
The gem is available as open source under the terms of the [BSD-3-Clause License](https://opensource.org/licenses/BSD-3-Clause).
|
106
|
+
In addition, L-BFGS-B carries the following condition for use:
|
107
|
+
|
108
|
+
This software is freely available, but we expect that all publications describing work using this software ,
|
109
|
+
or all commercial products using it, quote at least one of the references given below.
|
110
|
+
This software is released under the "New BSD License" (aka "Modified BSD License" or "3-clause license").
|
data/Rakefile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'rspec/core/rake_task'
|
3
|
+
|
4
|
+
RSpec::Core::RakeTask.new(:spec)
|
5
|
+
|
6
|
+
require 'rake/extensiontask'
|
7
|
+
|
8
|
+
task :build => :compile
|
9
|
+
|
10
|
+
Rake::ExtensionTask.new('lbfgsbext') do |ext|
|
11
|
+
ext.ext_dir = 'ext/lbfgsb'
|
12
|
+
ext.lib_dir = 'lib/lbfgsb'
|
13
|
+
end
|
14
|
+
|
15
|
+
task :default => [:clobber, :compile, :spec]
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'mkmf'
|
2
|
+
require 'numo/narray'
|
3
|
+
|
4
|
+
$LOAD_PATH.each do |lp|
|
5
|
+
if File.exist?(File.join(lp, 'numo/numo/narray.h'))
|
6
|
+
$INCFLAGS = "-I#{lp}/numo #{$INCFLAGS}"
|
7
|
+
break
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
unless have_header('numo/narray.h')
|
12
|
+
puts 'numo/narray.h not found.'
|
13
|
+
exit(1)
|
14
|
+
end
|
15
|
+
|
16
|
+
if RUBY_PLATFORM =~ /mswin|cygwin|mingw/
|
17
|
+
$LOAD_PATH.each do |lp|
|
18
|
+
if File.exist?(File.join(lp, 'numo/libnarray.a'))
|
19
|
+
$LDFLAGS = "-L#{lp}/numo #{$LDFLAGS}"
|
20
|
+
break
|
21
|
+
end
|
22
|
+
end
|
23
|
+
unless have_library('narray', 'nary_new')
|
24
|
+
puts 'libnarray.a not found.'
|
25
|
+
exit(1)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
$srcs = Dir.glob("#{$srcdir}/*.c").map { |path| File.basename(path) }
|
30
|
+
$srcs.concat(%w[blas.c linpack.c lbfgsb.c])
|
31
|
+
|
32
|
+
$INCFLAGS << " -I$(srcdir)/src"
|
33
|
+
$VPATH << "$(srcdir)/src"
|
34
|
+
|
35
|
+
create_makefile('lbfgsb/lbfgsbext')
|
@@ -0,0 +1,164 @@
|
|
1
|
+
#include "lbfgsbext.h"
|
2
|
+
|
3
|
+
VALUE rb_mLbfgsb;
|
4
|
+
|
5
|
+
static
|
6
|
+
VALUE lbfgsb_min_l_bfgs_b(VALUE self,
|
7
|
+
VALUE fnc, VALUE x_val, VALUE jcb, VALUE args,
|
8
|
+
VALUE l_val, VALUE u_val, VALUE nbd_val,
|
9
|
+
VALUE maxcor, VALUE ftol, VALUE gtol, VALUE maxiter, VALUE disp)
|
10
|
+
{
|
11
|
+
long i;
|
12
|
+
long n_iter;
|
13
|
+
long n_fev;
|
14
|
+
long n_jev;
|
15
|
+
long max_iter = NUM2LONG(maxiter);
|
16
|
+
narray_t* x_nary;
|
17
|
+
narray_t* l_nary;
|
18
|
+
narray_t* u_nary;
|
19
|
+
narray_t* nbd_nary;
|
20
|
+
long n;
|
21
|
+
long m = NUM2LONG(maxcor);
|
22
|
+
double *x_ptr;
|
23
|
+
double *l_ptr;
|
24
|
+
double *u_ptr;
|
25
|
+
long *nbd_ptr;
|
26
|
+
double f;
|
27
|
+
double *g;
|
28
|
+
double factr = NUM2DBL(ftol);
|
29
|
+
double pgtol = NUM2DBL(gtol);
|
30
|
+
double* wa;
|
31
|
+
long* iwa;
|
32
|
+
char task[60];
|
33
|
+
long iprint = NIL_P(disp) ? -1 : NUM2LONG(disp);
|
34
|
+
char csave[60];
|
35
|
+
long lsave[4];
|
36
|
+
long isave[44];
|
37
|
+
double dsave[29];
|
38
|
+
double* g_ptr;
|
39
|
+
VALUE g_val;
|
40
|
+
VALUE ret;
|
41
|
+
|
42
|
+
GetNArray(x_val, x_nary);
|
43
|
+
if (NA_NDIM(x_nary) != 1) {
|
44
|
+
rb_raise(rb_eArgError, "x must be a 1-D array.");
|
45
|
+
return Qnil;
|
46
|
+
}
|
47
|
+
n = (long)NA_SIZE(x_nary);
|
48
|
+
if (CLASS_OF(x_val) != numo_cDFloat) {
|
49
|
+
x_val = rb_funcall(numo_cDFloat, rb_intern("cast"), 1, x_val);
|
50
|
+
}
|
51
|
+
if (!RTEST(nary_check_contiguous(x_val))) {
|
52
|
+
x_val = nary_dup(x_val);
|
53
|
+
}
|
54
|
+
|
55
|
+
GetNArray(l_val, l_nary);
|
56
|
+
if (NA_NDIM(l_nary) != 1) {
|
57
|
+
rb_raise(rb_eArgError, "l must be a 1-D array.");
|
58
|
+
return Qnil;
|
59
|
+
}
|
60
|
+
if ((long)NA_SIZE(l_nary) != n) {
|
61
|
+
rb_raise(rb_eArgError, "The size of l must be equal to that of x.");
|
62
|
+
return Qnil;
|
63
|
+
}
|
64
|
+
if (CLASS_OF(l_val) != numo_cDFloat) {
|
65
|
+
l_val = rb_funcall(numo_cDFloat, rb_intern("cast"), 1, l_val);
|
66
|
+
}
|
67
|
+
if (!RTEST(nary_check_contiguous(l_val))) {
|
68
|
+
l_val = nary_dup(l_val);
|
69
|
+
}
|
70
|
+
|
71
|
+
GetNArray(u_val, u_nary);
|
72
|
+
if (NA_NDIM(u_nary) != 1) {
|
73
|
+
rb_raise(rb_eArgError, "u must be a 1-D array.");
|
74
|
+
return Qnil;
|
75
|
+
}
|
76
|
+
if ((long)NA_SIZE(u_nary) != n) {
|
77
|
+
rb_raise(rb_eArgError, "The size of u must be equal to that of x.");
|
78
|
+
return Qnil;
|
79
|
+
}
|
80
|
+
if (CLASS_OF(u_val) != numo_cDFloat) {
|
81
|
+
u_val = rb_funcall(numo_cDFloat, rb_intern("cast"), 1, u_val);
|
82
|
+
}
|
83
|
+
if (!RTEST(nary_check_contiguous(u_val))) {
|
84
|
+
u_val = nary_dup(u_val);
|
85
|
+
}
|
86
|
+
|
87
|
+
GetNArray(nbd_val, nbd_nary);
|
88
|
+
if (NA_NDIM(nbd_nary) != 1) {
|
89
|
+
rb_raise(rb_eArgError, "nbd must be a 1-D array.");
|
90
|
+
return Qnil;
|
91
|
+
}
|
92
|
+
if ((long)NA_SIZE(nbd_nary) != n) {
|
93
|
+
rb_raise(rb_eArgError, "The size of nbd must be equal to that of x.");
|
94
|
+
return Qnil;
|
95
|
+
}
|
96
|
+
if (CLASS_OF(nbd_val) != numo_cInt64) {
|
97
|
+
nbd_val = rb_funcall(numo_cInt64, rb_intern("cast"), 1, nbd_val);
|
98
|
+
}
|
99
|
+
if (!RTEST(nary_check_contiguous(nbd_val))) {
|
100
|
+
nbd_val = nary_dup(nbd_val);
|
101
|
+
}
|
102
|
+
|
103
|
+
x_ptr = (double*)na_get_pointer_for_read_write(x_val);
|
104
|
+
l_ptr = (double*)na_get_pointer_for_read(l_val);
|
105
|
+
u_ptr = (double*)na_get_pointer_for_read(u_val);
|
106
|
+
nbd_ptr = (long*)na_get_pointer_for_read(nbd_val);
|
107
|
+
g = ALLOC_N(double, n);
|
108
|
+
wa = ALLOC_N(double, (2 * m + 5) * n + 12 * m * m + 12 * m);
|
109
|
+
iwa = ALLOC_N(long, 3 * n);
|
110
|
+
|
111
|
+
f = 0.0;
|
112
|
+
for (i = 0; i < n; g[i++] = 0.0);
|
113
|
+
strcpy(task, "START");
|
114
|
+
n_fev = 0;
|
115
|
+
n_jev = 0;
|
116
|
+
|
117
|
+
for (n_iter = 0; n_iter < max_iter;) {
|
118
|
+
setulb_(
|
119
|
+
&n, &m, x_ptr, l_ptr, u_ptr, nbd_ptr, &f, g, &factr, &pgtol, wa, iwa,
|
120
|
+
task, &iprint, csave, lsave, isave, dsave
|
121
|
+
);
|
122
|
+
if (strncmp(task, "FG", 2) == 0) {
|
123
|
+
f = NUM2DBL(rb_funcall(self, rb_intern("fnc"), 3, fnc, x_val, args));
|
124
|
+
g_val = rb_funcall(self, rb_intern("jcb"), 3, jcb, x_val, args);
|
125
|
+
n_fev += 1;
|
126
|
+
n_jev += 1;
|
127
|
+
if (CLASS_OF(g_val) != numo_cDFloat) g_val = rb_funcall(numo_cDFloat, rb_intern("cast"), 1, g_val);
|
128
|
+
if (!RTEST(nary_check_contiguous(g_val))) g_val = nary_dup(g_val);
|
129
|
+
g_ptr = (double*)na_get_pointer_for_read(g_val);
|
130
|
+
for (i = 0; i < n; i++) g[i] = g_ptr[i];
|
131
|
+
} else if (strncmp(task, "NEW_X", 5) == 0) {
|
132
|
+
n_iter += 1;
|
133
|
+
continue;
|
134
|
+
} else {
|
135
|
+
break;
|
136
|
+
}
|
137
|
+
}
|
138
|
+
|
139
|
+
xfree(g);
|
140
|
+
xfree(wa);
|
141
|
+
xfree(iwa);
|
142
|
+
|
143
|
+
ret = rb_hash_new();
|
144
|
+
rb_hash_aset(ret, ID2SYM(rb_intern("task")), rb_str_new_cstr(task));
|
145
|
+
rb_hash_aset(ret, ID2SYM(rb_intern("x")), x_val);
|
146
|
+
rb_hash_aset(ret, ID2SYM(rb_intern("fnc")), DBL2NUM(f));
|
147
|
+
rb_hash_aset(ret, ID2SYM(rb_intern("jcb")), g_val);
|
148
|
+
rb_hash_aset(ret, ID2SYM(rb_intern("n_iter")), LONG2NUM(n_iter));
|
149
|
+
rb_hash_aset(ret, ID2SYM(rb_intern("n_fev")), LONG2NUM(n_fev));
|
150
|
+
rb_hash_aset(ret, ID2SYM(rb_intern("n_jev")), LONG2NUM(n_jev));
|
151
|
+
rb_hash_aset(ret, ID2SYM(rb_intern("success")), strncmp(task, "CONV", 4) == 0 ? Qtrue : Qfalse);
|
152
|
+
|
153
|
+
return ret;
|
154
|
+
}
|
155
|
+
|
156
|
+
void
|
157
|
+
Init_lbfgsbext(void)
|
158
|
+
{
|
159
|
+
rb_mLbfgsb = rb_define_module("Lbfgsb");
|
160
|
+
/* The value of double epsilon used in the native extension. */
|
161
|
+
rb_define_const(rb_mLbfgsb, "DBL_EPSILON", DBL2NUM(DBL_EPSILON));
|
162
|
+
/* @!visibility private */
|
163
|
+
rb_define_module_function(rb_mLbfgsb, "min_l_bfgs_b", lbfgsb_min_l_bfgs_b, 12);
|
164
|
+
}
|
@@ -0,0 +1,71 @@
|
|
1
|
+
3-clause license ("New BSD License" or "Modified BSD License")
|
2
|
+
New BSD License
|
3
|
+
Author Regents of the University of California
|
4
|
+
Publisher Public Domain
|
5
|
+
Published July 22, 1999[8]
|
6
|
+
DFSG compatible Yes[7]
|
7
|
+
FSF approved Yes[1]
|
8
|
+
OSI approved Yes[3]
|
9
|
+
GPL compatible Yes[1]
|
10
|
+
Copyleft No[1]
|
11
|
+
Copyfree Yes
|
12
|
+
Linking from code with a different license Yes
|
13
|
+
|
14
|
+
The advertising clause was removed from the license text in the official BSD on July 22, 1999 by William Hoskins, Director of
|
15
|
+
the Office of Technology Licensing for UC Berkeley.[8] Other BSD distributions removed the clause, but many similar clauses
|
16
|
+
remain in BSD-derived code from other sources, and unrelated code using a derived license.
|
17
|
+
|
18
|
+
While the original license is sometimes referred to as "BSD-old", the resulting 3-clause version is sometimes referred to by
|
19
|
+
"BSD-new." Other names include "New BSD", "revised BSD", "BSD-3", or "3-clause BSD". This version has been vetted as
|
20
|
+
an Open source license by the OSI as the "The BSD License".[3] The Free Software Foundation, which refers to the license
|
21
|
+
as the "Modified BSD License", states that it is compatible with the GNU GPL. The FSF encourages users to be specific
|
22
|
+
when referring to the license by name (i.e. not simply referring to it as "a BSD license" or "BSD-style") to avoid confusion with
|
23
|
+
the original BSD license.[1]
|
24
|
+
|
25
|
+
This version allows unlimited redistribution for any purpose as long as its copyright notices and the license's disclaimers of
|
26
|
+
warranty are maintained. The license also contains a clause restricting use of the names of contributors for endorsement of a
|
27
|
+
derived work without specific permission.
|
28
|
+
|
29
|
+
Copyright (c) <year>, <copyright holder>
|
30
|
+
All rights reserved.
|
31
|
+
|
32
|
+
Redistribution and use in source and binary forms, with or without
|
33
|
+
modification, are permitted provided that the following conditions are met:
|
34
|
+
* Redistributions of source code must retain the above copyright
|
35
|
+
notice, this list of conditions and the following disclaimer.
|
36
|
+
* Redistributions in binary form must reproduce the above copyright
|
37
|
+
notice, this list of conditions and the following disclaimer in the
|
38
|
+
documentation and/or other materials provided with the distribution.
|
39
|
+
* Neither the name of the <organization> nor the
|
40
|
+
names of its contributors may be used to endorse or promote products
|
41
|
+
derived from this software without specific prior written permission.
|
42
|
+
|
43
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
44
|
+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
45
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
46
|
+
DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
|
47
|
+
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
48
|
+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
49
|
+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
50
|
+
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
51
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
52
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
53
|
+
|
54
|
+
|
55
|
+
References
|
56
|
+
|
57
|
+
1. ^ a b c d e "Various Licenses and Comments about Them - GNU Project - Free Software Foundation (FSF): Modified BSD license".
|
58
|
+
Free Software Foundation. Retrieved 02 October 2010.
|
59
|
+
2. ^ a b c d e "Various Licenses and Comments about Them - GNU Project - Free Software Foundation (FSF): FreeBSD license".
|
60
|
+
Free Software Foundation. Retrieved 02 October 2010.
|
61
|
+
3. ^ a b c d e f "Open Source Initiative OSI - The BSD License:Licensing". Open Source Initiative. Retrieved 06 December 2009.
|
62
|
+
4. ^ a b c d "Various Licenses and Comments about Them - GNU Project - Free Software Foundation (FSF): Original BSD license".
|
63
|
+
Free Software Foundation. Retrieved 02 October 2010.
|
64
|
+
5. ^ The year given is the year 4.3BSD-Tahoe was released. Whether this is the first use of the license is not known.
|
65
|
+
6. ^ The year given is the year 4.3BSD-Reno was released. Whether this is the first use of the license is not known.
|
66
|
+
7. ^ a b "Debian -- License information". Debian. Retrieved 18 February 2010.
|
67
|
+
8. ^ a b c "To All Licensees, Distributors of Any Version of BSD". University of California, Berkeley. 1999-07-22. Retrieved
|
68
|
+
2006-11-15.
|
69
|
+
9. ^ Richard Stallman. "The BSD License Problem". Free Software Foundation. Retrieved 2006-11-15.
|
70
|
+
10. ^ "The FreeBSD Copyright". The FreeBSD Project. Retrieved 6 December 2009.
|
71
|
+
11. ^ "NetBSD Licensing and Redistribution". The NetBSD Foundation. Retrieved 06 December 2009.
|