Skip to content

Commit 57a4f8b

Browse files
committed
Fixed error with apply_locks method [skip ci]
1 parent 1ecf68c commit 57a4f8b

3 files changed

Lines changed: 12 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## 0.18.0 (unreleased)
22

3-
- Fixed error with `set_allowed_vehicles_for_index` method
3+
- Fixed error with `apply_locks` and `set_allowed_vehicles_for_index` methods
44
- Dropped support for Ruby < 3.3
55

66
## 0.17.1 (2026-02-19)

ext/or-tools/routing.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,11 @@ void init_routing(Rice::Module& m) {
458458
throw std::runtime_error{"Unknown solver status"};
459459
}
460460
})
461-
.define_method("apply_locks", &RoutingModel::ApplyLocks)
461+
.define_method(
462+
"apply_locks",
463+
[](RoutingModel& self, const std::vector<int64_t>& locks) {
464+
return self.ApplyLocks(locks);
465+
})
462466
.define_method("apply_locks_to_all_vehicles", &RoutingModel::ApplyLocksToAllVehicles)
463467
.define_method("pre_assignment", &RoutingModel::PreAssignment)
464468
.define_method("mutable_pre_assignment", &RoutingModel::MutablePreAssignment)

test/routing_test.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -914,4 +914,10 @@ def test_set_allowed_vehicles_for_index
914914
routing = ORTools::RoutingModel.new(manager)
915915
assert_nil routing.set_allowed_vehicles_for_index([0], 0)
916916
end
917+
918+
def test_apply_locks
919+
manager = ORTools::RoutingIndexManager.new(1, 1, 0)
920+
routing = ORTools::RoutingModel.new(manager)
921+
assert_nil routing.apply_locks([])
922+
end
917923
end

0 commit comments

Comments
 (0)