osqp 0.1.2 → 0.1.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: eec3a6f84d3330d75ac4bd3293ecfa4a13fd6bd1134ccf663a885db6f9d38fe1
4
- data.tar.gz: 40330861bf996109a354d294100532fa8b56f1f1e523cbd8422a5123322f5dd0
3
+ metadata.gz: e9808787d2680d0620a0d332fd4d42fbc95474d313bfa6ffa4b65f7d42c27d08
4
+ data.tar.gz: a49f6357ef19809d5b33a9463b0b2c2af573822cf82867445b15548bf4a6035a
5
5
  SHA512:
6
- metadata.gz: 51f93c37d11a8804b01813a0523aa7cce9b71babf794527c1208004534501dcdc3ae8334214a9ed01794dce38297f03714f8c35ab67e3754a1265b607900fe16
7
- data.tar.gz: d848c6cbf0bc426bbfc77142d16095117f53351ec42bd36115903307e32353b0e5a0a74baf9800f8c1c6a0aab5b78608fc9df592b13077695c93159f1306ee86
6
+ metadata.gz: 2e0ae4959e05063d439ecf0897eb4d406dbf84c1601629d845c7ee2b2b2ed88cf83a60ad90a7c1d6b572681e38d148ae05bb3a3fb7504eb7ad8e1f2cb5a94526
7
+ data.tar.gz: 62bf72c42951365a0e9ad548e20849a949dd4058d9198f02fffd63373fc137facf07afe857c9fdecc41e15ddfb1241eef9aa177acdfb85531accfe54f8218e33
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 0.1.3 (2022-04-08)
2
+
3
+ - Improved ARM detection
4
+ - Fixed `x` and `y` in solution
5
+ - Fixed memory issue
6
+
1
7
  ## 0.1.2 (2021-01-05)
2
8
 
3
9
  - 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
