Skip to content

Commit

Permalink
Merge branch 'develop' into feature/sim-9.2-rc4
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonMarechal25 authored Nov 14, 2024
2 parents 059565d + 6a3ba09 commit aaf7cee
Show file tree
Hide file tree
Showing 22 changed files with 507 additions and 207 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build_centos7.yml
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,10 @@ jobs:
cmake --build _build --config Release -j$(nproc)
- name: Run cucumber on outer_loop tests
- name: Tests with Cucumber
uses: ./.github/workflows/cucumber-tests
with:
feature: "features/outer_loop_tests.feature"
# feature: "features/outer_loop_tests.feature"
mpi_path: ${GITHUB_WORKSPACE}/_build/vcpkg_installed/x64-linux-release/tools/openmpi/bin

- name: Cache vcpkg binary dir
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build_oracle8.yml
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,10 @@ jobs:
cmake --build _build --config Release -j$(nproc)
- name: Run cucumber on outer_loop tests
- name: Tests with Cucumber
uses: ./.github/workflows/cucumber-tests
with:
feature: "features/outer_loop_tests.feature"
# feature: "features/outer_loop_tests.feature"
mpi_path: ${GITHUB_WORKSPACE}/_build/vcpkg_installed/x64-linux-release/tools/openmpi/bin

- name: Running unit tests
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/build_ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -150,13 +150,12 @@ jobs:
run: |
cmake --build _build --config Release -j$(nproc)
- name: Run cucumber on outer_loop tests
- name: Tests with Cucumber
uses: ./.github/workflows/cucumber-tests
with:
feature: "features/outer_loop_tests.feature"
# feature: "features/outer_loop_tests.feature"
mpi_path: ${{ github.workspace }}/_build/vcpkg_installed/x64-linux-release/tools/openmpi/bin


- name: Test
run: |
export PATH=${GITHUB_WORKSPACE}/_build/vcpkg_installed/x64-linux-release/tools/openmpi/bin:$PATH
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build_windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,10 @@ jobs:
cmake --build _build --config Release -j4
- name: Run cucumber on outer_loop tests
- name: Tests with Cucumber
uses: ./.github/workflows/cucumber-tests
with:
feature: "features/outer_loop_tests.feature"
# feature: "features/outer_loop_tests.feature"
mpi_path: /c/Program Files/Microsoft MPI/Bin


Expand Down
3 changes: 3 additions & 0 deletions CMakeGraphVizOptions.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
set(GRAPHVIZ_GENERATE_PER_TARGET FALSE)
set(GRAPHVIZ_IGNORE_TARGETS ".*test.*")
set(GRAPHVIZ_EXTERNAL_LIBS FALSE)
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -407,3 +407,10 @@ endif ()
#version file to define Xpansion and Antares-simulator versions
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/python/antares_xpansion/__version__.py.in ${CMAKE_CURRENT_SOURCE_DIR}/src/python/antares_xpansion/__version__.py)
include(CPack)

add_custom_target(graphviz
COMMAND ${CMAKE_COMMAND} "--graphviz=xpansion.dot" .
COMMAND dot -Tsvg xpansion.dot -o xpansion.svg
COMMAND dot -Tpng xpansion.dot -o xpansion.png
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
)
File renamed without changes.
30 changes: 30 additions & 0 deletions src/cpp/benders/benders_core/BendersMathLogger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,16 @@ LogDestination::LogDestination(const std::filesystem::path& file_path,
std::cerr << err_msg.str();
}
}
void LogDestination::setDelimiter(const std::string& delimiter) {
delimiter_ = delimiter;
}

