Skip to content

Commit 1a5a7b1

Browse files
authored
Merge branch 'branch-25.08' into no-int-var-fix
2 parents c20c9b5 + ecc6a76 commit 1a5a7b1

File tree

4 files changed

+32
-14
lines changed

4 files changed

+32
-14
lines changed

cpp/src/linear_programming/utilities/problem_checking.cu

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <cuopt/error.hpp>
2121
#include <cuopt/linear_programming/optimization_problem.hpp>
2222
#include <mip/mip_constants.hpp>
23+
#include <utilities/copy_helpers.hpp>
2324

2425
#include <thrust/functional.h>
2526
#include <thrust/logical.h>
@@ -73,6 +74,18 @@ void problem_checking_t<i_t, f_t>::check_initial_primal_representation(
7374
"has size %zu, while objective vector has size %zu.",
7475
primal_initial_solution.size(),
7576
op_problem.get_objective_coefficients().size());
77+
cuopt_expects(!thrust::any_of(op_problem.get_handle_ptr()->get_thrust_policy(),
78+
thrust::make_counting_iterator(0),
79+
thrust::make_counting_iterator(0) + op_problem.get_n_variables(),
80+
[lower_bounds = make_span(op_problem.get_variable_lower_bounds()),
81+
upper_bounds = make_span(op_problem.get_variable_upper_bounds()),
82+
assignment_span = make_span(primal_initial_solution),
83+
int_tol = 1e-8] __device__(i_t idx) {
84+
return assignment_span[idx] < lower_bounds[idx] - int_tol ||
85+
assignment_span[idx] > upper_bounds[idx] + int_tol;
86+
}),
87+
error_type_t::ValidationError,
88+
"Initial solution violates variable bounds.");
7689
}
7790
}
7891

cpp/src/mip/diversity/diversity_manager.cu

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ void diversity_manager_t<i_t, f_t>::add_user_given_solutions(
216216
cuopt_func_call(sol.test_variable_bounds(true));
217217
CUOPT_LOG_INFO("Adding initial solution success! feas %d objective %f excess %f",
218218
is_feasible,
219-
sol.get_objective(),
219+
sol.get_user_objective(),
220220
sol.get_total_excess());
221221
population.run_solution_callbacks(sol);
222222
initial_sol_vector.emplace_back(std::move(sol));
@@ -226,7 +226,7 @@ void diversity_manager_t<i_t, f_t>::add_user_given_solutions(
226226
Assignment size %lu \
227227
initial solution size %lu",
228228
sol.assignment.size(),
229-
init_sol->size());
229+
init_sol_assignment.size());
230230
}
231231
}
232232
}
@@ -320,6 +320,9 @@ bool diversity_manager_t<i_t, f_t>::run_presolve(f_t time_limit)
320320
if (!check_bounds_sanity(*problem_ptr)) { return false; }
321321
}
322322
stats.presolve_time = presolve_timer.elapsed_time();
323+
lp_optimal_solution.resize(problem_ptr->n_variables, problem_ptr->handle_ptr->get_stream());
324+
problem_ptr->handle_ptr->sync_stream();
325+
cudaDeviceSynchronize();
323326
return true;
324327
}
325328

@@ -392,7 +395,6 @@ solution_t<i_t, f_t> diversity_manager_t<i_t, f_t>::run_solver()
392395
cuopt::scope_guard([&]() { stats.total_solve_time = timer.elapsed_time(); });
393396
// after every change to the problem, we should resize all the relevant vars
394397
// we need to encapsulate that to prevent repetitions
395-
lp_optimal_solution.resize(problem_ptr->n_variables, problem_ptr->handle_ptr->get_stream());
396398
ls.resize_vectors(*problem_ptr, problem_ptr->handle_ptr);
397399
ls.lb_constraint_prop.temp_problem.setup(*problem_ptr);
398400
ls.lb_constraint_prop.bounds_update.setup(ls.lb_constraint_prop.temp_problem);
@@ -796,12 +798,14 @@ void diversity_manager_t<i_t, f_t>::set_simplex_solution(const std::vector<f_t>&
796798
{
797799
CUOPT_LOG_DEBUG("Setting simplex solution with objective %f", objective);
798800
using sol_t = solution_t<i_t, f_t>;
801+
context.handle_ptr->sync_stream();
802+
RAFT_CUDA_TRY(cudaSetDevice(context.handle_ptr->get_device()));
799803
cuopt_func_call(sol_t new_sol(*problem_ptr));
804+
cuopt_assert(new_sol.assignment.size() == solution.size(), "Assignment size mismatch");
800805
cuopt_func_call(new_sol.copy_new_assignment(solution));
801806
cuopt_func_call(new_sol.compute_feasibility());
802807
cuopt_assert(integer_equal(new_sol.get_user_objective(), objective, 1e-3), "Objective mismatch");
803808
std::lock_guard<std::mutex> lock(relaxed_solution_mutex);
804-
RAFT_CUDA_TRY(cudaSetDevice(context.handle_ptr->get_device()));
805809
simplex_solution_exists = true;
806810
global_concurrent_halt.store(1, std::memory_order_release);
807811
// it is safe to use lp_optimal_solution while executing the copy operation

cpp/src/mip/utils.cuh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -346,13 +346,13 @@ bool has_variable_bounds_violation(const raft::handle_t* handle_ptr,
346346
problem_t<i_t, f_t>* problem_ptr)
347347
{
348348
auto const assignment_span = make_span(assignment);
349-
return thrust::any_of(
350-
handle_ptr->get_thrust_policy(),
351-
thrust::make_counting_iterator(0),
352-
thrust::make_counting_iterator(0) + problem_ptr->original_problem_ptr->get_n_variables(),
353-
[assignment_span, problem_view = problem_ptr->view()] __device__(i_t idx) {
354-
return !problem_view.check_variable_within_bounds(idx, assignment_span[idx]);
355-
});
349+
return thrust::any_of(handle_ptr->get_thrust_policy(),
350+
thrust::make_counting_iterator(0),
351+
thrust::make_counting_iterator(0) + problem_ptr->n_variables,
352+
[assignment_span, problem_view = problem_ptr->view()] __device__(i_t idx) {
353+
return !problem_view.check_variable_within_bounds(idx,
354+
assignment_span[idx]);
355+
});
356356
}
357357

358358
} // namespace cuopt::linear_programming::detail

cpp/tests/mip/CMakeLists.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,10 @@ ConfigureTest(UNIT_TEST
4343
ConfigureTest(EMPTY_FIXED_PROBLEMS_TEST
4444
${CMAKE_CURRENT_SOURCE_DIR}/empty_fixed_problems_test.cu
4545
)
46-
ConfigureTest(FEASIBILITY_JUMP_TEST
47-
${CMAKE_CURRENT_SOURCE_DIR}/feasibility_jump_tests.cu
48-
)
46+
# Disable for now
47+
# ConfigureTest(FEASIBILITY_JUMP_TEST
48+
# ${CMAKE_CURRENT_SOURCE_DIR}/feasibility_jump_tests.cu
49+
# )
4950
ConfigureTest(MIP_TERMINATION_STATUS_TEST
5051
${CMAKE_CURRENT_SOURCE_DIR}/termination_test.cu
5152
)

0 commit comments

Comments
 (0)