or-tools 0.17.1 → 0.18.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: 7d08782975a4c387d502318dbd8c9335166a42ab76807b13ba78c7b249d6c879
4
- data.tar.gz: 1653c6a0bfac136e9bdbe22d6bc10bc24d699926d79963cb41777f9e90eb880f
3
+ metadata.gz: b4b9e112aef49d6377cfb072df599cc64adb317169212e9811ba601946cda981
4
+ data.tar.gz: 437a96678ed5b1d0b83ae2a8535a9d7b2165ebb28f1b8bf3bac62e3495e65ec4
5
5
  SHA512:
6
- metadata.gz: 582adf83f9dfcdfe426364a22efc2bdd8733b5582a4aa3bb0b720910bd4a5d75a8466937b6b8bfed892c655017d246da3953081d56533a15aac8ae10b1ec96c5
7
- data.tar.gz: e97b40eefc43fd253d2da0ad17f02a923649502d294904d49d4a431d1adc44c23222c8a59d61e36142400478bb6e128c90d00bee8419f0294c47f29aba4c4a93
6
+ metadata.gz: 6cd5ae717f0d0a9f01b3d44e52d311b0b93c82369c48a9dee7b71ca83dbbd094f48b29033d02ec319f4e69233a4366b9b6bd1025670a08b58514d1d068a0b261
7
+ data.tar.gz: 4806b7bff7d478eda84bb8b5169f683e7df7c08dc0d146d5b0a7bddf52a1c8dd164f4ee0338a5e01841b7057303c20ecb82cb8d4c01e309ea7ebc3478ef305c5
data/CHANGELOG.md CHANGED
@@ -1,3 +1,20 @@
1
+ ## 0.18.1 (2026-10-02)
2
+
3
+ - Added support for breaks for routing
4
+ - Added support for more constraints for routing
5
+ - Added more methods to `ConstraintSolverParameters`
6
+ - Added more methods to `RoutingModelParameters`
7
+ - Added more methods to `RoutingSearchParameters`
8
+ - Added more methods to `SatParameters`
9
+
10
+ ## 0.18.0 (2026-07-06)
11
+
12
+ - Added support for releasing GVL
13
+ - Added `stop_search` method to `CpSolverSolutionCallback`
14
+ - Fixed error with `apply_locks` and `set_allowed_vehicles_for_index` methods
15
+ - Removed `solve_with_solution_callback` and `search_for_all_solutions` methods
16
+ - Dropped support for Ruby < 3.3
17
+
1
18
  ## 0.17.1 (2026-02-19)
2
19
 
3
20
  - Fixed error with Rice 4.11
