Skip to content

Commit 4b01cf6

Browse files
committed
Fix missing headers for thrust::pair, add trailing return types where needed
1 parent 8a08824 commit 4b01cf6

File tree

16 files changed

+137
-86
lines changed

16 files changed

+137
-86
lines changed

cpp/src/linear_programming/utilities/problem_checking.cu

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,8 @@ void problem_checking_t<i_t, f_t>::check_csr_representation(
4545
cuopt_expects(thrust::all_of(op_problem.get_handle_ptr()->get_thrust_policy(),
4646
op_problem.get_constraint_matrix_indices().cbegin(),
4747
op_problem.get_constraint_matrix_indices().cend(),
48-
[n_variables = op_problem.get_n_variables()] __device__(i_t val) {
49-
return val >= 0 && val < n_variables;
50-
}),
48+
[n_variables = op_problem.get_n_variables()] __device__(
49+
i_t val) -> bool { return val >= 0 && val < n_variables; }),
5150
error_type_t::ValidationError,
5251
"A_indices values must positive lower than the number of variables (c size).");
5352
}
@@ -72,7 +71,7 @@ void problem_checking_t<i_t, f_t>::check_initial_primal_representation(
7271
[lower_bounds = make_span(op_problem.get_variable_lower_bounds()),
7372
upper_bounds = make_span(op_problem.get_variable_upper_bounds()),
7473
assignment_span = make_span(primal_initial_solution),
75-
int_tol = 1e-8] __device__(i_t idx) {
74+
int_tol = 1e-8] __device__(i_t idx) -> bool {
7675
return assignment_span[idx] < lower_bounds[idx] - int_tol ||
7776
assignment_span[idx] > upper_bounds[idx] + int_tol;
7877
}),
@@ -171,13 +170,14 @@ void problem_checking_t<i_t, f_t>::check_problem_representation(
171170

172171
// Check row type if set
173172
if (!op_problem.get_row_types().is_empty()) {
174-
cuopt_expects(
175-
thrust::all_of(op_problem.get_handle_ptr()->get_thrust_policy(),
176-
op_problem.get_row_types().cbegin(),
177-
op_problem.get_row_types().cend(),
178-
[] __device__(char val) { return val == 'E' || val == 'G' || val == 'L'; }),
179-
error_type_t::ValidationError,
180-
"row_types values must equal to 'E', 'G' or 'L'.");
173+
cuopt_expects(thrust::all_of(op_problem.get_handle_ptr()->get_thrust_policy(),
174+
op_problem.get_row_types().cbegin(),
175+
op_problem.get_row_types().cend(),
176+
[] __device__(char val) -> bool {
177+
return val == 'E' || val == 'G' || val == 'L';
178+
}),
179+
error_type_t::ValidationError,
180+
"row_types values must equal to 'E', 'G' or 'L'.");
181181

182182
cuopt_expects(
183183
op_problem.get_row_types().size() == op_problem.get_constraint_bounds().size(),
@@ -322,19 +322,17 @@ bool problem_checking_t<i_t, f_t>::has_crossing_bounds(
322322
thrust::make_counting_iterator(0),
323323
thrust::make_counting_iterator(0) + op_problem.get_variable_upper_bounds().size(),
324324
[upper_bounds = make_span(op_problem.get_variable_upper_bounds()),
325-
lower_bounds = make_span(op_problem.get_variable_lower_bounds())] __device__(size_t i) {
326-
return upper_bounds[i] >= lower_bounds[i];
327-
});
325+
lower_bounds = make_span(op_problem.get_variable_lower_bounds())] __device__(size_t i)
326+
-> bool { return upper_bounds[i] >= lower_bounds[i]; });
328327

329328
// Check if all constraint bounds are valid (upper >= lower)
330329
bool all_constraint_bounds_valid = thrust::all_of(
331330
op_problem.get_handle_ptr()->get_thrust_policy(),
332331
thrust::make_counting_iterator(0),
333332
thrust::make_counting_iterator(0) + op_problem.get_constraint_upper_bounds().size(),
334333
[upper_bounds = make_span(op_problem.get_constraint_upper_bounds()),
335-
lower_bounds = make_span(op_problem.get_constraint_lower_bounds())] __device__(size_t i) {
336-
return upper_bounds[i] >= lower_bounds[i];
337-
});
334+
lower_bounds = make_span(op_problem.get_constraint_lower_bounds())] __device__(size_t i)
335+
-> bool { return upper_bounds[i] >= lower_bounds[i]; });
338336

