From 1a4c4a6e6382115a1b0c116cd52bbbd087f870f4 Mon Sep 17 00:00:00 2001 From: "Nicolas L. Guidotti" Date: Tue, 11 Aug 2026 12:08:21 +0200 Subject: [PATCH] fixed uninitialized FJ constraint weights when the problem grows Signed-off-by: Nicolas L. Guidotti --- .../feasibility_jump/feasibility_jump.cu | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/cpp/src/mip_heuristics/feasibility_jump/feasibility_jump.cu b/cpp/src/mip_heuristics/feasibility_jump/feasibility_jump.cu index a6665e57e1..1853ecfcbd 100644 --- a/cpp/src/mip_heuristics/feasibility_jump/feasibility_jump.cu +++ b/cpp/src/mip_heuristics/feasibility_jump/feasibility_jump.cu @@ -1036,9 +1036,20 @@ void fj_t::resize_vectors(const raft::handle_t* handle_ptr) climbers[0]->grid_delta_buf.resize(update_weights_launch_dims.first.x, handle_ptr->get_stream()); // FJ related vars - cstr_weights.resize(pb_ptr->n_constraints, handle_ptr->get_stream()); - cstr_right_weights.resize(pb_ptr->n_constraints, handle_ptr->get_stream()); - cstr_left_weights.resize(pb_ptr->n_constraints, handle_ptr->get_stream()); + // the problem can gain constraints between two runs (e.g. the objective cutting plane added by + // the feasibility pump), and resize leaves the new elements uninitialized: give them the default + // weight + auto resize_weights = [&](rmm::device_uvector& weights) { + const auto old_size = weights.size(); + weights.resize(pb_ptr->n_constraints, handle_ptr->get_stream()); + if (old_size < weights.size()) { + thrust::uninitialized_fill( + handle_ptr->get_thrust_policy(), weights.begin() + old_size, weights.end(), 1.); + } + }; + resize_weights(cstr_weights); + resize_weights(cstr_right_weights); + resize_weights(cstr_left_weights); constraint_lower_bounds_csr.resize(pb_ptr->coefficients.size(), handle_ptr->get_stream()); constraint_upper_bounds_csr.resize(pb_ptr->coefficients.size(), handle_ptr->get_stream()); cstr_coeff_reciprocal.resize(pb_ptr->coefficients.size(), handle_ptr->get_stream());