@@ -65,22 +65,22 @@ This library is modeled after the OSQP [Python API](https://osqp.org/docs/interf
65
65
 
66
66
  ## History
67
67
 
68
- View the [changelog](https://github.com/ankane/osqp/blob/master/CHANGELOG.md)
68
+ View the [changelog](https://github.com/ankane/osqp-ruby/blob/master/CHANGELOG.md)
69
69
 
70
70
  ## Contributing
71
71
 
72
72
  Everyone is encouraged to help improve this project. Here are a few ways you can help:
73
73
 
74
- - [Report bugs](https://github.com/ankane/osqp/issues)
75
- - Fix bugs and [submit pull requests](https://github.com/ankane/osqp/pulls)
74
+ - [Report bugs](https://github.com/ankane/osqp-ruby/issues)
75
+ - Fix bugs and [submit pull requests](https://github.com/ankane/osqp-ruby/pulls)
76
76
  - Write, clarify, or fix documentation
77
77
  - Suggest or add new features
78
78
 
79
79
  To get started with development:
80
80
 
81
81
  ```sh
82
- git clone https://github.com/ankane/osqp.git
83
- cd osqp
82
+ git clone https://github.com/ankane/osqp-ruby.git
83
+ cd osqp-ruby
84
84
  bundle install
85
85
  bundle exec rake vendor:all
86
86
  bundle exec rake test
data/lib/osqp/ffi.rb CHANGED
@@ -66,6 +66,11 @@ module OSQP
66
66
  "c_float rho_estimate"
67
67
  ]
68
68
 
69
+ Solution = struct [
70
+ "c_float *x",
71
+ "c_float *y"
72
+ ]
73
+
69
74
  Workspace = struct [
70
75
  "OSQPData *data",
71
76
  "LinSysSolver *linsys_solver",
data/lib/osqp/solver.rb CHANGED
@@ -5,15 +5,16 @@ module OSQP
5
5
  set = create_settings(settings)
6
6
 
7
7
  # data
8
+ refs = []
8
9
  m, n = shape(a)
9
10
  data = FFI::Data.malloc
10
11
  data.n = n
11
12
  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)
13
+ data.p = csc_matrix(p, refs, upper: true)
14
+ data.q = float_array(q, refs)
15
+ data.a = csc_matrix(a, refs)
16
+ data.l = float_array(l, refs)
17
+ data.u = float_array(u, refs)
17
18
 
18
19
  # work
19
20
  work = FFI::Workspace.malloc
@@ -26,10 +27,11 @@ module OSQP
26
27
 
27
28
  check_result FFI.osqp_solve(@work)
28
29
 
29
- # data
30
+ # solution
31
+ solution = FFI::Solution.new(@work.solution)
30
32
  data = FFI::Data.new(@work.data)
31
- x = read_float_array(@work.x, data.n)
32
- y = read_float_array(@work.y, data.m)
33
+ x = read_float_array(solution.x, data.n)
34
+ y = read_float_array(solution.y, data.m)
33
35
 
34
36
  # info
35
37
  info = FFI::Info.new(@work.info)
@@ -102,14 +104,18 @@ module OSQP
102
104
  end
103
105
  end
104
106
 
105
- def float_array(arr)
107
+ def float_array(arr, refs = nil)
106
108
  # OSQP float = double
107
- Fiddle::Pointer[arr.to_a.pack("d*")]
109
+ ptr = Fiddle::Pointer[arr.to_a.pack("d*")]
110
+ refs << ptr if refs
111
+ ptr
108
112
  end
109
113
 
110
- def int_array(arr)
114
+ def int_array(arr, refs = nil)
111
115
  # OSQP int = long long
112
- Fiddle::Pointer[arr.to_a.pack("q*")]
116
+ ptr = Fiddle::Pointer[arr.to_a.pack("q*")]
117
+ refs << ptr if refs
118
+ ptr
113
119
  end
114
120
 
115
121
  def read_float_array(ptr, size)
@@ -123,7 +129,7 @@ module OSQP
123
129
  end
124
130
 
125
131
  # TODO add support sparse matrices
126
- def csc_matrix(mtx, upper: false)
132
+ def csc_matrix(mtx, refs, upper: false)
127
133
  mtx = mtx.to_a
128
134
 
129
135
  m, n = shape(mtx)
@@ -147,9 +153,9 @@ module OSQP
147
153
  end
148
154
 
149
155
  nnz = cx.size
150
- cx = float_array(cx)
151
- ci = int_array(ci)
152
- cp = int_array(cp)
156
+ cx = float_array(cx, refs)
157
+ ci = int_array(ci, refs)
158
+ cp = int_array(cp, refs)
153
159
 
154
160
  FFI.csc_matrix(m, n, nnz, cx, ci, cp)
155
161
  end
data/lib/osqp/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module OSQP
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
data/lib/osqp.rb CHANGED
@@ -15,7 +15,7 @@ module OSQP
15
15
  if Gem.win_platform?
16
16
  "libosqp.dll"
17
17
  elsif RbConfig::CONFIG["host_os"] =~ /darwin/i
18
- if RbConfig::CONFIG["host_cpu"] =~ /arm/i
18
+ if RbConfig::CONFIG["host_cpu"] =~ /arm|aarch64/i
19
19
  "libosqp.arm64.dylib"
20
20
  else
21
21
  "libosqp.dylib"
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: osqp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-01-06 00:00:00.000000000 Z
11
+ date: 2022-04-09 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
- email: andrew@chartkick.com
14
+ email: andrew@ankane.org
15
15
  executables: []
16
16
  extensions: []
17
17
  extra_rdoc_files: []
@@ -30,7 +30,7 @@ files:
30
30
  - vendor/libosqp.dll
31
31
  - vendor/libosqp.dylib
32
32
  - vendor/libosqp.so
33
- homepage: https://github.com/ankane/osqp
33
+ homepage: https://github.com/ankane/osqp-ruby
34
34
  licenses:
35
35
  - Apache-2.0
36
36
  metadata: {}
@@ -49,7 +49,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
49
49
  - !ruby/object:Gem::Version
50
50
  version: '0'
51
51
  requirements: []
52
- rubygems_version: 3.2.3
52
+ rubygems_version: 3.3.7
53
53
  signing_key:
54
54
  specification_version: 4
55
55
  summary: OSQP (Operator Splitting Quadratic Program) solver for Ruby