glpk 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 690771cd02dd1a3291ddf745247b26e45277bb5c3da3d40c3c3bd0d0162d91a7
4
- data.tar.gz: 051ded67d27bb14cfa1633c70e15b770920ebc01bbbbb6d32cac24a9f605902e
3
+ metadata.gz: 562dd3b6bbfbe501c454ab80f9a44ecadbc20035a0e52542dbeb03ebac763056
4
+ data.tar.gz: c56673b4b51e15e6657d35e813473ec192fff0f5d03f2bc3ebf1a5e99b97abe8
5
5
  SHA512:
6
- metadata.gz: 4561bc766f46edad790f9dff4259c91f2a5fb06008694dd3f6d668342472fb5eaf9faace3e714da01cf785b2681ae182c6a4ccd4d9e4bdc9e93dfe9042d5a3fc
7
- data.tar.gz: 8baebc4a5c8e7de113d87bec86fc7d6fe491c562bec192c91e7d5b5bbb76757902fee0d09f33f267044ff2eb5428fe5ecb3d9df6e32763ccef26f871109677d9
6
+ metadata.gz: d09999eea8b64cb9b432bffd60620e4b7aab27e578593f0489152525f62a125529c122a3a74a9d06874e141bd50a26b79a984148705f555cdfc06007cf7fdbb8
7
+ data.tar.gz: e6b556121291fcf6c6bc0a41a06f38910990dcdc74808c85c38b45ce65c19661a547ca52712c95f09bd389124c50f2f265e4105d9ffbc9b3557f88f719c8442b
data/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
+ ## 0.3.0 (2024-10-22)
2
+
3
+ - Dropped support for Ruby < 3.1
4
+
5
+ ## 0.2.1 (2023-06-07)
6
+
7
+ - Added `free` method
8
+ - Improved support for Mac ARM
9
+ - Fixed error with `dup` and `clone`
10
+
1
11
  ## 0.2.0 (2023-01-25)
2
12
 
3
13
  - Improved MIP status when LP fails
data/README.md CHANGED
@@ -2,7 +2,9 @@
2
2
 
3
3
  [GLPK](https://www.gnu.org/software/glpk/) - the GNU linear programming kit - for Ruby
4
4
 
5
- [![Build Status](https://github.com/ankane/glpk-ruby/workflows/build/badge.svg?branch=master)](https://github.com/ankane/glpk-ruby/actions)
5
+ Check out [Opt](https://github.com/ankane/opt) for a high-level interface
6
+
7
+ [![Build Status](https://github.com/ankane/glpk-ruby/actions/workflows/build.yml/badge.svg)](https://github.com/ankane/glpk-ruby/actions)
6
8
 
7
9
  ## Installation
8
10
 
@@ -74,6 +76,12 @@ problem = Glpk.read_lp("hello.lp")
74
76
  problem = Glpk.read_mps("hello.mps")
75
77
  ```
76
78
 
79
+ Free the problem (required in multi-threaded environments)
80
+
81
+ ```ruby
82
+ problem.free
83
+ ```
84
+
77
85
  ## Reference
78
86
 
79
87
  Set the message level
data/lib/glpk/problem.rb CHANGED
@@ -2,7 +2,13 @@ module Glpk
2
2
  class Problem
3
3
  def initialize
4
4
  @model = FFI.glp_create_prob
5
- ObjectSpace.define_finalizer(self, self.class.finalize(@model))
5
+ @model.free = FFI["glp_delete_prob"]
6
+ end
7
+
8
+ def free
9
+ model.free = nil
10
+ FFI.glp_delete_prob(model)
11
+ @model = nil
6
12
  end
7
13
 
8
14
  def load_problem(obj_dir:, obj_coef:, mat_ia:, mat_ja:, mat_ar:, col_kind:, col_lower:, col_upper:, row_lower:, row_upper:)
@@ -73,14 +79,10 @@ module Glpk
73
79
  end
74
80
  end
75
81
 
76
- def self.finalize(model)
77
- # must use proc instead of stabby lambda
78
- proc { FFI.glp_delete_prob(model) }
79
- end
80
-
81
82
  private
82
83
 
83
84
  def model
85
+ raise Error, "can't use freed problem" unless @model
84
86
  @model
85
87
  end
86
88
 
@@ -121,7 +123,7 @@ module Glpk
121
123
  row_primal: num_rows.times.map { |i| FFI.glp_get_row_prim(model, i + 1) },
122
124
  col_primal: num_cols.times.map { |i| FFI.glp_get_col_prim(model, i + 1) },
123
125
  row_dual: num_rows.times.map { |i| FFI.glp_get_row_dual(model, i + 1) },
124
- col_dual: num_cols.times.map { |i| FFI.glp_get_col_dual(model, i + 1) },
126
+ col_dual: num_cols.times.map { |i| FFI.glp_get_col_dual(model, i + 1) }
125
127
  }
126
128
  end
127
129
 
data/lib/glpk/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Glpk
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
data/lib/glpk.rb CHANGED
@@ -2,8 +2,8 @@
2
2
  require "fiddle/import"
3
3
 
4
4
  # modules
5
- require "glpk/problem"
6
- require "glpk/version"
5
+ require_relative "glpk/problem"
6
+ require_relative "glpk/version"
7
7
 
8
8
  module Glpk
9
9
  class Error < StandardError; end
@@ -16,7 +16,11 @@ module Glpk
16
16
  # TODO test
17
17
  ["glpk.dll"]
18
18
  elsif RbConfig::CONFIG["host_os"] =~ /darwin/i
19
- ["libglpk.dylib"]
19
+ if RbConfig::CONFIG["host_cpu"] =~ /arm|aarch64/i
20
+ ["libglpk.dylib", "/opt/homebrew/lib/libglpk.dylib"]
21
+ else
22
+ ["libglpk.dylib"]
23
+ end
20
24
  else
21
25
  ["libglpk.so", "libglpk.so.40"]
22
26
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glpk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-01-26 00:00:00.000000000 Z
12
- dependencies: []
11
+ date: 2024-10-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: fiddle
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  description:
14
28
  email: andrew@ankane.org
15
29
  executables: []
@@ -35,14 +49,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
35
49
  requirements:
36
50
  - - ">="
37
51
  - !ruby/object:Gem::Version
38
- version: '2.7'
52
+ version: '3.1'
39
53
  required_rubygems_version: !ruby/object:Gem::Requirement
40
54
  requirements:
41
55
  - - ">="
42
56
  - !ruby/object:Gem::Version
43
57
  version: '0'
44
58
  requirements: []
45
- rubygems_version: 3.4.1
59
+ rubygems_version: 3.5.16
46
60
  signing_key:
47
61
  specification_version: 4
48
62
  summary: Linear programming kit for Ruby