void MathLoggerBehaviour::write_header() {
setHeadersList();
LogsDestination().InsertDelimiter();
for (const auto& header : Headers()) {
LogsDestination() << header;
LogsDestination().InsertDelimiter();
}
LogsDestination() << std::endl;
}
Expand Down Expand Up @@ -154,36 +159,54 @@ double getDurationNotSolving(double iteration, double master,
void PrintBendersData(LogDestination& log_destination,
const CurrentIterationData& data, const HEADERSTYPE& type,
const BENDERSMETHOD& method) {
log_destination.InsertDelimiter();
log_destination << data.it;
log_destination.InsertDelimiter();
log_destination << std::scientific << std::setprecision(10) << data.lb;
log_destination.InsertDelimiter();
if (method == BENDERSMETHOD::BENDERS) {
log_destination << std::scientific << std::setprecision(10) << data.ub;
log_destination.InsertDelimiter();
log_destination << std::scientific << std::setprecision(10) << data.best_ub;
log_destination.InsertDelimiter();
log_destination << std::scientific << std::setprecision(2)
<< data.best_ub - data.lb;
log_destination.InsertDelimiter();
log_destination << std::scientific << std::setprecision(2)
<< (data.best_ub - data.lb) / data.best_ub;
log_destination.InsertDelimiter();
}
log_destination << data.min_simplexiter;
log_destination.InsertDelimiter();
log_destination << data.max_simplexiter;
log_destination.InsertDelimiter();
if (type == HEADERSTYPE::LONG || method == BENDERSMETHOD::BENDERS_BY_BATCH) {
log_destination << data.number_of_subproblem_solved;
log_destination.InsertDelimiter();
}
if (type == HEADERSTYPE::LONG) {
log_destination << data.cumulative_number_of_subproblem_solved;
log_destination.InsertDelimiter();
}

log_destination << std::setprecision(2) << data.iteration_time;
log_destination.InsertDelimiter();

log_destination << std::setprecision(2) << data.timer_master;
log_destination.InsertDelimiter();

log_destination << std::setprecision(2) << data.subproblems_walltime;
log_destination.InsertDelimiter();

if (type == HEADERSTYPE::LONG) {
log_destination << std::setprecision(2)
<< data.subproblems_cumulative_cputime;
log_destination.InsertDelimiter();
log_destination << std::setprecision(2)
<< getDurationNotSolving(data.iteration_time,
data.timer_master,
data.subproblems_walltime);
log_destination.InsertDelimiter();
}
log_destination << std::endl;
}
Expand All @@ -192,20 +215,27 @@ void PrintExternalLoopData(LogDestination& log_destination,
const CurrentIterationData& data,
const HEADERSTYPE& type,
const BENDERSMETHOD& method) {
log_destination.InsertDelimiter();
log_destination << data.outer_loop_current_iteration_data.benders_num_run;
log_destination.InsertDelimiter();
log_destination << std::scientific << std::setprecision(10)
<< data.outer_loop_current_iteration_data.max_criterion;
log_destination.InsertDelimiter();
log_destination << data.outer_loop_current_iteration_data.max_criterion_area;
log_destination.InsertDelimiter();

log_destination
<< std::scientific << std::setprecision(10)
<< data.outer_loop_current_iteration_data.outer_loop_bilevel_best_ub;
log_destination.InsertDelimiter();
log_destination
<< std::scientific << std::setprecision(10)
<< data.outer_loop_current_iteration_data.external_loop_lambda;
log_destination.InsertDelimiter();
log_destination
<< std::scientific << std::setprecision(10)
<< data.outer_loop_current_iteration_data.external_loop_lambda_min;
log_destination.InsertDelimiter();
log_destination
<< std::scientific << std::setprecision(10)
<< data.outer_loop_current_iteration_data.external_loop_lambda_max;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,16 @@ class LogDestination {

template <class T>
std::ostream& operator<<(const T& obj);
std::ostream& InsertDelimiter() { return *stream_ << delimiter_; }

private:
std::ofstream file_stream_;
std::ostream* stream_;
std::streamsize width_ = 40;
std::string delimiter_ = "\t";

public:
void setDelimiter(const std::string& delimiter);
};
template <class T>
std::ostream& LogDestination::operator<<(const T& obj) {
Expand Down Expand Up @@ -214,10 +219,14 @@ void MathLoggerExternalLoopSpecific<T>::setHeadersList() {
template <class T>
void MathLoggerExternalLoopSpecific<T>::Print(
const CurrentIterationData& data) {
LogsDestination().InsertDelimiter();
LogsDestination() << data.outer_loop_current_iteration_data.benders_num_run;
LogsDestination().InsertDelimiter();
LogsDestination() << data.it;
LogsDestination().InsertDelimiter();
for (const auto& t : data.outer_loop_current_iteration_data.*ptr_) {
LogsDestination() << std::scientific << std::setprecision(10) << t;
LogsDestination().InsertDelimiter();
}
LogsDestination() << std::endl;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ struct OuterLoopCurrentIterationData{
double external_loop_lambda = 0.;
double external_loop_lambda_min = 0.;
double external_loop_lambda_max = 0.;
std::string max_criterion_area;
std::string max_criterion_area_best_it;
std::string max_criterion_area = "N/A";
std::string max_criterion_area_best_it = "N/A";
};
/*! \struct
* struct that hold current Benders iteration
Expand Down
4 changes: 3 additions & 1 deletion src/cpp/benders/factories/BendersFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,9 @@ BendersMainFactory::ProcessCriterionInput() {
const auto fpath = std::filesystem::path(options_.INPUTROOT) /
options_.OUTER_LOOP_OPTION_FILE;
// if adequacy_criterion.yml is provided read it
if (std::filesystem::exists(fpath)) {
if ((method_ == BENDERSMETHOD::BENDERS_OUTERLOOP ||
method_ == BENDERSMETHOD::BENDERS_BY_BATCH_OUTERLOOP) &&
std::filesystem::exists(fpath)) {
return Benders::Criterion::OuterLoopInputFromYaml().Read(fpath);
}
// else compute criterion for all areas!
Expand Down
Loading

0 comments on commit aaf7cee

Please sign in to comment.