or-tools 0.5.0 → 0.5.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,19 +1,17 @@
1
1
  #include <ortools/constraint_solver/routing.h>
2
2
  #include <ortools/constraint_solver/routing_parameters.h>
3
3
 
4
- #include <rice/Array.hpp>
5
- #include <rice/Class.hpp>
6
- #include <rice/Constructor.hpp>
7
- #include <rice/Module.hpp>
8
- #include <rice/String.hpp>
9
- #include <rice/Symbol.hpp>
4
+ #include "ext.h"
10
5
 
6
+ using operations_research::Assignment;
7
+ using operations_research::ConstraintSolverParameters;
11
8
  using operations_research::DefaultRoutingSearchParameters;
12
9
  using operations_research::FirstSolutionStrategy;
13
10
  using operations_research::LocalSearchMetaheuristic;
14
11
  using operations_research::RoutingDimension;
15
12
  using operations_research::RoutingIndexManager;
16
13
  using operations_research::RoutingModel;
14
+ using operations_research::RoutingModelParameters;
17
15
  using operations_research::RoutingNodeIndex;
18
16
  using operations_research::RoutingSearchParameters;
19
17
 
@@ -24,99 +22,50 @@ using Rice::Object;
24
22
  using Rice::String;
25
23
  using Rice::Symbol;
26
24
 
27
- template<>
28
- inline
29
- RoutingNodeIndex from_ruby<RoutingNodeIndex>(Object x)
25
+ namespace Rice::detail
30
26
  {
31
- const RoutingNodeIndex index{from_ruby<int>(x)};
32
- return index;
33
- }
34
-
35
- template<>
36
- inline
37
- Object to_ruby<RoutingNodeIndex>(RoutingNodeIndex const &x)
38
- {
39
- return to_ruby<int>(x.value());
40
- }
41
-
42
- std::vector<RoutingNodeIndex> nodeIndexVector(Array x) {
43
- std::vector<RoutingNodeIndex> res;
44
- for (auto const& v : x) {
45
- res.push_back(from_ruby<RoutingNodeIndex>(v));
46
- }
47
- return res;
48
- }
27
+ template<>
28
+ struct Type<RoutingNodeIndex>
29
+ {
30
+ static bool verify()
31
+ {
32
+ return true;
33
+ }
34
+ };
49
35
 
