Skip to content

Commit

Permalink
fix Linux bug on empty criteria (#984)
Browse files Browse the repository at this point in the history
Improve the handling of criteria data and ensure that computations are
only performed when necessary.
  • Loading branch information
JasonMarechal25 authored Jan 15, 2025
2 parents 3f84ae6 + 42758b3 commit 51c2ede
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ class CriterionComputation {
*/
const CriterionInputData &getCriterionInputData() const;

bool IsEmpty() const {
return criterion_input_data_.Criteria().empty();
}

private:
std::vector<std::vector<int>> var_indices_ = {};
CriterionInputData criterion_input_data_;
Expand Down
14 changes: 8 additions & 6 deletions src/cpp/benders/benders_mpi/BendersMPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,14 @@ void BendersMpi::GatherCuts(const SubProblemDataMap &subproblem_data_map,

// only rank_0 receive non-emtpy gathered_subproblem_map
master_build_cuts(gathered_subproblem_map);

ComputeSubproblemsContributionToCriteria(subproblem_data_map);
if (_world.rank() == rank_0) {
criteria_vector_for_each_iteration_.push_back(
_data.criteria_current_iteration_data.criteria);
UpdateMaxCriterionArea();
if (!criterion_computation_.IsEmpty()) {
ComputeSubproblemsContributionToCriteria(subproblem_data_map);

if (_world.rank() == rank_0) {
criteria_vector_for_each_iteration_.push_back(
_data.criteria_current_iteration_data.criteria);
UpdateMaxCriterionArea();
}
}
}

Expand Down

0 comments on commit 51c2ede

Please sign in to comment.