or-tools 0.16.1 → 0.16.2

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: dee4a87960e33b5a357e9549cac01fadbbed11aa0e7b8fda11355383f01f853c
4
- data.tar.gz: 5cb68b2fb6beb48cf73f5d78fc14930a274da58bf8c743d5199588b4283bd3c7
3
+ metadata.gz: 63a926d63d95220ccee1d6861a26fdc96787a209210cf8473bc44855cb62f57d
4
+ data.tar.gz: 90a2bd6c3f72e759e22c104cfba792c39352d9908f3735fc17ca3ef15ca156db
5
5
  SHA512:
6
- metadata.gz: ab8788f734a9b525c9d7f385fc32947430c9727aec659a5f898436159a8e90684031508fb5f6bf099381821ff184344f101a52c90e23f716a2bf46f91e7e78e1
7
- data.tar.gz: 5b90c3c913f171e464da6c162659a7e4fc896fa30f6996e21d145b07f93d4a925d71af71d1ddee2eab27f1850545715abd2016bb52f6b6151badc06eb8a6f37a
6
+ metadata.gz: b73722ccaa5d9700513c633dce30fa73d748431790c45c6bc77afa50375322c312578de81cd90128bfc0d2f0baff289094dba555e81c4dcbfb4137fb427add85
7
+ data.tar.gz: 99d4db8c29b87db1e6697b1c8e5bb6475ea41e4ec7c85f05ab9ee0510c5484614d055745704a7b7ba1d3c39930bf8bcf1a98174ad68ec0ca197dac70deb72eb9
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.16.2 (2026-01-02)
2
+
3
+ - Fixed error with Rice 4.8
4
+
1
5
  ## 0.16.1 (2025-10-26)
2
6
 
3
7
  - Added `add_allowed_assignments` and `add_forbidden_assignments` methods to `CpModel`
@@ -24,7 +24,7 @@ namespace Rice::detail {
24
24
 
25
25
  explicit From_Ruby(Arg* arg) : arg_(arg) { }
26
26
 
27
- Convertible is_convertible(VALUE value) { return Convertible::Cast; }
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();
@@ -44,7 +44,7 @@ namespace Rice::detail {
44
44
 
45
45
  explicit From_Ruby(Arg* arg) : arg_(arg) { }
46
46
 
47
- Convertible is_convertible(VALUE value) { return Convertible::Cast; }
47
+ double is_convertible(VALUE value) { return Convertible::Exact; }
48
48
 
49
49
  LinearExpr convert(VALUE v) {
50
50
  LinearExpr expr;
@@ -30,7 +30,7 @@ namespace Rice::detail {
30
30
 
31
31
  explicit From_Ruby(Arg* arg) : arg_(arg) { }
32
32
 
33
- Convertible is_convertible(VALUE value) { return Convertible::Cast; }
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();
@@ -29,7 +29,7 @@ namespace Rice::detail {
29
29
 
30
30
  explicit From_Ruby(Arg* arg) : arg_(arg) { }
31
31
 
32
- Convertible is_convertible(VALUE value) { return Convertible::Cast; }
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();
@@ -40,7 +40,7 @@ namespace Rice::detail {
40
40
 
41
41
  explicit From_Ruby(Arg* arg) : arg_(arg) { }
42
42
 
43
- Convertible is_convertible(VALUE value) { return Convertible::Cast; }
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("add_disjunction", &RoutingModel::AddDisjunction, Rice::Arg("_indices"), Rice::Arg("_penalty"), Rice::Arg("_max_cardinality") = static_cast<int64_t>(1), Rice::Arg("_penalty_cost_behavior") = RoutingModel::PenaltyCostBehavior::PENALIZE_ONCE)
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
@@ -1,3 +1,3 @@
1
1
  module ORTools
2
- VERSION = "0.16.1"
2
+ VERSION = "0.16.2"
3
3
  end
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.1
4
+ version: 0.16.2
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.7'
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.7'
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: 3.6.9
88
+ rubygems_version: 4.0.3
89
89
  specification_version: 4
90
90
  summary: Operations research tools for Ruby
91
91
  test_files: []