-
Notifications
You must be signed in to change notification settings - Fork 71
Load balanced based multi probe #390
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: branch-25.10
Are you sure you want to change the base?
Changes from 24 commits
8b5cdfd
2035c9a
8df30a6
4987b67
d6e48ec
96eaf24
77c94d8
12e131d
cacd567
e062f51
f403cbb
4970cca
439ebf5
d490307
5272f72
af959b1
d77bfb2
c4ba103
02b7c58
f965358
360d11c
bafeb6c
4b7aa8c
40b4dbe
2a84cc7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,9 +42,15 @@ set(MIP_NON_LP_FILES | |
${CMAKE_CURRENT_SOURCE_DIR}/presolve/bounds_presolve.cu | ||
${CMAKE_CURRENT_SOURCE_DIR}/presolve/bounds_update_data.cu | ||
${CMAKE_CURRENT_SOURCE_DIR}/presolve/conditional_bound_strengthening.cu | ||
${CMAKE_CURRENT_SOURCE_DIR}/presolve/lb_bounds_presolve.cu | ||
${CMAKE_CURRENT_SOURCE_DIR}/presolve/lb_bounds_update_data.cu | ||
${CMAKE_CURRENT_SOURCE_DIR}/presolve/lb_problem.cu | ||
${CMAKE_CURRENT_SOURCE_DIR}/presolve/lb_multi_probe.cu | ||
${CMAKE_CURRENT_SOURCE_DIR}/presolve/load_balanced_bounds_presolve.cu | ||
${CMAKE_CURRENT_SOURCE_DIR}/presolve/multi_probe.cu | ||
${CMAKE_CURRENT_SOURCE_DIR}/presolve/probing_cache.cu | ||
${CMAKE_CURRENT_SOURCE_DIR}/presolve/trivial_presolve.cu | ||
${CMAKE_CURRENT_SOURCE_DIR}/problem/load_balanced_problem.cu | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is a bit confusing to have |
||
${CMAKE_CURRENT_SOURCE_DIR}/feasibility_jump/feasibility_jump.cu | ||
${CMAKE_CURRENT_SOURCE_DIR}/feasibility_jump/feasibility_jump_kernels.cu | ||
) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,7 +30,7 @@ namespace cuopt::linear_programming::detail { | |
|
||
template <typename i_t, typename f_t> | ||
bounds_repair_t<i_t, f_t>::bounds_repair_t(const problem_t<i_t, f_t>& pb, | ||
bound_presolve_t<i_t, f_t>& bound_presolve_) | ||
lb_bound_presolve_t<i_t, f_t>& bound_presolve_) | ||
: bound_presolve(bound_presolve_), | ||
candidates(pb.handle_ptr), | ||
best_bounds(pb.handle_ptr), | ||
|
@@ -67,25 +67,25 @@ void bounds_repair_t<i_t, f_t>::reset() | |
template <typename i_t, typename f_t> | ||
f_t bounds_repair_t<i_t, f_t>::get_ii_violation(problem_t<i_t, f_t>& problem) | ||
{ | ||
bound_presolve.calculate_activity_on_problem_bounds(problem); | ||
bound_presolve.calculate_constraint_slack_on_problem_bounds(problem); | ||
// calculate the violation and mark of violated constraints | ||
thrust::for_each( | ||
handle_ptr->get_thrust_policy(), | ||
thrust::make_counting_iterator(0), | ||
thrust::make_counting_iterator(0) + problem.n_constraints, | ||
[pb_v = problem.view(), | ||
violated_cstr_map = violated_cstr_map.data(), | ||
min_act = bound_presolve.upd.min_activity.data(), | ||
max_act = bound_presolve.upd.max_activity.data(), | ||
cnst_slack = make_span(bound_presolve.upd.cnst_slack), | ||
cstr_violations_up = cstr_violations_up.data(), | ||
cstr_violations_down = cstr_violations_down.data(), | ||
total_vio = total_vio.data()] __device__(i_t cstr_idx) { | ||
f_t cnst_lb = pb_v.constraint_lower_bounds[cstr_idx]; | ||
f_t cnst_ub = pb_v.constraint_upper_bounds[cstr_idx]; | ||
f_t eps = get_cstr_tolerance<i_t, f_t>( | ||
cnst_lb, cnst_ub, pb_v.tolerances.absolute_tolerance, pb_v.tolerances.relative_tolerance); | ||
f_t curr_cstr_violation_up = max(0., min_act[cstr_idx] - (cnst_ub + eps)); | ||
f_t curr_cstr_violation_down = max(0., cnst_lb - eps - max_act[cstr_idx]); | ||
auto slack = cnst_slack[cstr_idx]; | ||
f_t curr_cstr_violation_up = max(0., -get_lower(slack) - eps); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does the slack computation go negative or is there a min(0, slack) check? If it doesn't go negative this will not work. If it can go negative, we need to check other places if there is an implicit assumption that the slack is non-negative. |
||
f_t curr_cstr_violation_down = max(0., get_upper(slack) - eps); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't |
||
f_t violation = max(curr_cstr_violation_up, curr_cstr_violation_down); | ||
if (violation >= ROUNDOFF_TOLERANCE) { | ||
violated_cstr_map[cstr_idx] = 1; | ||
|
@@ -208,8 +208,7 @@ __global__ void compute_damages_kernel(typename problem_t<i_t, f_t>::view_t prob | |
typename candidates_t<i_t, f_t>::view_t candidates, | ||
raft::device_span<f_t> cstr_violations_up, | ||
raft::device_span<f_t> cstr_violations_down, | ||
raft::device_span<f_t> minimum_activity, | ||
raft::device_span<f_t> maximum_activity) | ||
raft::device_span<typename type_2<f_t>::type> cnst_slack) | ||
{ | ||
i_t var_idx = candidates.variable_index[blockIdx.x]; | ||
f_t shift_amount = candidates.bound_shift[blockIdx.x]; | ||
|
@@ -233,14 +232,23 @@ __global__ void compute_damages_kernel(typename problem_t<i_t, f_t>::view_t prob | |
f_t cnst_lb = problem.constraint_lower_bounds[c]; | ||
f_t cnst_ub = problem.constraint_upper_bounds[c]; | ||
f_t shift_in_activities = shift_amount * coeff; | ||
f_t new_min_act = minimum_activity[c] + shift_in_activities; | ||
f_t new_max_act = maximum_activity[c] + shift_in_activities; | ||
auto slack = cnst_slack[c]; | ||
f_t eps = get_cstr_tolerance<i_t, f_t>(cnst_lb, | ||
cnst_ub, | ||
problem.tolerances.absolute_tolerance, | ||
problem.tolerances.relative_tolerance); | ||
f_t new_violations_up = max(0., new_min_act - (cnst_ub + eps)); | ||
f_t new_violations_down = max(0., cnst_lb - eps - new_max_act); | ||
// Given | ||
// f_t new_min_act = minimum_activity[c] + shift_in_activities; | ||
// f_t new_max_act = maximum_activity[c] + shift_in_activities; | ||
// | ||
// f_t new_violations_up = max(0., new_min_act - (cnst_ub + eps)); | ||
// f_t new_violations_down = max(0., cnst_lb - eps - new_max_act); | ||
// becomes | ||
// f_t new_violations_up = max(0., shift_in_activities - (cnst_ub - min_act) - eps); | ||
// f_t new_violations_down = max(0., (cnst_lb - max_act) - shift_in_activities - eps); | ||
// becomes | ||
f_t new_violations_up = max(0., shift_in_activities - get_lower(slack) - eps); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. note: This is valid given that slack calculation allows negative. |
||
f_t new_violations_down = max(0., get_upper(slack) - shift_in_activities - eps); | ||
f_t new_vio = max(new_violations_up, new_violations_down); | ||
i_t curr_cstr_delta = i_t(curr_vio < ROUNDOFF_TOLERANCE) - i_t(new_vio < ROUNDOFF_TOLERANCE); | ||
n_infeasible_cstr_delta += curr_cstr_delta; | ||
|
@@ -262,13 +270,12 @@ void bounds_repair_t<i_t, f_t>::compute_damages(problem_t<i_t, f_t>& problem, i_ | |
CUOPT_LOG_TRACE("Bounds repair: Computing damanges!"); | ||
// TODO check performance, we can apply load balancing here | ||
const i_t TPB = 256; | ||
compute_damages_kernel<i_t, f_t><<<n_candidates, TPB, 0, handle_ptr->get_stream()>>>( | ||
problem.view(), | ||
candidates.view(), | ||
make_span(cstr_violations_up), | ||
make_span(cstr_violations_down), | ||
make_span(bound_presolve.upd.min_activity), | ||
make_span(bound_presolve.upd.max_activity)); | ||
compute_damages_kernel<i_t, f_t> | ||
<<<n_candidates, TPB, 0, handle_ptr->get_stream()>>>(problem.view(), | ||
candidates.view(), | ||
make_span(cstr_violations_up), | ||
make_span(cstr_violations_down), | ||
make_span(bound_presolve.upd.cnst_slack)); | ||
RAFT_CHECK_CUDA(handle_ptr->get_stream()); | ||
auto sort_iterator = thrust::make_zip_iterator( | ||
thrust::make_tuple(candidates.cstr_delta.data(), candidates.damage.data())); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trying to understand the structure: we are using lb versions throughout the code and want to phase-out the non-lb version, right? If that's the case, I would put the non-lb versions under legacy dir to be removed completely.