Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
25 changes: 20 additions & 5 deletions cpp/src/branch_and_bound/branch_and_bound.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,9 @@ branch_and_bound_t<i_t, f_t>::branch_and_bound_t(
}
#endif

upper_bound_ = inf;
root_objective_ = std::numeric_limits<f_t>::quiet_NaN();
upper_bound_ = inf;
root_lp_current_lower_bound_ = -inf;
root_objective_ = std::numeric_limits<f_t>::quiet_NaN();
}

template <typename i_t, typename f_t>
Expand Down Expand Up @@ -318,9 +319,19 @@ void branch_and_bound_t<i_t, f_t>::report_heuristic(f_t obj)
user_gap.c_str(),
toc(exploration_stats_.start_time));
} else {
settings_.log.printf("New solution from primal heuristics. Objective %+.6e. Time %.2f\n",
compute_user_objective(original_lp_, obj),
toc(exploration_stats_.start_time));
f_t user_obj = compute_user_objective(original_lp_, obj);
f_t user_lower = get_lower_bound();
if (!std::isfinite(user_lower)) {
f_t root_lower = root_lp_current_lower_bound_.load();
if (std::isfinite(root_lower)) { user_lower = root_lower; }
}
std::string gap_str = std::isfinite(user_lower)
? (". Gap: " + user_mip_gap<f_t>(user_obj, user_lower) + "\n")
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated
: "\n";
settings_.log.printf("New solution from primal heuristics. Objective %+.6e. Time %.2f%s",
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.

We follow the convention that time is always the last item in the log line.

So I think this should read
"New solution from primal heuristics. Objective %.+.6e. Gap %s. Time %.2f"

user_obj,
toc(exploration_stats_.start_time),
gap_str.c_str());
}
}

Expand Down Expand Up @@ -1943,6 +1954,7 @@ mip_status_t branch_and_bound_t<i_t, f_t>::solve(mip_solution_t<i_t, f_t>& solut
log.log_prefix = settings_.log.log_prefix;
solver_status_ = mip_status_t::UNSET;
is_running_ = false;
root_lp_current_lower_bound_ = -inf;
exploration_stats_.nodes_unexplored = 0;
Comment thread
coderabbitai[bot] marked this conversation as resolved.
exploration_stats_.nodes_explored = 0;
original_lp_.A.to_compressed_row(Arow_);
Expand Down Expand Up @@ -1972,6 +1984,9 @@ mip_status_t branch_and_bound_t<i_t, f_t>::solve(mip_solution_t<i_t, f_t>& solut
lp_settings.inside_mip = 1;
lp_settings.scale_columns = false;
lp_settings.concurrent_halt = get_root_concurrent_halt();
lp_settings.root_lp_progress_callback = [this](f_t user_obj) {
root_lp_current_lower_bound_.store(user_obj);
};
std::vector<i_t> basic_list(original_lp_.num_rows);
std::vector<i_t> nonbasic_list;
basis_update_mpf_t<i_t, f_t> basis_update(original_lp_.num_rows, settings_.refactor_frequency);
Expand Down
1 change: 1 addition & 0 deletions cpp/src/branch_and_bound/branch_and_bound.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ class branch_and_bound_t {
lp_solution_t<i_t, f_t> root_crossover_soln_;
std::vector<f_t> edge_norms_;
std::atomic<bool> root_crossover_solution_set_{false};
omp_atomic_t<f_t> root_lp_current_lower_bound_;
bool enable_concurrent_lp_root_solve_{false};
std::atomic<int> root_concurrent_halt_{0};
bool is_root_solution_set{false};
Expand Down
3 changes: 3 additions & 0 deletions cpp/src/dual_simplex/phase2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3520,6 +3520,9 @@ dual::status_t dual_phase2_with_advanced_basis(i_t phase,
primal_infeasibility_squared,
sum_perturb,
now);
if (phase == 2 && settings.inside_mip == 1 && settings.root_lp_progress_callback) {
settings.root_lp_progress_callback(compute_user_objective(lp, obj));
}
}

if (obj >= settings.cut_off) {
Expand Down
3 changes: 3 additions & 0 deletions cpp/src/dual_simplex/simplex_solver_settings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ struct simplex_solver_settings_t {
sub_mip(0),
solution_callback(nullptr),
heuristic_preemption_callback(nullptr),
root_lp_progress_callback(nullptr),
concurrent_halt(nullptr)
{
}
Expand Down Expand Up @@ -202,6 +203,8 @@ struct simplex_solver_settings_t {
std::function<void(const std::vector<f_t>&, f_t)> node_processed_callback;
std::function<void()> heuristic_preemption_callback;
std::function<void(std::vector<f_t>&, std::vector<f_t>&, f_t)> set_simplex_solution_callback;
std::function<void(f_t)>
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.

I think we should call this dual_simplex_objective_callback. It's potentially useful beyond the root lp.

root_lp_progress_callback; // Called with current dual obj during root LP
mutable logger_t log;
std::atomic<int>* concurrent_halt; // if nullptr ignored, if !nullptr, 0 if solver should
// continue, 1 if solver should halt
Expand Down