or-tools 0.17.1 → 0.18.1

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.
data/ext/or-tools/ext.cpp CHANGED
@@ -16,7 +16,7 @@ void init_routing(Rice::Module& m);
16
16
 
17
17
  extern "C"
18
18
  void Init_ext() {
19
- auto m = Rice::define_module("ORTools");
19
+ Rice::Module m = Rice::define_module("ORTools");
20
20
 
21
21
  m.define_singleton_function("lib_version", &operations_research::OrToolsVersionString);
22
22
 
@@ -8,8 +8,8 @@
8
8
 
9
9
  using operations_research::MPConstraint;
10
10
  using operations_research::MPObjective;
11
- using operations_research::MPSolverParameters;
12
11
  using operations_research::MPSolver;
12
+ using operations_research::MPSolverParameters;
13
13
  using operations_research::MPVariable;
14
14
 
15
15
  using Rice::Array;
@@ -34,13 +34,13 @@ namespace Rice::detail {
34
34
  double is_convertible(VALUE value) { return Convertible::Exact; }
35
35
 
36
36
  static MPSolver::OptimizationProblemType convert(VALUE x) {
37
- auto s = Symbol(x).str();
37
+ std::string s = Symbol(x).str();
38
38
  if (s == "glop") {
39
39
  return MPSolver::OptimizationProblemType::GLOP_LINEAR_PROGRAMMING;
40
40
  } else if (s == "cbc") {
41
41
  return MPSolver::OptimizationProblemType::CBC_MIXED_INTEGER_PROGRAMMING;
42
42
  } else {
43
- throw std::runtime_error("Unknown optimization problem type: " + s);
43
+ throw std::runtime_error{"Unknown optimization problem type: " + s};
44
44
  }
45
45
  }
46
46
 
@@ -175,7 +175,7 @@ void init_linear(Rice::Module& m) {
175
175
  [](const std::string& name, MPSolver::OptimizationProblemType problem_type) {
176
176
  MPSolver* solver = new MPSolver(name, problem_type);
177
177
  if (!solver) {
178
- throw std::runtime_error("Unrecognized solver type");
178
+ throw std::runtime_error{"Unrecognized solver type"};
179
179
  }
180
180
  return solver;
181
181
  }, Rice::Return().takeOwnership())
@@ -184,7 +184,7 @@ void init_linear(Rice::Module& m) {
184
184
  [](const std::string& solver_id) {
185
185
  MPSolver* solver = MPSolver::CreateSolver(solver_id);
186
186
  if (!solver) {
187
- throw std::runtime_error("Unrecognized solver type");
187
+ throw std::runtime_error{"Unrecognized solver type"};
188
188
  }
189
189
  return solver;
190
190
  }, Rice::Return().takeOwnership())
@@ -239,7 +239,7 @@ void init_linear(Rice::Module& m) {
239
239
  } else if (status == MPSolver::ResultStatus::NOT_SOLVED) {
240
240
  return Symbol("not_solved");
241
241
  } else {
242
- throw std::runtime_error("Unknown status");
242
+ throw std::runtime_error{"Unknown status"};
243
243
  }
244
244
  })
