@@ -258,13 +258,15 @@ void fj_t<i_t, f_t>::copy_weights(const weight_t<i_t, f_t>& weights,
258258 fj_left_weights = make_span (cstr_left_weights),
259259 fj_right_weights = make_span (cstr_right_weights),
260260 new_weights = make_span (weights.cstr_weights )] __device__ (i_t idx) {
261- fj_weights[idx] = idx >= old_size ? 1 . : new_weights[idx];
261+ f_t new_weight = idx >= old_size ? 1 . : new_weights[idx];
262+ cuopt_assert (isfinite (new_weight), " invalid weight" );
263+ cuopt_assert (new_weight >= 0.0 , " invalid weight" );
264+ new_weight = std::max (new_weight, 0.0 );
265+
266+ fj_weights[idx] = idx >= old_size ? 1 . : new_weight;
262267 // TODO: ask Alice how we can manage the previous left,right weights
263- fj_left_weights[idx] = idx >= old_size ? 1 . : new_weights[idx];
264- fj_right_weights[idx] = idx >= old_size ? 1 . : new_weights[idx];
265- cuopt_assert (isfinite (fj_weights[idx]), " invalid weight" );
266- cuopt_assert (isfinite (fj_left_weights[idx]), " invalid left weight" );
267- cuopt_assert (isfinite (fj_right_weights[idx]), " invalid right weight" );
268+ fj_left_weights[idx] = idx >= old_size ? 1 . : new_weight;
269+ fj_right_weights[idx] = idx >= old_size ? 1 . : new_weight;
268270 });
269271 thrust::transform (handle_ptr->get_thrust_policy (),
270272 weights.objective_weight .data (),
0 commit comments