or-tools 0.8.1 → 0.9.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: 3c17039d61f01ad9e167b5e8d1b39995a1f8a1cffa20d4c3e26485e2f0cf6b19
4
- data.tar.gz: e8e016ac25dda825bfb0115b5604dcffae4933514532a1c24659c9afe5bc5d59
3
+ metadata.gz: 8c04ebe4cc7e1ab63d7cd996f683afe5966d3069b2915d87d68a69f3767a9bea
4
+ data.tar.gz: 44975b51bc4433d3b2d35ea8aa55a5860f77aa21503f2983bb4d83de225e1774
5
5
  SHA512:
6
- metadata.gz: 7ebd2e2454cab59523831c3d2cd073d1ab4c052c3009157784058dae07c513860658371a82edcaf77aaaf7a75a8b0153db412b2d227ce1158bdf5d9d025bacd8
7
- data.tar.gz: d556fbc1778bc761824a3f218d5eccfae6e609ad00e80abe32a547e1ea6be39ac0dc0f5dade5f89b4a7315dc3af9a1c16524bb58e988962bc752fe5aba31c3b8
6
+ metadata.gz: e5667583ce71e21fb774d499ed8b9efb12dc13776f39632595517b1d60c1c5c3f6d1d2c58f712f2e1356fb69af81a91ba8507fcb3b001df67ea2e0eb04cfa562
7
+ data.tar.gz: 0db18ffcb4b67f75067fb1b805f0160ba72fdd18d1894f47a29e6a76a969c0463d7d7e787b0a8d77891cd517eb5b9bdf4780ee771a876fde6ca53a8561084f7c
data/CHANGELOG.md CHANGED
@@ -1,3 +1,14 @@
1
+ ## 0.9.0 (2022-12-02)
2
+
3
+ - Updated OR-Tools to 9.5
4
+ - Added `solve_from_assignment_with_parameters` to `RoutingModel`
5
+ - Improved `inspect` and `to_s` for expressions
6
+
7
+ ## 0.8.2 (2022-11-05)
8
+
9
+ - Added support for bool vars to `add_hint`
10
+ - Added support for empty sums to `CpModel`
11
+
1
12
  ## 0.8.1 (2022-08-22)
2
13
 
3
14
  - Added binary installation for Ubuntu 22.04
@@ -11,7 +22,7 @@
11
22
 
12
23
  ## 0.7.3 (2022-07-23)
13
24
 
14
- - Added more methods to `RoutingModel` and `RoutingDimension`
25
+ - Added more methods to `RoutingModel` and `RoutingDimension`
15
26
 
16
27
  ## 0.7.2 (2022-05-28)