data/README.md CHANGED
@@ -93,15 +93,15 @@ Specify people and their availabililty
93
93
  people = [
94
94
  {
95
95
  availability: [
96
- {starts_at: Time.parse("2025-01-01 08:00:00"), ends_at: Time.parse("2025-01-01 16:00:00")},
97
- {starts_at: Time.parse("2025-01-02 08:00:00"), ends_at: Time.parse("2025-01-02 16:00:00")}
96
+ {starts_at: Time.parse("2026-01-01 08:00:00"), ends_at: Time.parse("2026-01-01 16:00:00")},
97
+ {starts_at: Time.parse("2026-01-02 08:00:00"), ends_at: Time.parse("2026-01-02 16:00:00")}
98
98
  ],
99
99
  max_hours: 40 # optional, applies to entire scheduling period
100
100
  },
101
101
  {
102
102
  availability: [
103
- {starts_at: Time.parse("2025-01-01 08:00:00"), ends_at: Time.parse("2025-01-01 16:00:00")},
104
- {starts_at: Time.parse("2025-01-03 08:00:00"), ends_at: Time.parse("2025-01-03 16:00:00")}
103
+ {starts_at: Time.parse("2026-01-01 08:00:00"), ends_at: Time.parse("2026-01-01 16:00:00")},
104
+ {starts_at: Time.parse("2026-01-03 08:00:00"), ends_at: Time.parse("2026-01-03 16:00:00")}
105
105
  ],
106
106
  max_hours: 20
107
107
  }
@@ -112,9 +112,9 @@ Specify shifts
112
112
 
113
113
  ```ruby
114
114
  shifts = [
115
- {starts_at: Time.parse("2025-01-01 08:00:00"), ends_at: Time.parse("2025-01-01 16:00:00")},
116
- {starts_at: Time.parse("2025-01-02 08:00:00"), ends_at: Time.parse("2025-01-02 16:00:00")},
117
- {starts_at: Time.parse("2025-01-03 08:00:00"), ends_at: Time.parse("2025-01-03 16:00:00")}
115
+ {starts_at: Time.parse("2026-01-01 08:00:00"), ends_at: Time.parse("2026-01-01 16:00:00")},
116
+ {starts_at: Time.parse("2026-01-02 08:00:00"), ends_at: Time.parse("2026-01-02 16:00:00")},
117
+ {starts_at: Time.parse("2026-01-03 08:00:00"), ends_at: Time.parse("2026-01-03 16:00:00")}
118
118
  ]
119
119
  ```
120
120
 
@@ -537,7 +537,8 @@ end
537
537
  # invoke the solver
538
538
  solver = ORTools::CpSolver.new
539
539
  solution_printer = VarArraySolutionPrinter.new(letters)
540
- status = solver.search_for_all_solutions(model, solution_printer)
540
+ solver.parameters.enumerate_all_solutions = true
541
+ status = solver.solve(model, solution_printer)
541
542
 
542
543
  puts
543
544
  puts "Statistics"
@@ -598,7 +599,8 @@ end
598
599
  # call the solver and display the results
599
600
  solver = ORTools::CpSolver.new
600
601
  solution_printer = SolutionPrinter.new(queens)
601
- status = solver.search_for_all_solutions(model, solution_printer)
602
+ solver.parameters.enumerate_all_solutions = true
603
+ status = solver.solve(model, solution_printer)
602
604
  puts
603
605
  puts "Solutions found : %i" % solution_printer.solution_count
604
606
  ```
@@ -1887,11 +1889,13 @@ end
1887
1889
 
1888
1890
  # call the solver and display the results
1889
1891
  solver = ORTools::CpSolver.new
1892
+ solver.parameters.linearization_level = 0
1893
+ solver.parameters.enumerate_all_solutions = true
1890
1894
  a_few_solutions = 5.times.to_a
1891
1895
  solution_printer = NursesPartialSolutionPrinter.new(
1892
1896
  shifts, num_nurses, num_days, num_shifts, a_few_solutions
1893
1897
  )
1894
- solver.search_for_all_solutions(model, solution_printer)
1898
+ solver.solve(model, solution_printer)
1895
1899
 
1896
1900
  puts
1897
1901
  puts "Statistics"
@@ -30,7 +30,7 @@ void init_assignment(Rice::Module& m) {
30
30
  } else if (status == SimpleLinearSumAssignment::Status::POSSIBLE_OVERFLOW) {
31
31
  return Symbol("possible_overflow");
32
32
  } else {
33
- throw std::runtime_error("Unknown status");
33
+ throw std::runtime_error{"Unknown status"};
34
34
  }
35
35
  });
36
36
  }
@@ -27,11 +27,11 @@ namespace Rice::detail {
27
27
  double is_convertible(VALUE value) { return Convertible::Exact; }
28
28
 
29
29
  KnapsackSolver::SolverType convert(VALUE x) {
30
- auto s = Symbol(x).str();
30
+ std::string s = Symbol(x).str();
31
31
  if (s == "branch_and_bound") {
32
32
  return KnapsackSolver::KNAPSACK_MULTIDIMENSION_BRANCH_AND_BOUND_SOLVER;
33
33
  } else {
34
- throw std::runtime_error("Unknown solver type: " + s);
34
+ throw std::runtime_error{"Unknown solver type: " + s};
35
35
  }
36
36
  }
37
37
 
@@ -47,7 +47,7 @@ void init_bin_packing(Rice::Module& m) {
47
47
  .define_method("best_solution_contains?", &KnapsackSolver::BestSolutionContains)
48
48
  .define_method(
49
49
  "init",
50
- [](KnapsackSolver& self, std::vector<int64_t> values, std::vector<std::vector<int64_t>> weights, std::vector<int64_t> capacities) {
50
+ [](KnapsackSolver& self, const std::vector<int64_t>& values, const std::vector<std::vector<int64_t>>& weights, const std::vector<int64_t>& capacities) {
51
51
  self.Init(values, weights, capacities);
52
52
  });
53
53
  }
@@ -0,0 +1,37 @@
1
+ #pragma once
2
+
3
+ #include <chrono>
4
+ #include <condition_variable>
5
+ #include <mutex>
6
+ #include <optional>
7
+ #include <queue>
8
+
9
+ template<typename T>
10
+ class Channel {
11
+ std::queue<T> queue;
12
+ std::mutex mutex;
13
+ std::condition_variable cv;
14
+
15
+ public:
16
+ void send(T message) {
17
+ std::lock_guard<std::mutex> guard(mutex);
18
+ queue.push(std::move(message));
19
+ cv.notify_one();
20
+ }
21
+
22
+ template<typename U, typename V>
23
+ std::optional<T> recv_timeout(const std::chrono::duration<U, V>& duration) {
24
+ std::unique_lock<std::mutex> lock(mutex);
25
+ if (!cv.wait_for(lock, duration, [&] { return !queue.empty(); })) {
26
+ return std::nullopt;
27
+ }
28
+ T message = std::move(queue.front());
29
+ queue.pop();
30
+ return message;
31
+ }
32
+
33
+ bool empty() {
34
+ std::lock_guard<std::mutex> guard(mutex);
35
+ return queue.empty();
36
+ }
37
+ };