or-tools 0.7.1 → 0.8.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 +15 -0
- data/README.md +1 -12
- data/ext/or-tools/ext.cpp +1 -7
- data/ext/or-tools/extconf.rb +2 -1
- data/ext/or-tools/routing.cpp +151 -42
- data/ext/or-tools/vendor.rb +23 -28
- data/lib/or_tools/tsp.rb +1 -7
- data/lib/or_tools/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0b7f1f552804f88337c4d277ac7062a984c13ea67e43a8cd5567e8c0b8f1b3c6
|
4
|
+
data.tar.gz: 5bd93184a59799ef541745a8f4498f4cf25c525c290c3c2c7fbe2d5e5494c942
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 91077d2961b42021ee98f580d132f99a84128354bd054053de600510c4aba7343e1da9696a5d08a7c214742b92cac45200f85aa136d3e092d77b25ceb4033cdc
|
7
|
+
data.tar.gz: 316c4c0423522a2bdb78e006d38c412aa94cbaa14b4a37ebd3c04f340752d5f2adc5a3a9f5cf4adbd6968627a8e0504b58ae77d1d0876eb46cab783843957ead
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,18 @@
|
|
1
|
+
## 0.8.0 (2022-08-21)
|
2
|
+
|
3
|
+
- Updated OR-Tools to 9.4
|
4
|
+
- Added binary installation for Mac ARM
|
5
|
+
- Restored support for Debian 10
|
6
|
+
- Dropped support for Ruby < 2.7
|
7
|
+
|
8
|
+
## 0.7.3 (2022-07-23)
|
9
|
+
|
10
|
+
- Added more methods to `RoutingModel` and `RoutingDimension`
|
11
|
+
|
12
|
+
## 0.7.2 (2022-05-28)
|
13
|
+
|
14
|
+
- Fixed library not loaded error on Mac
|
15
|
+
|
1
16
|
## 0.7.1 (2022-05-27)
|
2
17
|
|
3
18
|
- Added support for time limit for `Solver`
|
data/README.md
CHANGED
@@ -12,7 +12,7 @@ Add this line to your application’s Gemfile:
|
|
12
12
|
gem "or-tools"
|
13
13
|
```
|
14
14
|
|
15
|
-
Installation can take a few minutes as OR-Tools downloads and builds.
|
15
|
+
Installation can take a few minutes as OR-Tools downloads and builds.
|
16
16
|
|
17
17
|
## Guides
|
18
18
|
|
@@ -2263,17 +2263,6 @@ possible_tables.each do |table|
|
|
2263
2263
|
end
|
2264
2264
|
```
|
2265
2265
|
|
2266
|
-
## Additional Instructions
|
2267
|
-
|
2268
|
-
### Mac ARM
|
2269
|
-
|
2270
|
-
ARM binaries are not available for Mac yet, so use Homebrew to install OR-Tools before installing the gem.
|
2271
|
-
|
2272
|
-
```sh
|
2273
|
-
brew install or-tools
|
2274
|
-
bundle config build.or-tools --with-or-tools-dir=/opt/homebrew
|
2275
|
-
```
|
2276
|
-
|
2277
2266
|
## History
|
2278
2267
|
|
2279
2268
|
View the [changelog](https://github.com/ankane/or-tools-ruby/blob/master/CHANGELOG.md)
|
data/ext/or-tools/ext.cpp
CHANGED
@@ -18,13 +18,7 @@ void Init_ext()
|
|
18
18
|
{
|
19
19
|
auto m = Rice::define_module("ORTools");
|
20
20
|
|
21
|
-
|
22
|
-
m.define_singleton_function(
|
23
|
-
"lib_version",
|
24
|
-
[]() {
|
25
|
-
return std::to_string(operations_research::OrToolsMajorVersion()) + "."
|
26
|
-
+ std::to_string(operations_research::OrToolsMinorVersion());
|
27
|
-
});
|
21
|
+
m.define_singleton_function("lib_version", &operations_research::OrToolsVersionString);
|
28
22
|
|
29
23
|
init_assignment(m);
|
30
24
|
init_bin_packing(m);
|
data/ext/or-tools/extconf.rb
CHANGED
@@ -23,8 +23,9 @@ else
|
|
23
23
|
rpath = "'#{rpath_prefix}/../../tmp/or-tools/lib'"
|
24
24
|
end
|
25
25
|
|
26
|
+
# find_header and find_library first check without adding path
|
27
|
+
# which can cause them to find system library
|
26
28
|
$INCFLAGS << " -I#{inc}"
|
27
|
-
|
28
29
|
$LDFLAGS.prepend("-Wl,-rpath,#{rpath} -L#{lib} ")
|
29
30
|
raise "OR-Tools not found" unless have_library("ortools")
|
30
31
|
|
data/ext/or-tools/routing.cpp
CHANGED
@@ -9,6 +9,7 @@ using operations_research::DefaultRoutingSearchParameters;
|
|
9
9
|
using operations_research::FirstSolutionStrategy;
|
10
10
|
using operations_research::LocalSearchMetaheuristic;
|
11
11
|
using operations_research::RoutingDimension;
|
12
|
+
using operations_research::RoutingDisjunctionIndex;
|
12
13
|
using operations_research::RoutingIndexManager;
|
13
14
|
using operations_research::RoutingModel;
|
14
15
|
using operations_research::RoutingModelParameters;
|
@@ -55,6 +56,19 @@ namespace Rice::detail
|
|
55
56
|
};
|
56
57
|
}
|
57
58
|
|
59
|
+
namespace Rice::detail
|
60
|
+
{
|
61
|
+
template<class T, class U>
|
62
|
+
class To_Ruby<std::pair<T, U>>
|
63
|
+
{
|
64
|
+
public:
|
65
|
+
VALUE convert(std::pair<T, U> const & x)
|
66
|
+
{
|
67
|
+
return rb_ary_new3(2, To_Ruby<T>().convert(x.first), To_Ruby<U>().convert(x.second));
|
68
|
+
}
|
69
|
+
};
|
70
|
+
}
|
71
|
+
|
58
72
|
void init_routing(Rice::Module& m) {
|
59
73
|
auto rb_cRoutingSearchParameters = Rice::define_class_under<RoutingSearchParameters>(m, "RoutingSearchParameters");
|
60
74
|
auto rb_cIntVar = Rice::define_class_under<operations_research::IntVar>(m, "IntVar");
|
@@ -198,8 +212,28 @@ void init_routing(Rice::Module& m) {
|
|
198
212
|
.define_method("old_end_max", &operations_research::IntervalVar::OldEndMax);
|
199
213
|
|
200
214
|
Rice::define_class_under<RoutingDimension>(m, "RoutingDimension")
|
215
|
+
.define_method("transit_value", &RoutingDimension::GetTransitValue)
|
216
|
+
// TODO GetTransitValueFromClass
|
217
|
+
.define_method("cumul_var", &RoutingDimension::CumulVar)
|
218
|
+
.define_method("transit_var", &RoutingDimension::TransitVar)
|
219
|
+
.define_method("fixed_transit_var", &RoutingDimension::FixedTransitVar)
|
220
|
+
.define_method("slack_var", &RoutingDimension::SlackVar)
|
221
|
+
.define_method("set_span_upper_bound_for_vehicle", &RoutingDimension::SetSpanUpperBoundForVehicle)
|
222
|
+
.define_method("set_span_cost_coefficient_for_vehicle", &RoutingDimension::SetSpanCostCoefficientForVehicle)
|
223
|
+
.define_method("set_span_cost_coefficient_for_all_vehicles", &RoutingDimension::SetSpanCostCoefficientForAllVehicles)
|
224
|
+
.define_method("set_global_span_cost_coefficient", &RoutingDimension::SetGlobalSpanCostCoefficient)
|
225
|
+
// alias
|
201
226
|
.define_method("global_span_cost_coefficient=", &RoutingDimension::SetGlobalSpanCostCoefficient)
|
202
|
-
.define_method("
|
227
|
+
.define_method("set_cumul_var_soft_upper_bound", &RoutingDimension::SetCumulVarSoftUpperBound)
|
228
|
+
.define_method("cumul_var_soft_upper_bound?", &RoutingDimension::HasCumulVarSoftUpperBound)
|
229
|
+
.define_method("cumul_var_soft_upper_bound", &RoutingDimension::GetCumulVarSoftUpperBound)
|
230
|
+
.define_method("cumul_var_soft_upper_bound_coefficient", &RoutingDimension::GetCumulVarSoftUpperBoundCoefficient)
|
231
|
+
.define_method("set_cumul_var_soft_lower_bound", &RoutingDimension::SetCumulVarSoftLowerBound)
|
232
|
+
.define_method("cumul_var_soft_lower_bound?", &RoutingDimension::HasCumulVarSoftLowerBound)
|
233
|
+
.define_method("cumul_var_soft_lower_bound", &RoutingDimension::GetCumulVarSoftLowerBound)
|
234
|
+
.define_method("cumul_var_soft_lower_bound_coefficient", &RoutingDimension::GetCumulVarSoftLowerBoundCoefficient);
|
235
|
+
|
236
|
+
Rice::define_class_under<RoutingDisjunctionIndex>(m, "RoutingDisjunctionIndex");
|
203
237
|
|
204
238
|
Rice::define_class_under<operations_research::Constraint>(m, "Constraint")
|
205
239
|
.define_method("post", &operations_research::Constraint::Post)
|
@@ -264,27 +298,99 @@ void init_routing(Rice::Module& m) {
|
|
264
298
|
|
265
299
|
Rice::define_class_under<RoutingModel>(m, "RoutingModel")
|
266
300
|
.define_constructor(Rice::Constructor<RoutingModel, RoutingIndexManager, RoutingModelParameters>(), Rice::Arg("index_manager"), Rice::Arg("parameters") = operations_research::DefaultRoutingModelParameters())
|
301
|
+
.define_method("register_unary_transit_vector", &RoutingModel::RegisterUnaryTransitVector)
|
267
302
|
.define_method(
|
268
|
-
"
|
303
|
+
"register_unary_transit_callback",
|
269
304
|
[](RoutingModel& self, Object callback) {
|
270
|
-
return self.
|
271
|
-
[callback](int64_t from_index
|
272
|
-
return Rice::detail::From_Ruby<int64_t>().convert(callback.call("call", from_index
|
305
|
+
return self.RegisterUnaryTransitCallback(
|
306
|
+
[callback](int64_t from_index) -> int64_t {
|
307
|
+
return Rice::detail::From_Ruby<int64_t>().convert(callback.call("call", from_index));
|
273
308
|
}
|
274
309
|
);
|
275
310
|
})
|
311
|
+
.define_method("register_transit_matrix", &RoutingModel::RegisterTransitMatrix)
|
276
312
|
.define_method(
|
277
|
-
"
|
313
|
+
"register_transit_callback",
|
278
314
|
[](RoutingModel& self, Object callback) {
|
279
|
-
return self.
|
280
|
-
[callback](int64_t from_index) -> int64_t {
|
281
|
-
return Rice::detail::From_Ruby<int64_t>().convert(callback.call("call", from_index));
|
315
|
+
return self.RegisterTransitCallback(
|
316
|
+
[callback](int64_t from_index, int64_t to_index) -> int64_t {
|
317
|
+
return Rice::detail::From_Ruby<int64_t>().convert(callback.call("call", from_index, to_index));
|
282
318
|
}
|
283
319
|
);
|
284
320
|
})
|
321
|
+
.define_method("add_dimension", &RoutingModel::AddDimension)
|
322
|
+
.define_method("add_dimension_with_vehicle_transits", &RoutingModel::AddDimensionWithVehicleTransits)
|
323
|
+
.define_method("add_dimension_with_vehicle_capacity", &RoutingModel::AddDimensionWithVehicleCapacity)
|
324
|
+
.define_method("add_dimension_with_vehicle_transit_and_capacity", &RoutingModel::AddDimensionWithVehicleTransitAndCapacity)
|
325
|
+
.define_method("add_constant_dimension_with_slack", &RoutingModel::AddConstantDimensionWithSlack)
|
326
|
+
.define_method("add_constant_dimension", &RoutingModel::AddConstantDimension)
|
327
|
+
.define_method("add_vector_dimension", &RoutingModel::AddVectorDimension)
|
328
|
+
.define_method("add_matrix_dimension", &RoutingModel::AddMatrixDimension)
|
329
|
+
// TODO AddDimensionDependentDimensionWithVehicleCapacity
|
330
|
+
// .define_method("make_path_spans_and_total_slacks", &RoutingModel::MakePathSpansAndTotalSlacks)
|
331
|
+
.define_method("all_dimension_names", &RoutingModel::GetAllDimensionNames)
|
332
|
+
// .define_method("dimensions", &RoutingModel::GetDimensions)
|
333
|
+
// .define_method("dimensions_with_soft_or_span_costs", &RoutingModel::GetDimensionsWithSoftOrSpanCosts)
|
334
|
+
.define_method("dimension?", &RoutingModel::HasDimension)
|
335
|
+
// .define_method("dimension_or_die", &RoutingModel::GetDimensionOrDie)
|
336
|
+
.define_method("mutable_dimension", &RoutingModel::GetMutableDimension)
|
337
|
+
.define_method("set_primary_constrained_dimension", &RoutingModel::SetPrimaryConstrainedDimension)
|
338
|
+
.define_method("primary_constrained_dimension", &RoutingModel::GetPrimaryConstrainedDimension)
|
339
|
+
.define_method("add_resource_group", &RoutingModel::AddResourceGroup)
|
340
|
+
.define_method("dimension_resource_group_indices", &RoutingModel::GetDimensionResourceGroupIndices)
|
341
|
+
.define_method("dimension_resource_group_index", &RoutingModel::GetDimensionResourceGroupIndex)
|
342
|
+
.define_method("add_disjunction", &RoutingModel::AddDisjunction, Rice::Arg("indices"), Rice::Arg("penalty"), Rice::Arg("max_cardinality") = (int64_t)1)
|
343
|
+
.define_method("disjunction_indices", &RoutingModel::GetDisjunctionIndices)
|
344
|
+
.define_method("disjunction_penalty", &RoutingModel::GetDisjunctionPenalty)
|
345
|
+
.define_method("disjunction_max_cardinality", &RoutingModel::GetDisjunctionMaxCardinality)
|
346
|
+
.define_method("number_of_disjunctions", &RoutingModel::GetNumberOfDisjunctions)
|
347
|
+
.define_method("mandatory_disjunctions?", &RoutingModel::HasMandatoryDisjunctions)
|
348
|
+
.define_method("max_cardinality_constrained_disjunctions?", &RoutingModel::HasMaxCardinalityConstrainedDisjunctions)
|
349
|
+
.define_method("perfect_binary_disjunctions", &RoutingModel::GetPerfectBinaryDisjunctions)
|
350
|
+
.define_method("ignore_disjunctions_already_forced_to_zero", &RoutingModel::IgnoreDisjunctionsAlreadyForcedToZero)
|
351
|
+
.define_method("add_soft_same_vehicle_constraint", &RoutingModel::AddSoftSameVehicleConstraint)
|
352
|
+
.define_method("set_allowed_vehicles_for_index", &RoutingModel::SetAllowedVehiclesForIndex)
|
353
|
+
.define_method("vehicle_allowed_for_index?", &RoutingModel::IsVehicleAllowedForIndex)
|
354
|
+
.define_method("add_pickup_and_delivery", &RoutingModel::AddPickupAndDelivery)
|
355
|
+
.define_method("add_pickup_and_delivery_sets", &RoutingModel::AddPickupAndDeliverySets)
|
356
|
+
.define_method("pickup_index_pairs", &RoutingModel::GetPickupIndexPairs)
|
357
|
+
.define_method("delivery_index_pairs", &RoutingModel::GetDeliveryIndexPairs)
|
358
|
+
// TODO SetPickupAndDeliveryPolicyOfAllVehicles
|
359
|
+
// TODO SetPickupAndDeliveryPolicyOfVehicle
|
360
|
+
// TODO GetPickupAndDeliveryPolicyOfVehicle
|
361
|
+
.define_method("num_of_singleton_nodes", &RoutingModel::GetNumOfSingletonNodes)
|
362
|
+
.define_method("unperformed_penalty", &RoutingModel::UnperformedPenalty)
|
363
|
+
.define_method("unperformed_penalty_or_value", &RoutingModel::UnperformedPenaltyOrValue)
|
285
364
|
.define_method("depot", &RoutingModel::GetDepot)
|
286
|
-
.define_method("
|
287
|
-
.define_method("
|
365
|
+
.define_method("set_maximum_number_of_active_vehicles", &RoutingModel::SetMaximumNumberOfActiveVehicles)
|
366
|
+
.define_method("maximum_number_of_active_vehicles", &RoutingModel::GetMaximumNumberOfActiveVehicles)
|
367
|
+
.define_method("set_arc_cost_evaluator_of_all_vehicles", &RoutingModel::SetArcCostEvaluatorOfAllVehicles)
|
368
|
+
.define_method("set_arc_cost_evaluator_of_vehicle", &RoutingModel::SetArcCostEvaluatorOfVehicle)
|
369
|
+
.define_method("set_fixed_cost_of_all_vehicles", &RoutingModel::SetFixedCostOfAllVehicles)
|
370
|
+
.define_method("set_fixed_cost_of_vehicle", &RoutingModel::SetFixedCostOfVehicle)
|
371
|
+
.define_method("fixed_cost_of_vehicle", &RoutingModel::GetFixedCostOfVehicle)
|
372
|
+
.define_method("set_amortized_cost_factors_of_all_vehicles", &RoutingModel::SetAmortizedCostFactorsOfAllVehicles)
|
373
|
+
.define_method("set_amortized_cost_factors_of_vehicle", &RoutingModel::SetAmortizedCostFactorsOfVehicle)
|
374
|
+
.define_method("amortized_linear_cost_factor_of_vehicles", &RoutingModel::GetAmortizedLinearCostFactorOfVehicles)
|
375
|
+
.define_method("amortized_quadratic_cost_factor_of_vehicles", &RoutingModel::GetAmortizedQuadraticCostFactorOfVehicles)
|
376
|
+
.define_method("set_vehicle_used_when_empty", &RoutingModel::SetVehicleUsedWhenEmpty)
|
377
|
+
.define_method("vehicle_used_when_empty?", &RoutingModel::IsVehicleUsedWhenEmpty)
|
378
|
+
.define_method("add_variable_minimized_by_finalizer", &RoutingModel::AddVariableMinimizedByFinalizer)
|
379
|
+
.define_method("add_variable_maximized_by_finalizer", &RoutingModel::AddVariableMaximizedByFinalizer)
|
380
|
+
.define_method("add_weighted_variable_minimized_by_finalizer", &RoutingModel::AddWeightedVariableMinimizedByFinalizer)
|
381
|
+
.define_method("add_weighted_variable_maximized_by_finalizer", &RoutingModel::AddWeightedVariableMaximizedByFinalizer)
|
382
|
+
.define_method("add_variable_target_to_finalizer", &RoutingModel::AddVariableTargetToFinalizer)
|
383
|
+
.define_method("add_weighted_variable_target_to_finalizer", &RoutingModel::AddWeightedVariableTargetToFinalizer)
|
384
|
+
.define_method("close_model", &RoutingModel::CloseModel)
|
385
|
+
// solve defined in Ruby
|
386
|
+
.define_method(
|
387
|
+
"solve_with_parameters",
|
388
|
+
[](RoutingModel& self, const RoutingSearchParameters& search_parameters) {
|
389
|
+
return self.SolveWithParameters(search_parameters);
|
390
|
+
})
|
391
|
+
.define_method("compute_lower_bound", &RoutingModel::ComputeLowerBound)
|
392
|
+
.define_method("status",
|
393
|
+
[](RoutingModel& self) {
|
288
394
|
auto status = self.status();
|
289
395
|
|
290
396
|
if (status == RoutingModel::ROUTING_NOT_SOLVED) {
|
@@ -301,30 +407,22 @@ void init_routing(Rice::Module& m) {
|
|
301
407
|
throw std::runtime_error("Unknown solver status");
|
302
408
|
}
|
303
409
|
})
|
304
|
-
.define_method("
|
305
|
-
.define_method("
|
306
|
-
.define_method("
|
307
|
-
.define_method("
|
308
|
-
.define_method("
|
309
|
-
.define_method("
|
310
|
-
.define_method("
|
311
|
-
.define_method(
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
.define_method(
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
})
|
321
|
-
.define_method(
|
322
|
-
"add_disjunction",
|
323
|
-
[](RoutingModel& self, std::vector<int64_t> indices, int64_t penalty) {
|
324
|
-
self.AddDisjunction(indices, penalty);
|
325
|
-
})
|
326
|
-
.define_method("add_pickup_and_delivery", &RoutingModel::AddPickupAndDelivery)
|
327
|
-
.define_method("solver", &RoutingModel::solver)
|
410
|
+
.define_method("apply_locks", &RoutingModel::ApplyLocks)
|
411
|
+
.define_method("apply_locks_to_all_vehicles", &RoutingModel::ApplyLocksToAllVehicles)
|
412
|
+
.define_method("pre_assignment", &RoutingModel::PreAssignment)
|
413
|
+
.define_method("mutable_pre_assignment", &RoutingModel::MutablePreAssignment)
|
414
|
+
.define_method("write_assignment", &RoutingModel::WriteAssignment)
|
415
|
+
.define_method("read_assignment", &RoutingModel::ReadAssignment)
|
416
|
+
.define_method("restore_assignment", &RoutingModel::RestoreAssignment)
|
417
|
+
.define_method("read_assignment_from_routes", &RoutingModel::ReadAssignmentFromRoutes)
|
418
|
+
.define_method("routes_to_assignment", &RoutingModel::RoutesToAssignment)
|
419
|
+
.define_method("assignment_to_routes", &RoutingModel::AssignmentToRoutes)
|
420
|
+
.define_method("compact_assignment", &RoutingModel::CompactAssignment)
|
421
|
+
.define_method("compact_and_check_assignment", &RoutingModel::CompactAndCheckAssignment)
|
422
|
+
.define_method("add_to_assignment", &RoutingModel::AddToAssignment)
|
423
|
+
.define_method("add_interval_to_assignment", &RoutingModel::AddIntervalToAssignment)
|
424
|
+
// TODO PackCumulsOfOptimizerDimensionsFromAssignment
|
425
|
+
// TODO AddLocalSearchFilter
|
328
426
|
.define_method("start", &RoutingModel::Start)
|
329
427
|
.define_method("end", &RoutingModel::End)
|
330
428
|
.define_method("start?", &RoutingModel::IsStart)
|
@@ -333,12 +431,23 @@ void init_routing(Rice::Module& m) {
|
|
333
431
|
.define_method("next", &RoutingModel::Next)
|
334
432
|
.define_method("vehicle_used?", &RoutingModel::IsVehicleUsed)
|
335
433
|
.define_method("next_var", &RoutingModel::NextVar)
|
434
|
+
.define_method("active_var", &RoutingModel::ActiveVar)
|
435
|
+
.define_method("active_vehicle_var", &RoutingModel::ActiveVehicleVar)
|
436
|
+
.define_method("vehicle_route_considered_var", &RoutingModel::VehicleRouteConsideredVar)
|
437
|
+
.define_method("vehicle_var", &RoutingModel::VehicleVar)
|
438
|
+
.define_method("resource_var", &RoutingModel::ResourceVar)
|
439
|
+
.define_method("cost_var", &RoutingModel::CostVar)
|
336
440
|
.define_method("arc_cost_for_vehicle", &RoutingModel::GetArcCostForVehicle)
|
337
|
-
.define_method("
|
338
|
-
.define_method("
|
339
|
-
.define_method(
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
441
|
+
.define_method("costs_are_homogeneous_across_vehicles?", &RoutingModel::CostsAreHomogeneousAcrossVehicles)
|
442
|
+
.define_method("homogeneous_cost", &RoutingModel::GetHomogeneousCost)
|
443
|
+
.define_method("arc_cost_for_first_solution", &RoutingModel::GetArcCostForFirstSolution)
|
444
|
+
.define_method("cost_classes_count", &RoutingModel::GetCostClassesCount)
|
445
|
+
.define_method("non_zero_cost_classes_count", &RoutingModel::GetNonZeroCostClassesCount)
|
446
|
+
.define_method("vehicle_classes_count", &RoutingModel::GetVehicleClassesCount)
|
447
|
+
.define_method("arc_is_more_constrained_than_arc?", &RoutingModel::ArcIsMoreConstrainedThanArc)
|
448
|
+
.define_method("solver", &RoutingModel::solver)
|
449
|
+
.define_method("nodes", &RoutingModel::nodes)
|
450
|
+
.define_method("vehicles", &RoutingModel::vehicles)
|
451
|
+
.define_method("size", &RoutingModel::Size)
|
452
|
+
.define_method("matching_model?", &RoutingModel::IsMatchingModel);
|
344
453
|
}
|
data/ext/or-tools/vendor.rb
CHANGED
@@ -4,21 +4,15 @@ require "fileutils"
|
|
4
4
|
require "net/http"
|
5
5
|
require "tmpdir"
|
6
6
|
|
7
|
-
version = "9.
|
7
|
+
version = "9.4.1874"
|
8
8
|
|
9
9
|
if RbConfig::CONFIG["host_os"] =~ /darwin/i
|
10
10
|
if RbConfig::CONFIG["host_cpu"] =~ /arm|aarch64/i
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
Run:
|
15
|
-
brew install or-tools
|
16
|
-
bundle config build.or-tools --with-or-tools-dir=/opt/homebrew
|
17
|
-
|
18
|
-
MSG
|
11
|
+
filename = "or-tools_arm64_MacOsX-12.5_cpp_v#{version}.tar.gz"
|
12
|
+
checksum = "ebc185bcb0a056a2704fb1c5175d5c11cc21a7e0634be65139cea55bb6a021ce"
|
19
13
|
else
|
20
|
-
filename = "or-
|
21
|
-
checksum = "
|
14
|
+
filename = "or-tools_x86_64_MacOsX-12.5_cpp_v#{version}.tar.gz"
|
15
|
+
checksum = "d03c706b51a6ef7aa77886dc3f135baaac52c00803bb548c286fbdeb4a419acd"
|
22
16
|
end
|
23
17
|
else
|
24
18
|
# try /etc/os-release with fallback to /usr/lib/os-release
|
@@ -32,21 +26,23 @@ else
|
|
32
26
|
os_version = os_info["VERSION_ID"]
|
33
27
|
|
34
28
|
if os == "ubuntu" && os_version == "20.04"
|
35
|
-
|
36
|
-
|
37
|
-
checksum = "3d1979967a2c9358b5bc956f2e6b608b00e89e13c71d48d075475ce4138b6d1c"
|
29
|
+
filename = "or-tools_amd64_ubuntu-20.04_cpp_v#{version}.tar.gz"
|
30
|
+
checksum = "1b09f0f60b5aab83aeec468842e4a166cd3a4e7910e807f55bc7f96d5dffabdb"
|
38
31
|
elsif os == "ubuntu" && os_version == "18.04"
|
39
|
-
filename = "or-tools_amd64_ubuntu-18.
|
40
|
-
checksum = "
|
32
|
+
filename = "or-tools_amd64_ubuntu-18.04_cpp_v#{version}.tar.gz"
|
33
|
+
checksum = "ef73ebd4ca0f82a1179fdb2aded3c2a85dfe2ab275d91b8a5b147a653ca861ab"
|
41
34
|
elsif os == "debian" && os_version == "11"
|
42
|
-
filename = "or-tools_amd64_debian-
|
43
|
-
checksum = "
|
35
|
+
filename = "or-tools_amd64_debian-11_cpp_v#{version}.tar.gz"
|
36
|
+
checksum = "651c62147f231fb90635c522e0a2c799e3de3991c2c75f7c6acb721e7b78946c"
|
37
|
+
elsif os == "debian" && os_version == "10"
|
38
|
+
filename = "or-tools_amd64_debian-10_cpp_v#{version}.tar.gz"
|
39
|
+
checksum = "36088bc6c6fbb96539245db7cddf498f77ae3e7b7c2cc8f6d7d89d76f90751fb"
|
44
40
|
elsif os == "centos" && os_version == "8"
|
45
|
-
filename = "or-tools_amd64_centos-
|
46
|
-
checksum = "
|
41
|
+
filename = "or-tools_amd64_centos-8_cpp_v#{version}.tar.gz"
|
42
|
+
checksum = "da2cb303ae332d207592f21bb504e4e2e33dc1b1e8f5747d413c082d9d05504a"
|
47
43
|
elsif os == "centos" && os_version == "7"
|
48
|
-
filename = "or-tools_amd64_centos-
|
49
|
-
checksum = "
|
44
|
+
filename = "or-tools_amd64_centos-7_cpp_v#{version}.tar.gz"
|
45
|
+
checksum = "9eaf0178467f4d2fdbe496f62223809aa43e313548cc6cb716e661c00472b4ff"
|
50
46
|
else
|
51
47
|
platform =
|
52
48
|
if Gem.win_platform?
|
@@ -142,12 +138,11 @@ Dir.mktmpdir do |extract_path|
|
|
142
138
|
|
143
139
|
# shared library
|
144
140
|
FileUtils.mkdir(File.join(path, "lib"))
|
145
|
-
Dir.glob("lib/libortools.{dylib,so.9}", base: extract_path) do |file|
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
File.symlink(so_path, File.join(path, "lib/libortools.so"))
|
141
|
+
Dir.glob("lib/libortools.{9.dylib,so.9}", base: extract_path) do |file|
|
142
|
+
so_path = File.join(path, file)
|
143
|
+
FileUtils.cp(File.join(extract_path, file), so_path)
|
144
|
+
ext = file.end_with?(".dylib") ? "dylib" : "so"
|
145
|
+
File.symlink(so_path, File.join(path, "lib/libortools.#{ext}"))
|
151
146
|
end
|
152
147
|
end
|
153
148
|
|
data/lib/or_tools/tsp.rb
CHANGED
@@ -22,13 +22,7 @@ module ORTools
|
|
22
22
|
manager = ORTools::RoutingIndexManager.new(locations.size, 1, 0)
|
23
23
|
routing = ORTools::RoutingModel.new(manager)
|
24
24
|
|
25
|
-
|
26
|
-
from_node = manager.index_to_node(from_index)
|
27
|
-
to_node = manager.index_to_node(to_index)
|
28
|
-
distance_matrix[from_node][to_node]
|
29
|
-
end
|
30
|
-
|
31
|
-
transit_callback_index = routing.register_transit_callback(distance_callback)
|
25
|
+
transit_callback_index = routing.register_transit_matrix(distance_matrix)
|
32
26
|
routing.set_arc_cost_evaluator_of_all_vehicles(transit_callback_index)
|
33
27
|
assignment = routing.solve(first_solution_strategy: :path_cheapest_arc)
|
34
28
|
|
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.8.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: 2022-
|
11
|
+
date: 2022-08-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rice
|
@@ -85,7 +85,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
85
85
|
requirements:
|
86
86
|
- - ">="
|
87
87
|
- !ruby/object:Gem::Version
|
88
|
-
version: '2.
|
88
|
+
version: '2.7'
|
89
89
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
90
|
requirements:
|
91
91
|
- - ">="
|