Skip to content

Commit fc11ebf

Browse files
committed
Updated OR-Tools to 9.12
1 parent 6f8abc9 commit fc11ebf

File tree

7 files changed

+39
-52
lines changed

7 files changed

+39
-52
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## 0.15.0 (unreleased)
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+
17
## 0.14.2 (2025-02-10)
28

39
- Fixed error with Rice 4.5

Rakefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ task :update do
2525
require "open-uri"
2626
require "tmpdir"
2727

28-
version = "9.11.4210"
29-
distributions = ["arm64_macOS-14.6.1", "x86_64_macOS-14.6.1", "amd64_ubuntu-24.04", "amd64_ubuntu-22.04", "amd64_ubuntu-20.04", "amd64_debian-11", "amd64_debian-12", "amd64_archlinux"]
28+
version = "9.12.4544"
29+
distributions = ["arm64_macOS-15.3.1", "x86_64_macOS-15.3.1", "amd64_ubuntu-24.04", "amd64_ubuntu-22.04", "amd64_ubuntu-20.04", "amd64_debian-11", "amd64_debian-12", "amd64_archlinux"]
3030

3131
short_version = version.split(".").first(2).join(".")
3232
distributions.each do |dist|
@@ -42,3 +42,5 @@ task :update do
4242
puts "#{dist}: #{Digest::SHA256.file(dest).hexdigest}"
4343
end
4444
end
45+
46+
CLEAN.add("tmp")

ext/or-tools/extconf.rb

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require "mkmf-rice"
22

3-
$CXXFLAGS << " -std=c++17 $(optflags) -DUSE_CBC"
3+
$CXXFLAGS << " -std=c++17 $(optflags) -DUSE_CBC -DOR_PROTO_DLL="
44

55
# show warnings
66
$CXXFLAGS << " -Wall -Wextra"
@@ -32,10 +32,7 @@
3232
# find_header and find_library first check without adding path
3333
# which can cause them to find system library
3434
$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} ")
3936
raise "OR-Tools not found" unless have_library("ortools")
4037

4138
create_makefile("or_tools/ext")

ext/or-tools/routing.cpp

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ using operations_research::RoutingModel;
1515
using operations_research::RoutingModelParameters;
1616
using operations_research::RoutingNodeIndex;
1717
using operations_research::RoutingSearchParameters;
18+
using operations_research::RoutingSearchStatus;
1819

