Skip to content

Commit d5791dc

Browse files
committed
handle ai reviewS
1 parent d01fd3b commit d5791dc

File tree

4 files changed

+35
-14
lines changed

4 files changed

+35
-14
lines changed

cpp/src/mip_heuristics/diversity/diversity_manager.cu

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ bool diversity_manager_t<i_t, f_t>::run_presolve(f_t time_limit)
221221
// do the resizing no-matter what, bounds presolve might not change the bounds but initial
222222
// trivial presolve might have
223223
ls.constraint_prop.bounds_update.resize(*problem_ptr);
224+
ls.constraint_prop.bounds_update.upd.init_changed_constraints(problem_ptr->handle_ptr);
224225
ls.constraint_prop.conditional_bounds_update.update_constraint_bounds(
225226
*problem_ptr, ls.constraint_prop.bounds_update);
226227
}

cpp/src/mip_heuristics/local_search/local_search.cu

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -209,15 +209,23 @@ bool local_search_t<i_t, f_t>::do_fj_solve(solution_t<i_t, f_t>& solution,
209209
if (time_limit == 0.) return solution.get_feasible();
210210

211211
timer_t timer(time_limit);
212+
const auto old_n_cstr_weights = in_fj.cstr_weights.size();
213+
const auto expected_n_cstr_weights = static_cast<size_t>(solution.problem_ptr->n_constraints);
212214
// in case this is the first time run, resize
213-
if (in_fj.cstr_weights.size() != (size_t)solution.problem_ptr->n_constraints) {
215+
if (old_n_cstr_weights != expected_n_cstr_weights) {
214216
in_fj.cstr_weights.resize(solution.problem_ptr->n_constraints,
215217
solution.handle_ptr->get_stream());
216-
// reset weights since this is most likely the first call
217-
thrust::uninitialized_fill(solution.handle_ptr->get_thrust_policy(),
218-
in_fj.cstr_weights.begin(),
219-
in_fj.cstr_weights.end(),
220-
1.);
218+
cuopt_assert(in_fj.cstr_weights.size() == expected_n_cstr_weights,
219+
"Constraint weights must match constraint count after resize");
220+
// Initialize only newly grown entries; shrinking does not need initialization.
221+
if (old_n_cstr_weights < expected_n_cstr_weights) {
222+
cuopt_assert(old_n_cstr_weights <= in_fj.cstr_weights.size(),
223+
"Constraint weight fill start must be within range");
224+
thrust::uninitialized_fill(solution.handle_ptr->get_thrust_policy(),
225+
in_fj.cstr_weights.begin() + old_n_cstr_weights,
226+
in_fj.cstr_weights.end(),
227+
1.);
228+
}
221229
}
222230
auto h_weights = cuopt::host_copy(in_fj.cstr_weights, solution.handle_ptr->get_stream());
223231
auto h_objective_weight = in_fj.objective_weight.value(solution.handle_ptr->get_stream());

cpp/src/mip_heuristics/presolve/conflict_graph/clique_table.cu

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -229,20 +229,30 @@ void remove_small_cliques(clique_table_t<i_t, f_t>& clique_table)
229229
}
230230
}
231231
for (size_t addtl_c = 0; addtl_c < clique_table.addtl_cliques.size(); addtl_c++) {
232-
const auto& addtl_clique = clique_table.addtl_cliques[addtl_c];
232+
const auto& addtl_clique = clique_table.addtl_cliques[addtl_c];
233+
const auto base_clique_idx = static_cast<size_t>(addtl_clique.clique_idx);
234+
cuopt_assert(base_clique_idx < to_delete.size(),
235+
"Additional clique points to invalid base clique index");
236+
// Remove additional cliques whose base clique is scheduled for deletion.
237+
if (to_delete[base_clique_idx]) {
238+
clique_table.addtl_cliques.erase(clique_table.addtl_cliques.begin() + addtl_c);
239+
addtl_c--;
240+
num_removed_addtl++;
241+
continue;
242+
}
233243
i_t size_of_clique =
234-
clique_table.first[addtl_clique.clique_idx].size() - addtl_clique.start_pos_on_clique + 1;
244+
clique_table.first[base_clique_idx].size() - addtl_clique.start_pos_on_clique + 1;
235245
if (size_of_clique < clique_table.min_clique_size) {
236246
// the items from first clique are already added to the adjlist
237247
// only add the items that are coming from the new var in the additional clique
238248
for (size_t i = addtl_clique.start_pos_on_clique;
239-
i < clique_table.first[addtl_clique.clique_idx].size();
249+
i < clique_table.first[base_clique_idx].size();
240250
i++) {
241251
// insert conflicts both way
242-
clique_table.adj_list_small_cliques[clique_table.first[addtl_clique.clique_idx][i]].insert(
252+
clique_table.adj_list_small_cliques[clique_table.first[base_clique_idx][i]].insert(
243253
addtl_clique.vertex_idx);
244254
clique_table.adj_list_small_cliques[addtl_clique.vertex_idx].insert(
245-
clique_table.first[addtl_clique.clique_idx][i]);
255+
clique_table.first[base_clique_idx][i]);
246256
}
247257
clique_table.addtl_cliques.erase(clique_table.addtl_cliques.begin() + addtl_c);
248258
addtl_c--;

cpp/src/mip_heuristics/problem/problem.cu

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2065,9 +2065,9 @@ void problem_t<i_t, f_t>::set_constraints_from_host_user_problem(
20652065
empty = (nnz == 0 && n_constraints == 0 && n_variables == 0);
20662066
20672067
auto stream = handle_ptr->get_stream();
2068-
cuopt::device_copy(coefficients, csr_A.x.underlying(), stream);
2069-
cuopt::device_copy(variables, csr_A.j.underlying(), stream);
2070-
cuopt::device_copy(offsets, csr_A.row_start.underlying(), stream);
2068+
cuopt::device_copy(coefficients, csr_A.x, stream);
2069+
cuopt::device_copy(variables, csr_A.j, stream);
2070+
cuopt::device_copy(offsets, csr_A.row_start, stream);
20712071
20722072
std::vector<f_t> h_constraint_lower_bounds(n_constraints);
20732073
std::vector<f_t> h_constraint_upper_bounds(n_constraints);
@@ -2118,6 +2118,8 @@ void problem_t<i_t, f_t>::set_constraints_from_host_user_problem(
21182118
lp_state.prev_dual.end(),
21192119
f_t{0});
21202120
}
2121+
handle_ptr->sync_stream();
2122+
RAFT_CHECK_CUDA(stream);
21212123
21222124
compute_transpose_of_problem();
21232125
combined_bounds.resize(n_constraints, stream);

0 commit comments

Comments
 (0)