osqp 0.1.2 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +16 -0
  3. data/README.md +24 -14
  4. data/lib/osqp/ffi.rb +7 -0
  5. data/lib/osqp/matrix.rb +64 -0
  6. data/lib/osqp/solver.rb +32 -59
  7. data/lib/osqp/utils.rb +15 -0
  8. data/lib/osqp/version.rb +1 -1
  9. data/lib/osqp.rb +13 -7
  10. data/vendor/aarch64-linux/LICENSE-amd.txt +36 -0
  11. data/vendor/{LICENSE → aarch64-linux/LICENSE-osqp.txt} +1 -1
  12. data/vendor/aarch64-linux/LICENSE-qdldl.txt +201 -0
  13. data/vendor/{NOTICE → aarch64-linux/NOTICE-osqp.txt} +0 -0
  14. data/vendor/aarch64-linux/libosqp.so +0 -0
  15. data/vendor/arm64-darwin/LICENSE-amd.txt +36 -0
  16. data/vendor/arm64-darwin/LICENSE-osqp.txt +201 -0
  17. data/vendor/arm64-darwin/LICENSE-qdldl.txt +201 -0
  18. data/vendor/arm64-darwin/NOTICE-osqp.txt +14 -0
  19. data/vendor/arm64-darwin/libosqp.dylib +0 -0
  20. data/vendor/x64-mingw/LICENSE-amd.txt +36 -0
  21. data/vendor/x64-mingw/LICENSE-osqp.txt +201 -0
  22. data/vendor/x64-mingw/LICENSE-qdldl.txt +201 -0
  23. data/vendor/x64-mingw/NOTICE-osqp.txt +14 -0
  24. data/vendor/x64-mingw/osqp.dll +0 -0
  25. data/vendor/x86_64-darwin/LICENSE-amd.txt +36 -0
  26. data/vendor/x86_64-darwin/LICENSE-osqp.txt +201 -0
  27. data/vendor/x86_64-darwin/LICENSE-qdldl.txt +201 -0
  28. data/vendor/x86_64-darwin/NOTICE-osqp.txt +14 -0
  29. data/vendor/x86_64-darwin/libosqp.dylib +0 -0
  30. data/vendor/x86_64-linux/LICENSE-amd.txt +36 -0
  31. data/vendor/x86_64-linux/LICENSE-osqp.txt +201 -0
  32. data/vendor/x86_64-linux/LICENSE-qdldl.txt +201 -0
  33. data/vendor/x86_64-linux/NOTICE-osqp.txt +14 -0
  34. data/vendor/x86_64-linux/libosqp.so +0 -0
  35. metadata +33 -12
  36. data/vendor/libosqp.arm64.dylib +0 -0
  37. data/vendor/libosqp.dll +0 -0
  38. data/vendor/libosqp.dylib +0 -0
  39. data/vendor/libosqp.so +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: eec3a6f84d3330d75ac4bd3293ecfa4a13fd6bd1134ccf663a885db6f9d38fe1
4
- data.tar.gz: 40330861bf996109a354d294100532fa8b56f1f1e523cbd8422a5123322f5dd0
3
+ metadata.gz: 1b2906722de1daf0e3f2441edee63d8cec2452012cd9fa91634f37418e66f6fc
4
+ data.tar.gz: ee0cf11cc8ea7d1676843699265ad27623d237940c756fdb9c49c8e404137b37
5
5
  SHA512:
6
- metadata.gz: 51f93c37d11a8804b01813a0523aa7cce9b71babf794527c1208004534501dcdc3ae8334214a9ed01794dce38297f03714f8c35ab67e3754a1265b607900fe16
7
- data.tar.gz: d848c6cbf0bc426bbfc77142d16095117f53351ec42bd36115903307e32353b0e5a0a74baf9800f8c1c6a0aab5b78608fc9df592b13077695c93159f1306ee86
6
+ metadata.gz: 835c7ac35d791e794b7da902a1a248696860ed09d05e8831d0d4b6c54615758f6d930443e1f4b4f21d0b9d10453882653db60e2bda46b107d342a3cda304e889
7
+ data.tar.gz: 027ec047ca635e1b9f36377921110444a90226dfa85ebeac44ccab5b1945aac2d37f487f7725ba5604f264551f852392855e087c84afd1c39cd7790278fa3c68
data/CHANGELOG.md CHANGED
@@ -1,3 +1,19 @@
1
+ ## 0.2.1 (2022-07-05)
2
+
3
+ - Added `Matrix` class
4
+
5
+ ## 0.2.0 (2022-06-12)
6
+
7
+ - Added ARM shared library for Linux
8
+ - Fixed issue with infinite bounds
9
+ - Dropped support for Ruby < 2.7
10
+
11
+ ## 0.1.3 (2022-04-08)
12
+
13
+ - Improved ARM detection
14
+ - Fixed `x` and `y` in solution
15
+ - Fixed memory issue
16
+
1
17
  ## 0.1.2 (2021-01-05)