1920
using Rice::Array;
2021
using Rice::Class;
@@ -331,7 +332,7 @@ void init_routing(Rice::Module& m) {
331332
.define_method("add_resource_group", &RoutingModel::AddResourceGroup)
332333
.define_method("dimension_resource_group_indices", &RoutingModel::GetDimensionResourceGroupIndices)
333334
.define_method("dimension_resource_group_index", &RoutingModel::GetDimensionResourceGroupIndex)
334-
.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)
335336
.define_method("disjunction_indices", &RoutingModel::GetDisjunctionIndices)
336337
.define_method("disjunction_penalty", &RoutingModel::GetDisjunctionPenalty)
337338
.define_method("disjunction_max_cardinality", &RoutingModel::GetDisjunctionMaxCardinality)
@@ -346,22 +347,14 @@ void init_routing(Rice::Module& m) {
346347
.define_method("add_pickup_and_delivery", &RoutingModel::AddPickupAndDelivery)
347348
.define_method("add_pickup_and_delivery_sets", &RoutingModel::AddPickupAndDeliverySets)
348349
.define_method(
349-
"pickup_positions",
350+
"pickup_position",
350351
[](RoutingModel& self, int64_t node_index) {
351-
std::vector<std::pair<int, int>> positions;
352-
for (const auto& v : self.GetPickupPositions(node_index)) {
353-
positions.emplace_back(v.pd_pair_index, v.alternative_index);
354-
}
355-
return positions;
352+
return self.GetPickupPosition(node_index);
356353
})
357354
.define_method(
358-
"delivery_positions",
355+
"delivery_position",
359356
[](RoutingModel& self, int64_t node_index) {
360-
std::vector<std::pair<int, int>> positions;
361-
for (const auto& v : self.GetDeliveryPositions(node_index)) {
362-
positions.emplace_back(v.pd_pair_index, v.alternative_index);
363-
}
364-
return positions;
357+
return self.GetDeliveryPosition(node_index);
365358
})
366359
.define_method("num_of_singleton_nodes", &RoutingModel::GetNumOfSingletonNodes)
367360
.define_method("unperformed_penalty", &RoutingModel::UnperformedPenalty)
@@ -403,15 +396,15 @@ void init_routing(Rice::Module& m) {
403396
[](RoutingModel& self) {
404397
auto status = self.status();
405398

406-
if (status == RoutingModel::ROUTING_NOT_SOLVED) {
399+
if (status == RoutingSearchStatus::ROUTING_NOT_SOLVED) {
407400
return Symbol("not_solved");
408-
} else if (status == RoutingModel::ROUTING_SUCCESS) {
401+
} else if (status == RoutingSearchStatus::ROUTING_SUCCESS) {
409402
return Symbol("success");
410-
} else if (status == RoutingModel::ROUTING_FAIL) {
403+
} else if (status == RoutingSearchStatus::ROUTING_FAIL) {
411404
return Symbol("fail");
412-
} else if (status == RoutingModel::ROUTING_FAIL_TIMEOUT) {
405+
} else if (status == RoutingSearchStatus::ROUTING_FAIL_TIMEOUT) {
413406
return Symbol("fail_timeout");
414-
} else if (status == RoutingModel::ROUTING_INVALID) {
407+
} else if (status == RoutingSearchStatus::ROUTING_INVALID) {
415408
return Symbol("invalid");
416409
} else {
417410
throw std::runtime_error("Unknown solver status");

ext/or-tools/vendor.rb

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@
33
require "net/http"
44
require "tmpdir"
55

6-
version = "9.11.4210"
6+
version = "9.12.4544"
77

88
arch = RbConfig::CONFIG["host_cpu"]
99
arm = arch.match?(/arm|aarch64/i)
1010

1111
if RbConfig::CONFIG["host_os"].match?(/darwin/i)
1212
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"
1515
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"
1818
end
1919
else
2020
# try /etc/os-release with fallback to /usr/lib/os-release
@@ -29,22 +29,22 @@
2929

3030
if os == "ubuntu" && os_version == "24.04" && !arm
3131
filename = "or-tools_amd64_ubuntu-24.04_cpp_v#{version}.tar.gz"
32-
checksum = "71761d93171b111fca736647a6cd00cb9e606474df597a8b48f3f5f2c73d4c0f"
32+
checksum = "71128e095024707bf9835faf4558cbe34acb79345e899bd532f3008a493a8970"
3333
elsif os == "ubuntu" && os_version == "22.04" && !arm
3434
filename = "or-tools_amd64_ubuntu-22.04_cpp_v#{version}.tar.gz"
35-
checksum = "f613574d4eae01afd966c8bde199990cbd9fad46035e675d71f17f5c7477eed4"
35+
checksum = "cb42ea7d7799a01fea7cdaafacbdfc67180d85f39532c6d2a8c4cfb419bd07ed"
3636
elsif os == "ubuntu" && os_version == "20.04" && !arm
3737
filename = "or-tools_amd64_ubuntu-20.04_cpp_v#{version}.tar.gz"
38-
checksum = "190b85f4510cab55fcb50b9850a0e2f94b2bdf5e266580650efbc5aaab760683"
38+
checksum = "ea51589fe80bd9cd4fb6203bd1e956b311cdb1d21bbd14f7b6dad75c81d3583c"
3939
elsif os == "debian" && os_version == "11" && !arm
4040
filename = "or-tools_amd64_debian-11_cpp_v#{version}.tar.gz"
41-
checksum = "a8354696f365aa13a2375da5f8f6cfd8785430681addcd887bfd194851dd4710"
41+
checksum = "dcee63b726569bd99c134e0e920173f955feae5856c3370a0bed03fdc995af50"
4242
elsif os == "debian" && os_version == "12" && !arm
4343
filename = "or-tools_amd64_debian-12_cpp_v#{version}.tar.gz"
44-
checksum = "9fda332f2f9d3b5647d85dd65de145ea3e2a1543714bf588f82da8ec57721cbf"
44+
checksum = "911143f50fe013fbd50d0dce460512106596adfc0f2ad9a2bc8afd218531bde4"
4545
elsif os == "arch" && !arm
4646
filename = "or-tools_amd64_archlinux_cpp_v#{version}.tar.gz"
47-
checksum = "ac892a949d871294b7e26b0730440ab8629b4021bf3c1641bc7c8fb09b45081f"
47+
checksum = "18c1d929e2144e9d9602659ea2fa790bd2a150f72c32c38a97f571839816d132"
4848
else
4949
platform =
5050
if Gem.win_platform?
@@ -139,16 +139,7 @@ def download_file(url, download_path, redirects = 0)
139139
FileUtils.cp_r(File.join(extract_path, "include"), File.join(path, "include"))
140140

141141
# shared library
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))
151-
end
142+
FileUtils.cp_r(File.join(extract_path, "lib"), File.join(path, "lib"))
152143
end
153144

154145
# export

lib/or_tools/routing_model.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,5 @@ def solve(solution_limit: nil, time_limit: nil, lns_time_limit: nil,
1313
search_parameters.log_search = log_search unless log_search.nil?
1414
solve_with_parameters(search_parameters)
1515
end
16-
17-
# previous names
18-
alias_method :pickup_index_pairs, :pickup_positions
19-
alias_method :delivery_index_pairs, :delivery_positions
2016
end
2117
end

test/constraint_test.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,8 @@ def test_cryptoarithmetic
153153
status = solver.solve(model, solution_printer)
154154
assert_equal :optimal, status
155155

156-
assert_equal 186, solver.num_conflicts
157-
assert_equal 1577, solver.num_branches
156+
assert_equal 184, solver.num_conflicts
157+
assert_equal 1850, solver.num_branches
158158
assert_equal 72, solution_printer.solution_count
159159
end
160160

@@ -267,6 +267,8 @@ def test_sum_empty_false
267267
model.add([].sum > 2)
268268
expected = <<~EOS
269269
constraints {
270+
bool_or {
271+
}
270272
}
271273
EOS
272274
assert_equal expected, model.inspect

0 commit comments

Comments
 (0)