or-tools 0.8.1 → 0.8.2

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: 3c17039d61f01ad9e167b5e8d1b39995a1f8a1cffa20d4c3e26485e2f0cf6b19
4
- data.tar.gz: e8e016ac25dda825bfb0115b5604dcffae4933514532a1c24659c9afe5bc5d59
3
+ metadata.gz: 3f76c7d5e0a5232ea519e3d96773c1c62ec718c4431f26d770db31881680662a
4
+ data.tar.gz: 951a90e2c6a30418ebc6c267a55205acb0946048278ee822912767b2a639ebc3
5
5
  SHA512:
6
- metadata.gz: 7ebd2e2454cab59523831c3d2cd073d1ab4c052c3009157784058dae07c513860658371a82edcaf77aaaf7a75a8b0153db412b2d227ce1158bdf5d9d025bacd8
7
- data.tar.gz: d556fbc1778bc761824a3f218d5eccfae6e609ad00e80abe32a547e1ea6be39ac0dc0f5dade5f89b4a7315dc3af9a1c16524bb58e988962bc752fe5aba31c3b8
6
+ metadata.gz: be8e00e0553d9413a4d213af5647cccd46baaf3f724981c7e3234d08420cf44cc039a5ef24b6f35460ba36644d6690ba697b19c6f62a647a0ddda5af447f887d
7
+ data.tar.gz: 1219df9128db35f3fec3c040b19c9a66a26a08c9222a97ef10aec5c09173bb256e7c35cbeb528d6bf2c5f81ebc06c58149f3f2f48a8dc1e5ac370b668b6f20df
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## 0.8.2 (2022-11-05)
2
+
3
+ - Added support for bool vars to `add_hint`
4
+ - Added support for empty sums to `CpModel`
5
+
1
6
  ## 0.8.1 (2022-08-22)
2
7
 
3
8
  - Added binary installation for Ubuntu 22.04
@@ -11,7 +16,7 @@
11
16
 
12
17
  ## 0.7.3 (2022-07-23)
13
18
 
14
- - Added more methods to `RoutingModel` and `RoutingDimension`
19
+ - Added more methods to `RoutingModel` and `RoutingDimension`
15
20
 
16
21
  ## 0.7.2 (2022-05-28)
17
22
 
data/README.md CHANGED
@@ -14,7 +14,7 @@ gem "or-tools"
14
14
 
15
15
  Installation can take a few minutes as OR-Tools downloads and builds.
16
16
 
17
- ## Guides
17
+ ## Getting Started
18
18
 
19
19
  Higher Level Interfaces
20
20
 
@@ -298,8 +298,18 @@ void init_constraint(Rice::Module& m) {
298
298
  })
299
299
  .define_method(
300
300
  "add_hint",
301
- [](CpModelBuilder& self, IntVar var, int64_t value) {
302
- self.AddHint(var, value);
301
+ [](CpModelBuilder& self, Object var, Object value) {
302
+ if (var.is_a(rb_cBoolVar)) {
303
+ self.AddHint(
304
+ Rice::detail::From_Ruby<BoolVar>().convert(var.value()),
305
+ Rice::detail::From_Ruby<bool>().convert(value.value())
306
+ );
307
+ } else {
308
+ self.AddHint(
309
+ Rice::detail::From_Ruby<IntVar>().convert(var.value()),
310
+ Rice::detail::From_Ruby<int64_t>().convert(value.value())
311
+ );
312
+ }
303
313
  })
304
314
  .define_method(
305
315
  "clear_hints",
@@ -1,25 +1,34 @@
1
1
  module ORTools
2
2
  class CpModel
3
3
  def add(comparison)
4
- method_name =
5
- case comparison.operator
6
- when "=="
7
- :add_equality
8
- when "!="
9
- :add_not_equal
10
- when ">"
11
- :add_greater_than
12
- when ">="
13
- :add_greater_or_equal
14
- when "<"
15
- :add_less_than
16
- when "<="
17
- :add_less_or_equal
18
- else
19
- raise ArgumentError, "Unknown operator: #{comparison.operator}"
20
- end
4
+ case comparison
5
+ when Comparison
6
+ method_name =
7
+ case comparison.operator
8
+ when "=="
9
+ :add_equality
10
+ when "!="
11
+ :add_not_equal
12
+ when ">"
13
+ :add_greater_than
14
+ when ">="
15
+ :add_greater_or_equal
16
+ when "<"
17
+ :add_less_than
18
+ when "<="
19
+ :add_less_or_equal
20
+ else
21
+ raise ArgumentError, "Unknown operator: #{comparison.operator}"
22
+ end
21
23
 
22
- send(method_name, comparison.left, comparison.right)
24
+ send(method_name, comparison.left, comparison.right)
25
+ when true
26
+ add_bool_or([true_var])
27
+ when false
28
+ add_bool_or([])
29
+ else
30
+ raise TypeError, "Not supported: CpModel#add(#{comparison})"
31
+ end
23
32
  end
24
33
 
25
34
  def sum(arr)
@@ -1,3 +1,3 @@
1
1
  module ORTools
2
- VERSION = "0.8.1"
2
+ VERSION = "0.8.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: or-tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-08-22 00:00:00.000000000 Z
11
+ date: 2022-11-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rice