Skip to content

Commit

Permalink
adequacy_criterion file (#876)
Browse files Browse the repository at this point in the history
  • Loading branch information
a-zakir authored Jul 22, 2024
1 parent cbf89ae commit d112ebb
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion data_test/external_loop_test/lp/options.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@
"LAST_MASTER_MPS": "master_last_iteration",
"LAST_MASTER_BASIS": "master_last_basis.bss",
"DO_OUTER_LOOP": true,
"OUTER_LOOP_OPTION_FILE": "data_test/external_loop_test/lp/adequacy_criterion.yml"
"OUTER_LOOP_OPTION_FILE": "adequacy_criterion.yml"
}
4 changes: 2 additions & 2 deletions src/cpp/benders/benders_core/BendersBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ BendersBase::BendersBase(const BendersBaseOptions &options, Logger logger,
}

std::filesystem::path BendersBase::OuterloopOptionsFile() const {
return std::filesystem::path(
_options.EXTERNAL_LOOP_OPTIONS.OUTER_LOOP_OPTION_FILE);
return std::filesystem::path(_options.INPUTROOT) /
_options.EXTERNAL_LOOP_OPTIONS.OUTER_LOOP_OPTION_FILE;
}

/*!
Expand Down
6 changes: 4 additions & 2 deletions src/python/antares_xpansion/config_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
Class to work on config
"""

import glob
import json
import os
import re
Expand Down Expand Up @@ -488,8 +487,11 @@ def _set_options_for_benders_solver(self):
self._config.method == "adequacy_criterion"
)
options_values[OptimisationKeys.outer_loop_option_file_key()] = (
self.outer_loop_options_path()
self._config.OUTER_LOOP_FILE
)
if os.path.exists(self.outer_loop_options_path()):
shutil.copy(self.outer_loop_options_path(), self._simulation_lp_path())

# generate options file for the solver
with open(self.options_file_path(), "w") as options_file:
json.dump(options_values, options_file, indent=4)
Expand Down
4 changes: 2 additions & 2 deletions tests/cpp/outer_loop/outer_loop_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const auto STUDY_PATH =
std::filesystem::path("data_test") / "external_loop_test";
const auto LP_DIR = STUDY_PATH / "lp";
const auto OPTIONS_FILE = LP_DIR / "options.json";
const auto OUTER_OPTIONS_FILE = LP_DIR / "adequacy_criterion.yml";
const auto OUTER_OPTIONS_FILE = "adequacy_criterion.yml";

class MasterUpdateBaseTest : public ::testing::TestWithParam<std::string> {
public:
Expand Down Expand Up @@ -97,7 +97,7 @@ TEST_P(MasterUpdateBaseTest, ConstraintIsAddedBendersMPI) {
benders_options.SOLVER_NAME = GetParam();
benders_options.EXTERNAL_LOOP_OPTIONS.DO_OUTER_LOOP = true;
benders_options.EXTERNAL_LOOP_OPTIONS.OUTER_LOOP_OPTION_FILE =
OUTER_OPTIONS_FILE.string();
OUTER_OPTIONS_FILE;
benders = std::make_shared<BendersMpi>(benders_options, logger, writer, *penv,
*pworld, math_log_driver);
benders->set_input_map(coupling_map);
Expand Down

0 comments on commit d112ebb

Please sign in to comment.