or-tools 0.14.1 → 0.15.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: 5803be6e2ff6de980c6f1a89ab9ccda1e2ee264139229bca865103c8379dc4a2
4
- data.tar.gz: 323fda85d36cc8dadb6720a23ac3e9eaa881e3618e74044c8b04773bb979c16e
3
+ metadata.gz: ea0dcf083694be566f08e7c531e3bbd7cd817fb454c6590a1edff5411e58b9c7
4
+ data.tar.gz: 334369dda3337181b10722f96a52211a079f29409e709a8bfd6685a3d9100916
5
5
  SHA512:
6
- metadata.gz: 48c9eba03b16bb2ce63edf62d52f33fc88595e691543f68dd1a2090adb7212958331534a97b801c7f54acce6626461bc0e268ac312ea34c1c50045dedcfbb3b4
7
- data.tar.gz: 8d91150d41201f8e47129ef3b48cfb4b63b5cb91c09c87d7ef01f87de4b82ff6d287fb2ca5e3b5a4984152bdb2e5a33f4c5b8fe9495d6a9e89ab81b31c1674ac
6
+ metadata.gz: 2d8956c463c473ceabe4803f23076d8c96617a4abbd64b7bc2873492bd9e41eed50929567ae71acdf42ea42c8bbbaf4716b132f27eae56cb307f311692444fa3
7
+ data.tar.gz: 4ca6955eb037764eae4fc99861b904298c9bb519bc5ff2a19d5709f24f2f1e3de72f3827a953c90f9e006bc5122dc122ff51ece505784b5b3db49d5a0aaa8a5e
data/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
+ ## 0.15.0 (2025-02-17)
2
+
3
+ - Updated OR-Tools to 9.12
4
+ - Removed `pickup_positions` and `pickup_index_pairs` (use `pickup_position` instead)
5
+ - Removed `delivery_positions` and `delivery_index_pairs` (use `delivery_position` instead)
6
+
7
+ ## 0.14.2 (2025-02-10)
8
+
9
+ - Fixed error with Rice 4.5
10
+
1
11
  ## 0.14.1 (2024-12-04)
2
12
 
3
13
  - Added support for parameters to `Solver`
@@ -13,16 +13,15 @@ namespace Rice::detail
13
13
  template<>
14
14
  struct Type<KnapsackSolver::SolverType>
15
15
  {
16
- static bool verify()
17
- {
18
- return true;
19
- }
16
+ static bool verify() { return true; }
20
17
  };
21
18
 
22
19
  template<>
23
20
  class From_Ruby<KnapsackSolver::SolverType>