339337
// Return true if any bounds are invalid (crossing)
340338
return !all_variable_bounds_valid || !all_constraint_bounds_valid;

cpp/src/mip/diversity/recombiners/bound_prop_recombiner.cuh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
#include "recombiner.cuh"
1111

12+
#include <thrust/pair.h>
1213
#include <mip/local_search/rounding/constraint_prop.cuh>
1314
#include <mip/relaxed_lp/relaxed_lp.cuh>
1415
#include <mip/solution/solution.cuh>

cpp/src/mip/feasibility_jump/utils.cuh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
#include "feasibility_jump.cuh"
1111

12+
#include <thrust/pair.h>
1213
#include <cuda/atomic>
1314
#include <raft/core/device_span.hpp>
1415
#include <rmm/device_scalar.hpp>

cpp/src/mip/local_search/rounding/bounds_repair.cu

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ void bounds_repair_t<i_t, f_t>::compute_damages(problem_t<i_t, f_t>& problem, i_
268268
sort_iterator + n_candidates,
269269
thrust::make_zip_iterator(thrust::make_tuple(
270270
candidates.bound_shift.data(), candidates.variable_index.data())),
271-
[] __device__(auto tuple1, auto tuple2) {
271+
[] __device__(auto tuple1, auto tuple2) -> bool {
272272
if (thrust::get<0>(tuple1) < thrust::get<0>(tuple2)) {
273273
return true;
274274
} else if (thrust::get<0>(tuple1) == thrust::get<0>(tuple2) &&
@@ -291,7 +291,7 @@ i_t bounds_repair_t<i_t, f_t>::find_cutoff_index(const candidates_t<i_t, f_t>& c
291291
handle_ptr->get_thrust_policy(),
292292
iterator,
293293
iterator + n_candidates,
294-
[best_cstr_delta, best_damage] __device__(auto tuple) {
294+
[best_cstr_delta, best_damage] __device__(auto tuple) -> bool {
295295
if (thrust::get<0>(tuple) == best_cstr_delta && thrust::get<1>(tuple) <= best_damage) {
296296
return true;
297297
}

cpp/src/mip/local_search/rounding/constraint_prop.cuh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
#pragma once
99

10+
#include <thrust/pair.h>
1011
#include <mip/local_search/rounding/bounds_repair.cuh>
1112
#include <mip/presolve/bounds_presolve.cuh>
1213
#include <mip/presolve/conditional_bound_strengthening.cuh>

cpp/src/mip/presolve/bounds_presolve.cuh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
#include <utilities/timer.hpp>
1818

19+
#include <thrust/pair.h>
20+
1921
#include "bounds_update_data.cuh"
2022
#include "utils.cuh"
2123

cpp/src/mip/presolve/bounds_update_helpers.cuh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66
/* clang-format on */
77

8+
#include <thrust/pair.h>
89
#include <mip/problem/problem.cuh>
910
#include <mip/utils.cuh>
1011
#include "bounds_update_data.cuh"

cpp/src/mip/problem/problem.cu

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -547,20 +547,21 @@ void problem_t<i_t, f_t>::check_problem_representation(bool check_transposed,
547547
cuopt_expects(thrust::all_of(handle_ptr->get_thrust_policy(),
548548
thrust::make_counting_iterator<i_t>(0),
549549
thrust::make_counting_iterator<i_t>(n_variables),
550-
[vars_bnd = make_span(variable_bounds)] __device__(i_t idx) {
550+
[vars_bnd = make_span(variable_bounds)] __device__(i_t idx) -> bool {
551551
auto bounds = vars_bnd[idx];
552552
return get_lower(bounds) <= get_upper(bounds);
553553
}),
554554
error_type_t::ValidationError,
555555
"Variable bounds are invalid");
556556
cuopt_expects(
557-
thrust::all_of(handle_ptr->get_thrust_policy(),
558-
thrust::make_counting_iterator<i_t>(0),
559-
thrust::make_counting_iterator<i_t>(n_constraints),
560-
[constraint_lower_bounds = constraint_lower_bounds.data(),
561-
constraint_upper_bounds = constraint_upper_bounds.data()] __device__(i_t idx) {
562-
return constraint_lower_bounds[idx] <= constraint_upper_bounds[idx];
563-
}),
557+
thrust::all_of(
558+
handle_ptr->get_thrust_policy(),
559+
thrust::make_counting_iterator<i_t>(0),
560+
thrust::make_counting_iterator<i_t>(n_constraints),
561+
[constraint_lower_bounds = constraint_lower_bounds.data(),
562+
constraint_upper_bounds = constraint_upper_bounds.data()] __device__(i_t idx) -> bool {
563+
return constraint_lower_bounds[idx] <= constraint_upper_bounds[idx];
564+
}),
564565
error_type_t::ValidationError,
565566
"Constraints bounds are invalid");
566567

@@ -582,23 +583,21 @@ void problem_t<i_t, f_t>::check_problem_representation(bool check_transposed,
582583
cuopt_assert(thrust::all_of(handle_ptr->get_thrust_policy(),
583584
integer_indices.cbegin(),
584585
integer_indices.cend(),
585-
[types = variable_types.data()] __device__(i_t idx) {
586+
[types = variable_types.data()] __device__(i_t idx) -> bool {
586587
return types[idx] == var_t::INTEGER;
587588
}),
588589
"The integer indices table contains references to non-integer variables.");
589590
cuopt_assert(thrust::all_of(handle_ptr->get_thrust_policy(),
590591
binary_indices.cbegin(),
591592
binary_indices.cend(),
592-
[bin_table = is_binary_variable.data()] __device__(i_t idx) {
593-
return bin_table[idx];
594-
}),
593+
[bin_table = is_binary_variable.data()] __device__(
594+
i_t idx) -> bool { return bin_table[idx]; }),
595595
"The binary indices table contains references to non-binary variables.");
596596
cuopt_assert(thrust::all_of(handle_ptr->get_thrust_policy(),
597597
nonbinary_indices.cbegin(),
598598
nonbinary_indices.cend(),
599-
[bin_table = is_binary_variable.data()] __device__(i_t idx) {
600-
return !bin_table[idx];
601-
}),
599+
[bin_table = is_binary_variable.data()] __device__(
600+
i_t idx) -> bool { return !bin_table[idx]; }),
602601
"The non-binary indices table contains references to binary variables.");
603602
cuopt_assert(
604603
thrust::all_of(
@@ -607,7 +606,7 @@ void problem_t<i_t, f_t>::check_problem_representation(bool check_transposed,
607606
thrust::make_counting_iterator<i_t>(n_variables),
608607
[types = variable_types.data(),
609608
bin_table = is_binary_variable.data(),
610-
pb_view = view()] __device__(i_t idx) {
609+
pb_view = view()] __device__(i_t idx) -> bool {
611610
// ensure the binary variable tables are correct
612611
if (bin_table[idx]) {
613612
if (!thrust::binary_search(
@@ -640,7 +639,7 @@ void problem_t<i_t, f_t>::check_problem_representation(bool check_transposed,
640639
thrust::make_counting_iterator<i_t>(n_variables),
641640
[types = variable_types.data(),
642641
bin_table = is_binary_variable.data(),
643-
pb_view = view()] __device__(i_t idx) {
642+
pb_view = view()] __device__(i_t idx) -> bool {
644643
// ensure the binary variable tables are correct
645644
if (bin_table[idx]) {
646645
if (!thrust::binary_search(
@@ -673,7 +672,7 @@ void problem_t<i_t, f_t>::check_problem_representation(bool check_transposed,
673672
thrust::make_counting_iterator<i_t>(n_variables),
674673
[types = variable_types.data(),
675674
bin_table = is_binary_variable.data(),
676-
pb_view = view()] __device__(i_t idx) {
675+
pb_view = view()] __device__(i_t idx) -> bool {
677676
// ensure the binary variable tables are correct
678677
if (bin_table[idx]) {
679678
if (!thrust::binary_search(
@@ -1212,7 +1211,7 @@ void problem_t<i_t, f_t>::set_implied_integers(const std::vector<i_t>& implied_i
12121211
objective_is_integral = thrust::all_of(handle_ptr->get_thrust_policy(),
12131212
thrust::make_counting_iterator(0),
12141213
thrust::make_counting_iterator(n_variables),
1215-
[v = view()] __device__(i_t var_idx) {
1214+
[v = view()] __device__(i_t var_idx) -> bool {
12161215
if (v.objective_coefficients[var_idx] == 0) return true;
12171216
return v.is_integer(v.objective_coefficients[var_idx]) &&
12181217
(v.variable_types[var_idx] == var_t::INTEGER ||

cpp/src/mip/problem/problem_helpers.cuh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ static void check_csr_representation([[maybe_unused]] const rmm::device_uvector<
250250
cuopt_assert(thrust::all_of(handle_ptr->get_thrust_policy(),
251251
variables.cbegin(),
252252
variables.cend(),
253-
[n_variables = n_variables] __device__(i_t val) {
253+
[n_variables = n_variables] __device__(i_t val) -> bool {
254254
return val >= 0 && val < n_variables;
255255
}),
256256
"A_indices values must positive lower than the number of variables (c size).");
@@ -267,7 +267,7 @@ static bool check_var_bounds_sanity(const detail::problem_t<i_t, f_t>& problem)
267267
thrust::counting_iterator(0),
268268
thrust::counting_iterator((i_t)problem.variable_bounds.size()),
269269
[tolerance = problem.tolerances.presolve_absolute_tolerance,
270-
var_bnd = make_span(problem.variable_bounds)] __device__(i_t index) {
270+
var_bnd = make_span(problem.variable_bounds)] __device__(i_t index) -> bool {
271271
auto var_bounds = var_bnd[index];
272272
return (get_lower(var_bounds) > get_upper(var_bounds) + tolerance);
273273
});
@@ -283,7 +283,7 @@ static bool check_constraint_bounds_sanity(const detail::problem_t<i_t, f_t>& pr
283283
thrust::counting_iterator((i_t)problem.constraint_lower_bounds.size()),
284284
[tolerance = problem.tolerances.presolve_absolute_tolerance,
285285
lb = make_span(problem.constraint_lower_bounds),
286-
ub = make_span(problem.constraint_upper_bounds)] __device__(i_t index) {
286+
ub = make_span(problem.constraint_upper_bounds)] __device__(i_t index) -> bool {
287287
return (lb[index] > ub[index] + tolerance);
288288
});
289289
return !crossing_bounds_detected;

cpp/src/mip/solution/solution.cuh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <mip/problem/problem.cuh>
1515
#include <mip/relaxed_lp/lp_state.cuh>
1616

17+
#include <thrust/pair.h>
1718
#include <raft/util/cuda_dev_essentials.cuh>
1819
#include <rmm/device_scalar.hpp>
1920
#include <rmm/device_uvector.hpp>

0 commit comments

Comments
 (0)