or-tools 0.4.3 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7a1064c39ae0b5431b303db41b4fe03da7f80d26beeab576b33b85fe47dee4d8
4
- data.tar.gz: 5819ef15c9ec8b1b507fb4e4596397a8f2e562fa72de6580b1e78188a404a3db
3
+ metadata.gz: 405e26b51140e6605acd8904d7e90e0e7f48b7cfd83641fef6e2e737e7b8cda4
4
+ data.tar.gz: e6e0506979a829c260f8bae70e7769524d59d83b7a52e1cadfb6e553d8116587
5
5
  SHA512:
6
- metadata.gz: 797f8fdba98a3843f3da03acdee070445e6f4a37650936a700ebab3af58bc779cd57c44b3b68341f28203beb986e6818a884d65588fa14264d0eb89463183d2e
7
- data.tar.gz: acd539cc1f14467ddd2edfaa65723590a216c709aa3085d2257472600e023e7757109eeade70f995131f26f9769250807c998d0d5e30d8ce51af90536063cf3b
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<int64> values;
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<int64>(rb_values[i]));
35
+ values.push_back(from_ruby<int64_t>(rb_values[i]));
36
36
  }
37
37
 
38
- std::vector<std::vector<int64>> weights;
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<int64> w;
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<int64>(rb_w[j]));
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<int64> capacities;
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<int64>(rb_capacities[i]));
50
+ capacities.push_back(from_ruby<int64_t>(rb_capacities[i]));
51
51
  }
52
52
 
53
53
  self.Init(values, weights, capacities);
@@ -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<int64>(x.call("to_i"));
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
- std::string type = ((String) o.call("class").call("name")).str();
42
- if (type == "ORTools::BoolVar") {
43
- expr.AddTerm(from_ruby<BoolVar>(cvar[0]), from_ruby<int64>(cvar[1]));
44
- } else if (type == "Integer") {
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<int64>(cvar[1]));
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
- std::string type = ((String) x.call("class").call("name")).str();
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, int64 start, int64 end, const std::string& name) {
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, int64 value) {
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, int64 value) {
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;
@@ -54,16 +54,16 @@ class Assignment {
54
54
  Assignment(const operations_research::Assignment* v) {
55
55
  self = v;
56
56
  }
57
- int64 ObjectiveValue() {
57
+ int64_t ObjectiveValue() {
58
58
  return self->ObjectiveValue();
59
59
  }
60
- int64 Value(const operations_research::IntVar* const var) const {
60
+ int64_t Value(const operations_research::IntVar* const var) const {
61
61
  return self->Value(var);
62
62
  }
63
- int64 Min(const operations_research::IntVar* const var) const {
63
+ int64_t Min(const operations_research::IntVar* const var) const {
64
64
  return self->Min(var);
65
65
  }
66
- int64 Max(const operations_research::IntVar* const var) const {
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, int64 value) {
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, int64 value) {
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, int64 value) {
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, int64 new_min, int64 new_max) {
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, int64 duration, const std::string& name) {
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, int64 capacity, const std::string& name) {
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<int64> demands;
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<int64>(rb_demands[i]));
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](int64 from_index, int64 to_index) -> int64 {
282
- return from_ruby<int64>(callback.call("call", from_index, to_index));
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](int64 from_index) -> int64 {
291
- return from_ruby<int64>(callback.call("call", from_index));
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, int64 slack_max, Array vc, bool fix_start_cumul_to_zero, const std::string& name) {
324
- std::vector<int64> vehicle_capacities;
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<int64>(vc[i]));
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, int64 slack_max, int64 capacity, bool fix_start_cumul_to_zero, const std::string& name) {
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, int64 penalty) {
342
- std::vector<int64> indices;
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<int64>(rb_indices[i]));
344
+ indices.push_back(from_ruby<int64_t>(rb_indices[i]));
345
345
  }
346
346
  self.AddDisjunction(indices, penalty);
347
347
  })
@@ -3,26 +3,29 @@ require "fileutils"
3
3
  require "net/http"
4
4
  require "tmpdir"
5
5
 
6
- version = "8.2.8710"
6
+ version = "9.0.9048"
7
7
 
8
8
  if RbConfig::CONFIG["host_os"] =~ /darwin/i
9
- filename = "or-tools_MacOsX-11.2.1_v#{version}.tar.gz"
10
- checksum = "1c3bd45ab10677aa96d404cb837067e786a6d98123d8b556cf29d6994aa43b3b"
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 = "ab3b3051b10a4bbe8d080857f3c4ef3cfe9c10896ff94f352bb779e993756dd7"
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 = "0d052deb2ba4491c29e86242fb5d61d0fe14bac847c2feaa35fbeff925ea40a0"
19
+ checksum = "08cf548d0179f7fa814bb7458be94cd1b8a3de14985e6a9faf6118a1d8571539"
20
20
  elsif os == "Debian" && os_version == "10"
21
21
  filename = "or-tools_debian-10_v#{version}.tar.gz"
22
- checksum = "1f2ec99181c92859ab46e68a6231babce92ded949fd1d08ee31afa4db04c43b3"
22
+ checksum = "063fb1d8765ae23b0bb25b9c561e904532713416fe0458f7db45a0f72190eb50"
23
23
  elsif os == "CentOS" && os_version == "8"
24
24
  filename = "or-tools_centos-8_v#{version}.tar.gz"
25
- checksum = "be638a20b36f6da81aa29fd24c69c4a66afc980b8a221b1cbabb3910b9827718"
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?
@@ -29,6 +29,10 @@ module ORTools
29
29
  @response.status
30
30
  end
31
31
 
32
+ def sufficient_assumptions_for_infeasibility
33
+ @response.sufficient_assumptions_for_infeasibility
34
+ end
35
+
32
36
  def parameters
33
37
  @parameters ||= SatParameters.new
34
38
  end
@@ -1,3 +1,3 @@
1
1
  module ORTools
2
- VERSION = "0.4.3"
2
+ VERSION = "0.5.0"
3
3
  end
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.3
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-03-26 00:00:00.000000000 Z
11
+ date: 2021-04-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rice