Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cpp/src/mip/diversity/diversity_manager.cu
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,7 @@ void diversity_manager_t<i_t, f_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<i_t, f_t>(sol)));
cuopt_func_call(sol.test_feasibility(true));
solution_t<i_t, f_t> ls_solution(sol);
ls.run_local_search(ls_solution, population.weights, timer);
Expand Down
1 change: 1 addition & 0 deletions cpp/src/mip/diversity/population.cu
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ std::vector<solution_t<i_t, f_t>> population_t<i_t, f_t>::get_external_solutions
solution_t<i_t, f_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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ bool line_segment_search_t<i_t, f_t>::search_line_segment(solution_t<i_t, f_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<f_t>::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) {
Expand All @@ -92,7 +92,7 @@ bool line_segment_search_t<i_t, f_t>::search_line_segment(solution_t<i_t, f_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;
}
Expand Down
32 changes: 16 additions & 16 deletions cpp/src/mip/problem/problem.cu
Original file line number Diff line number Diff line change
Expand Up @@ -572,26 +572,12 @@ void problem_t<i_t, f_t>::check_problem_representation(bool check_transposed,
template <typename i_t, typename f_t>
bool problem_t<i_t, f_t>::pre_process_assignment(rmm::device_uvector<f_t>& 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<f_t> temp_assignment(presolve_data.additional_var_used.size(),
Expand Down Expand Up @@ -630,6 +616,20 @@ bool problem_t<i_t, f_t>::pre_process_assignment(rmm::device_uvector<f_t>& 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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it solve the issue if you pass original problem bounds here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably, i didn't try it. But it was not accepting the solutions we outputted with get_solution.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because bounds are scaled so I think this is the issue

if (has_variable_bounds_violation) {
CUOPT_LOG_DEBUG("Solution discarded due to variable bounds violation");
return false;
}
return true;
}

Expand Down