Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cpp/src/branch_and_bound/branch_and_bound.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2506,7 +2506,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);
pc_.Arow = Arow_;
{
raft::common::nvtx::range scope_sb("BB::strong_branching");
strong_branching<i_t, f_t>(original_lp_,
Expand Down
34 changes: 17 additions & 17 deletions cpp/src/branch_and_bound/pseudo_costs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,14 @@ template <typename i_t, typename f_t>
objective_change_estimate_t<f_t> single_pivot_objective_change_estimate(
const lp_problem_t<i_t, f_t>& lp,
const simplex_solver_settings_t<i_t, f_t>& settings,
const csc_matrix_t<i_t, f_t>& A_transpose,
const csr_matrix_t<i_t, f_t>& Arow,
const std::vector<variable_status_t>& vstatus,
i_t variable_j,
i_t basic_j,
const lp_solution_t<i_t, f_t>& lp_solution,
const std::vector<i_t>& basic_list,
const std::vector<i_t>& nonbasic_list,
const std::vector<i_t>& nonbasic_mark,
const std::vector<i_t>& nonbasic_end,
basis_update_mpf_t<i_t, f_t>& basis_factors,
std::vector<i_t>& workspace,
std::vector<f_t>& delta_z,
Expand All @@ -82,7 +82,6 @@ objective_change_estimate_t<f_t> single_pivot_objective_change_estimate(
// Compute the objective estimate for the down and up branches of variable j
assert(variable_j >= 0);
assert(basic_j >= 0);

// Down branch
i_t direction = -1;
sparse_vector_t<i_t, f_t> e_k(lp.num_rows, 0);
Expand All @@ -104,11 +103,11 @@ objective_change_estimate_t<f_t> single_pivot_objective_change_estimate(
std::vector<i_t> delta_z_indices;
// delta_z starts out all zero
if (use_transpose) {
compute_delta_z(A_transpose,
compute_delta_z(Arow,
delta_y,
variable_j,
direction,
nonbasic_mark,
nonbasic_end,
workspace,
delta_z_indices,
delta_z,
Expand Down Expand Up @@ -234,10 +233,8 @@ void initialize_pseudo_costs_with_estimate(const lp_problem_t<i_t, f_t>& lp,
basic_map[basic_list[i]] = i;
}

std::vector<i_t> nonbasic_mark(n, -1);
for (i_t i = 0; i < n - m; i++) {
nonbasic_mark[nonbasic_list[i]] = i;
}
std::vector<i_t> nonbasic_end(lp.num_rows);
compute_initial_nonbasic_end(basic_map, pc.Arow, nonbasic_end);

for (i_t k = 0; k < fractional.size(); k++) {
const i_t j = fractional[k];
Expand All @@ -246,14 +243,14 @@ void initialize_pseudo_costs_with_estimate(const lp_problem_t<i_t, f_t>& lp,
objective_change_estimate_t<f_t> estimate =
single_pivot_objective_change_estimate(lp,
settings,
pc.AT,
pc.Arow,
vstatus,
j,
basic_map[j],
lp_solution,
basic_list,
nonbasic_list,
nonbasic_mark,
nonbasic_end,
basis_factors,
workspace,
delta_z,
Expand Down Expand Up @@ -1476,25 +1473,28 @@ i_t pseudo_costs_t<i_t, f_t>::reliable_variable_selection(
basic_map[worker->basic_list[i]] = i;
}

std::vector<i_t> nonbasic_mark(n, -1);
for (i_t i = 0; i < n - m; i++) {
nonbasic_mark[worker->nonbasic_list[i]] = i;
}
// Each thread will have a different basis
// So we need to make a copy of Arow before we permute the columns
// so that nonbasic variables appear first
csr_matrix_t<i_t, f_t> local_Arow = Arow;

std::vector<i_t> nonbasic_end(m);
compute_initial_nonbasic_end(basic_map, local_Arow, nonbasic_end);

for (auto& [score, j] : unreliable_list) {
if (pseudo_cost_num_down[j] == 0 || pseudo_cost_num_up[j] == 0) {
// Estimate the objective change by performing a single pivot of dual simplex.
objective_change_estimate_t<f_t> estimate =
single_pivot_objective_change_estimate(worker->leaf_problem,
settings,
AT,
local_Arow,
node_ptr->vstatus,
j,
basic_map[j],
leaf_solution,
worker->basic_list,
worker->nonbasic_list,
nonbasic_mark,
nonbasic_end,
Comment thread
chris-maes marked this conversation as resolved.
worker->basis_factors,
workspace,
delta_z,
Expand Down
4 changes: 2 additions & 2 deletions cpp/src/branch_and_bound/pseudo_costs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ class pseudo_costs_t {
pseudo_cost_num_up(num_variables),
pseudo_cost_mutex_up(num_variables),
pseudo_cost_mutex_down(num_variables),
AT(1, 1, 1)
Arow(1, 1, 1)
{
}

Expand Down Expand Up @@ -526,7 +526,7 @@ class pseudo_costs_t {

reliability_branching_settings_t<i_t, f_t> reliability_branching_settings;

csc_matrix_t<i_t, f_t> AT; // Transpose of the constraint matrix A
csr_matrix_t<i_t, f_t> Arow;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it an invariant that all the nonbasic coefficients appear first, or only in some contexts? Consider documenting. I'm also wondering if there's scope for a helper struct to group Arow with nonbasic_end since nonbasic_end is a property of the stored representation of the matrix.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In order to use the compute_delta_z function the nonbasic coefficients must appear first. I can add some documentation and consider grouping with a struct.

std::vector<omp_atomic_t<f_t>> pseudo_cost_sum_up;
std::vector<omp_atomic_t<f_t>> pseudo_cost_sum_down;
std::vector<omp_atomic_t<i_t>> pseudo_cost_num_up;
Expand Down
Loading