Skip to content

Commit

Permalink
fix variant visit
Browse files Browse the repository at this point in the history
  • Loading branch information
a-zakir committed Nov 13, 2024
1 parent fe87565 commit d29d0f4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
2 changes: 2 additions & 0 deletions src/cpp/benders/benders_core/BendersBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1028,6 +1028,7 @@ void BendersBase::init_data(double external_loop_lambda,


bool BendersBase::isExceptionRaised() const { return exception_raised_; }

/*
* after the 1st loop of the outer loop, we must re-build the objective
* function and costs
Expand All @@ -1041,6 +1042,7 @@ void BendersBase::UpdateOverallCosts() {

relevantIterationData_.best._invest_cost = _data.invest_cost;
}

void BendersBase::SetBilevelBestub(double bilevel_best_ub) {
_data.outer_loop_current_iteration_data.outer_loop_bilevel_best_ub =
bilevel_best_ub;
Expand Down
19 changes: 11 additions & 8 deletions src/cpp/benders/factories/BendersFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,11 @@ pBendersBase BendersMainFactory::PrepareForExecution(bool external_loop) {
writer_->write_log_level(options_.LOG_LEVEL);
writer_->write_master_name(options_.MASTER_NAME);
writer_->write_solver_name(options_.SOLVER_NAME);
benders->setCriterionComputationInputs(
std::get<Benders::Criterion::CriterionInputData>(
criterion_input_holder_));
benders->setCriterionComputationInputs(std::visit(
[](auto&& the_variant) {
return (Benders::Criterion::CriterionInputData)the_variant;
},
criterion_input_holder_));

return benders;
}
Expand Down Expand Up @@ -132,15 +134,16 @@ void BendersMainFactory::AddCriterionOutput(
std::shared_ptr<MathLoggerDriver> math_log_driver) {
const std::filesystem::path output_root(options_.OUTPUTROOT);

const auto& criterion_input_data =
std::get<Benders::Criterion::CriterionInputData>(criterion_input_holder_);

const auto& headers = criterion_input_data.PatternBodies();
const auto& headers =
std::visit([](auto&& the_variant) { return the_variant.PatternBodies(); },
criterion_input_holder_);
math_log_driver->add_logger(
output_root / LOLD_FILE, headers,
&OuterLoopCurrentIterationData::outer_loop_criterion);

positive_unsupplied_file_ = criterion_input_data.PatternsPrefix() + ".txt";
positive_unsupplied_file_ = std::visit(
[](auto&& the_variant) { return the_variant.PatternsPrefix(); },
criterion_input_holder_);
math_log_driver->add_logger(
output_root / positive_unsupplied_file_, headers,
&OuterLoopCurrentIterationData::outer_loop_patterns_values);
Expand Down

0 comments on commit d29d0f4

Please sign in to comment.