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 +4 -4
- data/CHANGELOG.md +17 -0
- data/README.md +14 -10
- data/ext/or-tools/assignment.cpp +1 -1
- data/ext/or-tools/bin_packing.cpp +3 -3
- data/ext/or-tools/channel.hpp +37 -0
- data/ext/or-tools/constraint.cpp +685 -63
- data/ext/or-tools/ext.cpp +1 -1
- data/ext/or-tools/linear.cpp +8 -8
- data/ext/or-tools/math_opt.cpp +8 -8
- data/ext/or-tools/network_flows.cpp +2 -2
- data/ext/or-tools/routing.cpp +256 -49
- data/ext/or-tools/vendor.rb +22 -53
- data/lib/or_tools/cp_solver.rb +1 -16
- data/lib/or_tools/cp_solver_solution_callback.rb +4 -0
- data/lib/or_tools/routing_model.rb +22 -0
- data/lib/or_tools/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b4b9e112aef49d6377cfb072df599cc64adb317169212e9811ba601946cda981
|
|
4
|
+
data.tar.gz: 437a96678ed5b1d0b83ae2a8535a9d7b2165ebb28f1b8bf3bac62e3495e65ec4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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("
|
|
97
|
-
{starts_at: Time.parse("
|
|
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("
|
|
104
|
-
{starts_at: Time.parse("
|
|
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("
|
|
116
|
-
{starts_at: Time.parse("
|
|
117
|
-
{starts_at: Time.parse("
|
|
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
|
-
|
|
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
|
-
|
|
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.
|
|
1898
|
+
solver.solve(model, solution_printer)
|
|
1895
1899
|
|
|
1896
1900
|
puts
|
|
1897
1901
|
puts "Statistics"
|
data/ext/or-tools/assignment.cpp
CHANGED
|
@@ -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
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
+
};
|