Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
14 changes: 8 additions & 6 deletions cpp/src/mip/diversity/recombiners/recombiner.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,14 @@ class recombiner_t {
reset(a.problem_ptr->n_integer_vars, a.handle_ptr);
const i_t TPB = 128;
i_t n_blocks = (a.problem_ptr->n_integer_vars + TPB - 1) / TPB;
assign_same_variables_kernel<i_t, f_t>
<<<n_blocks, TPB, 0, a.handle_ptr->get_stream()>>>(a.view(),
b.view(),
offspring.view(),
cuopt::make_span(remaining_indices),
n_remaining.data());
if (a.problem_ptr->n_integer_vars > 0) {
assign_same_variables_kernel<i_t, f_t>
<<<n_blocks, TPB, 0, a.handle_ptr->get_stream()>>>(a.view(),
b.view(),
offspring.view(),
cuopt::make_span(remaining_indices),
n_remaining.data());
}
i_t remaining_variables = this->n_remaining.value(a.handle_ptr->get_stream());

auto vec_remaining_indices =
Expand Down
18 changes: 10 additions & 8 deletions cpp/src/mip/presolve/lb_probing_cache.cu
Original file line number Diff line number Diff line change
Expand Up @@ -286,14 +286,16 @@ inline std::vector<i_t> compute_prioritized_integer_indices(
cuopt_assert(res, "The activity computation must be feasible during probing cache!");
CUOPT_LOG_INFO("prioritized integer_indices n_integer_vars %d", problem.pb->n_integer_vars);
// compute the min var slack
compute_min_slack_per_var<i_t, f_t>
<<<problem.pb->n_integer_vars, 128, 0, problem.handle_ptr->get_stream()>>>(
problem.pb->view(),
make_span_2(bound_presolve.cnst_slack),
make_span(min_slack_per_var),
make_span(different_coefficient),
make_span(max_excess_per_var),
make_span(max_n_violated_per_constraint));
if (problem.pb->n_integer_vars > 0) {
compute_min_slack_per_var<i_t, f_t>
<<<problem.pb->n_integer_vars, 128, 0, problem.handle_ptr->get_stream()>>>(
problem.pb->view(),
make_span_2(bound_presolve.cnst_slack),
make_span(min_slack_per_var),
make_span(different_coefficient),
make_span(max_excess_per_var),
make_span(max_n_violated_per_constraint));
}
auto iterator = thrust::make_zip_iterator(thrust::make_tuple(
max_n_violated_per_constraint.begin(), max_excess_per_var.begin(), min_slack_per_var.begin()));
// sort the vars
Expand Down
20 changes: 11 additions & 9 deletions cpp/src/mip/presolve/probing_cache.cu
Original file line number Diff line number Diff line change
Expand Up @@ -328,15 +328,17 @@ inline std::vector<i_t> compute_prioritized_integer_indices(
cuopt_assert(res, "The activity computation must be feasible during probing cache!");
CUOPT_LOG_DEBUG("prioritized integer_indices n_integer_vars %d", problem.n_integer_vars);
// compute the min var slack
compute_min_slack_per_var<i_t, f_t>
<<<problem.n_integer_vars, 128, 0, problem.handle_ptr->get_stream()>>>(
problem.view(),
make_span(bound_presolve.upd.min_activity),
make_span(bound_presolve.upd.max_activity),
make_span(min_slack_per_var),
make_span(different_coefficient),
make_span(max_excess_per_var),
make_span(max_n_violated_per_constraint));
if (problem.n_integer_vars > 0) {
compute_min_slack_per_var<i_t, f_t>
<<<problem.n_integer_vars, 128, 0, problem.handle_ptr->get_stream()>>>(
problem.view(),
make_span(bound_presolve.upd.min_activity),
make_span(bound_presolve.upd.max_activity),
make_span(min_slack_per_var),
make_span(different_coefficient),
make_span(max_excess_per_var),
make_span(max_n_violated_per_constraint));
}
auto iterator = thrust::make_zip_iterator(thrust::make_tuple(
max_n_violated_per_constraint.begin(), max_excess_per_var.begin(), min_slack_per_var.begin()));
// sort the vars
Expand Down
4 changes: 4 additions & 0 deletions cpp/src/mip/problem/problem.cu
Original file line number Diff line number Diff line change
Expand Up @@ -1145,6 +1145,10 @@ problem_t<i_t, f_t> problem_t<i_t, f_t>::get_problem_after_fixing_vars(
rmm::device_uvector<i_t>& variable_map,
const raft::handle_t* handle_ptr)
{
// Don't do anything if no variables are to be removed (may happen if presolve reduces a MIP to a
// LP problem)
if (variables_to_fix.size() == 0) { return *this; }

auto start_time = std::chrono::high_resolution_clock::now();
cuopt_assert(n_variables == assignment.size(), "Assignment size issue");
problem_t<i_t, f_t> problem(*this, true);
Expand Down
10 changes: 6 additions & 4 deletions cpp/src/mip/solve.cu
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,12 @@ mip_solution_t<i_t, f_t> run_mip(detail::problem_t<i_t, f_t>& problem,
running_mip);

cuopt_func_call(auto saved_problem = scaled_problem);
if (settings.mip_scaling) { scaling.scale_problem(); }
if (settings.initial_solutions.size() > 0) {
for (const auto& initial_solution : settings.initial_solutions) {
scaling.scale_primal(*initial_solution);
if (settings.mip_scaling) {
scaling.scale_problem();
if (settings.initial_solutions.size() > 0) {
for (const auto& initial_solution : settings.initial_solutions) {
scaling.scale_primal(*initial_solution);
}
}
}
// only call preprocess on scaled problem, so we can compute feasibility on the original problem
Expand Down
7 changes: 7 additions & 0 deletions cpp/tests/mip/empty_fixed_problems_test.cu
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,11 @@ TEST(mip_solve, empty_max_problem_with_objective_test)
EXPECT_NEAR(obj_val, 11, 1e-5);
}

TEST(mip_solve, mip_presolved_to_lp)
{
auto [termination_status, obj_val, lb] = test_mps_file("mip/mip-presolved-to-lp.mps", 5, false);
EXPECT_EQ(termination_status, mip_termination_status_t::Optimal);
EXPECT_NEAR(obj_val, 0, 1e-5);
}

} // namespace cuopt::linear_programming::test
32 changes: 32 additions & 0 deletions datasets/mip/mip-presolved-to-lp.mps
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
NAME LP_PROBLEM
ROWS
N OBJ
E R001
E R002
E R003
L R004
L R005
L R006
L R007
COLUMNS
X001 OBJ 1.000000
X001 R004 -1.000000
X001 R006 -1.000000
X002 OBJ 1.000000
X002 R005 -1.000000
X002 R007 -1.000000
X003 R001 1.000000
X003 R004 1.000000
X003 R006 -1.000000
X004 R002 1.000000
X004 R005 1.000000
X004 R007 -1.000000
X005 R001 -1.000000
X005 R002 -1.000000
X005 R003 1.000000
RHS
BOUNDS
LO BND1 X005 0.000000
UP BND1 X005 1.000000
BV BND1 X005
ENDATA
Loading