or-tools 0.16.1 → 0.16.3
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 +8 -0
- data/NOTICE.txt +1 -1
- data/ext/or-tools/bin_packing.cpp +1 -1
- data/ext/or-tools/constraint.cpp +1 -1
- data/ext/or-tools/linear.cpp +5 -5
- data/ext/or-tools/math_opt.cpp +1 -1
- data/ext/or-tools/routing.cpp +31 -2
- data/lib/or_tools/routing_model.rb +4 -0
- data/lib/or_tools/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 89bf514a3bb90453c41d32c13dc1eb00130d3fb78da594540517c47d4cc7cb91
|
|
4
|
+
data.tar.gz: 2cb6aecf6356e93b334abf4a05fab50c08c115973414d5bb0be771685e3e09c2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 71dc044a44a5d792b07d6cf956f6f5e033fa23f0ab02149ffd75bfb0a08d26a58545af32089957dc0632018a0433cf7764fb12f9a90ca1ed58b5723d4b9c5dd1
|
|
7
|
+
data.tar.gz: fed9575f36012944b25d8162367ed78a0beea5b53f76d232ce80a58ea1a18fca8d7ed2cc32b728f4573d3d2fe5d9c7a6de836fe6a9b409287507c9a68f4d6fd1
|
data/CHANGELOG.md
CHANGED
data/NOTICE.txt
CHANGED
|
@@ -24,7 +24,7 @@ namespace Rice::detail {
|
|
|
24
24
|
|
|
25
25
|
explicit From_Ruby(Arg* arg) : arg_(arg) { }
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
double is_convertible(VALUE value) { return Convertible::Exact; }
|
|
28
28
|
|
|
29
29
|
KnapsackSolver::SolverType convert(VALUE x) {
|
|
30
30
|
auto s = Symbol(x).str();
|
data/ext/or-tools/constraint.cpp
CHANGED
|
@@ -44,7 +44,7 @@ namespace Rice::detail {
|
|
|
44
44
|
|
|
45
45
|
explicit From_Ruby(Arg* arg) : arg_(arg) { }
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
double is_convertible(VALUE value) { return Convertible::Exact; }
|
|
48
48
|
|
|
49
49
|
LinearExpr convert(VALUE v) {
|
|
50
50
|
LinearExpr expr;
|
data/ext/or-tools/linear.cpp
CHANGED
|
@@ -30,7 +30,7 @@ namespace Rice::detail {
|
|
|
30
30
|
|
|
31
31
|
explicit From_Ruby(Arg* arg) : arg_(arg) { }
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
double is_convertible(VALUE value) { return Convertible::Exact; }
|
|
34
34
|
|
|
35
35
|
static MPSolver::OptimizationProblemType convert(VALUE x) {
|
|
36
36
|
auto s = Symbol(x).str();
|
|
@@ -172,21 +172,21 @@ void init_linear(Rice::Module& m) {
|
|
|
172
172
|
.define_singleton_function(
|
|
173
173
|
"_new",
|
|
174
174
|
[](const std::string& name, MPSolver::OptimizationProblemType problem_type) {
|
|
175
|
-
|
|
175
|
+
MPSolver* solver = new MPSolver(name, problem_type);
|
|
176
176
|
if (!solver) {
|
|
177
177
|
throw std::runtime_error("Unrecognized solver type");
|
|
178
178
|
}
|
|
179
179
|
return solver;
|
|
180
|
-
})
|
|
180
|
+
}, Rice::Return().takeOwnership())
|
|
181
181
|
.define_singleton_function(
|
|
182
182
|
"_create",
|
|
183
183
|
[](const std::string& solver_id) {
|
|
184
|
-
|
|
184
|
+
MPSolver* solver = MPSolver::CreateSolver(solver_id);
|
|
185
185
|
if (!solver) {
|
|
186
186
|
throw std::runtime_error("Unrecognized solver type");
|
|
187
187
|
}
|
|
188
188
|
return solver;
|
|
189
|
-
})
|
|
189
|
+
}, Rice::Return().takeOwnership())
|
|
190
190
|
.define_method(
|
|
191
191
|
"time_limit=",
|
|
192
192
|
[](MPSolver& self, double time_limit) {
|
data/ext/or-tools/math_opt.cpp
CHANGED
|
@@ -29,7 +29,7 @@ namespace Rice::detail {
|
|
|
29
29
|
|
|
30
30
|
explicit From_Ruby(Arg* arg) : arg_(arg) { }
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
double is_convertible(VALUE value) { return Convertible::Exact; }
|
|
33
33
|
|
|
34
34
|
static SolverType convert(VALUE x) {
|
|
35
35
|
auto s = Symbol(x).str();
|
data/ext/or-tools/routing.cpp
CHANGED
|
@@ -40,7 +40,7 @@ namespace Rice::detail {
|
|
|
40
40
|
|
|
41
41
|
explicit From_Ruby(Arg* arg) : arg_(arg) { }
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
double is_convertible(VALUE value) { return Convertible::Exact; }
|
|
44
44
|
|
|
45
45
|
RoutingNodeIndex convert(VALUE x) {
|
|
46
46
|
const RoutingNodeIndex index{From_Ruby<int>().convert(x)};
|
|
@@ -65,6 +65,35 @@ namespace Rice::detail {
|
|
|
65
65
|
private:
|
|
66
66
|
Arg* arg_ = nullptr;
|
|
67
67
|
};
|
|
68
|
+
|
|
69
|
+
template<>
|
|
70
|
+
struct Type<RoutingModel::PenaltyCostBehavior> {
|
|
71
|
+
static bool verify() { return true; }
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
template<>
|
|
75
|
+
class From_Ruby<RoutingModel::PenaltyCostBehavior> {
|
|
76
|
+
public:
|
|
77
|
+
From_Ruby() = default;
|
|
78
|
+
|
|
79
|
+
explicit From_Ruby(Arg* arg) : arg_(arg) { }
|
|
80
|
+
|
|
81
|
+
double is_convertible(VALUE value) { return Convertible::Exact; }
|
|
82
|
+
|
|
83
|
+
RoutingModel::PenaltyCostBehavior convert(VALUE x) {
|
|
84
|
+
auto s = Symbol(x).str();
|
|
85
|
+
if (s == "penalize_once") {
|
|
86
|
+
return RoutingModel::PenaltyCostBehavior::PENALIZE_ONCE;
|
|
87
|
+
} else if (s == "penalize_per_inactive") {
|
|
88
|
+
return RoutingModel::PenaltyCostBehavior::PENALIZE_PER_INACTIVE;
|
|
89
|
+
} else {
|
|
90
|
+
throw std::runtime_error("Unknown penalty cost behavior: " + s);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
private:
|
|
95
|
+
Arg* arg_ = nullptr;
|
|
96
|
+
};
|
|
68
97
|
} // namespace Rice::detail
|
|
69
98
|
|
|
70
99
|
void init_routing(Rice::Module& m) {
|
|
@@ -347,7 +376,7 @@ void init_routing(Rice::Module& m) {
|
|
|
347
376
|
.define_method("add_resource_group", &RoutingModel::AddResourceGroup)
|
|
348
377
|
.define_method("dimension_resource_group_indices", &RoutingModel::GetDimensionResourceGroupIndices)
|
|
349
378
|
.define_method("dimension_resource_group_index", &RoutingModel::GetDimensionResourceGroupIndex)
|
|
350
|
-
.define_method("
|
|
379
|
+
.define_method("_add_disjunction", &RoutingModel::AddDisjunction)
|
|
351
380
|
.define_method("disjunction_indices", &RoutingModel::GetDisjunctionIndices)
|
|
352
381
|
.define_method("disjunction_penalty", &RoutingModel::GetDisjunctionPenalty)
|
|
353
382
|
.define_method("disjunction_max_cardinality", &RoutingModel::GetDisjunctionMaxCardinality)
|
|
@@ -17,5 +17,9 @@ module ORTools
|
|
|
17
17
|
search_parameters.log_search = log_search unless log_search.nil?
|
|
18
18
|
solve_with_parameters(search_parameters)
|
|
19
19
|
end
|
|
20
|
+
|
|
21
|
+
def add_disjunction(indices, penalty, max_cardinality = 1, penalty_cost_behavior = :penalize_once)
|
|
22
|
+
_add_disjunction(indices, penalty, max_cardinality, penalty_cost_behavior)
|
|
23
|
+
end
|
|
20
24
|
end
|
|
21
25
|
end
|
data/lib/or_tools/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: or-tools
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.16.
|
|
4
|
+
version: 0.16.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Andrew Kane
|
|
@@ -15,14 +15,14 @@ dependencies:
|
|
|
15
15
|
requirements:
|
|
16
16
|
- - ">="
|
|
17
17
|
- !ruby/object:Gem::Version
|
|
18
|
-
version: '4.
|
|
18
|
+
version: '4.8'
|
|
19
19
|
type: :runtime
|
|
20
20
|
prerelease: false
|
|
21
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
22
22
|
requirements:
|
|
23
23
|
- - ">="
|
|
24
24
|
- !ruby/object:Gem::Version
|
|
25
|
-
version: '4.
|
|
25
|
+
version: '4.8'
|
|
26
26
|
email: andrew@ankane.org
|
|
27
27
|
executables: []
|
|
28
28
|
extensions:
|
|
@@ -85,7 +85,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
85
85
|
- !ruby/object:Gem::Version
|
|
86
86
|
version: '0'
|
|
87
87
|
requirements: []
|
|
88
|
-
rubygems_version:
|
|
88
|
+
rubygems_version: 4.0.3
|
|
89
89
|
specification_version: 4
|
|
90
90
|
summary: Operations research tools for Ruby
|
|
91
91
|
test_files: []
|