or-tools 0.4.3 → 0.5.0
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 +6 -0
- data/ext/or-tools/bin_packing.cpp +7 -7
- data/ext/or-tools/constraint.cpp +28 -21
- data/ext/or-tools/network_flows.cpp +2 -2
- data/ext/or-tools/routing.cpp +23 -23
- data/ext/or-tools/vendor.rb +10 -7
- data/lib/or_tools/cp_solver.rb +4 -0
- data/lib/or_tools/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 405e26b51140e6605acd8904d7e90e0e7f48b7cfd83641fef6e2e737e7b8cda4
|
4
|
+
data.tar.gz: e6e0506979a829c260f8bae70e7769524d59d83b7a52e1cadfb6e553d8116587
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 237e13e7340682d974602743de724031c28c99add58c4cf49e670bb05f4fa0c691dcf00dd75797a9ab3efcc9b5505a96f3a2a3d542db8c8746652ec114b5a258
|
7
|
+
data.tar.gz: 5c782dd281122001095663da47fce8279f5a2c29b6eed65e2288df6727c55724ef424d4c3bfda3ed3b4ce53493964b88d64f67fc843e97dafd98f3e21a4c5183
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
## 0.5.0 (2021-04-30)
|
2
|
+
|
3
|
+
- Updated OR-Tools to 9.0
|
4
|
+
- Added binary installation for CentOS 7
|
5
|
+
- Added `sufficient_assumptions_for_infeasibility` to `CpSolver`
|
6
|
+
|
1
7
|
## 0.4.3 (2021-03-26)
|
2
8
|
|
3
9
|
- Added `add_assumption`, `add_assumptions`, and `clear_assumptions` to `CpModel`
|
@@ -30,24 +30,24 @@ void init_bin_packing(Rice::Module& m) {
|
|
30
30
|
.define_method(
|
31
31
|
"init",
|
32
32
|
*[](KnapsackSolver& self, Array rb_values, Array rb_weights, Array rb_capacities) {
|
33
|
-
std::vector<
|
33
|
+
std::vector<int64_t> values;
|
34
34
|
for (std::size_t i = 0; i < rb_values.size(); ++i) {
|
35
|
-
values.push_back(from_ruby<
|
35
|
+
values.push_back(from_ruby<int64_t>(rb_values[i]));
|
36
36
|
}
|
37
37
|
|
38
|
-
std::vector<std::vector<
|
38
|
+
std::vector<std::vector<int64_t>> weights;
|
39
39
|
for (std::size_t i = 0; i < rb_weights.size(); ++i) {
|
40
40
|
Array rb_w = Array(rb_weights[i]);
|
41
|
-
std::vector<
|
41
|
+
std::vector<int64_t> w;
|
42
42
|
for (std::size_t j = 0; j < rb_w.size(); ++j) {
|
43
|
-
w.push_back(from_ruby<
|
43
|
+
w.push_back(from_ruby<int64_t>(rb_w[j]));
|
44
44
|
}
|
45
45
|
weights.push_back(w);
|
46
46
|
}
|
47
47
|
|
48
|
-
std::vector<
|
48
|
+
std::vector<int64_t> capacities;
|
49
49
|
for (std::size_t i = 0; i < rb_capacities.size(); ++i) {
|
50
|
-
capacities.push_back(from_ruby<
|
50
|
+
capacities.push_back(from_ruby<int64_t>(rb_capacities[i]));
|
51
51
|
}
|
52
52
|
|
53
53
|
self.Init(values, weights, capacities);
|
data/ext/or-tools/constraint.cpp
CHANGED
@@ -20,10 +20,14 @@ using operations_research::sat::SolutionBooleanValue;
|
|
20
20
|
using operations_research::sat::SolutionIntegerValue;
|
21
21
|
|
22
22
|
using Rice::Array;
|
23
|
+
using Rice::Class;
|
23
24
|
using Rice::Object;
|
24
25
|
using Rice::String;
|
25
26
|
using Rice::Symbol;
|
26
27
|
|
28
|
+
Class rb_cBoolVar;
|
29
|
+
Class rb_cSatIntVar;
|
30
|
+
|
27
31
|
template<>
|
28
32
|
inline
|
29
33
|
LinearExpr from_ruby<LinearExpr>(Object x)
|
@@ -31,29 +35,24 @@ LinearExpr from_ruby<LinearExpr>(Object x)
|
|
31
35
|
LinearExpr expr;
|
32
36
|
|
33
37
|
if (x.respond_to("to_i")) {
|
34
|
-
expr = from_ruby<
|
38
|
+
expr = from_ruby<int64_t>(x.call("to_i"));
|
35
39
|
} else if (x.respond_to("vars")) {
|
36
40
|
Array vars = x.call("vars");
|
37
|
-
for(auto const& var: vars) {
|
41
|
+
for (auto const& var: vars) {
|
38
42
|
auto cvar = (Array) var;
|
39
|
-
// TODO clean up
|
40
43
|
Object o = cvar[0];
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
expr.AddConstant(from_ruby<int64>(cvar[0]) * from_ruby<int64>(cvar[1]));
|
44
|
+
if (o.is_a(rb_cBoolVar)) {
|
45
|
+
expr.AddTerm(from_ruby<BoolVar>(cvar[0]), from_ruby<int64_t>(cvar[1]));
|
46
|
+
} else if (o.is_a(rb_cInteger)) {
|
47
|
+
expr.AddConstant(from_ruby<int64_t>(cvar[0]) * from_ruby<int64_t>(cvar[1]));
|
46
48
|
} else {
|
47
|
-
expr.AddTerm(from_ruby<IntVar>(cvar[0]), from_ruby<
|
49
|
+
expr.AddTerm(from_ruby<IntVar>(cvar[0]), from_ruby<int64_t>(cvar[1]));
|
48
50
|
}
|
49
51
|
}
|
52
|
+
} else if (x.is_a(rb_cBoolVar)) {
|
53
|
+
expr = from_ruby<BoolVar>(x);
|
50
54
|
} else {
|
51
|
-
|
52
|
-
if (type == "ORTools::BoolVar") {
|
53
|
-
expr = from_ruby<BoolVar>(x);
|
54
|
-
} else {
|
55
|
-
expr = from_ruby<IntVar>(x);
|
56
|
-
}
|
55
|
+
expr = from_ruby<IntVar>(x);
|
57
56
|
}
|
58
57
|
|
59
58
|
return expr;
|
@@ -128,8 +127,6 @@ LinearExprSpan from_ruby<LinearExprSpan>(Object x)
|
|
128
127
|
return LinearExprSpan(x);
|
129
128
|
}
|
130
129
|
|
131
|
-
Rice::Class rb_cSatIntVar;
|
132
|
-
|
133
130
|
// need a wrapper class since absl::Span doesn't own
|
134
131
|
class BoolVarSpan {
|
135
132
|
std::vector<BoolVar> vec;
|
@@ -178,7 +175,7 @@ void init_constraint(Rice::Module& m) {
|
|
178
175
|
}
|
179
176
|
});
|
180
177
|
|
181
|
-
Rice::define_class_under<BoolVar>(m, "BoolVar")
|
178
|
+
rb_cBoolVar = Rice::define_class_under<BoolVar>(m, "BoolVar")
|
182
179
|
.define_method("name", &BoolVar::Name)
|
183
180
|
.define_method("index", &BoolVar::index)
|
184
181
|
.define_method("not", &BoolVar::Not)
|
@@ -200,7 +197,7 @@ void init_constraint(Rice::Module& m) {
|
|
200
197
|
.define_constructor(Rice::Constructor<CpModelBuilder>())
|
201
198
|
.define_method(
|
202
199
|
"new_int_var",
|
203
|
-
*[](CpModelBuilder& self,
|
200
|
+
*[](CpModelBuilder& self, int64_t start, int64_t end, const std::string& name) {
|
204
201
|
const operations_research::Domain domain(start, end);
|
205
202
|
return self.NewIntVar(domain).WithName(name);
|
206
203
|
})
|
@@ -211,7 +208,7 @@ void init_constraint(Rice::Module& m) {
|
|
211
208
|
})
|
212
209
|
.define_method(
|
213
210
|
"new_constant",
|
214
|
-
*[](CpModelBuilder& self,
|
211
|
+
*[](CpModelBuilder& self, int64_t value) {
|
215
212
|
return self.NewConstant(value);
|
216
213
|
})
|
217
214
|
.define_method(
|
@@ -362,7 +359,7 @@ void init_constraint(Rice::Module& m) {
|
|
362
359
|
})
|
363
360
|
.define_method(
|
364
361
|
"add_hint",
|
365
|
-
*[](CpModelBuilder& self, IntVar var,
|
362
|
+
*[](CpModelBuilder& self, IntVar var, int64_t value) {
|
366
363
|
self.AddHint(var, value);
|
367
364
|
})
|
368
365
|
.define_method(
|
@@ -462,5 +459,15 @@ void init_constraint(Rice::Module& m) {
|
|
462
459
|
} else {
|
463
460
|
throw std::runtime_error("Unknown solver status");
|
464
461
|
}
|
462
|
+
})
|
463
|
+
.define_method(
|
464
|
+
"sufficient_assumptions_for_infeasibility",
|
465
|
+
*[](CpSolverResponse& self) {
|
466
|
+
auto a = Array();
|
467
|
+
auto assumptions = self.sufficient_assumptions_for_infeasibility();
|
468
|
+
for (auto const& v : assumptions) {
|
469
|
+
a.push(v);
|
470
|
+
}
|
471
|
+
return a;
|
465
472
|
});
|
466
473
|
}
|
@@ -47,7 +47,7 @@ void init_network_flows(Rice::Module& m) {
|
|
47
47
|
self.GetSourceSideMinCut(&result);
|
48
48
|
|
49
49
|
Array ret;
|
50
|
-
for(auto const& it: result) {
|
50
|
+
for (auto const& it: result) {
|
51
51
|
ret.push(it);
|
52
52
|
}
|
53
53
|
return ret;
|
@@ -59,7 +59,7 @@ void init_network_flows(Rice::Module& m) {
|
|
59
59
|
self.GetSinkSideMinCut(&result);
|
60
60
|
|
61
61
|
Array ret;
|
62
|
-
for(auto const& it: result) {
|
62
|
+
for (auto const& it: result) {
|
63
63
|
ret.push(it);
|
64
64
|
}
|
65
65
|
return ret;
|
data/ext/or-tools/routing.cpp
CHANGED
@@ -54,16 +54,16 @@ class Assignment {
|
|
54
54
|
Assignment(const operations_research::Assignment* v) {
|
55
55
|
self = v;
|
56
56
|
}
|
57
|
-
|
57
|
+
int64_t ObjectiveValue() {
|
58
58
|
return self->ObjectiveValue();
|
59
59
|
}
|
60
|
-
|
60
|
+
int64_t Value(const operations_research::IntVar* const var) const {
|
61
61
|
return self->Value(var);
|
62
62
|
}
|
63
|
-
|
63
|
+
int64_t Min(const operations_research::IntVar* const var) const {
|
64
64
|
return self->Min(var);
|
65
65
|
}
|
66
|
-
|
66
|
+
int64_t Max(const operations_research::IntVar* const var) const {
|
67
67
|
return self->Max(var);
|
68
68
|
}
|
69
69
|
};
|
@@ -180,17 +180,17 @@ void init_routing(Rice::Module& m) {
|
|
180
180
|
})
|
181
181
|
.define_method(
|
182
182
|
"solution_limit=",
|
183
|
-
*[](RoutingSearchParameters& self,
|
183
|
+
*[](RoutingSearchParameters& self, int64_t value) {
|
184
184
|
self.set_solution_limit(value);
|
185
185
|
})
|
186
186
|
.define_method(
|
187
187
|
"time_limit=",
|
188
|
-
*[](RoutingSearchParameters& self,
|
188
|
+
*[](RoutingSearchParameters& self, int64_t value) {
|
189
189
|
self.mutable_time_limit()->set_seconds(value);
|
190
190
|
})
|
191
191
|
.define_method(
|
192
192
|
"lns_time_limit=",
|
193
|
-
*[](RoutingSearchParameters& self,
|
193
|
+
*[](RoutingSearchParameters& self, int64_t value) {
|
194
194
|
self.mutable_lns_time_limit()->set_seconds(value);
|
195
195
|
});
|
196
196
|
|
@@ -218,7 +218,7 @@ void init_routing(Rice::Module& m) {
|
|
218
218
|
rb_cIntVar = Rice::define_class_under<operations_research::IntVar>(m, "IntVar")
|
219
219
|
.define_method(
|
220
220
|
"set_range",
|
221
|
-
*[](operations_research::IntVar& self,
|
221
|
+
*[](operations_research::IntVar& self, int64_t new_min, int64_t new_max) {
|
222
222
|
self.SetRange(new_min, new_max);
|
223
223
|
});
|
224
224
|
|
@@ -253,20 +253,20 @@ void init_routing(Rice::Module& m) {
|
|
253
253
|
})
|
254
254
|
.define_method(
|
255
255
|
"fixed_duration_interval_var",
|
256
|
-
*[](operations_research::Solver& self, operations_research::IntVar* const start_variable,
|
256
|
+
*[](operations_research::Solver& self, operations_research::IntVar* const start_variable, int64_t duration, const std::string& name) {
|
257
257
|
return self.MakeFixedDurationIntervalVar(start_variable, duration, name);
|
258
258
|
})
|
259
259
|
.define_method(
|
260
260
|
"cumulative",
|
261
|
-
*[](operations_research::Solver& self, Array rb_intervals, Array rb_demands,
|
261
|
+
*[](operations_research::Solver& self, Array rb_intervals, Array rb_demands, int64_t capacity, const std::string& name) {
|
262
262
|
std::vector<operations_research::IntervalVar*> intervals;
|
263
263
|
for (std::size_t i = 0; i < rb_intervals.size(); ++i) {
|
264
264
|
intervals.push_back(from_ruby<operations_research::IntervalVar*>(rb_intervals[i]));
|
265
265
|
}
|
266
266
|
|
267
|
-
std::vector<
|
267
|
+
std::vector<int64_t> demands;
|
268
268
|
for (std::size_t i = 0; i < rb_demands.size(); ++i) {
|
269
|
-
demands.push_back(from_ruby<
|
269
|
+
demands.push_back(from_ruby<int64_t>(rb_demands[i]));
|
270
270
|
}
|
271
271
|
|
272
272
|
return self.MakeCumulative(intervals, demands, capacity, name);
|
@@ -278,8 +278,8 @@ void init_routing(Rice::Module& m) {
|
|
278
278
|
"register_transit_callback",
|
279
279
|
*[](RoutingModel& self, Object callback) {
|
280
280
|
return self.RegisterTransitCallback(
|
281
|
-
[callback](
|
282
|
-
return from_ruby<
|
281
|
+
[callback](int64_t from_index, int64_t to_index) -> int64_t {
|
282
|
+
return from_ruby<int64_t>(callback.call("call", from_index, to_index));
|
283
283
|
}
|
284
284
|
);
|
285
285
|
})
|
@@ -287,8 +287,8 @@ void init_routing(Rice::Module& m) {
|
|
287
287
|
"register_unary_transit_callback",
|
288
288
|
*[](RoutingModel& self, Object callback) {
|
289
289
|
return self.RegisterUnaryTransitCallback(
|
290
|
-
[callback](
|
291
|
-
return from_ruby<
|
290
|
+
[callback](int64_t from_index) -> int64_t {
|
291
|
+
return from_ruby<int64_t>(callback.call("call", from_index));
|
292
292
|
}
|
293
293
|
);
|
294
294
|
})
|
@@ -320,16 +320,16 @@ void init_routing(Rice::Module& m) {
|
|
320
320
|
.define_method("add_dimension", &RoutingModel::AddDimension)
|
321
321
|
.define_method(
|
322
322
|
"add_dimension_with_vehicle_capacity",
|
323
|
-
*[](RoutingModel& self, int evaluator_index,
|
324
|
-
std::vector<
|
323
|
+
*[](RoutingModel& self, int evaluator_index, int64_t slack_max, Array vc, bool fix_start_cumul_to_zero, const std::string& name) {
|
324
|
+
std::vector<int64_t> vehicle_capacities;
|
325
325
|
for (std::size_t i = 0; i < vc.size(); ++i) {
|
326
|
-
vehicle_capacities.push_back(from_ruby<
|
326
|
+
vehicle_capacities.push_back(from_ruby<int64_t>(vc[i]));
|
327
327
|
}
|
328
328
|
self.AddDimensionWithVehicleCapacity(evaluator_index, slack_max, vehicle_capacities, fix_start_cumul_to_zero, name);
|
329
329
|
})
|
330
330
|
.define_method(
|
331
331
|
"add_dimension_with_vehicle_transits",
|
332
|
-
*[](RoutingModel& self, Array rb_indices,
|
332
|
+
*[](RoutingModel& self, Array rb_indices, int64_t slack_max, int64_t capacity, bool fix_start_cumul_to_zero, const std::string& name) {
|
333
333
|
std::vector<int> evaluator_indices;
|
334
334
|
for (std::size_t i = 0; i < rb_indices.size(); ++i) {
|
335
335
|
evaluator_indices.push_back(from_ruby<int>(rb_indices[i]));
|
@@ -338,10 +338,10 @@ void init_routing(Rice::Module& m) {
|
|
338
338
|
})
|
339
339
|
.define_method(
|
340
340
|
"add_disjunction",
|
341
|
-
*[](RoutingModel& self, Array rb_indices,
|
342
|
-
std::vector<
|
341
|
+
*[](RoutingModel& self, Array rb_indices, int64_t penalty) {
|
342
|
+
std::vector<int64_t> indices;
|
343
343
|
for (std::size_t i = 0; i < rb_indices.size(); ++i) {
|
344
|
-
indices.push_back(from_ruby<
|
344
|
+
indices.push_back(from_ruby<int64_t>(rb_indices[i]));
|
345
345
|
}
|
346
346
|
self.AddDisjunction(indices, penalty);
|
347
347
|
})
|
data/ext/or-tools/vendor.rb
CHANGED
@@ -3,26 +3,29 @@ require "fileutils"
|
|
3
3
|
require "net/http"
|
4
4
|
require "tmpdir"
|
5
5
|
|
6
|
-
version = "
|
6
|
+
version = "9.0.9048"
|
7
7
|
|
8
8
|
if RbConfig::CONFIG["host_os"] =~ /darwin/i
|
9
|
-
filename = "or-tools_MacOsX-11.2.
|
10
|
-
checksum = "
|
9
|
+
filename = "or-tools_MacOsX-11.2.3_v#{version}.tar.gz"
|
10
|
+
checksum = "adf73a00d4ec49558b67be5ce3cfc8f30268da2253b35feb11d0d40700550bf6"
|
11
11
|
else
|
12
12
|
os = %x[lsb_release -is].chomp rescue nil
|
13
13
|
os_version = %x[lsb_release -rs].chomp rescue nil
|
14
14
|
if os == "Ubuntu" && os_version == "20.04"
|
15
15
|
filename = "or-tools_ubuntu-20.04_v#{version}.tar.gz"
|
16
|
-
checksum = "
|
16
|
+
checksum = "5565343c1c310d2885a40ce850ae7e3468299b3fee97ae8eed8425ce06bd4960"
|
17
17
|
elsif os == "Ubuntu" && os_version == "18.04"
|
18
18
|
filename = "or-tools_ubuntu-18.04_v#{version}.tar.gz"
|
19
|
-
checksum = "
|
19
|
+
checksum = "08cf548d0179f7fa814bb7458be94cd1b8a3de14985e6a9faf6118a1d8571539"
|
20
20
|
elsif os == "Debian" && os_version == "10"
|
21
21
|
filename = "or-tools_debian-10_v#{version}.tar.gz"
|
22
|
-
checksum = "
|
22
|
+
checksum = "063fb1d8765ae23b0bb25b9c561e904532713416fe0458f7db45a0f72190eb50"
|
23
23
|
elsif os == "CentOS" && os_version == "8"
|
24
24
|
filename = "or-tools_centos-8_v#{version}.tar.gz"
|
25
|
-
checksum = "
|
25
|
+
checksum = "c98212ed4fc699d8ae70c1f53cd1d8dacd28e52970336fab5b86dedf7406f215"
|
26
|
+
elsif os == "CentOS" && os_version == "7"
|
27
|
+
filename = "or-tools_centos-7_v#{version}.tar.gz"
|
28
|
+
checksum = "b992bda4614bbc703583b0e9edcd2ade54bacfb9909399b20c8aa95ff7197d68"
|
26
29
|
else
|
27
30
|
platform =
|
28
31
|
if Gem.win_platform?
|
data/lib/or_tools/cp_solver.rb
CHANGED
data/lib/or_tools/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: or-tools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kane
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-04-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rice
|