diff --git a/cpp/src/mip_heuristics/diversity/diversity_manager.cu b/cpp/src/mip_heuristics/diversity/diversity_manager.cu index 23fb60853b..d4fcbfa738 100644 --- a/cpp/src/mip_heuristics/diversity/diversity_manager.cu +++ b/cpp/src/mip_heuristics/diversity/diversity_manager.cu @@ -240,6 +240,10 @@ void diversity_manager_t::add_user_given_solutions( } if (problem_ptr->pre_process_assignment(init_sol_assignment)) { + raft::copy(sol.assignment.data(), + init_sol_assignment.data(), + init_sol_assignment.size(), + sol.handle_ptr->get_stream()); relaxed_lp_settings_t lp_settings; lp_settings.time_limit = std::min(60., timer.remaining_time() / 2); lp_settings.tolerance = problem_ptr->tolerances.absolute_tolerance; @@ -250,11 +254,15 @@ void diversity_manager_t::add_user_given_solutions( problem_ptr->integer_indices, lp_settings, static_cast*>(nullptr)); - raft::copy(sol.assignment.data(), - init_sol_assignment.data(), - init_sol_assignment.size(), - sol.handle_ptr->get_stream()); bool is_feasible = sol.compute_feasibility(); + if (!is_feasible) { + raft::copy(sol.assignment.data(), + init_sol_assignment.data(), + init_sol_assignment.size(), + sol.handle_ptr->get_stream()); + is_feasible = sol.compute_feasibility(); + } + cuopt_func_call(sol.test_variable_bounds(true)); CUOPT_LOG_DEBUG("Adding initial solution success! feas %d objective %f excess %f", is_feasible, @@ -264,9 +272,8 @@ void diversity_manager_t::add_user_given_solutions( initial_sol_vector.emplace_back(std::move(sol)); } else { CUOPT_LOG_ERROR( - "Error cannot add the provided initial solution! \ - Assignment size %lu \ - initial solution size %lu", + "Error cannot add the provided initial solution! Assignment size %lu initial solution size " + "%lu", sol.assignment.size(), init_sol_assignment.size()); } diff --git a/cpp/src/mip_heuristics/problem/problem.cu b/cpp/src/mip_heuristics/problem/problem.cu index e38e889495..ccba2d5f2b 100644 --- a/cpp/src/mip_heuristics/problem/problem.cu +++ b/cpp/src/mip_heuristics/problem/problem.cu @@ -1706,6 +1706,13 @@ void problem_t::fix_given_variables(problem_t& original_prob variables_to_fix.end(), [variable_fix_mask = make_span(fixing_helpers.variable_fix_mask)] __device__( i_t x) { variable_fix_mask[x] = 1; }); + cuopt_func_call(thrust::for_each(handle_ptr->get_thrust_policy(), + variables_to_fix.begin(), + variables_to_fix.end(), + [assignment = make_span(assignment)] __device__(i_t x) { + cuopt_assert(isfinite(assignment[x]), + "Fixing a variable to a non-finite value"); + })); const i_t num_segments = original_problem.n_constraints; f_t initial_value{0.};