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
13 changes: 13 additions & 0 deletions cpp/src/linear_programming/utilities/problem_checking.cu
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <cuopt/error.hpp>
#include <cuopt/linear_programming/optimization_problem.hpp>
#include <mip/mip_constants.hpp>
#include <utilities/copy_helpers.hpp>

#include <thrust/functional.h>
#include <thrust/logical.h>
Expand Down Expand Up @@ -73,6 +74,18 @@ void problem_checking_t<i_t, f_t>::check_initial_primal_representation(
"has size %zu, while objective vector has size %zu.",
primal_initial_solution.size(),
op_problem.get_objective_coefficients().size());
cuopt_expects(!thrust::any_of(op_problem.get_handle_ptr()->get_thrust_policy(),
thrust::make_counting_iterator(0),
thrust::make_counting_iterator(0) + op_problem.get_n_variables(),
[lower_bounds = make_span(op_problem.get_variable_lower_bounds()),
upper_bounds = make_span(op_problem.get_variable_upper_bounds()),
assignment_span = make_span(primal_initial_solution),
int_tol = 1e-8] __device__(i_t idx) {
return assignment_span[idx] < lower_bounds[idx] - int_tol ||
assignment_span[idx] > upper_bounds[idx] + int_tol;
}),
error_type_t::ValidationError,
"Initial solution violates variable bounds.");
}
}

Expand Down
12 changes: 8 additions & 4 deletions cpp/src/mip/diversity/diversity_manager.cu
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ void diversity_manager_t<i_t, f_t>::add_user_given_solutions(
cuopt_func_call(sol.test_variable_bounds(true));
CUOPT_LOG_INFO("Adding initial solution success! feas %d objective %f excess %f",
is_feasible,
sol.get_objective(),
sol.get_user_objective(),
sol.get_total_excess());
population.run_solution_callbacks(sol);
initial_sol_vector.emplace_back(std::move(sol));
Expand All @@ -226,7 +226,7 @@ void diversity_manager_t<i_t, f_t>::add_user_given_solutions(
Assignment size %lu \
initial solution size %lu",
sol.assignment.size(),
init_sol->size());
init_sol_assignment.size());
}
}
}
Expand Down Expand Up @@ -320,6 +320,9 @@ bool diversity_manager_t<i_t, f_t>::run_presolve(f_t time_limit)
if (!check_bounds_sanity(*problem_ptr)) { return false; }
}
stats.presolve_time = presolve_timer.elapsed_time();
lp_optimal_solution.resize(problem_ptr->n_variables, problem_ptr->handle_ptr->get_stream());
problem_ptr->handle_ptr->sync_stream();
cudaDeviceSynchronize();
return true;
}

Expand Down Expand Up @@ -392,7 +395,6 @@ solution_t<i_t, f_t> diversity_manager_t<i_t, f_t>::run_solver()
cuopt::scope_guard([&]() { stats.total_solve_time = timer.elapsed_time(); });
// after every change to the problem, we should resize all the relevant vars
// we need to encapsulate that to prevent repetitions
lp_optimal_solution.resize(problem_ptr->n_variables, problem_ptr->handle_ptr->get_stream());
ls.resize_vectors(*problem_ptr, problem_ptr->handle_ptr);
ls.lb_constraint_prop.temp_problem.setup(*problem_ptr);
ls.lb_constraint_prop.bounds_update.setup(ls.lb_constraint_prop.temp_problem);
Expand Down Expand Up @@ -796,12 +798,14 @@ void diversity_manager_t<i_t, f_t>::set_simplex_solution(const std::vector<f_t>&
{
CUOPT_LOG_DEBUG("Setting simplex solution with objective %f", objective);
using sol_t = solution_t<i_t, f_t>;
context.handle_ptr->sync_stream();
RAFT_CUDA_TRY(cudaSetDevice(context.handle_ptr->get_device()));
cuopt_func_call(sol_t new_sol(*problem_ptr));
cuopt_assert(new_sol.assignment.size() == solution.size(), "Assignment size mismatch");
cuopt_func_call(new_sol.copy_new_assignment(solution));
cuopt_func_call(new_sol.compute_feasibility());
cuopt_assert(integer_equal(new_sol.get_user_objective(), objective, 1e-3), "Objective mismatch");
std::lock_guard<std::mutex> lock(relaxed_solution_mutex);
RAFT_CUDA_TRY(cudaSetDevice(context.handle_ptr->get_device()));
simplex_solution_exists = true;
global_concurrent_halt.store(1, std::memory_order_release);
// it is safe to use lp_optimal_solution while executing the copy operation
Expand Down
14 changes: 7 additions & 7 deletions cpp/src/mip/utils.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -346,13 +346,13 @@ bool has_variable_bounds_violation(const raft::handle_t* handle_ptr,
problem_t<i_t, f_t>* problem_ptr)
{
auto const assignment_span = make_span(assignment);
return thrust::any_of(
handle_ptr->get_thrust_policy(),
thrust::make_counting_iterator(0),
thrust::make_counting_iterator(0) + problem_ptr->original_problem_ptr->get_n_variables(),
[assignment_span, problem_view = problem_ptr->view()] __device__(i_t idx) {
return !problem_view.check_variable_within_bounds(idx, assignment_span[idx]);
});
return thrust::any_of(handle_ptr->get_thrust_policy(),
thrust::make_counting_iterator(0),
thrust::make_counting_iterator(0) + problem_ptr->n_variables,
[assignment_span, problem_view = problem_ptr->view()] __device__(i_t idx) {
return !problem_view.check_variable_within_bounds(idx,
assignment_span[idx]);
});
}

} // namespace cuopt::linear_programming::detail
7 changes: 4 additions & 3 deletions cpp/tests/mip/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,10 @@ ConfigureTest(UNIT_TEST
ConfigureTest(EMPTY_FIXED_PROBLEMS_TEST
${CMAKE_CURRENT_SOURCE_DIR}/empty_fixed_problems_test.cu
)
ConfigureTest(FEASIBILITY_JUMP_TEST
${CMAKE_CURRENT_SOURCE_DIR}/feasibility_jump_tests.cu
)
# Disable for now
# ConfigureTest(FEASIBILITY_JUMP_TEST
# ${CMAKE_CURRENT_SOURCE_DIR}/feasibility_jump_tests.cu
# )
ConfigureTest(MIP_TERMINATION_STATUS_TEST
${CMAKE_CURRENT_SOURCE_DIR}/termination_test.cu
)