-
Notifications
You must be signed in to change notification settings - Fork 122
Clique Table and Preprocessing #627
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: main
Are you sure you want to change the base?
Changes from all commits
594ec3f
f10535f
649062c
fe4cc7a
1d46ec9
1474bc5
b82f63f
1289cbc
60edd8e
103b4c2
adc9c73
5934c12
43f2ed0
3001b52
b45c27e
21e565a
3ae6047
2c78d02
8409f17
22f778b
12c8fcf
5d16246
6319046
96385fe
7cd0a4a
447713f
db8951a
ab2339b
7e322eb
d7f6a80
f58b8c5
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 |
|---|---|---|
|
|
@@ -9,10 +9,12 @@ | |
| #include "diversity_manager.cuh" | ||
|
|
||
| #include <mip/mip_constants.hpp> | ||
| #include <mip/presolve/conflict_graph/clique_table.cuh> | ||
| #include <mip/presolve/probing_cache.cuh> | ||
| #include <mip/presolve/trivial_presolve.cuh> | ||
| #include <mip/problem/problem_helpers.cuh> | ||
|
|
||
| #include <dual_simplex/user_problem.hpp> | ||
| #include <linear_programming/solve.cuh> | ||
|
|
||
| #include <utilities/scope_guard.hpp> | ||
|
|
@@ -200,16 +202,23 @@ bool diversity_manager_t<i_t, f_t>::run_presolve(f_t time_limit) | |
| const bool remap_cache_ids = true; | ||
| trivial_presolve(*problem_ptr, remap_cache_ids); | ||
| if (!problem_ptr->empty && !check_bounds_sanity(*problem_ptr)) { return false; } | ||
| // May overconstrain if Papilo presolve has been run before | ||
| if (!context.settings.presolve) { | ||
| if (!problem_ptr->empty) { | ||
| // do the resizing no-matter what, bounds presolve might not change the bounds but initial | ||
| // trivial presolve might have | ||
| ls.constraint_prop.bounds_update.resize(*problem_ptr); | ||
| if (!context.settings.heuristics_only && !problem_ptr->empty) { | ||
| dual_simplex::user_problem_t<i_t, f_t> host_problem(problem_ptr->handle_ptr); | ||
| problem_ptr->get_host_user_problem(host_problem); | ||
| find_initial_cliques(host_problem, context.settings.tolerances); | ||
| problem_ptr->set_constraints_from_host_user_problem(host_problem); | ||
| trivial_presolve(*problem_ptr, remap_cache_ids); | ||
| } | ||
| if (!problem_ptr->empty) { | ||
| // do the resizing no-matter what, bounds presolve might not change the bounds but | ||
| // initial trivial presolve might have | ||
| ls.constraint_prop.bounds_update.resize(*problem_ptr); | ||
| // May overconstrain if Papilo presolve has been run before | ||
| if (!context.settings.presolve) { | ||
| ls.constraint_prop.conditional_bounds_update.update_constraint_bounds( | ||
| *problem_ptr, ls.constraint_prop.bounds_update); | ||
| if (!check_bounds_sanity(*problem_ptr)) { return false; } | ||
| } | ||
| if (!check_bounds_sanity(*problem_ptr)) { return false; } | ||
|
Comment on lines
+205
to
+221
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. 🧩 Analysis chain🏁 Script executed: # Find bounds_update class/struct definition
rg -n "class.*bounds_update|struct.*bounds_update" --type-add='cu:*.cu' --type-add='cuh:*.cuh' -A 10Repository: NVIDIA/cuopt Length of output: 2672 🏁 Script executed: # Search for resize method in bounds_update context
rg -n "bounds_update.*resize|\.resize\(" --type-add='cu:*.cu' --type-add='cuh:*.cuh' --type-add='hpp:*.hpp' --type-add='h:*.h' -B 2 -A 3Repository: NVIDIA/cuopt Length of output: 50369 🏁 Script executed: # Find set_constraints_from_host_user_problem implementation
rg -n "set_constraints_from_host_user_problem" --type-add='cu:*.cu' --type-add='cuh:*.cuh' --type-add='hpp:*.hpp' --type-add='h:*.h' -A 5Repository: NVIDIA/cuopt Length of output: 2583 🏁 Script executed: # Check trivial_presolve function behavior
rg -n "void trivial_presolve|void.*trivial_presolve" --type-add='cu:*.cu' --type-add='cuh:*.cuh' --type-add='hpp:*.hpp' --type-add='h:*.h' -A 8Repository: NVIDIA/cuopt Length of output: 1556 🏁 Script executed: # Find bounds_update class and resize method
rg -n "class bounds_update_data_t|void.*resize" cpp/src/mip/presolve/bounds_update_data.cuh -A 15Repository: NVIDIA/cuopt Length of output: 328 🏁 Script executed: # Search for bounds_update resize implementations
rg -n "void resize" cpp/src/mip/presolve/bounds_update_data.cuh cpp/src/mip/presolve/load_balanced_bounds_presolve.cuh -B 2 -A 10Repository: NVIDIA/cuopt Length of output: 780 🏁 Script executed: # Look for bounds_update in constraint_prop context
rg -n "bounds_update.*resize|constraint_prop.*bounds_update" cpp/src/mip/local_search/rounding/constraint_prop.cu -B 3 -A 3Repository: NVIDIA/cuopt Length of output: 435 🏁 Script executed: # Check the file at diversity_manager.cu to see the exact context
sed -n '205,225p' cpp/src/mip/diversity/diversity_manager.cuRepository: NVIDIA/cuopt Length of output: 1192 🏁 Script executed: # Find the bounds_update_data_t::resize implementation
rg -n "bounds_update_data_t.*resize" cpp/src/mip/presolve/bounds_update_data.cu -A 20Repository: NVIDIA/cuopt Length of output: 1215 🏁 Script executed: # Also check what init_changed_constraints does
rg -n "init_changed_constraints" cpp/src/mip/presolve/bounds_update_data.cu -A 10Repository: NVIDIA/cuopt Length of output: 573 🏁 Script executed: # Check prepare_for_next_iteration
rg -n "prepare_for_next_iteration" cpp/src/mip/presolve/bounds_update_data.cu -A 10Repository: NVIDIA/cuopt Length of output: 551 🏁 Script executed: # Look for any reset or clear calls in bounds_update context
rg -n "bounds_changed|min_activity|max_activity" cpp/src/mip/presolve/bounds_update_data.cu -B 2 -A 2Repository: NVIDIA/cuopt Length of output: 1216 🏁 Script executed: # Check what update_constraint_bounds does with the bounds_update data
rg -n "update_constraint_bounds" cpp/src/mip/local_search/rounding/constraint_prop.cuh cpp/src/mip/local_search/rounding/constraint_prop.cu -A 15Repository: NVIDIA/cuopt Length of output: 38 🏁 Script executed: # Check if there's any initialization between resize and update_constraint_bounds
sed -n '212,220p' cpp/src/mip/diversity/diversity_manager.cuRepository: NVIDIA/cuopt Length of output: 515 🏁 Script executed: # Look for where init_changed_constraints is called
rg -n "init_changed_constraints" cpp/src/mip -r -B 2 -A 2Repository: NVIDIA/cuopt Length of output: 2421 🏁 Script executed: # Check bounds_update constructor and what values it initializes
sed -n '15,28p' cpp/src/mip/presolve/bounds_update_data.cuRepository: NVIDIA/cuopt Length of output: 795 Reinitialize bounds_update cached state after constraint replacement. After 🤖 Prompt for AI Agents |
||
| } | ||
| stats.presolve_time = presolve_timer.elapsed_time(); | ||
| lp_optimal_solution.resize(problem_ptr->n_variables, problem_ptr->handle_ptr->get_stream()); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -153,7 +153,16 @@ bool local_search_t<i_t, f_t>::do_fj_solve(solution_t<i_t, f_t>& solution, | |
| if (time_limit == 0.) return solution.get_feasible(); | ||
|
|
||
| timer_t timer(time_limit); | ||
|
|
||
| // in case this is the first time run, resize | ||
| if (in_fj.cstr_weights.size() != (size_t)solution.problem_ptr->n_constraints) { | ||
| in_fj.cstr_weights.resize(solution.problem_ptr->n_constraints, | ||
| solution.handle_ptr->get_stream()); | ||
| // reset weights since this is most likely the first call | ||
| thrust::uninitialized_fill(solution.handle_ptr->get_thrust_policy(), | ||
| in_fj.cstr_weights.begin(), | ||
| in_fj.cstr_weights.end(), | ||
| 1.); | ||
| } | ||
|
Comment on lines
156
to
165
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. Guard resize for shrinking and add CUDA error checks. If Proposed fix- if (in_fj.cstr_weights.size() != (size_t)solution.problem_ptr->n_constraints) {
- i_t old_size = in_fj.cstr_weights.size();
- in_fj.cstr_weights.resize(solution.problem_ptr->n_constraints,
- solution.handle_ptr->get_stream());
- thrust::uninitialized_fill(solution.handle_ptr->get_thrust_policy(),
- in_fj.cstr_weights.begin() + old_size,
- in_fj.cstr_weights.end(),
- 1.);
- }
+ auto new_size = static_cast<size_t>(solution.problem_ptr->n_constraints);
+ auto old_size = in_fj.cstr_weights.size();
+ if (old_size != new_size) {
+ in_fj.cstr_weights.resize(new_size, solution.handle_ptr->get_stream());
+ if (old_size < new_size) {
+ thrust::uninitialized_fill(solution.handle_ptr->get_thrust_policy(),
+ in_fj.cstr_weights.begin() + old_size,
+ in_fj.cstr_weights.end(),
+ 1.);
+ }
+ // Use your project’s CUDA_CHECK / equivalent macro here
+ CUOPT_CUDA_CHECK(cudaGetLastError());
+ }As per coding guidelines: Every CUDA kernel launch and memory operation must have error checking with CUDA_CHECK or equivalent verification. 🤖 Prompt for AI Agents |
||
| auto h_weights = cuopt::host_copy(in_fj.cstr_weights, solution.handle_ptr->get_stream()); | ||
| auto h_objective_weight = in_fj.objective_weight.value(solution.handle_ptr->get_stream()); | ||
| for (auto& cpu_fj : ls_cpu_fj) { | ||
|
|
||
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.
Add a debug bounds assert for
cstr_idx.Without a guard, an invalid
cstr_idxcan read pastrow_start. A debug assert keeps the fast path while catching misuse early.🔧 Suggested change (debug-only assert)
template <typename i_t, typename f_t> std::pair<i_t, i_t> csr_matrix_t<i_t, f_t>::get_constraint_range(i_t cstr_idx) const { + assert(cstr_idx >= 0); + assert(static_cast<size_t>(cstr_idx + 1) < this->row_start.size()); return std::make_pair(this->row_start[cstr_idx], this->row_start[cstr_idx + 1]); }🤖 Prompt for AI Agents