diff --git a/cpp/src/mip/diversity/diversity_manager.cu b/cpp/src/mip/diversity/diversity_manager.cu index d2efc99416..4a8f56e987 100644 --- a/cpp/src/mip/diversity/diversity_manager.cu +++ b/cpp/src/mip/diversity/diversity_manager.cu @@ -451,6 +451,7 @@ void diversity_manager_t::recombine_and_ls_with_all( if (solutions.size() > 0) { CUOPT_LOG_INFO("Running recombiners on B&B solutions with size %lu", solutions.size()); for (auto& sol : solutions) { + population.add_solution(std::move(solution_t(sol))); cuopt_func_call(sol.test_feasibility(true)); solution_t ls_solution(sol); ls.run_local_search(ls_solution, population.weights, timer); diff --git a/cpp/src/mip/diversity/population.cu b/cpp/src/mip/diversity/population.cu index 0780e77ced..d82ac0f14b 100644 --- a/cpp/src/mip/diversity/population.cu +++ b/cpp/src/mip/diversity/population.cu @@ -146,6 +146,7 @@ std::vector> population_t::get_external_solutions solution_t sol(*problem_ptr); sol.copy_new_assignment(h_solution_vec); sol.compute_feasibility(); + sol.handle_ptr->sync_stream(); return_vector.emplace_back(std::move(sol)); } if (external_solution_queue.size() > 0) { diff --git a/cpp/src/mip/local_search/line_segment_search/line_segment_search.cu b/cpp/src/mip/local_search/line_segment_search/line_segment_search.cu index c512714eec..1f166bdf69 100644 --- a/cpp/src/mip/local_search/line_segment_search/line_segment_search.cu +++ b/cpp/src/mip/local_search/line_segment_search/line_segment_search.cu @@ -80,7 +80,7 @@ bool line_segment_search_t::search_line_segment(solution_t& delta_vector.begin(), [n_points_to_search] __device__(const f_t& x) { return x / (n_points_to_search + 1); }); - f_t best_cost = std::numeric_limits::max(); + f_t best_cost = solution.get_quality(fj.cstr_weights, fj.objective_weight); bool initial_is_feasible = solution.get_feasible(); // TODO start from middle and increase the resolution later for (i_t i = 1; i <= n_points_to_search; ++i) { @@ -92,7 +92,7 @@ bool line_segment_search_t::search_line_segment(solution_t& const i_t index) { return point_1_ptr[index] + delta_ptr[index] * i; }); cuopt_func_call(solution.test_variable_bounds(false)); bool is_feasible = solution.round_nearest(); - if (is_feasible) { + if (is_feasibility_run && is_feasible) { CUOPT_LOG_DEBUG("Feasible found after line segment"); return true; } diff --git a/cpp/src/mip/problem/problem.cu b/cpp/src/mip/problem/problem.cu index 304b111ff5..e0caf1a263 100644 --- a/cpp/src/mip/problem/problem.cu +++ b/cpp/src/mip/problem/problem.cu @@ -572,26 +572,12 @@ void problem_t::check_problem_representation(bool check_transposed, template bool problem_t::pre_process_assignment(rmm::device_uvector& assignment) { - cuopt_assert(assignment.size() == original_problem_ptr->get_n_variables(), "size mismatch"); auto has_nans = cuopt::linear_programming::detail::has_nans(handle_ptr, assignment); if (has_nans) { - CUOPT_LOG_DEBUG("Solution discared due to nans"); - return false; - } - - auto has_integrality_discrepancy = cuopt::linear_programming::detail::has_integrality_discrepancy( - handle_ptr, integer_indices, assignment, tolerances.integrality_tolerance); - if (has_integrality_discrepancy) { - CUOPT_LOG_DEBUG("Solution discared due to integrality discrepancy"); - return false; - } - - auto has_variable_bounds_violation = - cuopt::linear_programming::detail::has_variable_bounds_violation(handle_ptr, assignment, this); - if (has_variable_bounds_violation) { - CUOPT_LOG_DEBUG("Solution discared due to variable bounds violation"); + CUOPT_LOG_DEBUG("Solution discarded due to nans"); return false; } + cuopt_assert(assignment.size() == original_problem_ptr->get_n_variables(), "size mismatch"); // create a temp assignment with the var size after bounds standardization (free vars added) rmm::device_uvector temp_assignment(presolve_data.additional_var_used.size(), @@ -630,6 +616,20 @@ bool problem_t::pre_process_assignment(rmm::device_uvector& assig temp_assignment.begin(), assignment.begin()); handle_ptr->sync_stream(); + + auto has_integrality_discrepancy = cuopt::linear_programming::detail::has_integrality_discrepancy( + handle_ptr, integer_indices, assignment, tolerances.integrality_tolerance); + if (has_integrality_discrepancy) { + CUOPT_LOG_DEBUG("Solution discarded due to integrality discrepancy"); + return false; + } + + auto has_variable_bounds_violation = + cuopt::linear_programming::detail::has_variable_bounds_violation(handle_ptr, assignment, this); + if (has_variable_bounds_violation) { + CUOPT_LOG_DEBUG("Solution discarded due to variable bounds violation"); + return false; + } return true; }