245
245
  .define_method(
@@ -247,7 +247,7 @@ void init_linear(Rice::Module& m) {
247
247
  [](MPSolver& self, bool obfuscate) {
248
248
  std::string model_str;
249
249
  if (!self.ExportModelAsLpFormat(obfuscate, &model_str)) {
250
- throw std::runtime_error("Export failed");
250
+ throw std::runtime_error{"Export failed"};
251
251
  }
252
252
  return model_str;
253
253
  })
@@ -256,7 +256,7 @@ void init_linear(Rice::Module& m) {
256
256
  [](MPSolver& self, bool fixed_format, bool obfuscate) {
257
257
  std::string model_str;
258
258
  if (!self.ExportModelAsMpsFormat(fixed_format, obfuscate, &model_str)) {
259
- throw std::runtime_error("Export failed");
259
+ throw std::runtime_error{"Export failed"};
260
260
  }
261
261
  return model_str;
262
262
  });
@@ -32,7 +32,7 @@ namespace Rice::detail {
32
32
  double is_convertible(VALUE value) { return Convertible::Exact; }
33
33
 
34
34
  static SolverType convert(VALUE x) {
35
- auto s = Symbol(x).str();
35
+ std::string s = Symbol(x).str();
36
36
  if (s == "gscip") {
37
37
  return SolverType::kGscip;
38
38
  } else if (s == "gurobi") {
@@ -54,7 +54,7 @@ namespace Rice::detail {
54
54
  } else if (s == "santorini") {
55
55
  return SolverType::kSantorini;
56
56
  } else {
57
- throw std::runtime_error("Unknown solver type: " + s);
57
+ throw std::runtime_error{"Unknown solver type: " + s};
58
58
  }
59
59
  }
60
60
 
@@ -71,11 +71,11 @@ void init_math_opt(Rice::Module& m) {
71
71
  .define_method(
72
72
  "name",
73
73
  [](Variable& self) {
74
- return std::string(self.name());
74
+ return std::string{self.name()};
75
75
  })
76
76
  .define_method(
77
77
  "_eql?",
78
- [](Variable& self, Variable &other) {
78
+ [](Variable& self, Variable& other) {
79
79
  return static_cast<bool>(self == other);
80
80
  });
81
81
 
@@ -106,7 +106,7 @@ void init_math_opt(Rice::Module& m) {
106
106
  } else if (reason == TerminationReason::kOtherError) {
107
107
  return Rice::Symbol("other");
108
108
  } else {
109
- throw std::runtime_error("Unknown termination reason");
109
+ throw std::runtime_error{"Unknown termination reason"};
110
110
  }
111
111
  });
112
112
 
@@ -143,18 +143,18 @@ void init_math_opt(Rice::Module& m) {
143
143
  })
144
144
  .define_method(
145
145
  "_set_upper_bound",
146
- [](Model& self, LinearConstraint constraint, double upper_bound) {
146
+ [](Model& self, const LinearConstraint& constraint, double upper_bound) {
147
147
  self.set_upper_bound(constraint, upper_bound);
148
148
  })
149
149
  .define_method(
150
150
  "_set_lower_bound",
151
- [](Model& self, LinearConstraint constraint, double upper_bound) {
151
+ [](Model& self, const LinearConstraint& constraint, double upper_bound) {
152
152
  self.set_lower_bound(constraint, upper_bound);
153
153
  })
154
154
  .define_method("_set_coefficient", &Model::set_coefficient)
155
155
  .define_method(
156
156
  "_set_objective_coefficient",
157
- [](Model& self, Variable variable, double value) {
157
+ [](Model& self, const Variable& variable, double value) {
158
158
  self.set_objective_coefficient(variable, value);
159
159
  })
160
160
  .define_method("_clear_objective", &Model::clear_objective)
@@ -36,7 +36,7 @@ void init_network_flows(Rice::Module& m) {
36
36
  } else if (status == SimpleMaxFlow::Status::BAD_RESULT) {
37
37
  return Symbol("bad_result");
38
38
  } else {
39
- throw std::runtime_error("Unknown status");
39
+ throw std::runtime_error{"Unknown status"};
40
40
  }
41
41
  })
42
42
  .define_method(
@@ -98,7 +98,7 @@ void init_network_flows(Rice::Module& m) {
98
98
  } else if (status == SimpleMinCostFlow::Status::BAD_COST_RANGE) {
99
99
  return Symbol("bad_cost_range");
100
100
  } else {
101
- throw std::runtime_error("Unknown status");
101
+ throw std::runtime_error{"Unknown status"};
102
102
  }
103
103
  });
104
104
  }