From fa5a99f210d31bb016ab4e71b5db97ef2dc43826 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jason=20Mar=C3=A9chal?= <45510813+JasonMarechal25@users.noreply.github.com> Date: Wed, 18 Oct 2023 16:14:53 +0200 Subject: [PATCH 1/2] Ci/centos (#696) * Remove dependency to antares-study-updater * Try simplify centOS image use * Update docker publish action * Add wheel package * Build TBB * Build boost test --- .github/workflows/build_centos7.yml | 17 +++-- .github/workflows/build_ubuntu.yml | 5 +- .github/workflows/build_windows.yml | 4 +- .github/workflows/centos-release.yml | 17 +++-- .../workflows/centos7-system-deps-build.yml | 65 +++++++++++-------- .github/workflows/publish_centos_docker.yml | 6 +- .github/workflows/sonarcloud.yml | 6 +- .github/workflows/ubuntu-release.yml | 6 +- .../workflows/windows-vcpkg-deps-build.yml | 4 +- .github/workflows/windows-vcpkg.yml | 6 +- CMakeLists.txt | 18 ++--- docker/centos7 | 46 ------------- docker/centos7-bare | 33 ---------- docker/centos7-system-deps | 23 +++++++ 14 files changed, 112 insertions(+), 144 deletions(-) delete mode 100644 docker/centos7 delete mode 100644 docker/centos7-bare create mode 100644 docker/centos7-system-deps diff --git a/.github/workflows/build_centos7.yml b/.github/workflows/build_centos7.yml index 2c452a584..d6aea8e3f 100644 --- a/.github/workflows/build_centos7.yml +++ b/.github/workflows/build_centos7.yml @@ -25,20 +25,20 @@ jobs: uses: tj-actions/changed-files@v32 with: files: | - docker/centos7-bare + docker/centos7-system-deps - name: Docker file push id: docker_push if: steps.changed-files.outputs.any_changed == 'true' - uses: elgohr/Publish-Docker-Github-Action@master + uses: elgohr/Publish-Docker-Github-Action@main with: name: antaresrte/rte-antares username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} workdir: docker - dockerfile: centos7-bare + dockerfile: centos7-system-deps cache: false - tags: centos7-xpansion-bare + tags: centos7-system-deps versions: runs-on: ubuntu-latest @@ -72,7 +72,7 @@ jobs: build: runs-on: ubuntu-latest needs: [ docker_publish, versions ] - container: 'antaresrte/rte-antares:centos7-xpansion-bare' + container: 'antaresrte/rte-antares:centos7-system-deps' strategy: matrix: xprs: [ XPRESS-ON, XPRESS-OFF ] @@ -117,8 +117,15 @@ jobs: with: prefix: "../rte-antares-deps-Release/" + - name: Compile tbb + uses: ./.github/workflows/compile-tbb + with: + cmake: 'cmake3' + - name: Install dependencies run: | + pip3 install --upgrade pip + pip3 install wheel #Does not work in requirements pip3 install -r requirements-tests.txt pip3 install -r requirements-ui.txt - name: Configure diff --git a/.github/workflows/build_ubuntu.yml b/.github/workflows/build_ubuntu.yml index 970f9e99b..da34dd653 100644 --- a/.github/workflows/build_ubuntu.yml +++ b/.github/workflows/build_ubuntu.yml @@ -60,10 +60,7 @@ jobs: - name: Install mandatory system libraries run: | sudo apt-get update --fix-missing - sudo apt-get install libjsoncpp-dev libgtest-dev libboost-mpi-dev libboost-program-options-dev libtbb-dev - cd /usr/src/googletest/ - sudo cmake . - sudo cmake --build . + sudo apt-get install -y ccache cmake libgtest-dev libjsoncpp-dev libtbb-dev libopenmpi-dev - name: Read antares-solver version id: antares-version diff --git a/.github/workflows/build_windows.yml b/.github/workflows/build_windows.yml index b9c156121..5f8c59407 100644 --- a/.github/workflows/build_windows.yml +++ b/.github/workflows/build_windows.yml @@ -110,9 +110,9 @@ jobs: shell: bash - name: Compile tbb - uses: ./.github/workflows/compile-tbb + uses: ./.github/workflows/compile-tbb with: - cmake: 'cmake' + cmake: 'cmake' - name: Download pre-compiled librairies uses: ./.github/workflows/download-extract-precompiled-libraries-zip diff --git a/.github/workflows/centos-release.yml b/.github/workflows/centos-release.yml index 052d7e005..736224b97 100644 --- a/.github/workflows/centos-release.yml +++ b/.github/workflows/centos-release.yml @@ -32,20 +32,20 @@ jobs: uses: tj-actions/changed-files@v32 with: files: | - docker/centos7-bare + docker/centos7-system-deps - name: Docker file push id: docker_push if: steps.changed-files.outputs.any_changed == 'true' - uses: elgohr/Publish-Docker-Github-Action@master + uses: elgohr/Publish-Docker-Github-Action@main with: name: antaresrte/rte-antares username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} workdir: docker - dockerfile: centos7-bare + dockerfile: centos7-system-deps cache: false - tags: centos7-xpansion-bare + tags: centos7-system-deps userguide: runs-on: ubuntu-latest @@ -107,7 +107,7 @@ jobs: build: runs-on: ubuntu-latest needs: [ docker_publish, userguide, versions ] - container: 'antaresrte/rte-antares:centos7-xpansion-bare' + container: 'antaresrte/rte-antares:centos7-system-deps' strategy: matrix: xprs: [ XPRESS-ON, XPRESS-OFF ] @@ -144,8 +144,15 @@ jobs: with: prefix: "../rte-antares-deps-Release/" + - name: Compile tbb + uses: ./.github/workflows/compile-tbb + with: + cmake: 'cmake3' + - name: Install dependencies run: | + pip3 install --upgrade pip + pip3 install wheel #Does not work in requirements pip3 install -r requirements-tests.txt pip3 install -r requirements-ui.txt diff --git a/.github/workflows/centos7-system-deps-build.yml b/.github/workflows/centos7-system-deps-build.yml index a569ae826..d06ce5499 100644 --- a/.github/workflows/centos7-system-deps-build.yml +++ b/.github/workflows/centos7-system-deps-build.yml @@ -8,6 +8,31 @@ on: - release/* - ci/* jobs: + docker_publish: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + with: + fetch-depth: 0 + - name: Get changed files + id: changed-files + uses: tj-actions/changed-files@v32 + with: + files: | + docker/centos7-system-deps + + - name: Docker file push + id: docker_push + if: steps.changed-files.outputs.any_changed == 'true' + uses: elgohr/Publish-Docker-Github-Action@main + with: + name: antaresrte/rte-antares + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + workdir: docker + dockerfile: centos7-system-deps + cache: false + tags: centos7-system-deps versions: runs-on: ubuntu-latest @@ -16,7 +41,7 @@ jobs: antares-xpansion-version: ${{steps.antares-xpansion-version.outputs.result}} antares-deps-version: ${{steps.antares-deps-version.outputs.result}} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v3.6.0 - name: Read antares-solver version id: antares-version uses: ./.github/actions/read-json-value @@ -41,40 +66,21 @@ jobs: build: runs-on: ubuntu-latest - needs: versions - container: 'centos:7' + needs: [ docker_publish, versions ] + container: 'antaresrte/rte-antares:centos7-system-deps' steps: - id: branch-name uses: tj-actions/branch-names@v6 - - name: Set up Python - run: | - yum update -y - yum install -y python3 python3-pip - pip3 install --upgrade pip - - - name: Install libraries - run: | - yum install -y wget git epel-release redhat-lsb-core gcc gcc-c++ make centos-release-scl scl-utils - yum install -y jsoncpp-devel gtest-devel openmpi-devel doxygen graphviz boost-program-options - yum install -y cmake3 devtoolset-9 environment-modules rpm-build zlib-devel - yum install -y rh-git227-git - yum install -y libuuid-devel - - - name: update bashrc - run: | - echo "source scl_source enable rh-git227" >> ~/.bashrc - echo "source scl_source enable devtoolset-9" >> ~/.bashrc - - - uses: actions/checkout@v3 + - uses: actions/checkout@v3.6.0 with: submodules: true - name: Install dependencies run: | + pip3 install wheel #Does not work in requirements pip3 install -r requirements-tests.txt - pip3 install -r requirements-ui.txt - name: Compile Boost uses: ./.github/workflows/compile-boost @@ -86,19 +92,26 @@ jobs: with: cmake: 'cmake3' + - name: Setup cmake + uses: jwlawson/actions-setup-cmake@v1.13 + with: + cmake-version: '3.22.x' + - name: Configure run: | + source /opt/rh/devtoolset-9/enable export LD_LIBRARY_PATH=/usr/lib64/openmpi/lib:$LD_LIBRARY_PATH export PATH=/usr/lib64/openmpi/bin:$PATH - cmake3 -B _build -S . \ + cmake -B _build -S . \ -DDEPS_INSTALL_DIR=rte-antares-deps-Release \ -DBUILD_TESTING=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=_install -DBUILD_UI=ON -DALLOW_RUN_AS_ROOT=ON - name: Build run: | + source /opt/rh/devtoolset-9/enable export LD_LIBRARY_PATH=/usr/lib64/openmpi/lib:$LD_LIBRARY_PATH export PATH=/usr/lib64/openmpi/bin:$PATH - cmake3 --build _build --config Release -j2 --target install + cmake --build _build --config Release -j2 --target install - name: Running unit tests run: | diff --git a/.github/workflows/publish_centos_docker.yml b/.github/workflows/publish_centos_docker.yml index 27f783454..12d7aa448 100644 --- a/.github/workflows/publish_centos_docker.yml +++ b/.github/workflows/publish_centos_docker.yml @@ -16,12 +16,12 @@ jobs: - name: Docker file push id: docker_push - uses: elgohr/Publish-Docker-Github-Action@master + uses: elgohr/Publish-Docker-Github-Action@main with: name: antaresrte/rte-antares username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} workdir: docker - dockerfile: centos7-bare + dockerfile: centos7-system-deps cache: false - tags: centos7-xpansion-bare \ No newline at end of file + tags: centos7-system-deps \ No newline at end of file diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index a32b8eb80..63e30b311 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -81,12 +81,12 @@ jobs: os: ${{matrix.os}} os-full-name: Ubuntu-20.04 buildtype: Debug - + - name: Compile Boost uses: ./.github/workflows/compile-boost - with: + with: prefix: "../rte-antares-deps-Release/" - + - name: Init submodule run: | diff --git a/.github/workflows/ubuntu-release.yml b/.github/workflows/ubuntu-release.yml index e6e7dfc25..49002094a 100644 --- a/.github/workflows/ubuntu-release.yml +++ b/.github/workflows/ubuntu-release.yml @@ -127,12 +127,12 @@ jobs: antares-version: ${{steps.antares-version.outputs.result}} os: ${{matrix.os}} os-full-name: Ubuntu-20.04 - + - name: Compile Boost uses: ./.github/workflows/compile-boost - with: + with: prefix: "../rte-antares-deps-Release/" - + - name: Download userguide uses: actions/download-artifact@v3 with: diff --git a/.github/workflows/windows-vcpkg-deps-build.yml b/.github/workflows/windows-vcpkg-deps-build.yml index 38be25c1a..0b832b1c2 100644 --- a/.github/workflows/windows-vcpkg-deps-build.yml +++ b/.github/workflows/windows-vcpkg-deps-build.yml @@ -83,9 +83,9 @@ jobs: shell: bash - name: Compile tbb - uses: ./.github/workflows/compile-tbb + uses: ./.github/workflows/compile-tbb with: - cmake: 'cmake' + cmake: 'cmake' - name: Configure run: | diff --git a/.github/workflows/windows-vcpkg.yml b/.github/workflows/windows-vcpkg.yml index a7e240815..063bdab22 100644 --- a/.github/workflows/windows-vcpkg.yml +++ b/.github/workflows/windows-vcpkg.yml @@ -154,10 +154,10 @@ jobs: shell: bash - name: Compile tbb - uses: ./.github/workflows/compile-tbb + uses: ./.github/workflows/compile-tbb with: - cmake: 'cmake' - + cmake: 'cmake' + - name: Download pre-compiled librairies uses: ./.github/workflows/download-extract-precompiled-libraries-zip with: diff --git a/CMakeLists.txt b/CMakeLists.txt index 4c2f72d2e..5e7050ca1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -349,20 +349,20 @@ install(DIRECTORY ${ANTARES_SOLVER_DIR}/../lib/ install(PROGRAMS ${ANTARES_SOLVER_PATH} TYPE BIN) - + find_package(antares-study-updater) if (antares-study-updater_FOUND) - if (${CMAKE_BUILD_TYPE} STREQUAL "Release") - get_target_property( ANTARES_STUDY_UPDATER_PATH antares-${ANTARES_VERSION}-study-updater IMPORTED_LOCATION_RELEASE ) - else() - get_target_property( ANTARES_STUDY_UPDATER_PATH antares-${ANTARES_VERSION}-study-updater IMPORTED_LOCATION_DEBUG ) - endif() + if (${CMAKE_BUILD_TYPE} STREQUAL "Release") + get_target_property(ANTARES_STUDY_UPDATER_PATH antares-${ANTARES_VERSION}-study-updater IMPORTED_LOCATION_RELEASE) + else () + get_target_property(ANTARES_STUDY_UPDATER_PATH antares-${ANTARES_VERSION}-study-updater IMPORTED_LOCATION_DEBUG) + endif () install(PROGRAMS ${ANTARES_STUDY_UPDATER_PATH} - TYPE BIN) - -endif() + TYPE BIN) + +endif () include (InstallRequiredSystemLibraries) diff --git a/docker/centos7 b/docker/centos7 deleted file mode 100644 index 976d2e93e..000000000 --- a/docker/centos7 +++ /dev/null @@ -1,46 +0,0 @@ -FROM centos:7 - -ARG ANTARES_DEPS_VERSION -ARG ANTARES_SOLVER_VERSION - -# Install requirements : update repo -RUN yum update -y - -# Install requirements : install epel -RUN yum install -y epel-release - -# Install requirements -RUN yum install -y git redhat-lsb-core gcc gcc-c++ make wget centos-release-scl scl-utils rpm-build &&\ - yum install -y cmake3 devtoolset-9 &&\ - yum install -y rh-git227-git - -# Install xpansion requirements -RUN yum install -y jsoncpp-devel gtest-devel openmpi-devel boost-openmpi-devel doxygen graphviz boost-program-options environment-modules rpm-build zlib-devel - -# Add python and pip installation for antares-xpansion -RUN yum install -y python3-pip &&\ - python3 -m pip install --upgrade pip &&\ - pip3 install pyinstaller pyyaml pytest numpy touch pytest-cov mkdocs mkdocs-material - -# Install tbb. tbb is required for execution policy (parallelization c++) but the system version is too old. -RUN git clone https://github.com/wjakob/tbb.git && \ - cd tbb/build && \ - cmake3 .. && \ - cmake3 --build . --target install -j8 - -# Download and extract pre-compiled libraries -RUN wget https://github.com/AntaresSimulatorTeam/antares-deps/releases/download/v${ANTARES_DEPS_VERSION}/rte-antares-deps-centos7-Release.tar.gz -RUN tar -xvf rte-antares-deps-centos7-Release.tar.gz -RUN rm -rf rte-antares-deps-centos7-Release.tar.gz - -RUN wget https://github.com/AntaresSimulatorTeam/Antares_Simulator/releases/download/v${ANTARES_SOLVER_VERSION}/antares-${ANTARES_SOLVER_VERSION}-CentOS-7.9.2009.tar.gz -RUN tar -xvf antares-${ANTARES_SOLVER_VERSION}-CentOS-7.9.2009-ortools-xpress.tar.gz -C rte-antares-deps-Release --strip-components=1 -RUN rm -rf antares-${ANTARES_SOLVER_VERSION}-CentOS-7.9.2009-ortools-xpress.tar.gz - -RUN yum install -y openmpi-devel -RUN wget https://github.com/boostorg/boost/releases/download/boost-1.81.0/boost-1.81.0.tar.gz \ - tar xvf boost-1.81.0.tar.gz \ - cd boost-1.81.0 \ - ./bootstrap.sh --with-libraries=serialization,program_options,mpi \ - echo "using mpi ;" >> project-config.jam \ - ./b2 install diff --git a/docker/centos7-bare b/docker/centos7-bare deleted file mode 100644 index 69a7e027a..000000000 --- a/docker/centos7-bare +++ /dev/null @@ -1,33 +0,0 @@ -FROM centos:7 - -# Install requirements: update repo -RUN yum update -y - -# Install requirements : install epel -RUN yum install -y epel-release - -# Install requirements -RUN yum install -y git redhat-lsb-core gcc gcc-c++ make wget centos-release-scl scl-utils rpm-build &&\ - yum install -y cmake3 devtoolset-9 - -RUN yum -y remove git && \ - yum -y install https://packages.endpointdev.com/rhel/7/os/x86_64/endpoint-repo.x86_64.rpm && \ - yum -y install git - -# Install xpansion requirements -RUN yum install -y jsoncpp-devel gtest-devel openmpi-devel doxygen graphviz environment-modules zlib-devel - -# Install tbb. tbb is required for execution policy (parallelization c++) but the system version is too old. -RUN git clone https://github.com/wjakob/tbb.git && \ - cd tbb/build && \ - cmake3 .. && \ - cmake3 --build . --target install -j8 - -# Add python and pip installation for antares-xpansion -RUN yum install -y python3-pip &&\ - python3 -m pip install --upgrade pip &&\ - pip3 install pyinstaller pyyaml pytest numpy touch pytest-cov mkdocs mkdocs-material - -#create user -RUN useradd user -# USER user diff --git a/docker/centos7-system-deps b/docker/centos7-system-deps new file mode 100644 index 000000000..753157e6c --- /dev/null +++ b/docker/centos7-system-deps @@ -0,0 +1,23 @@ +FROM centos:7 + +# Install requirements: update repo +RUN yum update -y + +# Install requirements : install epel +RUN yum install -y epel-release + +RUN \ + yum install -y wget git epel-release redhat-lsb-core gcc gcc-c++ make centos-release-scl scl-utils &&\ + yum install -y cmake3 devtoolset-9 environment-modules rpm-build zlib-devel &&\ + yum install -y jsoncpp-devel openmpi-devel doxygen graphviz &&\ + yum install -y gtest-devel &&\ + yum install -y install python3-devel && \ + yum install -y libuuid-devel + +RUN \ + yum -y install https://packages.endpointdev.com/rhel/7/os/x86_64/endpoint-repo.x86_64.rpm &&\ + yum install -y git + +#create user +RUN useradd user +# USER user From 0643037a5b545e3f7ab4bed81f2d40883383aa2b Mon Sep 17 00:00:00 2001 From: abdoulbari zakir <32519851+a-zakir@users.noreply.github.com> Date: Thu, 19 Oct 2023 06:42:22 -0700 Subject: [PATCH 2/2] fix mc-years bug --windows (#697) * implement SolverLogManager * check log filepath emptiness * move buffer initialization * check FILE* * logical * add check on file * define cbc model before it's file handler * deal with shared_ptr * Antares Simulator pre-release test * test version * update * test with simulator v8.7.1 * revert workflows * share solver log manager * update tests * run with simulator 8.8.0-rc2 * get rid of shared_ptr * add missings file * Avoid multiple procs to one file * cerr >>cout * Rollback * Test * Update SolverXpress.cpp * Update SolverXpress.cpp * Update antares_driver.py * Update SolverXpress.cpp * Update test_antares_driver.py * Update antares_driver.py * close log file * add test * Benders Step set Xpansion directory * fix test * fix test 2 * update * disable test * fix multiple call to fclose * restore * remove dev files * delete file * fix dangling ref --- antares-version.json | 4 +- src/cpp/benders/benders_core/BendersBase.cpp | 8 ++- .../benders/benders_core/SubproblemWorker.cpp | 5 +- src/cpp/benders/benders_core/Worker.cpp | 11 ++-- src/cpp/benders/benders_core/WorkerMaster.cpp | 13 ++--- .../benders_core/include/BendersBase.h | 4 +- .../benders_core/include/SubproblemWorker.h | 3 +- src/cpp/benders/benders_core/include/Worker.h | 2 +- .../benders_core/include/WorkerMaster.h | 3 +- src/cpp/benders/benders_mpi/BendersMPI.cpp | 4 +- .../benders_sequential/BendersSequential.cpp | 7 ++- src/cpp/benders/factories/BendersFactory.cpp | 3 +- src/cpp/benders/logger/UserFile.cpp | 6 +- src/cpp/lpnamer/main/RunProblemGeneration.cpp | 16 ++--- ...aresProblemToXpansionProblemTranslator.cpp | 5 +- ...ntaresProblemToXpansionProblemTranslator.h | 3 +- .../problem_modifier/IProblemProviderPort.h | 2 +- .../IXpansionProblemsProvider.h | 2 +- .../LinkProblemsGenerator.cpp | 11 ++-- .../problem_modifier/LinkProblemsGenerator.h | 11 ++-- .../MPSFileProblemProviderAdapter.cpp | 4 +- .../MPSFileProblemProviderAdapter.h | 2 +- .../problem_modifier/MasterGeneration.cpp | 8 +-- .../problem_modifier/MasterGeneration.h | 12 ++-- .../problem_modifier/MasterProblemBuilder.cpp | 4 +- .../problem_modifier/MasterProblemBuilder.h | 2 +- .../XpansionProblemsFromAntaresProvider.cpp | 4 +- .../XpansionProblemsFromAntaresProvider.h | 2 +- .../ZipProblemProviderAdapter.cpp | 4 +- .../ZipProblemProviderAdapter.h | 2 +- .../ZipProblemsProviderAdapter.cpp | 4 +- .../ZipProblemsProviderAdapter.h | 2 +- src/cpp/multisolver_interface/SolverCbc.cpp | 29 +++------- src/cpp/multisolver_interface/SolverCbc.h | 2 +- src/cpp/multisolver_interface/SolverClp.cpp | 28 +++------ src/cpp/multisolver_interface/SolverClp.h | 2 +- .../multisolver_interface/SolverFactory.cpp | 58 +++++++++++++++---- .../multisolver_interface/SolverXpress.cpp | 7 +-- src/cpp/multisolver_interface/SolverXpress.h | 2 +- .../multisolver_interface/SolverAbstract.h | 48 +++++++++++++++ .../multisolver_interface/SolverFactory.h | 4 +- src/python/antares_xpansion/__version__.py.in | 2 +- src/python/antares_xpansion/antares_driver.py | 2 +- src/python/antares_xpansion/config_loader.py | 8 +++ tests/cpp/benders/benders_sequential_test.cpp | 5 +- .../cpp/lp_namer/MasterProblemBuilderTest.cpp | 10 ++-- .../sensitivity/SensitivityPbModifierTest.cpp | 4 +- .../cpp/sensitivity/SensitivityStudyTest.cpp | 3 +- tests/python/test_antares_driver.py | 4 +- 49 files changed, 237 insertions(+), 154 deletions(-) diff --git a/antares-version.json b/antares-version.json index dd1aa7452..b9b8f0b57 100644 --- a/antares-version.json +++ b/antares-version.json @@ -1,6 +1,6 @@ { - "antares_version": "8.7.0", - "antares_version_executable": "8.7", + "antares_version": "8.8.0-rc2", + "antares_version_executable": "8.8", "antares_xpansion_version": "1.1.0", "antares_deps_version": "2.0.7", "minizip_ng_version": "3.0.6" diff --git a/src/cpp/benders/benders_core/BendersBase.cpp b/src/cpp/benders/benders_core/BendersBase.cpp index 4a04e1eb4..71e239603 100644 --- a/src/cpp/benders/benders_core/BendersBase.cpp +++ b/src/cpp/benders/benders_core/BendersBase.cpp @@ -654,8 +654,10 @@ LogData BendersBase::bendersDataToLogData( data.number_of_subproblem_resolved + cumulative_number_of_subproblem_resolved_before_resume}; } -void BendersBase::set_log_file(const std::filesystem::path &log_name) { - _log_name = log_name; +void BendersBase::set_log_file(const std::filesystem::path &log_file) { + _log_name = log_file; + + solver_log_manager_ = SolverLogManager(log_name()); } /*! @@ -715,7 +717,7 @@ void BendersBase::AddSubproblem( subproblem_map[kvp.first] = std::make_shared( kvp.second, GetSubproblemPath(kvp.first), SubproblemWeight(_data.nsubproblem, kvp.first), _options.SOLVER_NAME, - _options.LOG_LEVEL, log_name(), _logger); + _options.LOG_LEVEL, solver_log_manager_, _logger); } void BendersBase::free_subproblems() { diff --git a/src/cpp/benders/benders_core/SubproblemWorker.cpp b/src/cpp/benders/benders_core/SubproblemWorker.cpp index 8a0fc0e5e..111ed586b 100644 --- a/src/cpp/benders/benders_core/SubproblemWorker.cpp +++ b/src/cpp/benders/benders_core/SubproblemWorker.cpp @@ -13,9 +13,10 @@ SubproblemWorker::SubproblemWorker( VariableMap const &variable_map, const std::filesystem::path &path_to_mps, double const &slave_weight, const std::string &solver_name, - const int log_level, const std::filesystem::path &log_name, Logger logger) + const int log_level, SolverLogManager&solver_log_manager, + Logger logger) : Worker(logger) { - init(variable_map, path_to_mps, solver_name, log_level, log_name); + init(variable_map, path_to_mps, solver_name, log_level, solver_log_manager); int mps_ncols(_solver->get_ncols()); DblVector obj_func_coeffs(mps_ncols); diff --git a/src/cpp/benders/benders_core/Worker.cpp b/src/cpp/benders/benders_core/Worker.cpp index b0525c285..8eb22cb49 100644 --- a/src/cpp/benders/benders_core/Worker.cpp +++ b/src/cpp/benders/benders_core/Worker.cpp @@ -37,15 +37,16 @@ void Worker::get_value(double &lb) const { void Worker::init(VariableMap const &variable_map, const std::filesystem::path &path_to_mps, std::string const &solver_name, int log_level, - const std::filesystem::path &log_name) { + SolverLogManager&solver_log_manager) { _path_to_mps = path_to_mps; SolverFactory factory; + if (_is_master) { - _solver = - factory.create_solver(solver_name, SOLVER_TYPE::INTEGER, log_name); + _solver = factory.create_solver(solver_name, SOLVER_TYPE::INTEGER, + solver_log_manager); } else { - _solver = - factory.create_solver(solver_name, SOLVER_TYPE::CONTINUOUS, log_name); + _solver = factory.create_solver(solver_name, SOLVER_TYPE::CONTINUOUS, + solver_log_manager); } _solver->init(); diff --git a/src/cpp/benders/benders_core/WorkerMaster.cpp b/src/cpp/benders/benders_core/WorkerMaster.cpp index f9b0ad757..1758511fd 100644 --- a/src/cpp/benders/benders_core/WorkerMaster.cpp +++ b/src/cpp/benders/benders_core/WorkerMaster.cpp @@ -19,18 +19,17 @@ WorkerMaster::WorkerMaster(Logger logger) : Worker(logger) { * \param log_level : solver log level * \param subproblems_count : number of subproblems */ -WorkerMaster::WorkerMaster(VariableMap const &variable_map, - const std::filesystem::path &path_to_mps, - const std::string &solver_name, const int log_level, - int subproblems_count, - const std::filesystem::path &log_name, - const bool mps_has_alpha, Logger logger) +WorkerMaster::WorkerMaster( + VariableMap const &variable_map, const std::filesystem::path &path_to_mps, + const std::string &solver_name, const int log_level, int subproblems_count, + SolverLogManager&solver_log_manager, + const bool mps_has_alpha, Logger logger) : Worker(logger), subproblems_count(subproblems_count), _mps_has_alpha(mps_has_alpha) { _is_master = true; - init(variable_map, path_to_mps, solver_name, log_level, log_name); + init(variable_map, path_to_mps, solver_name, log_level, solver_log_manager); if (!_mps_has_alpha) { _set_upper_bounds(); } diff --git a/src/cpp/benders/benders_core/include/BendersBase.h b/src/cpp/benders/benders_core/include/BendersBase.h index ca4b05472..19b38c97c 100644 --- a/src/cpp/benders/benders_core/include/BendersBase.h +++ b/src/cpp/benders/benders_core/include/BendersBase.h @@ -136,6 +136,8 @@ class BendersBase { return cumulative_number_of_subproblem_resolved_before_resume; } + SolverLogManager solver_log_manager_; + private: void print_master_and_cut(std::ostream &file, int ite, WorkerMasterDataPtr &trace, Point const &xopt); @@ -157,7 +159,7 @@ class BendersBase { private: BendersBaseOptions _options; unsigned int _totalNbProblems = 0; - std::filesystem::path _log_name; + std::filesystem::path _log_name = ""; BendersRelevantIterationsData relevantIterationData_ = { std::make_shared(), nullptr}; WorkerMasterPtr _master; diff --git a/src/cpp/benders/benders_core/include/SubproblemWorker.h b/src/cpp/benders/benders_core/include/SubproblemWorker.h index ef745f545..9af7bcd0b 100644 --- a/src/cpp/benders/benders_core/include/SubproblemWorker.h +++ b/src/cpp/benders/benders_core/include/SubproblemWorker.h @@ -18,7 +18,8 @@ class SubproblemWorker : public Worker { SubproblemWorker(VariableMap const &variable_map, const std::filesystem::path &path_to_mps, double const &slave_weight, const std::string &solver_name, - const int log_level, const std::filesystem::path &log_name, + const int log_level, + SolverLogManager&solver_log_manager, Logger logger); virtual ~SubproblemWorker() = default; diff --git a/src/cpp/benders/benders_core/include/Worker.h b/src/cpp/benders/benders_core/include/Worker.h index 5641416fa..b41a5521c 100644 --- a/src/cpp/benders/benders_core/include/Worker.h +++ b/src/cpp/benders/benders_core/include/Worker.h @@ -22,7 +22,7 @@ class Worker { void init(VariableMap const &variable_map, const std::filesystem::path &path_to_mps, std::string const &solver_name, int log_level, - const std::filesystem::path &log_name); + SolverLogManager&solver_log_manager); virtual ~Worker() = default; void get_value(double &lb) const; diff --git a/src/cpp/benders/benders_core/include/WorkerMaster.h b/src/cpp/benders/benders_core/include/WorkerMaster.h index ac09b1483..fa64ff561 100644 --- a/src/cpp/benders/benders_core/include/WorkerMaster.h +++ b/src/cpp/benders/benders_core/include/WorkerMaster.h @@ -15,7 +15,8 @@ class WorkerMaster : public Worker { WorkerMaster(VariableMap const &variable_map, const std::filesystem::path &path_to_mps, const std::string &solver_name, const int log_level, - int subproblems_count, const std::filesystem::path &log_name, + int subproblems_count, + SolverLogManager&solver_log_manager, bool mps_has_alpha, Logger logger); virtual ~WorkerMaster() = default; diff --git a/src/cpp/benders/benders_mpi/BendersMPI.cpp b/src/cpp/benders/benders_mpi/BendersMPI.cpp index 5757066fd..5c86a6f35 100644 --- a/src/cpp/benders/benders_mpi/BendersMPI.cpp +++ b/src/cpp/benders/benders_mpi/BendersMPI.cpp @@ -44,8 +44,8 @@ void BendersMpi::BuildMasterProblem() { if (_world.rank() == rank_0) { reset_master(new WorkerMaster(master_variable_map, get_master_path(), get_solver_name(), get_log_level(), - _data.nsubproblem, log_name(), IsResumeMode(), - _logger)); + _data.nsubproblem, solver_log_manager_, + IsResumeMode(), _logger)); } } /*! diff --git a/src/cpp/benders/benders_sequential/BendersSequential.cpp b/src/cpp/benders/benders_sequential/BendersSequential.cpp index ff3464969..e595ba17d 100644 --- a/src/cpp/benders/benders_sequential/BendersSequential.cpp +++ b/src/cpp/benders/benders_sequential/BendersSequential.cpp @@ -24,9 +24,10 @@ BendersSequential::BendersSequential(BendersBaseOptions const &options, void BendersSequential::InitializeProblems() { MatchProblemToId(); - reset_master(new WorkerMaster( - master_variable_map, get_master_path(), get_solver_name(), - get_log_level(), _data.nsubproblem, log_name(), IsResumeMode(), _logger)); + reset_master(new WorkerMaster(master_variable_map, get_master_path(), + get_solver_name(), get_log_level(), + _data.nsubproblem, solver_log_manager_, + IsResumeMode(), _logger)); for (const auto &problem : coupling_map) { const auto subProblemFilePath = GetSubproblemPath(problem.first); diff --git a/src/cpp/benders/factories/BendersFactory.cpp b/src/cpp/benders/factories/BendersFactory.cpp index 58b1b702a..35df81627 100644 --- a/src/cpp/benders/factories/BendersFactory.cpp +++ b/src/cpp/benders/factories/BendersFactory.cpp @@ -64,6 +64,7 @@ int RunBenders(char** argv, const std::filesystem::path& options_file, std::ostringstream oss_l = start_message(options, benders->BendersName()); oss_l << std::endl; logger->display_message(oss_l.str()); + benders->set_log_file(log_reports_name); writer->write_log_level(options.LOG_LEVEL); @@ -118,4 +119,4 @@ BendersMainFactory::BendersMainFactory( } int BendersMainFactory::Run() const { return RunBenders(argv_, options_file_, *penv_, *pworld_, method_); -} \ No newline at end of file +} diff --git a/src/cpp/benders/logger/UserFile.cpp b/src/cpp/benders/logger/UserFile.cpp index 2668fdb18..b856f72d7 100644 --- a/src/cpp/benders/logger/UserFile.cpp +++ b/src/cpp/benders/logger/UserFile.cpp @@ -24,7 +24,11 @@ UserFile::UserFile(const std::filesystem::path &filename) { } } -UserFile::~UserFile() { _file.close(); } +UserFile::~UserFile() { + if (_file.is_open()) { + _file.close(); + } +} void UserFile::display_message(const std::string &str) { _file << PrefixMessage(LogUtils::LOGLEVEL::INFO, CONTEXT) << str << std::endl; diff --git a/src/cpp/lpnamer/main/RunProblemGeneration.cpp b/src/cpp/lpnamer/main/RunProblemGeneration.cpp index f08164257..c6cbf682f 100644 --- a/src/cpp/lpnamer/main/RunProblemGeneration.cpp +++ b/src/cpp/lpnamer/main/RunProblemGeneration.cpp @@ -117,7 +117,7 @@ void validateMasterFormulation( } std::vector> getXpansionProblems( - const std::filesystem::path& log_file_path, const std::string& solver_name, + SolverLogManager& solver_log_manager, const std::string& solver_name, const std::vector& mpsList, std::filesystem::path& lpDir_, std::shared_ptr& reader) { std::vector problem_names; @@ -126,7 +126,7 @@ std::vector> getXpansionProblems( [](ProblemData const& data) { return data._problem_mps; }); auto adapter = std::make_shared(lpDir_, reader, problem_names); - return adapter->provideProblems(solver_name, log_file_path); + return adapter->provideProblems(solver_name, solver_log_manager); } void RunProblemGeneration( const std::filesystem::path& xpansion_output_dir, @@ -171,16 +171,18 @@ void RunProblemGeneration( bool use_zip_implementation = true; bool use_file_implementation = false; + + auto solver_log_manager = SolverLogManager(log_file_path); Couplings couplings; - LinkProblemsGenerator linkProblemsGenerator(lpDir_, links, solver_name, - logger, log_file_path, rename_problems); + LinkProblemsGenerator linkProblemsGenerator( + lpDir_, links, solver_name, logger, solver_log_manager, rename_problems); if (use_zip_implementation) { std::shared_ptr reader = InstantiateZipReader(antares_archive_path); /* Main stuff */ std::vector> xpansion_problems = - getXpansionProblems(log_file_path, solver_name, mpsList, lpDir_, + getXpansionProblems(solver_log_manager, solver_name, mpsList, lpDir_, reader); std::vector, ProblemData>> @@ -228,7 +230,7 @@ void RunProblemGeneration( XpansionProblemsFromAntaresProvider adapter(lps); auto xpansion_problems = - adapter.provideProblems(solver_name, log_file_path); + adapter.provideProblems(solver_name, solver_log_manager); std::vector, ProblemData>> problems_and_data; for (int i = 0; i < xpansion_problems.size(); ++i) { @@ -259,7 +261,7 @@ void RunProblemGeneration( MasterGeneration master_generation( xpansion_output_dir, links, additionalConstraints, couplings, - master_formulation, solver_name, logger, log_file_path); + master_formulation, solver_name, logger, solver_log_manager); (*logger)(LogUtils::LOGLEVEL::INFO) << "Problem Generation ran in: " << format_time_str(problem_generation_timer.elapsed()) << std::endl; diff --git a/src/cpp/lpnamer/problem_modifier/AntaresProblemToXpansionProblemTranslator.cpp b/src/cpp/lpnamer/problem_modifier/AntaresProblemToXpansionProblemTranslator.cpp index 4268e6fdc..8c1ee291d 100644 --- a/src/cpp/lpnamer/problem_modifier/AntaresProblemToXpansionProblemTranslator.cpp +++ b/src/cpp/lpnamer/problem_modifier/AntaresProblemToXpansionProblemTranslator.cpp @@ -11,11 +11,10 @@ std::shared_ptr AntaresProblemToXpansionProblemTranslator::translateToXpansionProblem( const LpsFromAntares& lps, unsigned int year, unsigned int week, - const std::string& solver_name, - const std::filesystem::path& log_file_path) { + const std::string& solver_name, SolverLogManager& solver_log_manager) { SolverFactory factory; auto problem = std::make_shared( - factory.create_solver(solver_name, log_file_path)); + factory.create_solver(solver_name, solver_log_manager)); problem->init(); const auto& constant = lps._constant; const auto& hebdo = lps._hebdo.at({year, week}); diff --git a/src/cpp/lpnamer/problem_modifier/AntaresProblemToXpansionProblemTranslator.h b/src/cpp/lpnamer/problem_modifier/AntaresProblemToXpansionProblemTranslator.h index 354a75300..1c6e2fa48 100644 --- a/src/cpp/lpnamer/problem_modifier/AntaresProblemToXpansionProblemTranslator.h +++ b/src/cpp/lpnamer/problem_modifier/AntaresProblemToXpansionProblemTranslator.h @@ -11,7 +11,6 @@ class AntaresProblemToXpansionProblemTranslator { public: [[nodiscard]] static std::shared_ptr translateToXpansionProblem( const LpsFromAntares& lps, unsigned int year, unsigned int week, - const std::string& solver_name, - const std::filesystem::path& log_file_path); + const std::string& solver_name, SolverLogManager& solver_log_manager); static std::vector convertSignToLEG(char* data); }; diff --git a/src/cpp/lpnamer/problem_modifier/IProblemProviderPort.h b/src/cpp/lpnamer/problem_modifier/IProblemProviderPort.h index 02770f866..0c85a9568 100644 --- a/src/cpp/lpnamer/problem_modifier/IProblemProviderPort.h +++ b/src/cpp/lpnamer/problem_modifier/IProblemProviderPort.h @@ -11,5 +11,5 @@ class IProblemProviderPort { virtual ~IProblemProviderPort() = default; [[nodiscard]] virtual std::shared_ptr provide_problem( const std::string& solver_name, - const std::filesystem::path& log_file_path) const = 0; + SolverLogManager& solver_log_manager) const = 0; }; diff --git a/src/cpp/lpnamer/problem_modifier/IXpansionProblemsProvider.h b/src/cpp/lpnamer/problem_modifier/IXpansionProblemsProvider.h index 21ce5f5cb..89c3e24ed 100644 --- a/src/cpp/lpnamer/problem_modifier/IXpansionProblemsProvider.h +++ b/src/cpp/lpnamer/problem_modifier/IXpansionProblemsProvider.h @@ -12,5 +12,5 @@ class IXpansionProblemsProvider { virtual ~IXpansionProblemsProvider() = default; [[nodiscard]] virtual std::vector> provideProblems( const std::string& solver_name, - const std::filesystem::path& log_file_path) const = 0; + SolverLogManager& solver_log_manager) const = 0; }; diff --git a/src/cpp/lpnamer/problem_modifier/LinkProblemsGenerator.cpp b/src/cpp/lpnamer/problem_modifier/LinkProblemsGenerator.cpp index 5c4259bf8..2f741eae4 100644 --- a/src/cpp/lpnamer/problem_modifier/LinkProblemsGenerator.cpp +++ b/src/cpp/lpnamer/problem_modifier/LinkProblemsGenerator.cpp @@ -29,18 +29,16 @@ void LinkProblemsGenerator::treat( const std::string &problem_name, Couplings &couplings, IProblemProviderPort *problem_provider, - IProblemVariablesProviderPort *variable_provider, - IProblemWriter *writer) const { + IProblemVariablesProviderPort *variable_provider, IProblemWriter *writer) { auto in_prblm = - problem_provider->provide_problem(_solver_name, log_file_path_); + problem_provider->provide_problem(_solver_name, solver_log_manager_); treat(problem_name, couplings, in_prblm.get(), variable_provider, writer); } void LinkProblemsGenerator::treat( const std::string &problem_name, Couplings &couplings, Problem *problem, - IProblemVariablesProviderPort *variable_provider, - IProblemWriter *writer) const { + IProblemVariablesProviderPort *variable_provider, IProblemWriter *writer) { ProblemVariables problem_variables = variable_provider->Provide(); if (rename_problems_) { @@ -74,7 +72,8 @@ void LinkProblemsGenerator::treatloop(const std::filesystem::path &root, [&](const auto &mps) { auto adapter = std::make_unique( root, mps._problem_mps); - auto problem = adapter->provide_problem(_solver_name, log_file_path_); + auto problem = + adapter->provide_problem(_solver_name, solver_log_manager_); std::unique_ptr variables_provider; if (rename_problems_) { variables_provider = std::make_unique( diff --git a/src/cpp/lpnamer/problem_modifier/LinkProblemsGenerator.h b/src/cpp/lpnamer/problem_modifier/LinkProblemsGenerator.h index 59ab56e47..cb75ed2b0 100644 --- a/src/cpp/lpnamer/problem_modifier/LinkProblemsGenerator.h +++ b/src/cpp/lpnamer/problem_modifier/LinkProblemsGenerator.h @@ -32,13 +32,12 @@ class LinkProblemsGenerator { std::filesystem::path& lpDir, const std::vector& links, std::string solver_name, ProblemGenerationLog::ProblemGenerationLoggerSharedPointer logger, - std::filesystem::path log_file_path, - bool rename_problems) + SolverLogManager& solver_log_manager, bool rename_problems) : _links(links), _solver_name(std::move(solver_name)), lpDir_(lpDir), logger_(std::move(logger)), - log_file_path_(std::move(log_file_path)), + solver_log_manager_(solver_log_manager), rename_problems_(rename_problems) {} void treatloop(const std::filesystem::path& root, Couplings& couplings, @@ -46,11 +45,11 @@ class LinkProblemsGenerator { IProblemWriter* writer); void treat(const std::string& problem_name, Couplings& couplings, Problem* problem, IProblemVariablesProviderPort* variable_provider, - IProblemWriter* writer) const; + IProblemWriter* writer); void treat(const std::string& problem_name, Couplings& couplings, IProblemProviderPort* problem_provider, IProblemVariablesProviderPort* variable_provider, - IProblemWriter* writer) const; + IProblemWriter* writer); private: const std::vector& _links; @@ -58,6 +57,6 @@ class LinkProblemsGenerator { std::filesystem::path lpDir_ = ""; ProblemGenerationLog::ProblemGenerationLoggerSharedPointer logger_; mutable std::mutex coupling_mutex_; - std::filesystem::path log_file_path_; bool rename_problems_ = false; + SolverLogManager& solver_log_manager_; }; diff --git a/src/cpp/lpnamer/problem_modifier/MPSFileProblemProviderAdapter.cpp b/src/cpp/lpnamer/problem_modifier/MPSFileProblemProviderAdapter.cpp index be09c7565..533e4cb90 100644 --- a/src/cpp/lpnamer/problem_modifier/MPSFileProblemProviderAdapter.cpp +++ b/src/cpp/lpnamer/problem_modifier/MPSFileProblemProviderAdapter.cpp @@ -9,11 +9,11 @@ #include "multisolver_interface/SolverFactory.h" std::shared_ptr MPSFileProblemProviderAdapter::provide_problem( const std::string& solver_name, - const std::filesystem::path& log_file_path) const { + SolverLogManager& solver_log_manager) const { SolverFactory factory; auto const lp_mps_name = lp_dir_ / problem_name_; auto in_prblm = std::make_shared( - factory.create_solver(solver_name, log_file_path)); + factory.create_solver(solver_name, solver_log_manager)); in_prblm->read_prob_mps(lp_mps_name); return in_prblm; diff --git a/src/cpp/lpnamer/problem_modifier/MPSFileProblemProviderAdapter.h b/src/cpp/lpnamer/problem_modifier/MPSFileProblemProviderAdapter.h index 6df68af81..712152315 100644 --- a/src/cpp/lpnamer/problem_modifier/MPSFileProblemProviderAdapter.h +++ b/src/cpp/lpnamer/problem_modifier/MPSFileProblemProviderAdapter.h @@ -11,7 +11,7 @@ class MPSFileProblemProviderAdapter : public IProblemProviderPort { const std::string& problem_name); [[nodiscard]] std::shared_ptr provide_problem( const std::string& solver_name, - const std::filesystem::path& log_file_path) const override; + SolverLogManager& solver_log_manager) const override; const std::filesystem::path lp_dir_; const std::string& problem_name_; }; diff --git a/src/cpp/lpnamer/problem_modifier/MasterGeneration.cpp b/src/cpp/lpnamer/problem_modifier/MasterGeneration.cpp index 59001d5df..79552088e 100644 --- a/src/cpp/lpnamer/problem_modifier/MasterGeneration.cpp +++ b/src/cpp/lpnamer/problem_modifier/MasterGeneration.cpp @@ -12,11 +12,11 @@ MasterGeneration::MasterGeneration( const AdditionalConstraints &additionalConstraints_p, Couplings &couplings, std::string const &master_formulation, std::string const &solver_name, ProblemGenerationLog::ProblemGenerationLoggerSharedPointer logger, - const std::filesystem::path &log_file_path) + SolverLogManager&solver_log_manager) : logger_(logger) { add_candidates(links); write_master_mps(rootPath, master_formulation, solver_name, - additionalConstraints_p, log_file_path); + additionalConstraints_p, solver_log_manager); write_structure_file(rootPath, couplings); } @@ -36,10 +36,10 @@ void MasterGeneration::write_master_mps( const std::filesystem::path &rootPath, std::string const &master_formulation, std::string const &solver_name, const AdditionalConstraints &additionalConstraints_p, - const std::filesystem::path &log_file_path) const { + SolverLogManager&solver_log_manager) const { SolverAbstract::Ptr master_l = MasterProblemBuilder(master_formulation) - .build(solver_name, candidates, log_file_path); + .build(solver_name, candidates, solver_log_manager); treatAdditionalConstraints(master_l, additionalConstraints_p, logger_); std::string const &lp_name = "master"; diff --git a/src/cpp/lpnamer/problem_modifier/MasterGeneration.h b/src/cpp/lpnamer/problem_modifier/MasterGeneration.h index 7c9588df9..e284e2c12 100644 --- a/src/cpp/lpnamer/problem_modifier/MasterGeneration.h +++ b/src/cpp/lpnamer/problem_modifier/MasterGeneration.h @@ -25,15 +25,15 @@ class MasterGeneration { Couplings &couplings, std::string const &master_formulation, std::string const &solver_name, ProblemGenerationLog::ProblemGenerationLoggerSharedPointer logger, - const std::filesystem::path &log_file_path); + SolverLogManager&solver_log_manager); private: /*methods*/ void add_candidates(const std::vector &links); - void write_master_mps(const std::filesystem::path &rootPath, - std::string const &master_formulation, - std::string const &solver_name, - const AdditionalConstraints &additionalConstraints_p, - const std::filesystem::path &log_file_path) const; + void write_master_mps( + const std::filesystem::path &rootPath, + std::string const &master_formulation, std::string const &solver_name, + const AdditionalConstraints &additionalConstraints_p, + SolverLogManager&solver_log_manager) const; void write_structure_file(const std::filesystem::path &rootPath, const Couplings &couplings) const; diff --git a/src/cpp/lpnamer/problem_modifier/MasterProblemBuilder.cpp b/src/cpp/lpnamer/problem_modifier/MasterProblemBuilder.cpp index 66ad8a7dd..8830d15b8 100644 --- a/src/cpp/lpnamer/problem_modifier/MasterProblemBuilder.cpp +++ b/src/cpp/lpnamer/problem_modifier/MasterProblemBuilder.cpp @@ -16,12 +16,12 @@ MasterProblemBuilder::MasterProblemBuilder( std::shared_ptr MasterProblemBuilder::build( const std::string& solverName, const std::vector& candidates, - const std::filesystem::path& log_file_path) { + SolverLogManager& solver_log_manager) { _indexOfNvar.clear(); _indexOfPmaxVar.clear(); SolverFactory factory; - auto master_l = factory.create_solver(solverName, log_file_path); + auto master_l = factory.create_solver(solverName, solver_log_manager); addVariablesPmaxOnEachCandidate(candidates, master_l); diff --git a/src/cpp/lpnamer/problem_modifier/MasterProblemBuilder.h b/src/cpp/lpnamer/problem_modifier/MasterProblemBuilder.h index 8633edb13..28cfabe05 100644 --- a/src/cpp/lpnamer/problem_modifier/MasterProblemBuilder.h +++ b/src/cpp/lpnamer/problem_modifier/MasterProblemBuilder.h @@ -19,7 +19,7 @@ class MasterProblemBuilder { explicit MasterProblemBuilder(const std::string& master_formulation); std::shared_ptr build( const std::string& solverName, const std::vector& candidates, - const std::filesystem::path& log_file_path); + SolverLogManager& solver_log_manager); private: void addNvarOnEachIntegerCandidate( diff --git a/src/cpp/lpnamer/problem_modifier/XpansionProblemsFromAntaresProvider.cpp b/src/cpp/lpnamer/problem_modifier/XpansionProblemsFromAntaresProvider.cpp index f4f7aa79d..090095e89 100644 --- a/src/cpp/lpnamer/problem_modifier/XpansionProblemsFromAntaresProvider.cpp +++ b/src/cpp/lpnamer/problem_modifier/XpansionProblemsFromAntaresProvider.cpp @@ -16,7 +16,7 @@ XpansionProblemsFromAntaresProvider::XpansionProblemsFromAntaresProvider( std::vector> XpansionProblemsFromAntaresProvider::provideProblems( const std::string& solver_name, - const std::filesystem::path& log_file_path) const { + SolverLogManager& solver_log_manager) const { std::vector> xpansion_problems; xpansion_problems.reserve( XpansionProblemsFromAntaresProvider::antares_hebdo_problems._hebdo @@ -26,7 +26,7 @@ XpansionProblemsFromAntaresProvider::provideProblems( xpansion_problems.push_back( AntaresProblemToXpansionProblemTranslator::translateToXpansionProblem( XpansionProblemsFromAntaresProvider::antares_hebdo_problems, - problem_id.year, problem_id.week, solver_name, log_file_path)); + problem_id.year, problem_id.week, solver_name, solver_log_manager)); } return xpansion_problems; } \ No newline at end of file diff --git a/src/cpp/lpnamer/problem_modifier/XpansionProblemsFromAntaresProvider.h b/src/cpp/lpnamer/problem_modifier/XpansionProblemsFromAntaresProvider.h index 576044fb1..7a1a09c4d 100644 --- a/src/cpp/lpnamer/problem_modifier/XpansionProblemsFromAntaresProvider.h +++ b/src/cpp/lpnamer/problem_modifier/XpansionProblemsFromAntaresProvider.h @@ -13,6 +13,6 @@ class XpansionProblemsFromAntaresProvider : public IXpansionProblemsProvider { explicit XpansionProblemsFromAntaresProvider(LpsFromAntares antares); [[nodiscard]] std::vector> provideProblems( const std::string& solver_name, - const std::filesystem::path& log_file_path) const override; + SolverLogManager& solver_log_manager) const override; LpsFromAntares antares_hebdo_problems; }; diff --git a/src/cpp/lpnamer/problem_modifier/ZipProblemProviderAdapter.cpp b/src/cpp/lpnamer/problem_modifier/ZipProblemProviderAdapter.cpp index 5406f89bc..a8bf4a9a8 100644 --- a/src/cpp/lpnamer/problem_modifier/ZipProblemProviderAdapter.cpp +++ b/src/cpp/lpnamer/problem_modifier/ZipProblemProviderAdapter.cpp @@ -17,13 +17,13 @@ void ZipProblemProviderAdapter::reader_extract_file( std::shared_ptr ZipProblemProviderAdapter::provide_problem( const std::string& solver_name, - const std::filesystem::path& log_file_path) const { + SolverLogManager& solver_log_manager) const { reader_extract_file(problem_name_, *archive_reader_, lp_dir_); SolverFactory factory; auto const lp_mps_name = ZipProblemProviderAdapter::lp_dir_ / ZipProblemProviderAdapter::problem_name_; auto in_prblm = std::make_shared( - factory.create_solver(solver_name, log_file_path)); + factory.create_solver(solver_name, solver_log_manager)); in_prblm->read_prob_mps(lp_mps_name); return in_prblm; diff --git a/src/cpp/lpnamer/problem_modifier/ZipProblemProviderAdapter.h b/src/cpp/lpnamer/problem_modifier/ZipProblemProviderAdapter.h index 9c1d4c480..75ebc4f2b 100644 --- a/src/cpp/lpnamer/problem_modifier/ZipProblemProviderAdapter.h +++ b/src/cpp/lpnamer/problem_modifier/ZipProblemProviderAdapter.h @@ -18,6 +18,6 @@ class ZipProblemProviderAdapter : public IProblemProviderPort { const std::string problem_name_; [[nodiscard]] std::shared_ptr provide_problem( const std::string& solver_name, - const std::filesystem::path& log_file_path) const override; + SolverLogManager& solver_log_manager) const override; std::shared_ptr archive_reader_; }; diff --git a/src/cpp/lpnamer/problem_modifier/ZipProblemsProviderAdapter.cpp b/src/cpp/lpnamer/problem_modifier/ZipProblemsProviderAdapter.cpp index e7047a539..bf8aeae6f 100644 --- a/src/cpp/lpnamer/problem_modifier/ZipProblemsProviderAdapter.cpp +++ b/src/cpp/lpnamer/problem_modifier/ZipProblemsProviderAdapter.cpp @@ -13,7 +13,7 @@ std::vector> ZipProblemsProviderAdapter::provideProblems( const std::string& solver_name, - const std::filesystem::path& log_file_path) const { + SolverLogManager& solver_log_manager) const { std::vector> problems(problem_names_.size()); // Order is important. Problems need to be in the same order as names std::transform(std::execution::par, @@ -23,7 +23,7 @@ ZipProblemsProviderAdapter::provideProblems( ZipProblemProviderAdapter problem_provider(lp_dir_, name, archive_reader_); return problem_provider.provide_problem(solver_name, - log_file_path); + solver_log_manager); }); return problems; } diff --git a/src/cpp/lpnamer/problem_modifier/ZipProblemsProviderAdapter.h b/src/cpp/lpnamer/problem_modifier/ZipProblemsProviderAdapter.h index 4a53f4907..0036bd8dc 100644 --- a/src/cpp/lpnamer/problem_modifier/ZipProblemsProviderAdapter.h +++ b/src/cpp/lpnamer/problem_modifier/ZipProblemsProviderAdapter.h @@ -13,7 +13,7 @@ class ZipProblemsProviderAdapter : public IXpansionProblemsProvider { std::vector problem_names); [[nodiscard]] std::vector> provideProblems( const std::string& solver_name, - const std::filesystem::path& log_file_path) const override; + SolverLogManager& solver_log_manager) const override; std::shared_ptr archive_reader_; std::filesystem::path lp_dir_; std::vector problem_names_; diff --git a/src/cpp/multisolver_interface/SolverCbc.cpp b/src/cpp/multisolver_interface/SolverCbc.cpp index d7e689234..06d3de0fc 100644 --- a/src/cpp/multisolver_interface/SolverCbc.cpp +++ b/src/cpp/multisolver_interface/SolverCbc.cpp @@ -8,20 +8,14 @@ *************************************************************************************************/ int SolverCbc::_NumberOfProblems = 0; -SolverCbc::SolverCbc(const std::filesystem::path &log_file) : SolverCbc() { - _log_file = log_file; - if (_log_file.empty()) { +SolverCbc::SolverCbc(SolverLogManager &log_manager) : SolverCbc() { + _fp = log_manager.log_file_ptr; + if (!_fp) { std::cout << "Empty log file name, fallback to default behaviour" << std::endl; } else { - if ((_fp = fopen(_log_file.string().c_str(), "a+")) == nullptr) { - std::cerr << "Invalid log file name passed as parameter: " << _log_file - << std::endl; - } else { - setvbuf(_fp, nullptr, _IONBF, 0); - _clp_inner_solver.messageHandler()->setFilePointer(_fp); - _cbc.messageHandler()->setFilePointer(_fp); - } + _clp_inner_solver.messageHandler()->setFilePointer(_fp); + _cbc.messageHandler()->setFilePointer(_fp); } } SolverCbc::SolverCbc() { @@ -34,14 +28,13 @@ SolverCbc::SolverCbc(const std::shared_ptr toCopy) // Try to cast the solver in fictif to a SolverCbc if (const auto c = dynamic_cast(toCopy.get())) { _clp_inner_solver = OsiClpSolverInterface(c->_clp_inner_solver); - _log_file = toCopy->_log_file; - _fp = fopen(_log_file.string().c_str(), "a+"); - if (_fp != nullptr) { - setvbuf(_fp, nullptr, _IONBF, 0); + + defineCbcModelFromInnerSolver(); + _fp = c->_fp; + if (_fp) { _clp_inner_solver.messageHandler()->setFilePointer(_fp); _cbc.messageHandler()->setFilePointer(_fp); } - defineCbcModelFromInnerSolver(); } else { _NumberOfProblems -= 1; throw InvalidSolverForCopyException(toCopy->get_solver_name(), name_, @@ -51,10 +44,6 @@ SolverCbc::SolverCbc(const std::shared_ptr toCopy) SolverCbc::~SolverCbc() { _NumberOfProblems -= 1; - if (_fp != nullptr) { - fclose(_fp); - _fp = nullptr; - } free(); } diff --git a/src/cpp/multisolver_interface/SolverCbc.h b/src/cpp/multisolver_interface/SolverCbc.h index 57484779a..f81228f0d 100644 --- a/src/cpp/multisolver_interface/SolverCbc.h +++ b/src/cpp/multisolver_interface/SolverCbc.h @@ -39,7 +39,7 @@ class SolverCbc : public SolverAbstract { * @brief Default constructor of a CBC solver */ SolverCbc(); - explicit SolverCbc(const std::filesystem::path &log_file); + explicit SolverCbc(SolverLogManager&log_manager); /** * @brief Copy constructor of solver, copy the problem toCopy in memory and diff --git a/src/cpp/multisolver_interface/SolverClp.cpp b/src/cpp/multisolver_interface/SolverClp.cpp index 1071ed073..e770a6e60 100644 --- a/src/cpp/multisolver_interface/SolverClp.cpp +++ b/src/cpp/multisolver_interface/SolverClp.cpp @@ -8,38 +8,28 @@ *************************************************************************************************/ int SolverClp::_NumberOfProblems = 0; -SolverClp::SolverClp(const std::filesystem::path &log_file) : SolverClp() { - _log_file = log_file; - if (_log_file.empty()) { +SolverClp::SolverClp(SolverLogManager &log_manager) : SolverClp() { + _fp = log_manager.log_file_ptr; + if (!_fp) { std::cout << "Empty log file name, fallback to default behaviour" << std::endl; } else { - if ((_fp = fopen(_log_file.string().c_str(), "a+")) == NULL) { - std::cerr << "Invalid log file name passed as parameter: " << _log_file - << std::endl; - } else { - setvbuf(_fp, NULL, _IONBF, 0); - _clp.messageHandler()->setFilePointer(_fp); - } + _clp.messageHandler()->setFilePointer(_fp); } } SolverClp::SolverClp() { _NumberOfProblems += 1; - _fp = nullptr; set_output_log_level(0); } SolverClp::SolverClp(const std::shared_ptr toCopy) : SolverClp() { - _fp = nullptr; // Try to cast the solver in fictif to a SolverClp if (const auto c = dynamic_cast(toCopy.get())) { _clp = ClpSimplex(c->_clp); - _log_file = toCopy->_log_file; - _fp = fopen(_log_file.string().c_str(), "a+"); - if (_fp != nullptr) { - setvbuf(_fp, nullptr, _IONBF, 0); - _clp.messageHandler()->setFilePointer(_fp); + _fp = c->_fp; + if (_fp) { + _clp.messageHandler()->setFilePointer(c->_fp); } } else { _NumberOfProblems -= 1; @@ -50,10 +40,6 @@ SolverClp::SolverClp(const std::shared_ptr toCopy) SolverClp::~SolverClp() { _NumberOfProblems -= 1; - if (_fp != nullptr) { - fclose(_fp); - _fp = nullptr; - } free(); } diff --git a/src/cpp/multisolver_interface/SolverClp.h b/src/cpp/multisolver_interface/SolverClp.h index 803a7e8d6..9be4aa893 100644 --- a/src/cpp/multisolver_interface/SolverClp.h +++ b/src/cpp/multisolver_interface/SolverClp.h @@ -40,7 +40,7 @@ class SolverClp : public SolverAbstract { * @brief Default constructor of a CLP solver */ SolverClp(); - explicit SolverClp(const std::filesystem::path &log_file); + explicit SolverClp(SolverLogManager &log_manager); /** * @brief Copy constructor of CLP, copy the problem toCopy in memory and name diff --git a/src/cpp/multisolver_interface/SolverFactory.cpp b/src/cpp/multisolver_interface/SolverFactory.cpp index 62be10ca0..1ec81c52b 100644 --- a/src/cpp/multisolver_interface/SolverFactory.cpp +++ b/src/cpp/multisolver_interface/SolverFactory.cpp @@ -21,40 +21,76 @@ SolverFactory::SolverFactory() { SolverAbstract::Ptr SolverFactory::create_solver( const std::string &solver_name, const SOLVER_TYPE solver_type) const { - return create_solver(solver_name, solver_type, ""); + if (solver_name == "") { + throw InvalidSolverNameException(solver_name, LOGLOCATION); + } +#ifdef XPRESS + else if (solver_name == XPRESS_STR) { + return std::make_shared(); + } +#endif +#ifdef COIN_OR + if (solver_name == COIN_STR && solver_type == SOLVER_TYPE::CONTINUOUS) { + return std::make_shared(); + } else if (solver_name == COIN_STR && solver_type == SOLVER_TYPE::INTEGER) { + return std::make_shared(); + } +#endif + else { + throw InvalidSolverNameException(solver_name, LOGLOCATION); + } } + SolverAbstract::Ptr SolverFactory::create_solver( const std::string &solver_name, const SOLVER_TYPE solver_type, - const std::filesystem::path &log_name) const { + SolverLogManager &log_manager) const { #ifdef COIN_OR if (solver_name == COIN_STR && solver_type == SOLVER_TYPE::CONTINUOUS) { - return std::make_shared(log_name); + return std::make_shared(log_manager); } else if (solver_name == COIN_STR && solver_type == SOLVER_TYPE::INTEGER) { - return std::make_shared(log_name); + return std::make_shared(log_manager); } #endif - return create_solver(solver_name, log_name); + return create_solver(solver_name, log_manager); } + SolverAbstract::Ptr SolverFactory::create_solver( const std::string &solver_name) const { - return create_solver(solver_name, ""); + if (solver_name == "") { + throw InvalidSolverNameException(solver_name, LOGLOCATION); + } +#ifdef XPRESS + else if (solver_name == XPRESS_STR) { + return std::make_shared(); + } +#endif +#ifdef COIN_OR + else if (solver_name == CLP_STR) { + return std::make_shared(); + } else if (solver_name == CBC_STR) { + return std::make_shared(); + } +#endif + else { + throw InvalidSolverNameException(solver_name, LOGLOCATION); + } } + SolverAbstract::Ptr SolverFactory::create_solver( - const std::string &solver_name, - const std::filesystem::path &log_name) const { + const std::string &solver_name, SolverLogManager &log_manager) const { if (solver_name == "") { throw InvalidSolverNameException(solver_name, LOGLOCATION); } #ifdef XPRESS else if (solver_name == XPRESS_STR) { - return std::make_shared(log_name); + return std::make_shared(log_manager); } #endif #ifdef COIN_OR else if (solver_name == CLP_STR) { - return std::make_shared(log_name); + return std::make_shared(log_manager); } else if (solver_name == CBC_STR) { - return std::make_shared(log_name); + return std::make_shared(log_manager); } #endif else { diff --git a/src/cpp/multisolver_interface/SolverXpress.cpp b/src/cpp/multisolver_interface/SolverXpress.cpp index 49e88e4a4..1832f0c3d 100644 --- a/src/cpp/multisolver_interface/SolverXpress.cpp +++ b/src/cpp/multisolver_interface/SolverXpress.cpp @@ -14,11 +14,10 @@ int SolverXpress::_NumberOfProblems = 0; std::mutex SolverXpress::license_guard; const std::map TYPETONAME = {{1, "rows"}, {2, "columns"}}; -SolverXpress::SolverXpress(const std::filesystem::path &log_file) - : SolverXpress() { - _log_file = log_file; - if (_log_file != "") { +SolverXpress::SolverXpress(SolverLogManager &log_manager) : SolverXpress() { + if (log_manager.log_file_path != "") { _log_stream.open(_log_file, std::ofstream::out | std::ofstream::app); + _log_file = log_manager.log_file_path; add_stream(_log_stream); } } diff --git a/src/cpp/multisolver_interface/SolverXpress.h b/src/cpp/multisolver_interface/SolverXpress.h index fbe6d3613..06cd8bf61 100644 --- a/src/cpp/multisolver_interface/SolverXpress.h +++ b/src/cpp/multisolver_interface/SolverXpress.h @@ -33,7 +33,7 @@ class SolverXpress : public SolverAbstract { * @brief Default constructor of a XPRESS solver */ SolverXpress(); - SolverXpress(const std::filesystem::path &log_file); + SolverXpress(SolverLogManager &log_manager); /** * @brief Copy constructor of XPRESS, copy the problem toCopy in memory and diff --git a/src/cpp/multisolver_interface/include/multisolver_interface/SolverAbstract.h b/src/cpp/multisolver_interface/include/multisolver_interface/SolverAbstract.h index 1eae50699..6ad34e3be 100644 --- a/src/cpp/multisolver_interface/include/multisolver_interface/SolverAbstract.h +++ b/src/cpp/multisolver_interface/include/multisolver_interface/SolverAbstract.h @@ -2,6 +2,7 @@ #include #include +#include #include #include #include @@ -12,6 +13,53 @@ #include "LogUtils.h" +class SolverLogManager { + public: + explicit SolverLogManager() = default; + explicit SolverLogManager(const SolverLogManager &other) + : SolverLogManager(other.log_file_path) {} + + explicit SolverLogManager(const std::filesystem::path &log_file) + : log_file_path(log_file) { + init(); + } + + SolverLogManager &operator=(const SolverLogManager &other) { + if (this == &other) { + return *this; + } + log_file_path = other.log_file_path; + init(); + return *this; + } + + void init() { +#ifdef __linux__ + if (log_file_path.empty() || + (log_file_ptr = fopen(log_file_path.string().c_str(), "a+")) == nullptr) +#elif _WIN32 + if (log_file_path.empty() || + (log_file_ptr = _fsopen(log_file_path.string().c_str(), "a+", + _SH_DENYNO)) == nullptr) +#endif + { + std::cout << "Invalid log file name passed as parameter: " + << std::quoted(log_file_path.string()) << std::endl; + } else { + setvbuf(log_file_ptr, nullptr, _IONBF, 0); + } + } + ~SolverLogManager() { + if (log_file_ptr) { + fclose(log_file_ptr); + log_file_ptr = nullptr; + } + } + + FILE *log_file_ptr = nullptr; + std::filesystem::path log_file_path = ""; +}; + class InvalidStatusException : public LogUtils::XpansionError { public: diff --git a/src/cpp/multisolver_interface/include/multisolver_interface/SolverFactory.h b/src/cpp/multisolver_interface/include/multisolver_interface/SolverFactory.h index 91594b58d..20cdfe57e 100644 --- a/src/cpp/multisolver_interface/include/multisolver_interface/SolverFactory.h +++ b/src/cpp/multisolver_interface/include/multisolver_interface/SolverFactory.h @@ -33,7 +33,7 @@ class SolverFactory { SolverAbstract::Ptr create_solver(const std::string &solver_name) const; SolverAbstract::Ptr create_solver( const std::string &solver_name, - const std::filesystem::path &log_name) const; + SolverLogManager&log_manager) const; /** * @brief Creates and returns to an object solver from the wanted @@ -46,7 +46,7 @@ class SolverFactory { const SOLVER_TYPE solver_type) const; SolverAbstract::Ptr create_solver( const std::string &solver_name, const SOLVER_TYPE solver_type, - const std::filesystem::path &log_name) const; + SolverLogManager&log_manager) const; /** * @brief Copy constructor : Creates and returns to an object solver from the diff --git a/src/python/antares_xpansion/__version__.py.in b/src/python/antares_xpansion/__version__.py.in index 8a80bfa4a..70fee4dea 100644 --- a/src/python/antares_xpansion/__version__.py.in +++ b/src/python/antares_xpansion/__version__.py.in @@ -1,2 +1,2 @@ __version__ = "${CMAKE_PROJECT_VERSION}" -__antares_simulator_version__ = "${ANTARES_VERSION_TAG}" +__antares_simulator_version__ = "${ANTARES_VERSION}" diff --git a/src/python/antares_xpansion/antares_driver.py b/src/python/antares_xpansion/antares_driver.py index b52d9bce2..e47d425b7 100644 --- a/src/python/antares_xpansion/antares_driver.py +++ b/src/python/antares_xpansion/antares_driver.py @@ -103,7 +103,7 @@ def _get_antares_cmd(self): cmd = [str(self.antares_exe_path), self.data_dir, self.ANTARES_N_CPU_OPTION, str(self.antares_n_cpu), self.zip_option] simulator_version = version.parse(__antares_simulator_version__) simulator_version_with_named_mps = version.parse(self.FIRST_VERSION_WITH_NAMED_PROBLEMS) - if (simulator_version.major > simulator_version_with_named_mps.major) or (simulator_version.major == simulator_version_with_named_mps.major and simulator_version.minor == simulator_version_with_named_mps.minor): + if (simulator_version.major > simulator_version_with_named_mps.major) or (simulator_version.major >= simulator_version_with_named_mps.major and simulator_version.minor >= simulator_version_with_named_mps.minor): cmd.append("--named-mps-problems") return cmd diff --git a/src/python/antares_xpansion/config_loader.py b/src/python/antares_xpansion/config_loader.py index f533e00d9..7330b4736 100644 --- a/src/python/antares_xpansion/config_loader.py +++ b/src/python/antares_xpansion/config_loader.py @@ -504,6 +504,9 @@ def _set_last_simulation_name(self): self._last_study = self.last_modified_study(self.antares_output()) self._set_xpansion_simulation_name() + class NotAnXpansionOutputDir(Exception): + pass + def _set_xpansion_simulation_name(self): if self.step() in ["resume", "sensitivity"] : @@ -512,6 +515,11 @@ def _set_xpansion_simulation_name(self): self._xpansion_simulation_name = self._last_study.parent / self._last_study.stem with zipfile.ZipFile(self._last_study, 'r') as output_zip: output_zip.extractall(self._xpansion_simulation_name) + elif self.step() == "benders": + if(not self._last_study.name.endswith("-Xpansion")): + raise ConfigLoader.NotAnXpansionOutputDir(f"Error! {self._last_study} is not an Xpansion output directory") + self._xpansion_simulation_name = self._last_study + else: self._xpansion_simulation_name = self._last_study.parent / \ (self._last_study.stem+"-Xpansion") diff --git a/tests/cpp/benders/benders_sequential_test.cpp b/tests/cpp/benders/benders_sequential_test.cpp index 4f1e37910..acf7f2c29 100644 --- a/tests/cpp/benders/benders_sequential_test.cpp +++ b/tests/cpp/benders/benders_sequential_test.cpp @@ -78,10 +78,11 @@ class BendersSequentialDouble : public BendersSequential { void InitializeProblems() override { MatchProblemToId(); + auto solver_log_manager = SolverLogManager(log_name()); reset_master(new WorkerMaster(master_variable_map, get_master_path(), get_solver_name(), get_log_level(), - _data.nsubproblem, log_name(), IsResumeMode(), - _logger)); + _data.nsubproblem, solver_log_manager, + IsResumeMode(), _logger)); for (const auto &problem : coupling_map) { const auto subProblemFilePath = GetSubproblemPath(problem.first); AddSubproblem(problem); diff --git a/tests/cpp/lp_namer/MasterProblemBuilderTest.cpp b/tests/cpp/lp_namer/MasterProblemBuilderTest.cpp index 827f0f606..725181d15 100644 --- a/tests/cpp/lp_namer/MasterProblemBuilderTest.cpp +++ b/tests/cpp/lp_namer/MasterProblemBuilderTest.cpp @@ -32,9 +32,9 @@ TEST(MasterProblemBuilderTest, test_one_candidate_not_integer) { candidates.insert(candidates.end(), candidateFromLink.begin(), candidateFromLink.end()); } - + auto solver_log_manager = SolverLogManager(""); auto master_problem = MasterProblemBuilder(master_formulation) - .build(solver_name, candidates, ""); + .build(solver_name, candidates, solver_log_manager); ASSERT_EQ(master_problem->get_ncols(), 1); ASSERT_EQ( master_problem->get_col_names(0, master_problem->get_ncols() - 1)[0], @@ -87,8 +87,9 @@ TEST(MasterProblemBuilderTest, test_one_candidate_integer_problem_integer) { candidateFromLink.end()); } + auto solver_log_manager = SolverLogManager(""); auto master_problem = MasterProblemBuilder(master_formulation) - .build(solver_name, candidates, ""); + .build(solver_name, candidates, solver_log_manager); ASSERT_EQ(master_problem->get_ncols(), 2); std::vector colTypeArray(master_problem->get_ncols()); @@ -149,8 +150,9 @@ TEST(MasterProblemBuilderTest, test_one_candidate_integer_problem_relaxed) { candidateFromLink.end()); } + auto solver_log_manager = SolverLogManager(""); auto master_problem = MasterProblemBuilder(master_formulation) - .build(solver_name, candidates, ""); + .build(solver_name, candidates, solver_log_manager); ASSERT_EQ(master_problem->get_ncols(), 1); ASSERT_EQ( master_problem->get_col_names(0, master_problem->get_ncols() - 1)[0], diff --git a/tests/cpp/sensitivity/SensitivityPbModifierTest.cpp b/tests/cpp/sensitivity/SensitivityPbModifierTest.cpp index 4b579e7e5..c1ff05934 100644 --- a/tests/cpp/sensitivity/SensitivityPbModifierTest.cpp +++ b/tests/cpp/sensitivity/SensitivityPbModifierTest.cpp @@ -55,7 +55,9 @@ class SensitivityProblemModifierTest : public ::testing::Test std::string solver_name = "CBC"; SolverFactory factory; - SolverAbstract::Ptr solver_model = factory.create_solver(solver_name, std::tmpnam(nullptr)); + auto solver_log_manager = SolverLogManager(std::tmpnam(nullptr)); + SolverAbstract::Ptr solver_model = + factory.create_solver(solver_name, solver_log_manager); solver_model->init(); solver_model->read_prob_mps(last_master_mps_path); diff --git a/tests/cpp/sensitivity/SensitivityStudyTest.cpp b/tests/cpp/sensitivity/SensitivityStudyTest.cpp index a50fdac79..6559f5b9b 100644 --- a/tests/cpp/sensitivity/SensitivityStudyTest.cpp +++ b/tests/cpp/sensitivity/SensitivityStudyTest.cpp @@ -38,7 +38,8 @@ class SensitivityStudyTest : public ::testing::Test { void init_solver(std::string solver_name, std::string last_master_mps_path) { SolverFactory factory; - math_problem = factory.create_solver(solver_name, std::tmpnam(nullptr)); + auto solver_log_manager = SolverLogManager(std::tmpnam(nullptr)); + math_problem = factory.create_solver(solver_name, solver_log_manager); math_problem->init(); math_problem->read_prob_mps(last_master_mps_path); } diff --git a/tests/python/test_antares_driver.py b/tests/python/test_antares_driver.py index 806e5d7b0..8411e6290 100644 --- a/tests/python/test_antares_driver.py +++ b/tests/python/test_antares_driver.py @@ -239,8 +239,8 @@ def get_settings_dir(antares_study_path: Path): class TestAntaresDriver: def setup_method(self): #TODO update antares version which comes with named problems - self.nammed_problems = version.parse(__antares_simulator_version__) >= version.parse("8.6") - + #self.nammed_problems = version.parse(__antares_simulator_version__) >= version.parse("8.6") + self.nammed_problems=True def test_antares_cmd(self, tmp_path): study_dir = tmp_path exe_path = "/Path/to/bin1"