or-tools 0.10.1 → 0.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6c2f60a5c859f2659349bfb6f77336d2078f8d8747b76fcd8e3e10e7cfb25e28
4
- data.tar.gz: a8d18cf5002f42735d1e458451f7902909ad7e552ed78e77ef52477108bbed16
3
+ metadata.gz: db5ea336dfbb4e2a150736473ff1e51cbd125976ea287a130b95316d81b438b2
4
+ data.tar.gz: 2998d8aefe52396ebabe019d5093343980c785c2735ae3f1396d884000f9cc1c
5
5
  SHA512:
6
- metadata.gz: 7394863f44908fcadda86df82fa469c69e6178cdc376db90cc2a1d1142738af7f60b22eb0d66ad252ff1c8fd4a93d169194b462973ce158797519d0b5bb8a5dc
7
- data.tar.gz: c8b8ca7f9f0c78e2dbf88555f23d5463e0b281e65afd83ebcd581062203d8b348aa76acf87f0bb55fef5736882cea48e33cd9a6f801addc60e80de9051b7fcf8
6
+ metadata.gz: 25a64519e5ca3ec8e2746369e54f234961022da4bad42283e76ad323b9e39218683d0e1831a7e79bb46237966674f1729b46e50c894f435dceee438bdd1e6aee
7
+ data.tar.gz: 47c5ae441d52e4e84bb2f1efcb97b1f9b0786870fb6f6ddb87b6e115a1ab337453c1550b3bed3d4a3558393f250b37367653104a31ea1fbb57fe6f290ac37f86
data/CHANGELOG.md CHANGED
@@ -1,3 +1,14 @@
1
+ ## 0.11.1 (2023-12-04)
2
+
3
+ - Added binary installation for Arch Linux
4
+ - Added binary installation for Debian 11 ARM
5
+
6
+ ## 0.11.0 (2023-11-16)
7
+
8
+ - Updated OR-Tools to 9.8
9
+ - Dropped support for Ubuntu 18.04, Debian 10, and CentOS 8
10
+ - Dropped support for Ruby < 3
11
+
1
12
  ## 0.10.1 (2023-03-20)
2
13
 
3
14
  - Added `domain` method to `SatIntVar`
data/README.md CHANGED
@@ -1607,6 +1607,8 @@ end
1607
1607
  solver.minimize(data[:bins].sum { |j| y[j] })
1608
1608
 
1609
1609
  # call the solver and print the solution
1610
+ status = solver.solve
1611
+
1610
1612
  if status == :optimal
1611
1613
  num_bins = 0
1612
1614
  data[:bins].each do |j|
@@ -152,6 +152,14 @@ void init_constraint(Rice::Module& m) {
152
152
  "enumerate_all_solutions",
153
153
  [](SatParameters& self) {
154
154
  return self.enumerate_all_solutions();
155
+ })
156
+ .define_method("num_workers=",
157
+ [](SatParameters& self, int32_t value){
158
+ self.set_num_workers(value);
159
+ })
160
+ .define_method("cp_model_presolve=",
161
+ [](SatParameters& self, bool value) {
162
+ self.set_cp_model_presolve(value);
155
163
  });
156
164
 
157
165
  Rice::define_class_under<CpModelBuilder>(m, "CpModel")
