Skip to content

Commit

Permalink
partial rename outer_loop (#873)
Browse files Browse the repository at this point in the history
  • Loading branch information
a-zakir authored Jul 15, 2024
1 parent ab1693e commit cbf89ae
Show file tree
Hide file tree
Showing 12 changed files with 21 additions and 35 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/outer_loop_options.yml"
"OUTER_LOOP_OPTION_FILE": "data_test/external_loop_test/lp/adequacy_criterion.yml"
}
16 changes: 0 additions & 16 deletions src/cpp/benders/benders_core/OuterLoopInputDataReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,22 +113,6 @@ OuterLoopInputData OuterLoopInputFromYaml::Read(
return yaml_content.as<OuterLoopInputData>();
}

/*
# critère d'arrêt de l'algo
stopping_threshold: 1e-4
# seuil
criterion_count_threshold: 1e-1
patterns:
- area: "N0"
criterion: 1
- area: "N1"
criterion: 1
- area: "N2"
criterion: 1
- area: "N3"
criterion: 1
*/

namespace YAML {

template <>
Expand Down
3 changes: 1 addition & 2 deletions src/cpp/benders/benders_core/include/SimulationOptions.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -78,5 +78,4 @@ BENDERS_OPTIONS_MACRO(DO_OUTER_LOOP, bool, false, asBool())

// Outer Loop Options file
BENDERS_OPTIONS_MACRO(OUTER_LOOP_OPTION_FILE, std::string,
"outer_loop_options.json", asString())

"adequacy_criterion.yml", asString())
2 changes: 1 addition & 1 deletion src/cpp/benders/outer_loop/OuterLoop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ void OuterLoop::PrintLog() {
std::ostringstream msg;
auto logger = benders_->_logger;
logger->PrintIterationSeparatorBegin();
msg << "*** Outer loop: " << benders_->GetBendersRunNumber();
msg << "*** Adequacy criterion loop: " << benders_->GetBendersRunNumber();
logger->display_message(msg.str());
msg.str("");
// TODO criterion per pattern (aka prefix+area) at best Benders ?
Expand Down
2 changes: 1 addition & 1 deletion src/cpp/exe/full_run/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ int main(int argc, char** argv) {
world, SOLVER::BENDERS);
benders_factory.Run();
}
if (solver == "outer_loop") {
if (solver == "adequacy_criterion") {
auto benders_factory = BendersMainFactory(argc_, argv, options_file, env,
world, SOLVER::OUTER_LOOP);
benders_factory.Run();
Expand Down
2 changes: 1 addition & 1 deletion src/python/antares_xpansion/benders_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def get_lp_path(self):
def set_solver(self):
if self.method == "benders":
self.solver = self.benders
elif self.method == "outer_loop":
elif self.method == "adequacy_criterion":
self.solver = self.outer_loop
elif self.method == "mergeMPS":
self.solver = self.merge_mps
Expand Down
4 changes: 3 additions & 1 deletion src/python/antares_xpansion/config_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,9 @@ def _set_options_for_benders_solver(self):
] = self._config.LAST_MASTER_MPS
options_values[OptimisationKeys.last_master_basis_key()] = self._config.LAST_MASTER_BASIS
options_values[OptimisationKeys.batch_size_key()] = self.get_batch_size()
options_values[OptimisationKeys.do_outer_loop_key()] = self._config.method == "outer_loop"
options_values[OptimisationKeys.do_outer_loop_key()] = (
self._config.method == "adequacy_criterion"
)
options_values[OptimisationKeys.outer_loop_option_file_key()] = (
self.outer_loop_options_path()
)
Expand Down
17 changes: 9 additions & 8 deletions src/python/antares_xpansion/input_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,15 @@ def _initialize_parser(self):
dest=LauncherOptionsKeys.installDir_key(),
help="The directory where all binaries are located",
default=LauncherOptionsDefaultValues.DEFAULT_VALUE())
self.parser.add_argument("-m", "--method",
dest=LauncherOptionsKeys.method_key(),
type=str,
choices=["benders",
"mergeMPS",
"outer_loop"],
help="Choose the optimization method",
default=LauncherOptionsDefaultValues.DEFAULT_VALUE())
self.parser.add_argument(
"-m",
"--method",
dest=LauncherOptionsKeys.method_key(),
type=str,
choices=["benders", "mergeMPS", "adequacy_criterion"],
help="Choose the optimization method",
default=LauncherOptionsDefaultValues.DEFAULT_VALUE(),
)
self.parser.add_argument("-n", "--np",
dest=LauncherOptionsKeys.n_mpi_key(),
default=LauncherOptionsDefaultValues.DEFAULT_VALUE(),
Expand Down
4 changes: 2 additions & 2 deletions src/python/antares_xpansion/xpansionConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ def _set_constants(self):
self.LAST_MASTER_BASIS = "master_last_basis.bss"
self.WEIGHTS = "weights"
self.CONSTRAINTS = "constraints"
self.OUTER_LOOP_FILE = "outer_loop.yml"
self.OUTER_LOOP_DIR = "outer_loop"
self.OUTER_LOOP_FILE = "adequacy_criterion.yml"
self.OUTER_LOOP_DIR = "adequacy_criterion"

def _set_default_settings(self):
self.settings_default = {
Expand Down
2 changes: 1 addition & 1 deletion 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 / "outer_loop_options.yml";
const auto OUTER_OPTIONS_FILE = LP_DIR / "adequacy_criterion.yml";

class MasterUpdateBaseTest : public ::testing::TestWithParam<std::string> {
public:
Expand Down
2 changes: 1 addition & 1 deletion tests/python/test_benders_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def test_benders_cmd_outer_loop(self, tmp_path):
with patch(MOCK_SUBPROCESS_RUN, autospec=True) as run_function:
expected_cmd = [exe_path, self.OPTIONS_JSON]
run_function.return_value.returncode = 0
benders_driver.launch(simulation_output_path, "outer_loop", True)
benders_driver.launch(simulation_output_path, "adequacy_criterion", True)
args, _ = run_function.call_args_list[0]
assert args[0] == expected_cmd

Expand Down

0 comments on commit cbf89ae

Please sign in to comment.