2
18
 
3
19
  - Added ARM shared library for Mac
data/README.md CHANGED
@@ -1,15 +1,15 @@
1
- # OSQP
1
+ # OSQP Ruby
2
2
 
3
3
  The [OSQP](https://osqp.org/) (Operator Splitting Quadratic Program) solver for Ruby
4
4
 
5
- [![Build Status](https://github.com/ankane/osqp/workflows/build/badge.svg?branch=master)](https://github.com/ankane/osqp/actions)
5
+ [![Build Status](https://github.com/ankane/osqp-ruby/workflows/build/badge.svg?branch=master)](https://github.com/ankane/osqp-ruby/actions)
6
6
 
7
7
  ## Installation
8
8
 
9
9
  Add this line to your application’s Gemfile:
10
10
 
11
11
  ```ruby
12
- gem 'osqp'
12
+ gem "osqp"
13
13
  ```
14
14
 
15
15
  ## Getting Started
@@ -17,9 +17,9 @@ gem 'osqp'
17
17
  Prep the problem - here’s how it should be [setup](https://osqp.org/docs/examples/setup-and-solve.html)
18
18
 
19
19
  ```ruby
20
- p = [[4, 1], [0, 2]]
20
+ p = OSQP::Matrix.from_dense([[4, 1], [0, 2]])
21
21
  q = [1, 1]
22
- a = [[1, 1], [1, 0], [0, 1]]
22
+ a = OSQP::Matrix.from_dense([[1, 1], [1, 0], [0, 1]])
23
23
  l = [1, 0, 0]
24
24
  u = [1, 0.7, 0.7]
25
25
  ```
@@ -41,16 +41,26 @@ solver.warm_start(x, y)
41
41
 
42
42
  ## Data
43
43
 
44
- Arrays and matrices can be Ruby arrays
44
+ Matrices can be a sparse matrix
45
45
 
46
46
  ```ruby
47
- [[1, 2, 3], [4, 5, 6]]
47
+ a = OSQP::Matrix.new(3, 2)
48
+ a[0, 0] = 1
49
+ a[1, 0] = 2
50
+ # or
51
+ OSQP::Matrix.from_dense([[1, 0], [2, 0], [0, 0]])
48
52
  ```
49
53
 
50
- Or a Numo NArrays
54
+ Arrays can be Ruby arrays
51
55
 
52
56
  ```ruby
53
- Numo::DFloat.new(3, 2).seq
57
+ [1, 2, 3]
58
+ ```
59
+
60
+ Or Numo arrays
61
+
62
+ ```ruby
63
+ Numo::NArray.cast([1, 2, 3])
54
64
  ```
55
65
 
56
66
  ## Resources
@@ -65,22 +75,22 @@ This library is modeled after the OSQP [Python API](https://osqp.org/docs/interf
65
75
 
66
76
  ## History
67
77
 
68
- View the [changelog](https://github.com/ankane/osqp/blob/master/CHANGELOG.md)
78
+ View the [changelog](https://github.com/ankane/osqp-ruby/blob/master/CHANGELOG.md)
69
79
 
70
80
  ## Contributing
71
81
 
72
82
  Everyone is encouraged to help improve this project. Here are a few ways you can help:
73
83
 
74
- - [Report bugs](https://github.com/ankane/osqp/issues)
75
- - Fix bugs and [submit pull requests](https://github.com/ankane/osqp/pulls)
84
+ - [Report bugs](https://github.com/ankane/osqp-ruby/issues)
85
+ - Fix bugs and [submit pull requests](https://github.com/ankane/osqp-ruby/pulls)
76
86
  - Write, clarify, or fix documentation
77
87
  - Suggest or add new features
78
88
 
79
89
  To get started with development:
80
90
 
81
91
  ```sh
82
- git clone https://github.com/ankane/osqp.git
83
- cd osqp
92
+ git clone https://github.com/ankane/osqp-ruby.git
93
+ cd osqp-ruby
84
94
  bundle install
85
95
  bundle exec rake vendor:all
86
96
  bundle exec rake test
data/lib/osqp/ffi.rb CHANGED
@@ -14,6 +14,8 @@ module OSQP
14
14
  typealias "c_int", "long long"
15
15
  typealias "enum", "int"
16
16
 
17
+ OSQP_INFTY = 1e30
18
+
17
19
  Data = struct [
18
20
  "c_int n",
19
21
  "c_int m",
@@ -66,6 +68,11 @@ module OSQP
66
68
  "c_float rho_estimate"
67
69
  ]
68
70
 
71
+ Solution = struct [
72
+ "c_float *x",
73
+ "c_float *y"
74
+ ]
75
+
69
76
  Workspace = struct [
70
77
  "OSQPData *data",
71
78
  "LinSysSolver *linsys_solver",
@@ -0,0 +1,64 @@
1
+ module OSQP
2
+ class Matrix
3
+ attr_reader :m, :n
4
+
5
+ def initialize(m, n)
6
+ @m = m
7
+ @n = n
8
+ @data = {}
9
+ end
10
+
11
+ def []=(row_index, column_index, value)
12
+ raise IndexError, "row index out of bounds" if row_index < 0 || row_index >= @m
13
+ raise IndexError, "column index out of bounds" if column_index < 0 || column_index >= @n
14
+ if value == 0
15
+ (@data[column_index] ||= {}).delete(row_index)
16
+ else
17
+ (@data[column_index] ||= {})[row_index] = value
18
+ end
19
+ end
20
+
21
+ def to_ptr
22
+ cx = []
23
+ ci = []
24
+ cp = []
25
+
26
+ # CSC format
27
+ # https://www.gormanalysis.com/blog/sparse-matrix-storage-formats/
28
+ cp << 0
29
+ n.times do |j|
30
+ (@data[j] || {}).sort_by { |k, v| k }.each do |k, v|
31
+ cx << v
32
+ ci << k
33
+ end
34
+ # cumulative column values
35
+ cp << cx.size
36
+ end
37
+
38
+ nnz = cx.size
39
+ cx = Utils.float_array(cx)
40
+ ci = Utils.int_array(ci)
41
+ cp = Utils.int_array(cp)
42
+
43
+ ptr = FFI.csc_matrix(m, n, nnz, cx, ci, cp)
44
+ # save refs
45
+ ptr.instance_variable_set(:@osqp_refs, [cx, ci, cp])
46
+ ptr
47
+ end
48
+
49
+ def self.from_dense(data)
50
+ data = data.to_a
51
+ m = data.size
52
+ n = m > 0 ? data.first.size : 0
53
+
54
+ mtx = Matrix.new(m, n)
55
+ data.each_with_index do |row, i|
56
+ raise ArgumentError, "row has different number of columns" if row.size != n
57
+ row.each_with_index do |v, j|
58
+ mtx[i, j] = v if v != 0
59
+ end
60
+ end
61
+ mtx
62
+ end
63
+ end
64
+ end
data/lib/osqp/solver.rb CHANGED
@@ -4,16 +4,26 @@ module OSQP
4
4
  # settings
5
5
  set = create_settings(settings)
6
6
 
7
+ # ensure bounds within OSQP infinity
8
+ l = l.map { |v| v < -FFI::OSQP_INFTY ? -FFI::OSQP_INFTY : v }
9
+ u = u.map { |v| v > FFI::OSQP_INFTY ? FFI::OSQP_INFTY : v }
10
+
7
11
  # data
8
- m, n = shape(a)
12
+ # do not assign directly to struct to keep refs
13
+ p = csc_matrix(p, upper: true)
14
+ q = Utils.float_array(q)
15
+ a = csc_matrix(a)
16
+ l = Utils.float_array(l)
17
+ u = Utils.float_array(u)
18
+
9
19
  data = FFI::Data.malloc
10
- data.n = n
11
- data.m = m
12
- data.p = csc_matrix(p, upper: true)
13
- data.q = float_array(q)
14
- data.a = csc_matrix(a)
15
- data.l = float_array(l)
16
- data.u = float_array(u)
20
+ data.n = a.n
21
+ data.m = a.m
22
+ data.p = p
23
+ data.q = q
24
+ data.a = a
25
+ data.l = l
26
+ data.u = u
17
27
 
18
28
  # work
19
29
  work = FFI::Workspace.malloc
@@ -26,10 +36,11 @@ module OSQP
26
36
 
27
37
  check_result FFI.osqp_solve(@work)
28
38
 
29
- # data
39
+ # solution
40
+ solution = FFI::Solution.new(@work.solution)
30
41
  data = FFI::Data.new(@work.data)
31
- x = read_float_array(@work.x, data.n)
32
- y = read_float_array(@work.y, data.m)
42
+ x = read_float_array(solution.x, data.n)
43
+ y = read_float_array(solution.y, data.m)
33
44
 
34
45
  # info
35
46
  info = FFI::Info.new(@work.info)
@@ -62,11 +73,11 @@ module OSQP
62
73
  raise Error, "Expected y to be size #{m}, got #{y.size}" if y && y.size != m
63
74
 
64
75
  if x && y
65
- check_result FFI.osqp_warm_start(@work, float_array(x), float_array(y))
76
+ check_result FFI.osqp_warm_start(@work, Utils.float_array(x), Utils.float_array(y))
66
77
  elsif x
67
- check_result FFI.osqp_warm_start_x(@work, float_array(x))
78
+ check_result FFI.osqp_warm_start_x(@work, Utils.float_array(x))
68
79
  elsif y
69
- check_result FFI.osqp_warm_start_y(@work, float_array(y))
80
+ check_result FFI.osqp_warm_start_y(@work, Utils.float_array(y))
70
81
  else
71
82
  raise Error, "Must set x or y"
72
83
  end
@@ -102,16 +113,6 @@ module OSQP
102
113
  end
103
114
  end
104
115
 
105
- def float_array(arr)
106
- # OSQP float = double
107
- Fiddle::Pointer[arr.to_a.pack("d*")]
108
- end
109
-
110
- def int_array(arr)
111
- # OSQP int = long long
112
- Fiddle::Pointer[arr.to_a.pack("q*")]
113
- end
114
-
115
116
  def read_float_array(ptr, size)
116
117
  # OSQP float = double
117
118
  ptr[0, size * Fiddle::SIZEOF_DOUBLE].unpack("d*")
@@ -122,36 +123,18 @@ module OSQP
122
123
  char_ptr[0, idx].map(&:chr).join
123
124
  end
124
125
 
125
- # TODO add support sparse matrices
126
126
  def csc_matrix(mtx, upper: false)
127
- mtx = mtx.to_a
128
-
129
- m, n = shape(mtx)
130
-
131
- cx = []
132
- ci = []
133
- cp = []
134
-
135
- # CSC format
136
- # https://www.gormanalysis.com/blog/sparse-matrix-storage-formats/
137
- cp << 0
138
- n.times do |j|
139
- mtx.each_with_index do |row, i|
140
- if row[j] != 0 && (!upper || i <= j)
141
- cx << row[j]
142
- ci << i
127
+ mtx = Matrix.from_dense(mtx) unless mtx.is_a?(Matrix)
128
+
129
+ if upper
130
+ mtx.m.times do |i|
131
+ mtx.n.times do |j|
132
+ mtx[i, j] = 0 if i > j
143
133
  end
144
134
  end
145
- # cumulative column values
146
- cp << cx.size
147
135
  end
148
136
 
149
- nnz = cx.size
150
- cx = float_array(cx)
151
- ci = int_array(ci)
152
- cp = int_array(cp)
153
-
154
- FFI.csc_matrix(m, n, nnz, cx, ci, cp)
137
+ mtx
155
138
  end
156
139
 
157
140
  def dimensions
@@ -159,16 +142,6 @@ module OSQP
159
142
  [data.m, data.n]
160
143
  end
161
144
 
162
- def shape(a)
163
- if defined?(Matrix) && a.is_a?(Matrix)
164
- [a.row_count, a.column_count]
165
- elsif defined?(Numo::NArray) && a.is_a?(Numo::NArray)
166
- a.shape
167
- else
168
- [a.size, a.first.size]
169
- end
170
- end
171
-
172
145
  def create_settings(settings)
173
146
  set = FFI::Settings.malloc
174
147
  FFI.osqp_set_default_settings(set)
data/lib/osqp/utils.rb ADDED
@@ -0,0 +1,15 @@
1
+ module OSQP
2
+ module Utils
3
+ class << self
4
+ def float_array(arr)
5
+ # OSQP float = double
6
+ Fiddle::Pointer[arr.to_a.pack("d*")]
7
+ end
8
+
9
+ def int_array(arr)
10
+ # OSQP int = long long
11
+ Fiddle::Pointer[arr.to_a.pack("q*")]
12
+ end
13
+ end
14
+ end
15
+ end
data/lib/osqp/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module OSQP
2
- VERSION = "0.1.2"
2
+ VERSION = "0.2.1"
3
3
  end
data/lib/osqp.rb CHANGED
@@ -2,7 +2,9 @@
2
2
  require "fiddle/import"
3
3
 
4
4
  # modules
5
+ require "osqp/matrix"
5
6
  require "osqp/solver"
7
+ require "osqp/utils"
6
8
  require "osqp/version"
7
9
 
8
10
  module OSQP
@@ -11,19 +13,23 @@ module OSQP
11
13
  class << self
12
14
  attr_accessor :ffi_lib
13
15
  end
14
- lib_name =
16
+ lib_path =
15
17
  if Gem.win_platform?
16
- "libosqp.dll"
18
+ "x64-mingw/osqp.dll"
17
19
  elsif RbConfig::CONFIG["host_os"] =~ /darwin/i
18
- if RbConfig::CONFIG["host_cpu"] =~ /arm/i
19
- "libosqp.arm64.dylib"
20
+ if RbConfig::CONFIG["host_cpu"] =~ /arm|aarch64/i
21
+ "arm64-darwin/libosqp.dylib"
20
22
  else
21
- "libosqp.dylib"
23
+ "x86_64-darwin/libosqp.dylib"
22
24
  end
23
25
  else
24
- "libosqp.so"
26
+ if RbConfig::CONFIG["host_cpu"] =~ /arm|aarch64/i
27
+ "aarch64-linux/libosqp.so"
28
+ else
29
+ "x86_64-linux/libosqp.so"
30
+ end
25
31
  end
26
- vendor_lib = File.expand_path("../vendor/#{lib_name}", __dir__)
32
+ vendor_lib = File.expand_path("../vendor/#{lib_path}", __dir__)
27
33
  self.ffi_lib = [vendor_lib]
28
34
 
29
35
  # friendlier error message
@@ -0,0 +1,36 @@
1
+ AMD, Copyright (c), 1996-2015, Timothy A. Davis,
2
+ Patrick R. Amestoy, and Iain S. Duff. All Rights Reserved.
3
+
4
+ Availability:
5
+
6
+ http://www.suitesparse.com
7
+
8
+ -------------------------------------------------------------------------------
9
+ AMD License: BSD 3-clause:
10
+ -------------------------------------------------------------------------------
11
+
12
+ Redistribution and use in source and binary forms, with or without
13
+ modification, are permitted provided that the following conditions are met:
14
+ * Redistributions of source code must retain the above copyright
15
+ notice, this list of conditions and the following disclaimer.
16
+ * Redistributions in binary form must reproduce the above copyright
17
+ notice, this list of conditions and the following disclaimer in the
18
+ documentation and/or other materials provided with the distribution.
19
+ * Neither the name of the organizations to which the authors are
20
+ affiliated, nor the names of its contributors may be used to endorse
21
+ or promote products derived from this software without specific prior
22
+ written permission.
23
+
24
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27
+ ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
28
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
30
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32
+ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33
+ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
34
+ DAMAGE.
35
+
36
+
@@ -186,7 +186,7 @@
186
186
  same "printed page" as the copyright notice for easier
187
187
  identification within third-party archives.
188
188
 
189
- Copyright 2019 Bartolomeo Stellato, Goran Banjac, Paul Goulart, Stephen Boyd
189
+ Copyright 2021 Bartolomeo Stellato, Goran Banjac, Paul Goulart, Stephen Boyd
190
190
 
191
191
  Licensed under the Apache License, Version 2.0 (the "License");
192
192
  you may not use this file except in compliance with the License.
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
File without changes
Binary file