@@ -408,10 +416,13 @@ void init_constraint(Rice::Module& m) {
408
416
  parameters.set_num_search_workers(1);
409
417
 
410
418
  m.Add(NewFeasibleSolutionObserver(
411
- [callback](const CpSolverResponse& r) {
412
- // TODO find a better way to do this
413
- callback.call("response=", r);
414
- callback.call("on_solution_callback");
419
+ [&callback](const CpSolverResponse& r) {
420
+ // ensure Ruby thread
421
+ if (ruby_native_thread_p()) {
422
+ // TODO find a better way to do this
423
+ callback.call("response=", r);
424
+ callback.call("on_solution_callback");
425
+ }
415
426
  })
416
427
  );
417
428
  }
@@ -26,7 +26,10 @@ end
26
26
  # find_header and find_library first check without adding path
27
27
  # which can cause them to find system library
28
28
  $INCFLAGS << " -I#{inc}"
29
- $LDFLAGS.prepend("-Wl,-rpath,#{rpath} -L#{lib} ")
29
+ # could support shared libraries for protobuf and abseil
30
+ # but keep simple for now
31
+ raise "libprotobuf.a not found" unless File.exist?("#{lib}/libprotobuf.a")
32
+ $LDFLAGS.prepend("-Wl,-rpath,#{rpath} -L#{lib} #{lib}/libprotobuf.a ")
30
33
  raise "OR-Tools not found" unless have_library("ortools")
31
34
 
32
35
  create_makefile("or_tools/ext")
@@ -353,8 +353,24 @@ void init_routing(Rice::Module& m) {
353
353
  .define_method("vehicle_allowed_for_index?", &RoutingModel::IsVehicleAllowedForIndex)
354
354
  .define_method("add_pickup_and_delivery", &RoutingModel::AddPickupAndDelivery)
355
355
  .define_method("add_pickup_and_delivery_sets", &RoutingModel::AddPickupAndDeliverySets)
356
- .define_method("pickup_index_pairs", &RoutingModel::GetPickupIndexPairs)
357
- .define_method("delivery_index_pairs", &RoutingModel::GetDeliveryIndexPairs)
356
+ .define_method(
357
+ "pickup_positions",
358
+ [](RoutingModel& self, int64_t node_index) {
359
+ std::vector<std::pair<int, int>> positions;
360
+ for (const auto& v : self.GetPickupPositions(node_index)) {
361
+ positions.emplace_back(v.pd_pair_index, v.alternative_index);
362
+ }
363
+ return positions;
364
+ })
365
+ .define_method(
366
+ "delivery_positions",
367
+ [](RoutingModel& self, int64_t node_index) {
368
+ std::vector<std::pair<int, int>> positions;
369
+ for (const auto& v : self.GetDeliveryPositions(node_index)) {
370
+ positions.emplace_back(v.pd_pair_index, v.alternative_index);
371
+ }
372
+ return positions;
373
+ })
358
374
  // TODO SetPickupAndDeliveryPolicyOfAllVehicles
359
375
  // TODO SetPickupAndDeliveryPolicyOfVehicle
360
376
  // TODO GetPickupAndDeliveryPolicyOfVehicle
@@ -4,15 +4,18 @@ require "fileutils"
4
4
  require "net/http"
5
5
  require "tmpdir"
6
6
 
7
- version = "9.6.2534"
7
+ version = "9.8.3296"
8
+
9
+ arch = RbConfig::CONFIG["host_cpu"]
10
+ arm = arch =~ /arm|aarch64/i
8
11
 
9
12
  if RbConfig::CONFIG["host_os"] =~ /darwin/i
10
- if RbConfig::CONFIG["host_cpu"] =~ /arm|aarch64/i
11
- filename = "or-tools_arm64_macOS-13.2.1_cpp_v#{version}.tar.gz"
12
- checksum = "bb82c3b071e8ea5366a52137f400b280120221611758e38bf3d55c819f81c34b"
13
+ if arm
14
+ filename = "or-tools_arm64_macOS-14.1_cpp_v#{version}.tar.gz"
15
+ checksum = "253efad127c55b78967e3e3a3b4a573f9da0a2562c4f33f14fbf462ca58448f7"
13
16
  else
14
- filename = "or-tools_x86_64_macOS-13.2.1_cpp_v#{version}.tar.gz"
15
- checksum = "0957ed39792d5f6135edf86ed75e78fff5b2f36ec0ae63e30c46bd6a6a97797f"
17
+ filename = "or-tools_x86_64_macOS-14.1_cpp_v#{version}.tar.gz"
18
+ checksum = "fe48b022799c807baba79a2b13c29bf9d9614827ba082fc688559d0cab879a86"
16
19
  end
17
20
  else
18
21
  # try /etc/os-release with fallback to /usr/lib/os-release
@@ -25,33 +28,30 @@ else
25
28
  os = os_info["ID"]
26
29
  os_version = os_info["VERSION_ID"]
27
30
 
28
- if os == "ubuntu" && os_version == "22.04"
31
+ if os == "ubuntu" && os_version == "22.04" && !arm
29
32
  filename = "or-tools_amd64_ubuntu-22.04_cpp_v#{version}.tar.gz"
30
- checksum = "e7960113b156b13e23a179ca09646845e762f452aa525bf9b12a40e5ae3c6ca4"
31
- elsif os == "ubuntu" && os_version == "20.04"
33
+ checksum = "2a332e95897ac6fc2cfd0122bcbc07cfd286d0f579111529cc99ac3076f5421a"
34
+ elsif os == "ubuntu" && os_version == "20.04" && !arm
32
35
  filename = "or-tools_amd64_ubuntu-20.04_cpp_v#{version}.tar.gz"
33
- checksum = "aff9714ee8ffd1c936024d6a754f697cf80d4fd5aafa4cf121a4dde114f3813f"
34
- elsif os == "ubuntu" && os_version == "18.04"
35
- filename = "or-tools_amd64_ubuntu-18.04_cpp_v#{version}.tar.gz"
36
- checksum = "467713721be3fdc709cc7fd0c8d6ad99dda73cab1b9c5de3568336c6ebef6473"
37
- elsif os == "debian" && os_version == "11"
36
+ checksum = "95789f8d93dfb298efecd1c0b888f9a148c011e1a20505b00c38452d68b01644"
37
+ elsif os == "debian" && os_version == "11" && !arm
38
38
  filename = "or-tools_amd64_debian-11_cpp_v#{version}.tar.gz"
39
- checksum = "4191e3e910156d6e9d6e69fb9ab6ed57c683f018b218b46cce91c7ece6549dc6"
40
- elsif os == "debian" && os_version == "10"
41
- filename = "or-tools_amd64_debian-10_cpp_v#{version}.tar.gz"
42
- checksum = "f141f16cf92877ed5819e0104126a31c9c139c070de06d7f40c957a4e6ce9284"
43
- elsif os == "centos" && os_version == "8"
44
- filename = "or-tools_amd64_centos-8_cpp_v#{version}.tar.gz"
45
- checksum = "05e2dfc5c82d5122e0c26ce4548cddcae2d474b3b18c024bc189dab887357157"
46
- elsif os == "centos" && os_version == "7"
39
+ checksum = "e7dd81b13c53c739447254b8836ece55f8b92a107688cc9f3511705c9962fa2d"
40
+ elsif os == "debian" && os_version == "11" && arm
41
+ filename = "or-tools_arm64_debian-11_cpp_v#{version}.tar.gz"
42
+ checksum = "77a88d01eb612ffac0f6e030e30e58a3d171fe75d93a527ec55a06f9070332ab"
43
+ elsif os == "centos" && os_version == "7" && !arm
47
44
  filename = "or-tools_amd64_centos-7_cpp_v#{version}.tar.gz"
48
- checksum = "96012ac1280a98d6a67e764494bf60971eece859dca95fb6470ffd4065af7444"
45
+ checksum = "d9f193572d3a38b3062ae4cb89afc654e662eb734a9361b1575d649b9530cf60"
46
+ elsif os == "arch" && !arm
47
+ filename = "or-tools_amd64_archlinux_cpp_v#{version}.tar.gz"
48
+ checksum = "803e4b78e7d05b8027a2a391183c8c7855bb758f74d9ced872cfa68e0b9d7d64"
49
49
  else
50
50
  platform =
51
51
  if Gem.win_platform?
52
52
  "Windows"
53
53
  elsif os || os_version
54
- "#{os} #{os_version}"
54
+ "#{os} #{os_version} #{arch}"
55
55
  else
56
56
  "Unknown"
57
57
  end
@@ -147,6 +147,9 @@ Dir.mktmpdir do |extract_path|
147
147
  ext = file.end_with?(".dylib") ? "dylib" : "so"
148
148
  File.symlink(so_path, File.join(path, "lib/libortools.#{ext}"))
149
149
  end
150
+ ["lib/libprotobuf.a"].each do |file|
151
+ FileUtils.cp(File.join(extract_path, file), File.join(path, file))
152
+ end
150
153
  end
151
154
 
152
155
  # export
data/lib/or-tools.rb CHANGED
@@ -2,37 +2,37 @@
2
2
  require "or_tools/ext"
3
3
 
4
4
  # modules
5
- require "or_tools/comparison"
6
- require "or_tools/comparison_operators"
7
- require "or_tools/bool_var"
8
- require "or_tools/constant"
9
- require "or_tools/cp_model"
10
- require "or_tools/cp_solver"
11
- require "or_tools/cp_solver_solution_callback"
12
- require "or_tools/int_var"
13
- require "or_tools/knapsack_solver"
14
- require "or_tools/linear_constraint"
15
- require "or_tools/linear_expr"
16
- require "or_tools/mp_variable"
17
- require "or_tools/product_cst"
18
- require "or_tools/routing_index_manager"
19
- require "or_tools/routing_model"
20
- require "or_tools/sat_linear_expr"
21
- require "or_tools/sat_int_var"
22
- require "or_tools/solver"
23
- require "or_tools/sum_array"
24
- require "or_tools/version"
5
+ require_relative "or_tools/comparison"
6
+ require_relative "or_tools/comparison_operators"
7
+ require_relative "or_tools/bool_var"
8
+ require_relative "or_tools/constant"
9
+ require_relative "or_tools/cp_model"
10
+ require_relative "or_tools/cp_solver"
11
+ require_relative "or_tools/cp_solver_solution_callback"
12
+ require_relative "or_tools/int_var"
13
+ require_relative "or_tools/knapsack_solver"
14
+ require_relative "or_tools/linear_constraint"
15
+ require_relative "or_tools/linear_expr"
16
+ require_relative "or_tools/mp_variable"
17
+ require_relative "or_tools/product_cst"
18
+ require_relative "or_tools/routing_index_manager"
19
+ require_relative "or_tools/routing_model"
20
+ require_relative "or_tools/sat_linear_expr"
21
+ require_relative "or_tools/sat_int_var"
22
+ require_relative "or_tools/solver"
23
+ require_relative "or_tools/sum_array"
24
+ require_relative "or_tools/version"
25
25
 
26
26
  # solution printers
27
- require "or_tools/objective_solution_printer"
28
- require "or_tools/var_array_solution_printer"
29
- require "or_tools/var_array_and_objective_solution_printer"
27
+ require_relative "or_tools/objective_solution_printer"
28
+ require_relative "or_tools/var_array_solution_printer"
29
+ require_relative "or_tools/var_array_and_objective_solution_printer"
30
30
 
31
31
  # higher level interfaces
32
- require "or_tools/basic_scheduler"
33
- require "or_tools/seating"
34
- require "or_tools/sudoku"
35
- require "or_tools/tsp"
32
+ require_relative "or_tools/basic_scheduler"
33
+ require_relative "or_tools/seating"
34
+ require_relative "or_tools/sudoku"
35
+ require_relative "or_tools/tsp"
36
36
 
37
37
  module ORTools
38
38
  class Error < StandardError; end
@@ -13,5 +13,9 @@ module ORTools
13
13
  search_parameters.log_search = log_search unless log_search.nil?
14
14
  solve_with_parameters(search_parameters)
15
15
  end
16
+
17
+ # previous names
18
+ alias_method :pickup_index_pairs, :pickup_positions
19
+ alias_method :delivery_index_pairs, :delivery_positions
16
20
  end
17
21
  end
@@ -1,3 +1,3 @@
1
1
  module ORTools
2
- VERSION = "0.10.1"
2
+ VERSION = "0.11.1"
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.10.1
4
+ version: 0.11.1
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-03-20 00:00:00.000000000 Z
11
+ date: 2023-12-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rice
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 4.0.2
19
+ version: '4.1'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 4.0.2
26
+ version: '4.1'
27
27
  description:
28
28
  email: andrew@ankane.org
29
29
  executables: []
@@ -85,14 +85,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
85
85
  requirements:
86
86
  - - ">="
87
87
  - !ruby/object:Gem::Version
88
- version: '2.7'
88
+ version: '3'
89
89
  required_rubygems_version: !ruby/object:Gem::Requirement
90
90
  requirements:
91
91
  - - ">="
92
92
  - !ruby/object:Gem::Version
93
93
  version: '0'
94
94
  requirements: []
95
- rubygems_version: 3.4.6
95
+ rubygems_version: 3.4.10
96
96
  signing_key:
97
97
  specification_version: 4
98
98
  summary: Operations research tools for Ruby