or-tools 0.10.1 → 0.11.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: 6c2f60a5c859f2659349bfb6f77336d2078f8d8747b76fcd8e3e10e7cfb25e28
4
- data.tar.gz: a8d18cf5002f42735d1e458451f7902909ad7e552ed78e77ef52477108bbed16
3
+ metadata.gz: 68ea17bb23e576a57ac2f4949cf79d0248445dc90fbf8148a538d02c3b853bb7
4
+ data.tar.gz: 4d066a51a1dea924f8d8edad1f70313002073233e92c86f07418f7ad19a1f29e
5
5
  SHA512:
6
- metadata.gz: 7394863f44908fcadda86df82fa469c69e6178cdc376db90cc2a1d1142738af7f60b22eb0d66ad252ff1c8fd4a93d169194b462973ce158797519d0b5bb8a5dc
7
- data.tar.gz: c8b8ca7f9f0c78e2dbf88555f23d5463e0b281e65afd83ebcd581062203d8b348aa76acf87f0bb55fef5736882cea48e33cd9a6f801addc60e80de9051b7fcf8
6
+ metadata.gz: 06fd522bf2d86fff7117637d07e62168a1cc4b10bf371d11fd5d8973027e43079c93723abe666e071ac77dd683a73cb584f0987d1ec78d842f1a0e66a75ce2f9
7
+ data.tar.gz: 558b06c83bc6e8108d6175325a7d6408b047f127c16a5f12a197d83509eeca2a9dc9ed01ea72383ed6176aae8fc4d18a378003d8ca274cff42a117a5d164a989
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 0.11.0 (2023-11-16)
2
+
3
+ - Updated OR-Tools to 9.8
4
+ - Dropped support for Ubuntu 18.04, Debian 10, and CentOS 8
5
+ - Dropped support for Ruby < 3
6
+
1
7
  ## 0.10.1 (2023-03-20)
2
8
 
3
9
  - 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,15 @@ require "fileutils"
4
4
  require "net/http"
5
5
  require "tmpdir"
6
6
 
7
- version = "9.6.2534"
7
+ version = "9.8.3296"
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_macOS-13.2.1_cpp_v#{version}.tar.gz"
12
- checksum = "bb82c3b071e8ea5366a52137f400b280120221611758e38bf3d55c819f81c34b"
11
+ filename = "or-tools_arm64_macOS-14.1_cpp_v#{version}.tar.gz"
12
+ checksum = "253efad127c55b78967e3e3a3b4a573f9da0a2562c4f33f14fbf462ca58448f7"
13
13
  else
14
- filename = "or-tools_x86_64_macOS-13.2.1_cpp_v#{version}.tar.gz"
15
- checksum = "0957ed39792d5f6135edf86ed75e78fff5b2f36ec0ae63e30c46bd6a6a97797f"
14
+ filename = "or-tools_x86_64_macOS-14.1_cpp_v#{version}.tar.gz"
15
+ checksum = "fe48b022799c807baba79a2b13c29bf9d9614827ba082fc688559d0cab879a86"
16
16
  end
17
17
  else
18
18
  # try /etc/os-release with fallback to /usr/lib/os-release
@@ -27,25 +27,16 @@ 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 = "e7960113b156b13e23a179ca09646845e762f452aa525bf9b12a40e5ae3c6ca4"
30
+ checksum = "2a332e95897ac6fc2cfd0122bcbc07cfd286d0f579111529cc99ac3076f5421a"
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 = "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"
33
+ checksum = "95789f8d93dfb298efecd1c0b888f9a148c011e1a20505b00c38452d68b01644"
37
34
  elsif os == "debian" && os_version == "11"
38
35
  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"
36
+ checksum = "e7dd81b13c53c739447254b8836ece55f8b92a107688cc9f3511705c9962fa2d"
46
37
  elsif os == "centos" && os_version == "7"
47
38
  filename = "or-tools_amd64_centos-7_cpp_v#{version}.tar.gz"
48
- checksum = "96012ac1280a98d6a67e764494bf60971eece859dca95fb6470ffd4065af7444"
39
+ checksum = "d9f193572d3a38b3062ae4cb89afc654e662eb734a9361b1575d649b9530cf60"
49
40
  else
50
41
  platform =
51
42
  if Gem.win_platform?
@@ -147,6 +138,9 @@ Dir.mktmpdir do |extract_path|
147
138
  ext = file.end_with?(".dylib") ? "dylib" : "so"
148
139
  File.symlink(so_path, File.join(path, "lib/libortools.#{ext}"))
149
140
  end
141
+ ["lib/libprotobuf.a"].each do |file|
142
+ FileUtils.cp(File.join(extract_path, file), File.join(path, file))
143
+ end
150
144
  end
151
145
 
152
146
  # 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.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.10.1
4
+ version: 0.11.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: 2023-03-20 00:00:00.000000000 Z
11
+ date: 2023-11-17 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