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 +4 -4
- data/CHANGELOG.md +10 -0
- data/README.md +9 -1
- data/lib/glpk/problem.rb +9 -7
- data/lib/glpk/version.rb +1 -1
- data/lib/glpk.rb +7 -3
- metadata +19 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 562dd3b6bbfbe501c454ab80f9a44ecadbc20035a0e52542dbeb03ebac763056
|
4
|
+
data.tar.gz: c56673b4b51e15e6657d35e813473ec192fff0f5d03f2bc3ebf1a5e99b97abe8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d09999eea8b64cb9b432bffd60620e4b7aab27e578593f0489152525f62a125529c122a3a74a9d06874e141bd50a26b79a984148705f555cdfc06007cf7fdbb8
|
7
|
+
data.tar.gz: e6b556121291fcf6c6bc0a41a06f38910990dcdc74808c85c38b45ce65c19661a547ca52712c95f09bd389124c50f2f265e4105d9ffbc9b3557f88f719c8442b
|
data/CHANGELOG.md
CHANGED
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
|
-
[
|
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
|
-
|
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
data/lib/glpk.rb
CHANGED
@@ -2,8 +2,8 @@
|
|
2
2
|
require "fiddle/import"
|
3
3
|
|
4
4
|
# modules
|
5
|
-
|
6
|
-
|
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
|
-
["
|
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.
|
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:
|
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: '
|
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.
|
59
|
+
rubygems_version: 3.5.16
|
46
60
|
signing_key:
|
47
61
|
specification_version: 4
|
48
62
|
summary: Linear programming kit for Ruby
|