-
Notifications
You must be signed in to change notification settings - Fork 160
Unified pseudocost object for the regular and deterministic mode #1020
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
Open
nguidotti
wants to merge
10
commits into
NVIDIA:main
Choose a base branch
from
nguidotti:simplify-pseudocost
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
e77dbc2
split worker and worker pool in separated file. code cleanup.
nguidotti 62d0452
simplified logic for pseudo cost (and its snapshot) for the regular a…
nguidotti a517f13
fixed compilation
nguidotti f31599c
added missing header
nguidotti 202738f
fixed guard against no incumbent when calling guided diving
nguidotti 4aed76c
addressing code rabbit comments. replaced AT in pseudo_costs_t with a…
nguidotti a5c111d
missing dereference
nguidotti 919e445
Merge branch 'main' into simplify-pseudocost
nguidotti c433e41
increase the wheel size limit
nguidotti 3676432
increasing wheel size limit for CUDA 12
nguidotti File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,7 @@ | |
| /* clang-format on */ | ||
|
|
||
| #include <branch_and_bound/branch_and_bound.hpp> | ||
| #include <branch_and_bound/diving_heuristics.hpp> | ||
| #include <branch_and_bound/mip_node.hpp> | ||
| #include <branch_and_bound/pseudo_costs.hpp> | ||
|
|
||
|
|
@@ -35,15 +36,12 @@ | |
| #include <deque> | ||
| #include <future> | ||
| #include <limits> | ||
| #include <map> | ||
| #include <optional> | ||
| #include <string> | ||
| #include <thread> | ||
| #include <unordered_map> | ||
| #include <vector> | ||
|
|
||
| namespace cuopt::linear_programming::dual_simplex { | ||
|
|
||
| namespace { | ||
|
|
||
| template <typename f_t> | ||
|
|
@@ -1039,7 +1037,9 @@ struct deterministic_bfs_policy_t | |
| const std::vector<i_t>& fractional, | ||
| const std::vector<f_t>& x) override | ||
| { | ||
| i_t var = this->worker.pc_snapshot.variable_selection(fractional, x); | ||
| logger_t log; | ||
| log.log = false; | ||
| i_t var = this->worker.pc_snapshot.variable_selection(fractional, x, log); | ||
| auto dir = martin_criteria(x[var], this->bnb.root_relax_soln_.x[var]); | ||
| return {var, dir}; | ||
| } | ||
|
|
@@ -1048,8 +1048,10 @@ struct deterministic_bfs_policy_t | |
| const std::vector<i_t>& fractional, | ||
| const std::vector<f_t>& x) override | ||
| { | ||
| logger_t log; | ||
| log.log = false; | ||
| node->objective_estimate = | ||
| this->worker.pc_snapshot.obj_estimate(fractional, x, node->lower_bound); | ||
| this->worker.pc_snapshot.obj_estimate(fractional, x, node->lower_bound, log); | ||
| } | ||
|
|
||
| void on_node_completed(mip_node_t<i_t, f_t>* node, | ||
|
|
@@ -1114,33 +1116,36 @@ struct deterministic_diving_policy_t | |
| const std::vector<i_t>& fractional, | ||
| const std::vector<f_t>& x) override | ||
| { | ||
| logger_t log; | ||
| log.log = false; | ||
|
|
||
| switch (this->worker.diving_type) { | ||
| case search_strategy_t::PSEUDOCOST_DIVING: | ||
| return this->worker.variable_selection_from_snapshot(fractional, x); | ||
| return pseudocost_diving( | ||
| this->worker.pc_snapshot, fractional, x, *this->worker.root_solution, log); | ||
|
|
||
| case search_strategy_t::LINE_SEARCH_DIVING: | ||
| if (this->worker.root_solution) { | ||
| logger_t log; | ||
| log.log = false; | ||
| return line_search_diving<i_t, f_t>(fractional, x, *this->worker.root_solution, log); | ||
| } | ||
| return this->worker.variable_selection_from_snapshot(fractional, x); | ||
| return line_search_diving<i_t, f_t>(fractional, x, *this->worker.root_solution, log); | ||
|
|
||
| case search_strategy_t::GUIDED_DIVING: | ||
| return this->worker.guided_variable_selection(fractional, x); | ||
| if (this->worker.incumbent_snapshot.empty()) { | ||
| return pseudocost_diving( | ||
| this->worker.pc_snapshot, fractional, x, *this->worker.root_solution, log); | ||
| } else { | ||
| return guided_diving( | ||
| this->worker.pc_snapshot, fractional, x, this->worker.incumbent_snapshot, log); | ||
| } | ||
|
|
||
| case search_strategy_t::COEFFICIENT_DIVING: { | ||
| logger_t log; | ||
| log.log = false; | ||
| return coefficient_diving<i_t, f_t>(this->bnb.original_lp_, | ||
| return coefficient_diving<i_t, f_t>(this->worker.leaf_problem, | ||
| fractional, | ||
| x, | ||
| this->bnb.var_up_locks_, | ||
| this->bnb.var_down_locks_, | ||
| log); | ||
| } | ||
|
|
||
| default: return this->worker.variable_selection_from_snapshot(fractional, x); | ||
| default: CUOPT_LOG_ERROR("Invalid diving method!"); return {-1, rounding_direction_t::NONE}; | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -1188,6 +1193,9 @@ std::pair<node_status_t, rounding_direction_t> branch_and_bound_t<i_t, f_t>::upd | |
| node_status_t status = node_status_t::PENDING; | ||
| rounding_direction_t round_dir = rounding_direction_t::NONE; | ||
|
|
||
| worker->recompute_basis = true; | ||
| worker->recompute_bounds = true; | ||
|
Comment on lines
+1190
to
+1191
Contributor
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. Maybe this could be turned into a member function of worker (or a policy function)? something like invalidate_basis or something of the sort (probably not an ideal suggestion, but I feel like we could be higher-level here) |
||
|
|
||
| if (lp_status == dual::status_t::DUAL_UNBOUNDED) { | ||
| node_ptr->lower_bound = inf; | ||
| policy.graphviz(search_tree, node_ptr, "infeasible", 0.0); | ||
|
|
@@ -1247,6 +1255,8 @@ std::pair<node_status_t, rounding_direction_t> branch_and_bound_t<i_t, f_t>::upd | |
| assert(dir != rounding_direction_t::NONE); | ||
|
|
||
| policy.update_objective_estimate(node_ptr, leaf_fractional, leaf_solution.x); | ||
| worker->recompute_basis = false; | ||
| worker->recompute_bounds = false; | ||
|
|
||
| logger_t log; | ||
| log.log = false; | ||
|
|
@@ -2506,7 +2516,7 @@ mip_status_t branch_and_bound_t<i_t, f_t>::solve(mip_solution_t<i_t, f_t>& solut | |
| set_uninitialized_steepest_edge_norms(original_lp_, basic_list, edge_norms_); | ||
|
|
||
| pc_.resize(original_lp_.num_cols); | ||
| original_lp_.A.transpose(pc_.AT); | ||
| original_lp_.A.transpose(*pc_.AT); | ||
| { | ||
| raft::common::nvtx::range scope_sb("BB::strong_branching"); | ||
| strong_branching<i_t, f_t>(original_lp_, | ||
|
|
@@ -3321,11 +3331,12 @@ template <typename PoolT> | |
| void branch_and_bound_t<i_t, f_t>::deterministic_broadcast_snapshots( | ||
| PoolT& pool, const std::vector<f_t>& incumbent_snapshot) | ||
| { | ||
| deterministic_snapshot_t<i_t, f_t> snap; | ||
| snap.upper_bound = upper_bound_.load(); | ||
| snap.total_lp_iters = exploration_stats_.total_lp_iters.load(); | ||
| snap.incumbent = incumbent_snapshot; | ||
| snap.pc_snapshot = pc_.create_snapshot(); | ||
| deterministic_snapshot_t<i_t, f_t> snap{ | ||
| .upper_bound = upper_bound_, | ||
| .pc_snapshot = pc_, | ||
| .incumbent = incumbent_snapshot, | ||
| .total_lp_iters = exploration_stats_.total_lp_iters, | ||
| }; | ||
|
|
||
| for (auto& worker : pool) { | ||
| worker.set_snapshots(snap); | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| /* clang-format off */ | ||
| /* | ||
| * SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
| /* clang-format on */ | ||
|
|
||
| #pragma once | ||
|
|
||
| namespace cuopt::linear_programming::dual_simplex { | ||
|
|
||
| constexpr int num_search_strategies = 5; | ||
|
|
||
| // Indicate the search and variable selection algorithms used by each thread | ||
| // in B&B (See [1]). | ||
| // | ||
| // [1] T. Achterberg, “Constraint Integer Programming,” PhD, Technischen Universität Berlin, | ||
| // Berlin, 2007. doi: 10.14279/depositonce-1634. | ||
| enum search_strategy_t : int { | ||
| BEST_FIRST = 0, // Best-First + Plunging. | ||
| PSEUDOCOST_DIVING = 1, // Pseudocost diving (9.2.5) | ||
| LINE_SEARCH_DIVING = 2, // Line search diving (9.2.4) | ||
| GUIDED_DIVING = 3, // Guided diving (9.2.3). | ||
| COEFFICIENT_DIVING = 4 // Coefficient diving (9.2.1) | ||
| }; | ||
|
|
||
| enum class rounding_direction_t { NONE = -1, DOWN = 0, UP = 1 }; | ||
|
|
||
| enum class branch_and_bound_mode_t { PARALLEL = 0, DETERMINISTIC = 1 }; | ||
|
|
||
| } // namespace cuopt::linear_programming::dual_simplex |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.