17
28
 
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",
@@ -47,7 +47,6 @@ namespace Rice::detail
47
47
  void init_linear(Rice::Module& m) {
48
48
  Rice::define_class_under<LinearRange>(m, "LinearRange");
49
49
 
50
- // TODO remove in 0.8.0
51
50
  auto rb_cLinearExpr = Rice::define_class_under<LinearExpr>(m, "LinearExpr");
52
51
  rb_cLinearExpr.define_constructor(Rice::Constructor<LinearExpr>());
53
52
 
@@ -388,6 +388,11 @@ void init_routing(Rice::Module& m) {
388
388
  [](RoutingModel& self, const RoutingSearchParameters& search_parameters) {
389
389
  return self.SolveWithParameters(search_parameters);
390
390
  })
391
+ .define_method(
392
+ "solve_from_assignment_with_parameters",
393
+ [](RoutingModel& self, const Assignment* assignment, const RoutingSearchParameters& search_parameters) {
394
+ return self.SolveFromAssignmentWithParameters(assignment, search_parameters);
395
+ })
391
396
  .define_method("compute_lower_bound", &RoutingModel::ComputeLowerBound)
392
397
  .define_method("status",
393
398
  [](RoutingModel& self) {
@@ -4,15 +4,15 @@ require "fileutils"
4
4
  require "net/http"
5
5
  require "tmpdir"
6
6
 
7
- version = "9.4.1874"
7
+ version = "9.5.2237"
8
8
 
9
9
  if RbConfig::CONFIG["host_os"] =~ /darwin/i
10
10
  if RbConfig::CONFIG["host_cpu"] =~ /arm|aarch64/i
11
- filename = "or-tools_arm64_MacOsX-12.5_cpp_v#{version}.tar.gz"
12
- checksum = "ebc185bcb0a056a2704fb1c5175d5c11cc21a7e0634be65139cea55bb6a021ce"
11
+ filename = "or-tools_arm64_macOS-13.0.1_cpp_v#{version}.tar.gz"
12
+ checksum = "9041ccb29618bce793c68eaa30a01b1fbaa6491656bddd942753d9a412544db7"
13
13
  else
14
- filename = "or-tools_x86_64_MacOsX-12.5_cpp_v#{version}.tar.gz"
15
- checksum = "d03c706b51a6ef7aa77886dc3f135baaac52c00803bb548c286fbdeb4a419acd"
14
+ filename = "or-tools_x86_64_macOS-13.0.1_cpp_v#{version}.tar.gz"
15
+ checksum = "f4af2bfd3b19cff6056e01abcddf1f5a54a0da891cafd73a25a671a3abd17c76"
16
16
  end
17
17
  else
18
18
  # try /etc/os-release with fallback to /usr/lib/os-release
@@ -27,25 +27,25 @@ else
27
27
 
28
28
  if os == "ubuntu" && os_version == "22.04"
29
29
  filename = "or-tools_amd64_ubuntu-22.04_cpp_v#{version}.tar.gz"
30
- checksum = "d7e222fc4f30c9864bfa3062accc8b4dd291c3166ba9cf3576c6c86eded71940"
30
+ checksum = "acecd79867f4bd5f6b91d95743fc858e939d8611e534914a540ee4f46c535247"
31
31
  elsif os == "ubuntu" && os_version == "20.04"
32
32
  filename = "or-tools_amd64_ubuntu-20.04_cpp_v#{version}.tar.gz"
33
- checksum = "1b09f0f60b5aab83aeec468842e4a166cd3a4e7910e807f55bc7f96d5dffabdb"
33
+ checksum = "506b420e1b1232440e49680e55ae087000f2c92b1009e46417c774d8332f217b"
34
34
  elsif os == "ubuntu" && os_version == "18.04"
35
35
  filename = "or-tools_amd64_ubuntu-18.04_cpp_v#{version}.tar.gz"
36
- checksum = "ef73ebd4ca0f82a1179fdb2aded3c2a85dfe2ab275d91b8a5b147a653ca861ab"
36
+ checksum = "96ee5b4f3cf6dfece6dc54a78c6aa4a55dae5bd7d4f4176b332d3f3aa6cd973f"
37
37
  elsif os == "debian" && os_version == "11"
38
38
  filename = "or-tools_amd64_debian-11_cpp_v#{version}.tar.gz"
39
- checksum = "651c62147f231fb90635c522e0a2c799e3de3991c2c75f7c6acb721e7b78946c"
39
+ checksum = "00bef600d0e2452544484f26f49bada4f717d7735f9d65c3961def8ab83876d3"
40
40
  elsif os == "debian" && os_version == "10"
41
41
  filename = "or-tools_amd64_debian-10_cpp_v#{version}.tar.gz"
42
- checksum = "36088bc6c6fbb96539245db7cddf498f77ae3e7b7c2cc8f6d7d89d76f90751fb"
42
+ checksum = "a45c566dbfe818386bc1aa061a167650c691f447b2937cdc8bdb1e9054ba4715"
43
43
  elsif os == "centos" && os_version == "8"
44
44
  filename = "or-tools_amd64_centos-8_cpp_v#{version}.tar.gz"
45
- checksum = "da2cb303ae332d207592f21bb504e4e2e33dc1b1e8f5747d413c082d9d05504a"
45
+ checksum = "af82328d06c402917735482045e7abc37a6f9258db3d607d6efc62c27f765334"
46
46
  elsif os == "centos" && os_version == "7"
47
47
  filename = "or-tools_amd64_centos-7_cpp_v#{version}.tar.gz"
48
- checksum = "9eaf0178467f4d2fdbe496f62223809aa43e313548cc6cb716e661c00472b4ff"
48
+ checksum = "3d28bdd3ab27224b80960393c7f51e7c228ae78297c28e4ae79bc6c269ae44fe"
49
49
  else
50
50
  platform =
51
51
  if Gem.win_platform?
@@ -9,12 +9,11 @@ module ORTools
9
9
  end
10
10
 
11
11
  def to_s
12
- "#{left.inspect} #{operator} #{right.inspect}"
12
+ "#{left} #{operator} #{right}"
13
13
  end
14
14
 
15
- # TODO add class
16
15
  def inspect
17
- to_s
16
+ "#<#{self.class.name} #{to_s}>"
18
17
  end
19
18
  end
20
19
  end
@@ -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,5 +1,4 @@
1
1
  module ORTools
2
- # TODO change to VariableExpr in 0.8.0
3
2
  class MPVariable < LinearExpr
4
3
  def add_self_to_coeff_map_or_stack(coeffs, multiplier, stack)
5
4
  coeffs[self] += multiplier
@@ -13,7 +13,11 @@ module ORTools
13
13
  if @coef == -1
14
14
  "-#{@expr}"
15
15
  else
16
- "(#{@coef} * #{@expr})"
16
+ expr = @expr.to_s
17
+ if expr.include?("+") || expr.include?("-")
18
+ expr = "(#{expr})"
19
+ end
20
+ "#{@coef} * #{expr}"
17
21
  end
18
22
  end
19
23
 
@@ -22,9 +22,8 @@ module ORTools
22
22
  name
23
23
  end
24
24
 
25
- # TODO add class
26
25
  def inspect
27
- to_s
26
+ "#<#{self.class.name} #{to_s}>"
28
27
  end
29
28
  end
30
29
  end
@@ -27,7 +27,7 @@ module ORTools
27
27
  def to_s
28
28
  vars.map do |v|
29
29
  k = v[0]
30
- k = k.respond_to?(:name) ? k.name : k.inspect
30
+ k = k.respond_to?(:name) ? k.name : k.to_s
31
31
  if v[1] == 1
32
32
  k
33
33
  else
@@ -36,9 +36,8 @@ module ORTools
36
36
  end.join(" + ").sub(" + -", " - ")
37
37
  end
38
38
 
39
- # TODO add class
40
39
  def inspect
41
- to_s
40
+ "#<#{self.class.name} #{to_s}>"
42
41
  end
43
42
 
44
43
  private
@@ -17,7 +17,7 @@ module ORTools
17
17
  end
18
18
 
19
19
  def to_s
20
- "(#{@array.map(&:to_s).join(" + ")})"
20
+ "#{@array.map(&:to_s).reject { |v| v == "0" }.join(" + ")}".gsub(" + -", " - ")
21
21
  end
22
22
  end
23
23
  end
@@ -1,3 +1,3 @@
1
1
  module ORTools
2
- VERSION = "0.8.1"
2
+ VERSION = "0.9.0"
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.9.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: 2022-08-22 00:00:00.000000000 Z
11
+ date: 2022-12-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rice