Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
a-zakir committed Nov 13, 2024
1 parent d29d0f4 commit edc1e02
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 14 deletions.
9 changes: 8 additions & 1 deletion src/cpp/benders/benders_core/common.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "antares-xpansion/benders/benders_core/common.h"

#include <antares-xpansion/xpansion_interfaces/LogUtils.h>
/*!
* \brief Return the distance between two point using 2-norm
*
Expand Down Expand Up @@ -29,6 +30,11 @@ void usage(int argc) {
}
}

struct InvalidStructureFile
: public LogUtils::XpansionError<std::runtime_error> {
using LogUtils::XpansionError<std::runtime_error>::XpansionError;
};

/*!
* \brief Build the input from the structure file
*
Expand All @@ -44,7 +50,8 @@ void usage(int argc) {
* \note The id in the coupling_map is that of the variable in the solver
*responsible for the creation of the structure file.
*/
CouplingMap build_input(const std::filesystem::path &structure_path) {
CouplingMap CouplingMapGenerator::build_input(
const std::filesystem::path &structure_path) {
CouplingMap coupling_map;
std::ifstream summary(structure_path, std::ios::in);
if (!summary) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,5 +191,7 @@ struct BendersBaseOptions : public BaseOptions {
};

void usage(int argc);
CouplingMap build_input(const std::filesystem::path &structure_path);
struct CouplingMapGenerator {
static CouplingMap build_input(const std::filesystem::path &structure_path);
};
Json::Value get_json_file_content(const std::filesystem::path &json_file);
5 changes: 2 additions & 3 deletions src/cpp/benders/factories/BendersFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include "antares-xpansion/benders/factories/WriterFactories.h"
#include "antares-xpansion/helpers/AreaParser.h"
#include "antares-xpansion/helpers/Timer.h"
#include "antares-xpansion/xpansion_interfaces/ILogger.h"
#include "antares-xpansion/xpansion_interfaces/LogUtils.h"

BENDERSMETHOD DeduceBendersMethod(size_t coupling_map_size, size_t batch_size,
Expand All @@ -39,8 +38,8 @@ pBendersBase BendersMainFactory::PrepareForExecution(bool external_loop) {
BendersBaseOptions benders_options(options_.get_benders_options());
benders_options.EXTERNAL_LOOP_OPTIONS.DO_OUTER_LOOP = external_loop;


const auto coupling_map = build_input(benders_options.STRUCTURE_FILE);
const auto coupling_map =
CouplingMapGenerator::build_input(benders_options.STRUCTURE_FILE);

method_ = DeduceBendersMethod(coupling_map.size(), options_.BATCH_SIZE,
external_loop);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@
#include "antares-xpansion/benders/benders_core/common.h"
#include "antares-xpansion/benders/benders_mpi/BendersMPI.h"

struct InvalidStructureFile
: public LogUtils::XpansionError<std::runtime_error> {
using LogUtils::XpansionError<std::runtime_error>::XpansionError;
};

class BendersMainFactory {
private:
char** argv_;
Expand Down
2 changes: 1 addition & 1 deletion src/cpp/benders/merge_mps/MergeMPS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ MergeMPS::MergeMPS(const MergeMPSOptions &options, Logger &logger,
void MergeMPS::launch() {
const auto inputRootDir = std::filesystem::path(_options.INPUTROOT);
auto structure_path(inputRootDir / _options.STRUCTURE_FILE);
CouplingMap input = build_input(structure_path);
CouplingMap input = CouplingMapGenerator::build_input(structure_path);

SolverFactory factory;
std::string solver_to_use =
Expand Down
6 changes: 3 additions & 3 deletions tests/cpp/outer_loop/outer_loop_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ void CheckMinInvestmentConstraint(const VariableMap& master_variables,

TEST_P(MasterUpdateBaseTest, ConstraintIsAddedBendersMPI) {
BendersBaseOptions bendersoptions = BuildBendersOptions();
CouplingMap coupling_map =
build_input(std::filesystem::path(bendersoptions.INPUTROOT) /
bendersoptions.STRUCTURE_FILE);
CouplingMap coupling_map = CouplingMapGenerator::build_input(
std::filesystem::path(bendersoptions.INPUTROOT) /
bendersoptions.STRUCTURE_FILE);
// override solver
bendersoptions.SOLVER_NAME = GetParam();
bendersoptions.EXTERNAL_LOOP_OPTIONS.DO_OUTER_LOOP = true;
Expand Down

0 comments on commit edc1e02

Please sign in to comment.