24
21
  {
25
22
  public:
23
+ Convertible is_convertible(VALUE value) { return Convertible::Cast; }
24
+
26
25
  KnapsackSolver::SolverType convert(VALUE x)
27
26
  {
28
27
  auto s = Symbol(x).str();
@@ -32,16 +32,15 @@ namespace Rice::detail
32
32
  template<>
33
33
  struct Type<LinearExpr>
34
34
  {
35
- static bool verify()
36
- {
37
- return true;
38
- }
35
+ static bool verify() { return true; }
39
36
  };
40
37
 
41
38
  template<>
42
39
  class From_Ruby<LinearExpr>
43
40
  {
44
41
  public:
42
+ Convertible is_convertible(VALUE value) { return Convertible::Cast; }
43
+
45
44
  LinearExpr convert(VALUE v)
46
45
  {
47
46
  LinearExpr expr;
@@ -1,6 +1,6 @@
1
1
  require "mkmf-rice"
2
2
 
3
- $CXXFLAGS << " -std=c++17 $(optflags) -DUSE_CBC"
3
+ $CXXFLAGS << " -std=c++17 $(optflags) -DUSE_CBC -DOR_PROTO_DLL="
4
4
 
5
5
  # show warnings
6
6
  $CXXFLAGS << " -Wall -Wextra"
@@ -9,7 +9,7 @@ $CXXFLAGS << " -Wall -Wextra"
9
9
  $CXXFLAGS << " -Wno-sign-compare -Wno-ignored-qualifiers -Wno-unused-parameter -Wno-missing-field-initializers"
10
10
 
11
11
  # hide Rice warnings
12
- $CXXFLAGS << " -Wno-implicit-fallthrough"
12
+ $CXXFLAGS << " -Wno-unused-private-field -Wno-implicit-fallthrough"
13
13
 
14
14
  inc, lib = dir_config("or-tools")
15
15
  if inc || lib
@@ -32,10 +32,7 @@ end
32
32
  # find_header and find_library first check without adding path
33
33
  # which can cause them to find system library
34
34
  $INCFLAGS << " -I#{inc}"
35
- # could support shared libraries for protobuf and abseil
36
- # but keep simple for now
37
- raise "libprotobuf.a not found" unless File.exist?("#{lib}/libprotobuf.a")
38
- $LDFLAGS.prepend("-Wl,-rpath,#{rpath} -L#{lib} #{lib}/libprotobuf.a ")
35
+ $LDFLAGS.prepend("-Wl,-rpath,#{rpath} -L#{lib} ")
39
36
  raise "OR-Tools not found" unless have_library("ortools")
40
37
 
41
38
  create_makefile("or_tools/ext")
@@ -20,15 +20,14 @@ namespace Rice::detail
20
20
  template<>
21
21
  struct Type<MPSolver::OptimizationProblemType>
22
22
  {
23
- static bool verify()
24
- {
25
- return true;
26
- }
23
+ static bool verify() { return true; }
27
24
  };
28
25
 
29
26
  template<>
30
27
  struct From_Ruby<MPSolver::OptimizationProblemType>
31
28
  {
29
+ Convertible is_convertible(VALUE value) { return Convertible::Cast; }
30
+
32
31
  static MPSolver::OptimizationProblemType convert(VALUE x)
33
32
  {
34
33
  auto s = Symbol(x).str();
@@ -108,7 +107,13 @@ void init_linear(Rice::Module& m) {
108
107
  "presolve",
109
108
  [](MPSolverParameters& self) {
110
109
  int presolve = self.GetIntegerParam(MPSolverParameters::IntegerParam::PRESOLVE);
111
- return presolve != MPSolverParameters::PresolveValues::PRESOLVE_OFF;
110
+ if (presolve == MPSolverParameters::PresolveValues::PRESOLVE_ON) {
111
+ return Rice::True;
112
+ } else if (presolve == MPSolverParameters::PresolveValues::PRESOLVE_OFF) {
113
+ return Rice::False;
114
+ } else {
115
+ return Rice::Nil;
116
+ }
112
117
  })
113
118
  .define_method(
114
119
  "incrementality=",
@@ -125,7 +130,13 @@ void init_linear(Rice::Module& m) {
125
130
  "incrementality",
126
131
  [](MPSolverParameters& self) {
127
132
  int incrementality = self.GetIntegerParam(MPSolverParameters::IntegerParam::INCREMENTALITY);
128
- return incrementality != MPSolverParameters::IncrementalityValues::INCREMENTALITY_OFF;
133
+ if (incrementality == MPSolverParameters::IncrementalityValues::INCREMENTALITY_ON) {
134
+ return Rice::True;
135
+ } else if (incrementality == MPSolverParameters::IncrementalityValues::INCREMENTALITY_OFF) {
136
+ return Rice::False;
137
+ } else {
138
+ return Rice::Nil;
139
+ }
129
140
  })
130
141
  .define_method(
131
142
  "scaling=",
@@ -142,7 +153,13 @@ void init_linear(Rice::Module& m) {
142
153
  "scaling",
143
154
  [](MPSolverParameters& self) {
144
155
  int scaling = self.GetIntegerParam(MPSolverParameters::IntegerParam::SCALING);
145
- return scaling != MPSolverParameters::ScalingValues::SCALING_OFF;
156
+ if (scaling == MPSolverParameters::ScalingValues::SCALING_ON) {
157
+ return Rice::True;
158
+ } else if (scaling == MPSolverParameters::ScalingValues::SCALING_OFF) {
159
+ return Rice::False;
160
+ } else {
161
+ return Rice::Nil;
162
+ }
146
163
  });
147
164
 
148
165
  Rice::define_class_under<MPSolver>(m, "Solver")
@@ -20,15 +20,14 @@ namespace Rice::detail
20
20
  template<>
21
21
  struct Type<SolverType>
22
22
  {
23
- static bool verify()
24
- {
25
- return true;
26
- }
23
+ static bool verify() { return true; }
27
24
  };
28
25
 
29
26
  template<>
30
27
  struct From_Ruby<SolverType>
31
28
  {
29
+ Convertible is_convertible(VALUE value) { return Convertible::Cast; }
30
+
32
31
  static SolverType convert(VALUE x)
33
32
  {
34
33
  auto s = Symbol(x).str();
@@ -15,6 +15,7 @@ using operations_research::RoutingModel;
15
15
  using operations_research::RoutingModelParameters;
16
16
  using operations_research::RoutingNodeIndex;
17
17
  using operations_research::RoutingSearchParameters;
18
+ using operations_research::RoutingSearchStatus;
18
19
 
19
20
  using Rice::Array;
20
21
  using Rice::Class;
@@ -28,16 +29,15 @@ namespace Rice::detail
28
29
  template<>
29
30
  struct Type<RoutingNodeIndex>
30
31
  {
31
- static bool verify()
32
- {
33
- return true;
34
- }
32
+ static bool verify() { return true; }
35
33
  };
36
34
 
37
35
  template<>
38
36
  class From_Ruby<RoutingNodeIndex>
39
37
  {
40
38
  public:
39
+ Convertible is_convertible(VALUE value) { return Convertible::Cast; }
40
+
41
41
  RoutingNodeIndex convert(VALUE x)
42
42
  {
43
43
  const RoutingNodeIndex index{From_Ruby<int>().convert(x)};
@@ -285,7 +285,7 @@ void init_routing(Rice::Module& m) {
285
285
  Rice::define_class_under<RoutingModel::ResourceGroup>(m, "ResourceGroup");
286
286
 
287
287
  Rice::define_class_under<RoutingModel>(m, "RoutingModel")
288
- .define_constructor(Rice::Constructor<RoutingModel, RoutingIndexManager, RoutingModelParameters>(), Rice::Arg("index_manager"), Rice::Arg("parameters") = operations_research::DefaultRoutingModelParameters())
288
+ .define_constructor(Rice::Constructor<RoutingModel, RoutingIndexManager, RoutingModelParameters>(), Rice::Arg("_index_manager"), Rice::Arg("_parameters") = operations_research::DefaultRoutingModelParameters())
289
289
  .define_method("register_unary_transit_vector", &RoutingModel::RegisterUnaryTransitVector)
290
290
  .define_method(
291
291
  "register_unary_transit_callback",
@@ -300,7 +300,7 @@ void init_routing(Rice::Module& m) {
300
300
  return Rice::detail::From_Ruby<int64_t>().convert(callback.call("call", from_index));
301
301
  }
302
302
  );
303
- }, Rice::Arg("callback").keepAlive())
303
+ }, Rice::Arg("_callback").keepAlive())
304
304
  .define_method("register_transit_matrix", &RoutingModel::RegisterTransitMatrix)
305
305
  .define_method(
306
306
  "register_transit_callback",
@@ -315,7 +315,7 @@ void init_routing(Rice::Module& m) {
315
315
  return Rice::detail::From_Ruby<int64_t>().convert(callback.call("call", from_index, to_index));
316
316
  }
317
317
  );
318
- }, Rice::Arg("callback").keepAlive())
318
+ }, Rice::Arg("_callback").keepAlive())
319
319
  .define_method("add_dimension", &RoutingModel::AddDimension)
320
320
  .define_method("add_dimension_with_vehicle_transits", &RoutingModel::AddDimensionWithVehicleTransits)
321
321
  .define_method("add_dimension_with_vehicle_capacity", &RoutingModel::AddDimensionWithVehicleCapacity)
@@ -332,7 +332,7 @@ void init_routing(Rice::Module& m) {
332
332
  .define_method("add_resource_group", &RoutingModel::AddResourceGroup)
333
333
  .define_method("dimension_resource_group_indices", &RoutingModel::GetDimensionResourceGroupIndices)
334
334
  .define_method("dimension_resource_group_index", &RoutingModel::GetDimensionResourceGroupIndex)
335
- .define_method("add_disjunction", &RoutingModel::AddDisjunction, Rice::Arg("indices"), Rice::Arg("penalty"), Rice::Arg("max_cardinality") = (int64_t)1)
335
+ .define_method("add_disjunction", &RoutingModel::AddDisjunction, Rice::Arg("_indices"), Rice::Arg("_penalty"), Rice::Arg("_max_cardinality") = (int64_t)1, Rice::Arg("_penalty_cost_behavior") = RoutingModel::PenaltyCostBehavior::PENALIZE_ONCE)
336
336
  .define_method("disjunction_indices", &RoutingModel::GetDisjunctionIndices)
337
337
  .define_method("disjunction_penalty", &RoutingModel::GetDisjunctionPenalty)
338
338
  .define_method("disjunction_max_cardinality", &RoutingModel::GetDisjunctionMaxCardinality)
@@ -347,22 +347,14 @@ void init_routing(Rice::Module& m) {
347
347
  .define_method("add_pickup_and_delivery", &RoutingModel::AddPickupAndDelivery)
348
348
  .define_method("add_pickup_and_delivery_sets", &RoutingModel::AddPickupAndDeliverySets)
349
349
  .define_method(
350
- "pickup_positions",
350
+ "pickup_position",
351
351
  [](RoutingModel& self, int64_t node_index) {
352
- std::vector<std::pair<int, int>> positions;
353
- for (const auto& v : self.GetPickupPositions(node_index)) {
354
- positions.emplace_back(v.pd_pair_index, v.alternative_index);
355
- }
356
- return positions;
352
+ return self.GetPickupPosition(node_index);
357
353
  })
358
354
  .define_method(
359
- "delivery_positions",
355
+ "delivery_position",
360
356
  [](RoutingModel& self, int64_t node_index) {
361
- std::vector<std::pair<int, int>> positions;
362
- for (const auto& v : self.GetDeliveryPositions(node_index)) {
363
- positions.emplace_back(v.pd_pair_index, v.alternative_index);
364
- }
365
- return positions;
357
+ return self.GetDeliveryPosition(node_index);
366
358
  })
367
359
  .define_method("num_of_singleton_nodes", &RoutingModel::GetNumOfSingletonNodes)
368
360
  .define_method("unperformed_penalty", &RoutingModel::UnperformedPenalty)
@@ -404,15 +396,15 @@ void init_routing(Rice::Module& m) {
404
396
  [](RoutingModel& self) {
405
397
  auto status = self.status();
406
398
 
407
- if (status == RoutingModel::ROUTING_NOT_SOLVED) {
399
+ if (status == RoutingSearchStatus::ROUTING_NOT_SOLVED) {
408
400
  return Symbol("not_solved");
409
- } else if (status == RoutingModel::ROUTING_SUCCESS) {
401
+ } else if (status == RoutingSearchStatus::ROUTING_SUCCESS) {
410
402
  return Symbol("success");
411
- } else if (status == RoutingModel::ROUTING_FAIL) {
403
+ } else if (status == RoutingSearchStatus::ROUTING_FAIL) {
412
404
  return Symbol("fail");
413
- } else if (status == RoutingModel::ROUTING_FAIL_TIMEOUT) {
405
+ } else if (status == RoutingSearchStatus::ROUTING_FAIL_TIMEOUT) {
414
406
  return Symbol("fail_timeout");
415
- } else if (status == RoutingModel::ROUTING_INVALID) {
407
+ } else if (status == RoutingSearchStatus::ROUTING_INVALID) {
416
408
  return Symbol("invalid");
417
409
  } else {
418
410
  throw std::runtime_error("Unknown solver status");
@@ -3,18 +3,18 @@ require "fileutils"
3
3
  require "net/http"
4
4
  require "tmpdir"
5
5
 
6
- version = "9.11.4210"
6
+ version = "9.12.4544"
7
7
 
8
8
  arch = RbConfig::CONFIG["host_cpu"]
9
9
  arm = arch.match?(/arm|aarch64/i)
10
10
 
11
11
  if RbConfig::CONFIG["host_os"].match?(/darwin/i)
12
12
  if arm
13
- filename = "or-tools_arm64_macOS-14.6.1_cpp_v#{version}.tar.gz"
14
- checksum = "a106668eb1975c1672874ef24b4f8e2e56669467a63349e5ea8ef5419814c31b"
13
+ filename = "or-tools_arm64_macOS-15.3.1_cpp_v#{version}.tar.gz"
14
+ checksum = "02f89e54bd8d86e6e069f843aeed10a444ff329052e5a7fd732c5e4ec4f845fb"
15
15
  else
16
- filename = "or-tools_x86_64_macOS-14.6.1_cpp_v#{version}.tar.gz"
17
- checksum = "cc87a7f8c68ec4fed6c6de6565b0b625f2f0047185a8a4449ef4b5a305b60e55"
16
+ filename = "or-tools_x86_64_macOS-15.3.1_cpp_v#{version}.tar.gz"
17
+ checksum = "515af60e73e7fa620bab7f4a7d60b9069075d814453d91906aa39993d714f28d"
18
18
  end
19
19
  else
20
20
  # try /etc/os-release with fallback to /usr/lib/os-release
@@ -29,22 +29,22 @@ else
29
29
 
30
30
  if os == "ubuntu" && os_version == "24.04" && !arm
31
31
  filename = "or-tools_amd64_ubuntu-24.04_cpp_v#{version}.tar.gz"
32
- checksum = "71761d93171b111fca736647a6cd00cb9e606474df597a8b48f3f5f2c73d4c0f"
32
+ checksum = "71128e095024707bf9835faf4558cbe34acb79345e899bd532f3008a493a8970"
33
33
  elsif os == "ubuntu" && os_version == "22.04" && !arm
34
34
  filename = "or-tools_amd64_ubuntu-22.04_cpp_v#{version}.tar.gz"
35
- checksum = "f613574d4eae01afd966c8bde199990cbd9fad46035e675d71f17f5c7477eed4"
35
+ checksum = "cb42ea7d7799a01fea7cdaafacbdfc67180d85f39532c6d2a8c4cfb419bd07ed"
36
36
  elsif os == "ubuntu" && os_version == "20.04" && !arm
37
37
  filename = "or-tools_amd64_ubuntu-20.04_cpp_v#{version}.tar.gz"
38
- checksum = "190b85f4510cab55fcb50b9850a0e2f94b2bdf5e266580650efbc5aaab760683"
38
+ checksum = "ea51589fe80bd9cd4fb6203bd1e956b311cdb1d21bbd14f7b6dad75c81d3583c"
39
39
  elsif os == "debian" && os_version == "11" && !arm
40
40
  filename = "or-tools_amd64_debian-11_cpp_v#{version}.tar.gz"
41
- checksum = "a8354696f365aa13a2375da5f8f6cfd8785430681addcd887bfd194851dd4710"
41
+ checksum = "dcee63b726569bd99c134e0e920173f955feae5856c3370a0bed03fdc995af50"
42
42
  elsif os == "debian" && os_version == "12" && !arm
43
43
  filename = "or-tools_amd64_debian-12_cpp_v#{version}.tar.gz"
44
- checksum = "9fda332f2f9d3b5647d85dd65de145ea3e2a1543714bf588f82da8ec57721cbf"
44
+ checksum = "911143f50fe013fbd50d0dce460512106596adfc0f2ad9a2bc8afd218531bde4"
45
45
  elsif os == "arch" && !arm
46
46
  filename = "or-tools_amd64_archlinux_cpp_v#{version}.tar.gz"
47
- checksum = "ac892a949d871294b7e26b0730440ab8629b4021bf3c1641bc7c8fb09b45081f"
47
+ checksum = "18c1d929e2144e9d9602659ea2fa790bd2a150f72c32c38a97f571839816d132"
48
48
  else
49
49
  platform =
50
50
  if Gem.win_platform?
@@ -132,22 +132,17 @@ Dir.mktmpdir do |extract_path|
132
132
  raise "License not found" unless license_files.any?
133
133
  license_files.each do |file|
134
134
  FileUtils.mkdir_p(File.join(path, File.dirname(file)))
135
- FileUtils.cp(File.join(extract_path, file), File.join(path, file))
135
+ FileUtils.mv(File.join(extract_path, file), File.join(path, file))
136
136
  end
137
137
 
138
138
  # include
139
- FileUtils.cp_r(File.join(extract_path, "include"), File.join(path, "include"))
139
+ FileUtils.mv(File.join(extract_path, "include"), File.join(path, "include"))
140
140
 
141
141
  # shared library
142
142
  FileUtils.mkdir(File.join(path, "lib"))
143
- Dir.glob("lib/libortools.{9.dylib,so.9}", base: extract_path) do |file|
144
- so_path = File.join(path, file)
145
- FileUtils.cp(File.join(extract_path, file), so_path)
146
- ext = file.end_with?(".dylib") ? "dylib" : "so"
147
- File.symlink(so_path, File.join(path, "lib/libortools.#{ext}"))
148
- end
149
- ["lib/libprotobuf.a"].each do |file|
150
- FileUtils.cp(File.join(extract_path, file), File.join(path, file))
143
+ Dir.glob("lib/lib*{.dylib,.so,.so.*}", base: extract_path) do |file|
144
+ next if file.include?("libprotoc.")
145
+ FileUtils.mv(File.join(extract_path, file), File.join(path, file))
151
146
  end
152
147
  end
153
148
 
@@ -13,9 +13,5 @@ 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
20
16
  end
21
17
  end
@@ -1,3 +1,3 @@
1
1
  module ORTools
2
- VERSION = "0.14.1"
2
+ VERSION = "0.15.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: or-tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.1
4
+ version: 0.15.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2024-12-04 00:00:00.000000000 Z
10
+ date: 2025-02-17 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: rice
@@ -16,15 +15,14 @@ dependencies:
16
15
  requirements:
17
16
  - - ">="
18
17
  - !ruby/object:Gem::Version
19
- version: 4.3.3
18
+ version: '4.5'
20
19
  type: :runtime
21
20
  prerelease: false
22
21
  version_requirements: !ruby/object:Gem::Requirement
23
22
  requirements:
24
23
  - - ">="
25
24
  - !ruby/object:Gem::Version
26
- version: 4.3.3
27
- description:
25
+ version: '4.5'
28
26
  email: andrew@ankane.org
29
27
  executables: []
30
28
  extensions:
@@ -74,7 +72,6 @@ homepage: https://github.com/ankane/or-tools-ruby
74
72
  licenses:
75
73
  - Apache-2.0
76
74
  metadata: {}
77
- post_install_message:
78
75
  rdoc_options: []
79
76
  require_paths:
80
77
  - lib
@@ -89,8 +86,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
89
86
  - !ruby/object:Gem::Version
90
87
  version: '0'
91
88
  requirements: []
92
- rubygems_version: 3.5.22
93
- signing_key:
89
+ rubygems_version: 3.6.2
94
90
  specification_version: 4
95
91
  summary: Operations research tools for Ruby
96
92
  test_files: []