50
- // need a wrapper class due to const
51
- class Assignment {
52
- const operations_research::Assignment* self;
36
+ template<>
37
+ class From_Ruby<RoutingNodeIndex>
38
+ {
53
39
  public:
54
- Assignment(const operations_research::Assignment* v) {
55
- self = v;
56
- }
57
- int64_t ObjectiveValue() {
58
- return self->ObjectiveValue();
59
- }
60
- int64_t Value(const operations_research::IntVar* const var) const {
61
- return self->Value(var);
62
- }
63
- int64_t Min(const operations_research::IntVar* const var) const {
64
- return self->Min(var);
65
- }
66
- int64_t Max(const operations_research::IntVar* const var) const {
67
- return self->Max(var);
40
+ RoutingNodeIndex convert(VALUE x)
41
+ {
42
+ const RoutingNodeIndex index{From_Ruby<int>().convert(x)};
43
+ return index;
68
44
  }
69
- };
70
-
71
- Class rb_cIntVar;
72
- Class rb_cIntervalVar;
73
- Class rb_cRoutingDimension;
74
- Class rb_cConstraint;
75
- Class rb_cSolver2;
76
-
77
- template<>
78
- inline
79
- Object to_ruby<operations_research::IntVar*>(operations_research::IntVar* const &x)
80
- {
81
- return Rice::Data_Object<operations_research::IntVar>(x, rb_cIntVar, nullptr, nullptr);
82
- }
83
-
84
- template<>
85
- inline
86
- Object to_ruby<operations_research::IntervalVar*>(operations_research::IntervalVar* const &x)
87
- {
88
- return Rice::Data_Object<operations_research::IntervalVar>(x, rb_cIntervalVar, nullptr, nullptr);
89
- }
90
-
91
- template<>
92
- inline
93
- Object to_ruby<RoutingDimension*>(RoutingDimension* const &x)
94
- {
95
- return Rice::Data_Object<RoutingDimension>(x, rb_cRoutingDimension, nullptr, nullptr);
96
- }
45
+ };
97
46
 
98
- template<>
99
- inline
100
- Object to_ruby<operations_research::Constraint*>(operations_research::Constraint* const &x)
101
- {
102
- return Rice::Data_Object<operations_research::Constraint>(x, rb_cConstraint, nullptr, nullptr);
103
- }
104
-
105
- template<>
106
- inline
107
- Object to_ruby<operations_research::Solver*>(operations_research::Solver* const &x)
108
- {
109
- return Rice::Data_Object<operations_research::Solver>(x, rb_cSolver2, nullptr, nullptr);
47
+ template<>
48
+ class To_Ruby<RoutingNodeIndex>
49
+ {
50
+ public:
51
+ VALUE convert(RoutingNodeIndex const & x)
52
+ {
53
+ return To_Ruby<int>().convert(x.value());
54
+ }
55
+ };
110
56
  }
111
57
 
112
58
  void init_routing(Rice::Module& m) {
113
- m.define_singleton_method("default_routing_search_parameters", &DefaultRoutingSearchParameters);
59
+ auto rb_cRoutingSearchParameters = Rice::define_class_under<RoutingSearchParameters>(m, "RoutingSearchParameters");
60
+ auto rb_cIntVar = Rice::define_class_under<operations_research::IntVar>(m, "IntVar");
114
61
 
115
- Rice::define_class_under<RoutingSearchParameters>(m, "RoutingSearchParameters")
62
+ m.define_singleton_function("default_routing_search_parameters", &DefaultRoutingSearchParameters);
63
+
64
+ rb_cRoutingSearchParameters
116
65
  .define_method(
117
66
  "first_solution_strategy=",
118
- *[](RoutingSearchParameters& self, Symbol value) {
119
- std::string s = Symbol(value).str();
67
+ [](RoutingSearchParameters& self, Symbol value) {
68
+ auto s = Symbol(value).str();
120
69
 
121
70
  FirstSolutionStrategy::Value v;
122
71
  if (s == "path_cheapest_arc") {
@@ -155,8 +104,8 @@ void init_routing(Rice::Module& m) {
155
104
  })
156
105
  .define_method(
157
106
  "local_search_metaheuristic=",
158
- *[](RoutingSearchParameters& self, Symbol value) {
159
- std::string s = Symbol(value).str();
107
+ [](RoutingSearchParameters& self, Symbol value) {
108
+ auto s = Symbol(value).str();
160
109
 
161
110
  LocalSearchMetaheuristic::Value v;
162
111
  if (s == "guided_local_search") {
@@ -175,35 +124,35 @@ void init_routing(Rice::Module& m) {
175
124
  })
176
125
  .define_method(
177
126
  "log_search=",
178
- *[](RoutingSearchParameters& self, bool value) {
127
+ [](RoutingSearchParameters& self, bool value) {
179
128
  self.set_log_search(value);
180
129
  })
181
130
  .define_method(
182
131
  "solution_limit=",
183
- *[](RoutingSearchParameters& self, int64_t value) {
132
+ [](RoutingSearchParameters& self, int64_t value) {
184
133
  self.set_solution_limit(value);
185
134
  })
186
135
  .define_method(
187
136
  "time_limit=",
188
- *[](RoutingSearchParameters& self, int64_t value) {
137
+ [](RoutingSearchParameters& self, int64_t value) {
189
138
  self.mutable_time_limit()->set_seconds(value);
190
139
  })
191
140
  .define_method(
192
141
  "lns_time_limit=",
193
- *[](RoutingSearchParameters& self, int64_t value) {
142
+ [](RoutingSearchParameters& self, int64_t value) {
194
143
  self.mutable_lns_time_limit()->set_seconds(value);
195
144
  });
196
145
 
197
146
  Rice::define_class_under<RoutingIndexManager>(m, "RoutingIndexManager")
198
- .define_singleton_method(
147
+ .define_singleton_function(
199
148
  "_new_depot",
200
- *[](int num_nodes, int num_vehicles, RoutingNodeIndex depot) {
149
+ [](int num_nodes, int num_vehicles, RoutingNodeIndex depot) {
201
150
  return RoutingIndexManager(num_nodes, num_vehicles, depot);
202
151
  })
203
- .define_singleton_method(
152
+ .define_singleton_function(
204
153
  "_new_starts_ends",
205
- *[](int num_nodes, int num_vehicles, Array starts, Array ends) {
206
- return RoutingIndexManager(num_nodes, num_vehicles, nodeIndexVector(starts), nodeIndexVector(ends));
154
+ [](int num_nodes, int num_vehicles, std::vector<RoutingNodeIndex> starts, std::vector<RoutingNodeIndex> ends) {
155
+ return RoutingIndexManager(num_nodes, num_vehicles, starts, ends);
207
156
  })
208
157
  .define_method("index_to_node", &RoutingIndexManager::IndexToNode)
209
158
  .define_method("node_to_index", &RoutingIndexManager::NodeToIndex);
@@ -215,29 +164,55 @@ void init_routing(Rice::Module& m) {
215
164
  .define_method("max", &Assignment::Max);
216
165
 
217
166
  // not to be confused with operations_research::sat::IntVar
218
- rb_cIntVar = Rice::define_class_under<operations_research::IntVar>(m, "IntVar")
167
+ rb_cIntVar
168
+ .define_method("var?", &operations_research::IntVar::IsVar)
169
+ .define_method("value", &operations_research::IntVar::Value)
170
+ .define_method("remove_value", &operations_research::IntVar::RemoveValue)
171
+ .define_method("remove_interval", &operations_research::IntVar::RemoveInterval)
172
+ .define_method("remove_values", &operations_research::IntVar::RemoveValues)
173
+ .define_method("set_values", &operations_research::IntVar::SetValues)
174
+ .define_method("size", &operations_research::IntVar::Size)
175
+ .define_method("contains", &operations_research::IntVar::Contains)
176
+ .define_method("old_min", &operations_research::IntVar::OldMin)
177
+ .define_method("old_max", &operations_research::IntVar::OldMax)
219
178
  .define_method(
220
179
  "set_range",
221
- *[](operations_research::IntVar& self, int64_t new_min, int64_t new_max) {
180
+ [](operations_research::IntVar& self, int64_t new_min, int64_t new_max) {
222
181
  self.SetRange(new_min, new_max);
223
182
  });
224
183
 
225
- rb_cIntervalVar = Rice::define_class_under<operations_research::IntervalVar>(m, "IntervalVar");
184
+ Rice::define_class_under<operations_research::IntervalVar>(m, "IntervalVar")
185
+ .define_method("start_min", &operations_research::IntervalVar::StartMin)
186
+ .define_method("start_max", &operations_research::IntervalVar::StartMax)
187
+ .define_method("set_start_min", &operations_research::IntervalVar::SetStartMin)
188
+ .define_method("set_start_max", &operations_research::IntervalVar::SetStartMax)
189
+ .define_method("set_start_range", &operations_research::IntervalVar::SetStartRange)
190
+ .define_method("old_start_min", &operations_research::IntervalVar::OldStartMin)
191
+ .define_method("old_start_max", &operations_research::IntervalVar::OldStartMax)
192
+ .define_method("end_min", &operations_research::IntervalVar::EndMin)
193
+ .define_method("end_max", &operations_research::IntervalVar::EndMax)
194
+ .define_method("set_end_min", &operations_research::IntervalVar::SetEndMin)
195
+ .define_method("set_end_max", &operations_research::IntervalVar::SetEndMax)
196
+ .define_method("set_end_range", &operations_research::IntervalVar::SetEndRange)
197
+ .define_method("old_end_min", &operations_research::IntervalVar::OldEndMin)
198
+ .define_method("old_end_max", &operations_research::IntervalVar::OldEndMax);
226
199
 
227
- rb_cRoutingDimension = Rice::define_class_under<RoutingDimension>(m, "RoutingDimension")
200
+ Rice::define_class_under<RoutingDimension>(m, "RoutingDimension")
228
201
  .define_method("global_span_cost_coefficient=", &RoutingDimension::SetGlobalSpanCostCoefficient)
229
202
  .define_method("cumul_var", &RoutingDimension::CumulVar);
230
203
 
231
- rb_cConstraint = Rice::define_class_under<operations_research::Constraint>(m, "Constraint");
204
+ Rice::define_class_under<operations_research::Constraint>(m, "Constraint")
205
+ .define_method("post", &operations_research::Constraint::Post)
206
+ .define_method("debug_string", &operations_research::Constraint::DebugString);
232
207
 
233
- rb_cSolver2 = Rice::define_class_under<operations_research::Solver>(m, "Solver2")
208
+ Rice::define_class_under<operations_research::Solver>(m, "Solver2")
234
209
  .define_method(
235
210
  "add",
236
- *[](operations_research::Solver& self, Object o) {
211
+ [](operations_research::Solver& self, Object o) {
237
212
  operations_research::Constraint* constraint;
238
213
  if (o.respond_to("left")) {
239
- operations_research::IntExpr* left(from_ruby<operations_research::IntVar*>(o.call("left")));
240
- operations_research::IntExpr* right(from_ruby<operations_research::IntVar*>(o.call("right")));
214
+ operations_research::IntExpr* left(Rice::detail::From_Ruby<operations_research::IntVar*>().convert(o.call("left")));
215
+ operations_research::IntExpr* right(Rice::detail::From_Ruby<operations_research::IntVar*>().convert(o.call("right")));
241
216
  auto op = o.call("operator").to_s().str();
242
217
  if (op == "==") {
243
218
  constraint = self.MakeEquality(left, right);
@@ -247,54 +222,69 @@ void init_routing(Rice::Module& m) {
247
222
  throw std::runtime_error("Unknown operator");
248
223
  }
249
224
  } else {
250
- constraint = from_ruby<operations_research::Constraint*>(o);
225
+ constraint = Rice::detail::From_Ruby<operations_research::Constraint*>().convert(o);
251
226
  }
252
227
  self.AddConstraint(constraint);
253
228
  })
254
229
  .define_method(
255
230
  "fixed_duration_interval_var",
256
- *[](operations_research::Solver& self, operations_research::IntVar* const start_variable, int64_t duration, const std::string& name) {
231
+ [](operations_research::Solver& self, operations_research::IntVar* const start_variable, int64_t duration, const std::string& name) {
257
232
  return self.MakeFixedDurationIntervalVar(start_variable, duration, name);
258
233
  })
259
234
  .define_method(
260
235
  "cumulative",
261
- *[](operations_research::Solver& self, Array rb_intervals, Array rb_demands, int64_t capacity, const std::string& name) {
262
- std::vector<operations_research::IntervalVar*> intervals;
263
- for (std::size_t i = 0; i < rb_intervals.size(); ++i) {
264
- intervals.push_back(from_ruby<operations_research::IntervalVar*>(rb_intervals[i]));
265
- }
236
+ [](operations_research::Solver& self, std::vector<operations_research::IntervalVar*> intervals, std::vector<int64_t> demands, int64_t capacity, const std::string& name) {
237
+ return self.MakeCumulative(intervals, demands, capacity, name);
238
+ });
266
239
 
267
- std::vector<int64_t> demands;
268
- for (std::size_t i = 0; i < rb_demands.size(); ++i) {
269
- demands.push_back(from_ruby<int64_t>(rb_demands[i]));
270
- }
240
+ Rice::define_class_under<ConstraintSolverParameters>(m, "ConstraintSolverParameters")
241
+ .define_method(
242
+ "trace_propagation=",
243
+ [](ConstraintSolverParameters& self, bool value) {
244
+ self.set_trace_propagation(value);
245
+ })
246
+ .define_method(
247
+ "trace_search=",
248
+ [](ConstraintSolverParameters& self, bool value) {
249
+ self.set_trace_search(value);
250
+ });
271
251
 
272
- return self.MakeCumulative(intervals, demands, capacity, name);
252
+ Rice::define_class_under<RoutingModelParameters>(m, "RoutingModelParameters")
253
+ .define_method(
254
+ "solver_parameters",
255
+ [](RoutingModelParameters& self) {
256
+ return self.mutable_solver_parameters();
273
257
  });
274
258
 
259
+ m.define_singleton_function(
260
+ "default_routing_model_parameters",
261
+ []() {
262
+ return operations_research::DefaultRoutingModelParameters();
263
+ });
264
+
275
265
  Rice::define_class_under<RoutingModel>(m, "RoutingModel")
276
- .define_constructor(Rice::Constructor<RoutingModel, RoutingIndexManager>())
266
+ .define_constructor(Rice::Constructor<RoutingModel, RoutingIndexManager, RoutingModelParameters>(), Rice::Arg("index_manager"), Rice::Arg("parameters") = operations_research::DefaultRoutingModelParameters())
277
267
  .define_method(
278
268
  "register_transit_callback",
279
- *[](RoutingModel& self, Object callback) {
269
+ [](RoutingModel& self, Object callback) {
280
270
  return self.RegisterTransitCallback(
281
271
  [callback](int64_t from_index, int64_t to_index) -> int64_t {
282
- return from_ruby<int64_t>(callback.call("call", from_index, to_index));
272
+ return Rice::detail::From_Ruby<int64_t>().convert(callback.call("call", from_index, to_index));
283
273
  }
284
274
  );
285
275
  })
286
276
  .define_method(
287
277
  "register_unary_transit_callback",
288
- *[](RoutingModel& self, Object callback) {
278
+ [](RoutingModel& self, Object callback) {
289
279
  return self.RegisterUnaryTransitCallback(
290
280
  [callback](int64_t from_index) -> int64_t {
291
- return from_ruby<int64_t>(callback.call("call", from_index));
281
+ return Rice::detail::From_Ruby<int64_t>().convert(callback.call("call", from_index));
292
282
  }
293
283
  );
294
284
  })
295
285
  .define_method("depot", &RoutingModel::GetDepot)
296
286
  .define_method("size", &RoutingModel::Size)
297
- .define_method("status", *[](RoutingModel& self) {
287
+ .define_method("status", [](RoutingModel& self) {
298
288
  auto status = self.status();
299
289
 
300
290
  if (status == RoutingModel::ROUTING_NOT_SOLVED) {
@@ -320,29 +310,17 @@ void init_routing(Rice::Module& m) {
320
310
  .define_method("add_dimension", &RoutingModel::AddDimension)
321
311
  .define_method(
322
312
  "add_dimension_with_vehicle_capacity",
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
- for (std::size_t i = 0; i < vc.size(); ++i) {
326
- vehicle_capacities.push_back(from_ruby<int64_t>(vc[i]));
327
- }
313
+ [](RoutingModel& self, int evaluator_index, int64_t slack_max, std::vector<int64_t> vehicle_capacities, bool fix_start_cumul_to_zero, const std::string& name) {
328
314
  self.AddDimensionWithVehicleCapacity(evaluator_index, slack_max, vehicle_capacities, fix_start_cumul_to_zero, name);
329
315
  })
330
316
  .define_method(
331
317
  "add_dimension_with_vehicle_transits",
332
- *[](RoutingModel& self, Array rb_indices, int64_t slack_max, int64_t capacity, bool fix_start_cumul_to_zero, const std::string& name) {
333
- std::vector<int> evaluator_indices;
334
- for (std::size_t i = 0; i < rb_indices.size(); ++i) {
335
- evaluator_indices.push_back(from_ruby<int>(rb_indices[i]));
336
- }
318
+ [](RoutingModel& self, std::vector<int> evaluator_indices, int64_t slack_max, int64_t capacity, bool fix_start_cumul_to_zero, const std::string& name) {
337
319
  self.AddDimensionWithVehicleTransits(evaluator_indices, slack_max, capacity, fix_start_cumul_to_zero, name);
338
320
  })
339
321
  .define_method(
340
322
  "add_disjunction",
341
- *[](RoutingModel& self, Array rb_indices, int64_t penalty) {
342
- std::vector<int64_t> indices;
343
- for (std::size_t i = 0; i < rb_indices.size(); ++i) {
344
- indices.push_back(from_ruby<int64_t>(rb_indices[i]));
345
- }
323
+ [](RoutingModel& self, std::vector<int64_t> indices, int64_t penalty) {
346
324
  self.AddDisjunction(indices, penalty);
347
325
  })
348
326
  .define_method("add_pickup_and_delivery", &RoutingModel::AddPickupAndDelivery)
@@ -360,9 +338,7 @@ void init_routing(Rice::Module& m) {
360
338
  .define_method("add_variable_minimized_by_finalizer", &RoutingModel::AddVariableMinimizedByFinalizer)
361
339
  .define_method(
362
340
  "solve_with_parameters",
363
- *[](RoutingModel& self, const RoutingSearchParameters& search_parameters) {
364
- auto assignment = self.SolveWithParameters(search_parameters);
365
- // std::cout << assignment->DebugString();
366
- return (Assignment) assignment;
341
+ [](RoutingModel& self, const RoutingSearchParameters& search_parameters) {
342
+ return self.SolveWithParameters(search_parameters);
367
343
  });
368
344
  }
@@ -3,29 +3,32 @@ require "fileutils"
3
3
  require "net/http"
4
4
  require "tmpdir"
5
5
 
6
- version = "9.0.9048"
6
+ version = "9.1.9490"
7
7
 
8
8
  if RbConfig::CONFIG["host_os"] =~ /darwin/i
9
- filename = "or-tools_MacOsX-11.2.3_v#{version}.tar.gz"
10
- checksum = "adf73a00d4ec49558b67be5ce3cfc8f30268da2253b35feb11d0d40700550bf6"
9
+ filename = "or-tools_MacOsX-11.6_v#{version}.tar.gz"
10
+ checksum = "97a2b113806c1b2d17f9b3f30571c9ee82722eb22e06bd124d94118f3a84da2c"
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
- filename = "or-tools_ubuntu-20.04_v#{version}.tar.gz"
16
- checksum = "5565343c1c310d2885a40ce850ae7e3468299b3fee97ae8eed8425ce06bd4960"
15
+ filename = "or-tools_amd64_ubuntu-20.04_v#{version}.tar.gz"
16
+ checksum = "cf82e5c343ab74bef320b240a2c3937b07df945e60b91bbc771b477c0856c1bd"
17
17
  elsif os == "Ubuntu" && os_version == "18.04"
18
- filename = "or-tools_ubuntu-18.04_v#{version}.tar.gz"
19
- checksum = "08cf548d0179f7fa814bb7458be94cd1b8a3de14985e6a9faf6118a1d8571539"
18
+ filename = "or-tools_amd64_ubuntu-18.04_v#{version}.tar.gz"
19
+ checksum = "b641677cc3e1095b7e8efd9c5c948698f5e2c238d10d06f1abf0b0ee240addf2"
20
+ elsif os == "Debian" && os_version == "11"
21
+ filename = "or-tools_amd64_debian-11_v#{version}.tar.gz"
22
+ checksum = "de7e63988fc62c64718d8f8f37f98a1c589c89ebc46fc1f378da4b66ad385ff1"
20
23
  elsif os == "Debian" && os_version == "10"
21
- filename = "or-tools_debian-10_v#{version}.tar.gz"
22
- checksum = "063fb1d8765ae23b0bb25b9c561e904532713416fe0458f7db45a0f72190eb50"
24
+ filename = "or-tools_amd64_debian-10_v#{version}.tar.gz"
25
+ checksum = "80411caeccac079fe8ee6018ceae844f5f04d2deecacd3406d51354dea5435e4"
23
26
  elsif os == "CentOS" && os_version == "8"
24
- filename = "or-tools_centos-8_v#{version}.tar.gz"
25
- checksum = "c98212ed4fc699d8ae70c1f53cd1d8dacd28e52970336fab5b86dedf7406f215"
27
+ filename = "or-tools_amd64_centos-8_v#{version}.tar.gz"
28
+ checksum = "fe23b04dd7a20c5902fbf89bb626080296489a05e0bfb39225e71be5e9cee1ac"
26
29
  elsif os == "CentOS" && os_version == "7"
27
- filename = "or-tools_centos-7_v#{version}.tar.gz"
28
- checksum = "b992bda4614bbc703583b0e9edcd2ade54bacfb9909399b20c8aa95ff7197d68"
30
+ filename = "or-tools_amd64_centos-7_v#{version}.tar.gz"
31
+ checksum = "ef48363b27591c25f8702e085024aa7b5f5190ad94c859481116538f04c124f9"
29
32
  else
30
33
  platform =
31
34
  if Gem.win_platform?
@@ -6,8 +6,8 @@ module ORTools
6
6
 
7
7
  def_delegators :@response, :objective_value, :num_conflicts, :num_branches, :wall_time
8
8
 
9
- def solve(model)
10
- @response = _solve(model, parameters)
9
+ def solve(model, observer = nil)
10
+ @response = _solve(model, parameters, observer)
11
11
  @response.status
12
12
  end
13
13
 
@@ -20,13 +20,19 @@ module ORTools
20
20
  end
21
21
 
22
22
  def solve_with_solution_callback(model, observer)
23
- @response = _solve_with_observer(model, parameters, observer, false)
24
- @response.status
23
+ warn "[or-tools] solve_with_solution_callback is deprecated; use solve(model, callback)"
24
+ solve(model, observer)
25
25
  end
26
26
 
27
27
  def search_for_all_solutions(model, observer)
28
- @response = _solve_with_observer(model, parameters, observer, true)
29
- @response.status
28
+ warn "[or-tools] search_for_all_solutions is deprecated; use solve() with solver.parameters.enumerate_all_solutions = true"
29
+ previous_value = parameters.enumerate_all_solutions
30
+ begin
31
+ parameters.enumerate_all_solutions = true
32
+ solve(model, observer)
33
+ ensure
34
+ parameters.enumerate_all_solutions = previous_value
35
+ end
30
36
  end
31
37
 
32
38
  def sufficient_assumptions_for_infeasibility
@@ -78,7 +78,7 @@ module ORTools
78
78
 
79
79
  # min known neighbors rule
80
80
  same_table_by_person = Hash.new { |hash, key| hash[key] = [] }
81
- same_table.each do |(g1, g2, t), v|
81
+ same_table.each do |(g1, g2, _t), v|
82
82
  next unless @connections_for[g1][g2]
83
83
  same_table_by_person[g1] << v
84
84
  same_table_by_person[g2] << v
@@ -1,3 +1,3 @@
1
1
  module ORTools
2
- VERSION = "0.5.0"
2
+ VERSION = "0.5.4"
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.5.0
4
+ version: 0.5.4
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-04-30 00:00:00.000000000 Z
11
+ date: 2021-10-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rice
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '3'
19
+ version: 4.0.2
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '3'
26
+ version: 4.0.2
27
27
  description:
28
28
  email: andrew@ankane.org
29
29
  executables: []
@@ -39,6 +39,7 @@ files:
39
39
  - ext/or-tools/bin_packing.cpp
40
40
  - ext/or-tools/constraint.cpp
41
41
  - ext/or-tools/ext.cpp
42
+ - ext/or-tools/ext.h
42
43
  - ext/or-tools/extconf.rb
43
44
  - ext/or-tools/linear.cpp
44
45
  - ext/or-tools/network_flows.cpp
@@ -86,7 +87,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
86
87
  - !ruby/object:Gem::Version
87
88
  version: '0'
88
89
  requirements: []
89
- rubygems_version: 3.2.3
90
+ rubygems_version: 3.2.22
90
91
  signing_key:
91
92
  specification_version: 4
92
93
  summary: Operations research tools for Ruby