opt-rb 0.1.1 → 0.1.3

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: 8fbd52b19c465db0b32b7ef39a80c581904de6cfd257ca20f28c04fb0ac50b31
4
- data.tar.gz: 1dea622c2248537c91c9d66ec80b749a60485195acbc25383a6377b53f4c7086
3
+ metadata.gz: 8adfde8fc1962e5cf69e3bfb6eb1a8b416e5960ed4bfb63c6ffba8a2eff224a4
4
+ data.tar.gz: 6d799d6e79b71715ca255bb21d6935c558031b76ea945398d4d153d53c6064ea
5
5
  SHA512:
6
- metadata.gz: 405e7e4a8109885cb1c97e0fc9380e346ae9876439376635fa1d3cd0f1cdf293ca005e6bc31b7af49913c2a52ade0972690b6b155e13db07f4919eda12125625
7
- data.tar.gz: 6d3b768fefe6388cf3b21dcb499e1c80e7d2eb4c5f61febd2ce72ec1f4ea7cae790267620a452ca805684d4434fa35bcada98d9ad89865cac2f099d063fe8255
6
+ metadata.gz: 349ab72435d08d1d58203c616f194b6575c3e3210e21b0e42f23cc2dcd9e7806d1b6837e2574901cd87787432ae61c3b689535cbddf65c41cf62a0b2b49bb990
7
+ data.tar.gz: d97fb3c4449fe2d281035dc6312a23ba9bda66c7bf7b2758b293463ce8a93e6a6ec113e1af1cff9d3223b52f243de9dce84d1d6fb3986e13fecc2efcb4aa2868
data/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ ## 0.1.3 (2023-06-09)
2
+
3
+ - Fixed error with GLPK and threads
4
+
5
+ ## 0.1.2 (2023-05-01)
6
+
7
+ - Added `value` method for expressions
8
+ - Fixed error selecting solver
9
+
1
10
  ## 0.1.1 (2023-04-16)
2
11
 
3
12
  - Added support for semi-continuous and semi-integer variables
@@ -57,6 +57,13 @@ module Opt
57
57
  end
58
58
  end
59
59
 
60
+ def value
61
+ values = parts.map(&:value)
62
+ return nil if values.any?(&:nil?)
63
+
64
+ values.sum
65
+ end
66
+
60
67
  def vars
61
68
  @vars ||= @parts.flat_map(&:vars)
62
69
  end
data/lib/opt/problem.rb CHANGED
@@ -40,7 +40,7 @@ module Opt
40
40
 
41
41
  raise Error, "No solvers found" if Opt.available_solvers.empty?
42
42
 
43
- solver ||= (Opt.default_solvers[type] || Opt.available_solvers.find { |s| s.supports_type?(type) })
43
+ solver ||= (Opt.default_solvers[type] || Opt.available_solvers.find { |s| Opt.solvers[s].supports_type?(type) })
44
44
  raise Error, "No solvers found for #{type}" unless solver
45
45
 
46
46
  # TODO better error message
data/lib/opt/product.rb CHANGED
@@ -11,6 +11,12 @@ module Opt
11
11
  "#{inspect_part(@left)} * #{inspect_part(@right)}"
12
12
  end
13
13
 
14
+ def value
15
+ return nil if left.value.nil? || right.value.nil?
16
+
17
+ left.value * right.value
18
+ end
19
+
14
20
  def vars
15
21
  @vars ||= (@left.vars + @right.vars).uniq
16
22
  end
@@ -40,6 +40,7 @@ module Opt
40
40
  row_upper: row_upper,
41
41
  )
42
42
  res = model.solve(message_level: verbose ? 3 : 0, time_limit: time_limit)
43
+ model.free if model.respond_to?(:free)
43
44
 
44
45
  status =
45
46
  case res[:status]
data/lib/opt/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Opt
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opt-rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
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: 2023-04-17 00:00:00.000000000 Z
11
+ date: 2023-06-09 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: andrew@ankane.org