Skip to content

Commit d0c5a42

Browse files
committed
fix thrust build + more timer checks
1 parent fcfd4f0 commit d0c5a42

File tree

7 files changed

+39
-12
lines changed

7 files changed

+39
-12
lines changed

cpp/src/mip_heuristics/diversity/diversity_manager.cu

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -201,18 +201,20 @@ bool diversity_manager_t<i_t, f_t>::run_presolve(f_t time_limit)
201201
compute_probing_cache(ls.constraint_prop.bounds_update, *problem_ptr, probing_timer);
202202
if (problem_is_infeasible) { return false; }
203203
}
204-
const bool remap_cache_ids = true;
205-
trivial_presolve(*problem_ptr, remap_cache_ids);
206-
if (!problem_ptr->empty && !check_bounds_sanity(*problem_ptr)) { return false; }
207-
// May overconstrain if Papilo presolve has been run before
208-
if (context.settings.presolver == presolver_t::None) {
209-
if (!problem_ptr->empty) {
210-
// do the resizing no-matter what, bounds presolve might not change the bounds but initial
211-
// trivial presolve might have
212-
ls.constraint_prop.bounds_update.resize(*problem_ptr);
213-
ls.constraint_prop.conditional_bounds_update.update_constraint_bounds(
214-
*problem_ptr, ls.constraint_prop.bounds_update);
215-
if (!check_bounds_sanity(*problem_ptr)) { return false; }
204+
if (!presolve_timer.check_time_limit()) {
205+
const bool remap_cache_ids = true;
206+
trivial_presolve(*problem_ptr, remap_cache_ids);
207+
if (!problem_ptr->empty && !check_bounds_sanity(*problem_ptr)) { return false; }
208+
// May overconstrain if Papilo presolve has been run before
209+
if (context.settings.presolver == presolver_t::None) {
210+
if (!problem_ptr->empty) {
211+
// do the resizing no-matter what, bounds presolve might not change the bounds but initial
212+
// trivial presolve might have
213+
ls.constraint_prop.bounds_update.resize(*problem_ptr);
214+
ls.constraint_prop.conditional_bounds_update.update_constraint_bounds(
215+
*problem_ptr, ls.constraint_prop.bounds_update);
216+
if (!check_bounds_sanity(*problem_ptr)) { return false; }
217+
}
216218
}
217219
}
218220
stats.presolve_time = presolve_timer.elapsed_time();

cpp/src/mip_heuristics/solve.cu

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,11 @@ mip_solution_t<i_t, f_t> run_mip(detail::problem_t<i_t, f_t>& problem,
153153
detail::trivial_presolve(scaled_problem);
154154

155155
detail::mip_solver_t<i_t, f_t> solver(scaled_problem, settings, scaling, timer);
156+
if (timer.check_time_limit()) {
157+
CUOPT_LOG_INFO("Time limit reached before main solve");
158+
detail::solution_t<i_t, f_t> sol(problem);
159+
return sol.get_solution(false, solver.get_solver_stats(), false);
160+
}
156161
auto scaled_sol = solver.run_solver();
157162
bool is_feasible_before_scaling = scaled_sol.get_feasible();
158163
scaled_sol.problem_ptr = &problem;

cpp/src/mip_heuristics/solver.cu

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,14 @@ solution_t<i_t, f_t> mip_solver_t<i_t, f_t>::run_solver()
134134
return sol;
135135
}
136136

137+
if (timer_.check_time_limit()) {
138+
CUOPT_LOG_INFO("Time limit reached after presolve");
139+
solution_t<i_t, f_t> sol(*context.problem_ptr);
140+
context.stats.total_solve_time = timer_.elapsed_time();
141+
context.problem_ptr->post_process_solution(sol);
142+
return sol;
143+
}
144+
137145
// if the problem was reduced to a LP: run concurrent LP
138146
if (run_presolve && context.problem_ptr->n_integer_vars == 0) {
139147
CUOPT_LOG_INFO("Problem reduced to a LP, running concurrent LP");
@@ -285,6 +293,14 @@ solution_t<i_t, f_t> mip_solver_t<i_t, f_t>::run_solver()
285293
std::placeholders::_5,
286294
std::placeholders::_6);
287295

296+
if (timer_.check_time_limit()) {
297+
CUOPT_LOG_INFO("Time limit reached during B&B setup");
298+
solution_t<i_t, f_t> sol(*context.problem_ptr);
299+
context.stats.total_solve_time = timer_.elapsed_time();
300+
context.problem_ptr->post_process_solution(sol);
301+
return sol;
302+
}
303+
288304
// Fork a thread for branch and bound
289305
// std::async and std::future allow us to get the return value of bb::solve()
290306
// without having to manually manage the thread

cpp/src/pdlp/swap_and_resize_helper.cuh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <thrust/iterator/permutation_iterator.h>
1717
#include <thrust/iterator/transform_iterator.h>
1818
#include <thrust/iterator/zip_iterator.h>
19+
#include <thrust/tuple.h>
1920
#include <thrust/universal_vector.h>
2021

2122
#include <cuda/std/tuple>

cpp/src/pdlp/utils.cuh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include <thrust/execution_policy.h>
2626
#include <thrust/functional.h>
2727
#include <thrust/transform_reduce.h>
28+
#include <thrust/tuple.h>
2829

2930
namespace cuopt::linear_programming::detail {
3031

cpp/src/utilities/copy_helpers.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <rmm/exec_policy.hpp>
1616

1717
#include <thrust/transform.h>
18+
#include <thrust/tuple.h>
1819
#include <thrust/universal_vector.h>
1920

2021
#include <cuda/std/functional>

cpp/src/utilities/cuda_helpers.cuh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <utilities/macros.cuh>
1111

1212
#include <thrust/host_vector.h>
13+
#include <thrust/tuple.h>
1314
#include <mutex>
1415
#include <raft/core/device_span.hpp>
1516
#include <raft/util/cuda_utils.cuh>

0 commit comments

Comments
 (0)