From c66b890b8366fb647d95f133ead3cb726fb719e5 Mon Sep 17 00:00:00 2001 From: abdoulbari zakir <32519851+a-zakir@users.noreply.github.com> Date: Thu, 11 Jan 2024 10:56:27 +0100 Subject: [PATCH 01/14] Fix new release GH workflow (#1860) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Florian Omnès <26088210+flomnes@users.noreply.github.com> --- .github/workflows/build-userguide.yml | 26 +++--- .github/workflows/centos7.yml | 32 ++++--- .github/workflows/new_release.yml | 75 +++++++++++----- .github/workflows/oracle8.yml | 32 +++---- .github/workflows/ubuntu.yml | 55 ++++++------ .github/workflows/windows-vcpkg.yml | 122 +++++++++++++++----------- 6 files changed, 198 insertions(+), 144 deletions(-) diff --git a/.github/workflows/build-userguide.yml b/.github/workflows/build-userguide.yml index c8752df8f3..fdd474a9c2 100644 --- a/.github/workflows/build-userguide.yml +++ b/.github/workflows/build-userguide.yml @@ -7,19 +7,21 @@ on: branches: - release/* - doc/* + workflow_call: + inputs: + run-tests: + required: true + type: boolean env: - IS_RELEASE: ${{ github.event_name == 'release' && github.event.action == 'created' }} + IS_RELEASE: ${{ github.event_name == 'workflow_dispatch' }} jobs: build: - runs-on: ${{ matrix.os }} + runs-on: ubuntu-20.04 if: "!contains(github.event.head_commit.message, '[skip ci]')" - strategy: - matrix: - os: [ubuntu-20.04] steps: - uses: actions/checkout@v3 @@ -27,7 +29,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v4 with: - python-version: 3.8 + python-version: 3.12 - name: Install dependencies run: | @@ -55,10 +57,12 @@ jobs: name: pdf-reference-guide path: ${{ env.PDF_PATH }} - - name: Upload user guide as release asset + + - name: Publish assets if: ${{ env.IS_RELEASE == 'true' }} - uses: alexellis/upload-assets@0.4.0 env: - GITHUB_TOKEN: ${{ github.token }} - with: - asset_paths: ${{ env.PDF_PATH_ASSET }} + GITHUB_TOKEN: ${{ github.token }} + tag: ${{ github.event.inputs.release_tag }} + run: | + gh release upload "$tag" ${{ env.PDF_PATH }} + diff --git a/.github/workflows/centos7.yml b/.github/workflows/centos7.yml index 418d7c09de..8ef8ca5a7a 100644 --- a/.github/workflows/centos7.yml +++ b/.github/workflows/centos7.yml @@ -8,10 +8,15 @@ on: - develop schedule: - cron: '21 2 * * *' + workflow_call: + inputs: + run-tests: + required: true + type: boolean env: GITHUB_TOKEN: ${{ github.token }} - IS_RELEASE: ${{ github.event_name == 'release' && github.event.action == 'created' }} + IS_RELEASE: ${{ github.event_name == 'workflow_dispatch' }} IS_PUSH: ${{ github.event_name == 'push' }} jobs: @@ -110,21 +115,20 @@ jobs: with: path: _build/*.rpm - publish_assets: - name: Publish assets - needs: build - runs-on: ubuntu-latest - - steps: - - name: Download all artifacts + - name: Install gh if: ${{ env.IS_RELEASE == 'true' }} - uses: actions/download-artifact@v3 - + run: | + yum -y install dnf + dnf -y install 'dnf-command(config-manager)' + dnf -y config-manager --add-repo https://cli.github.com/packages/rpm/gh-cli.repo + dnf -y install gh - name: Publish assets if: ${{ env.IS_RELEASE == 'true' }} - uses: alexellis/upload-assets@0.4.0 env: - GITHUB_TOKEN: ${{ github.token }} - with: - asset_paths: '["*/*.tar.gz", "*/*.rpm"]' + GITHUB_TOKEN: ${{ github.token }} + tag: ${{ github.event.inputs.release_tag }} + run: | + gh release upload "$tag" _build/*.tar.gz _build/*.rpm + + \ No newline at end of file diff --git a/.github/workflows/new_release.yml b/.github/workflows/new_release.yml index 5a4c77da34..bdb156a776 100644 --- a/.github/workflows/new_release.yml +++ b/.github/workflows/new_release.yml @@ -13,26 +13,55 @@ on: description: "Run all tests (true/false)" required: true jobs: - release: - runs-on: ubuntu-20.04 - outputs: - url: ${{ steps.create_release.outputs.upload_url }} - steps: - - name: Release creation - uses: actions/create-release@v1 - id: create_release - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: ${{ github.event.inputs.release_tag }} - release_name: ${{ github.event.inputs.release_name }} - body: | - Please complete description - - - ubuntu: - name: Release - Ubuntu - needs: release - uses: ./.github/workflows/ubuntu.yml - with: - run-tests: ${{ fromJSON(inputs.run-tests) }} + release: + name: Release pushed tag + runs-on: ubuntu-20.04 + steps: + - name: Create release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + tag: ${{ github.event.inputs.release_tag }} + title: ${{ github.event.inputs.release_name }} + tests: ${{ github.event.inputs.run-tests }} + run: | + gh release create "$tag" \ + --repo="$GITHUB_REPOSITORY" \ + --title="$title" \ + --notes="Run tests: $tests" + + + + ubuntu: + name: Release - Ubuntu + needs: release + uses: ./.github/workflows/ubuntu.yml + with: + run-tests: ${{ fromJSON(inputs.run-tests) }} + + windows: + name: Release - Windows + needs: release + uses: ./.github/workflows/windows-vcpkg.yml + with: + run-tests: ${{ fromJSON(inputs.run-tests) }} + + centos7: + name: Release - centos7 + needs: release + uses: ./.github/workflows/centos7.yml + with: + run-tests: ${{ fromJSON(inputs.run-tests) }} + + oracle8: + name: Release - oracle8 + needs: release + uses: ./.github/workflows/oracle8.yml + with: + run-tests: ${{ fromJSON(inputs.run-tests) }} + + user_guide: + name: User Guide + needs: release + uses: ./.github/workflows/build-userguide.yml + with: + run-tests: ${{ fromJSON(inputs.run-tests) }} diff --git a/.github/workflows/oracle8.yml b/.github/workflows/oracle8.yml index 75c05f845f..2c0ea15c5e 100644 --- a/.github/workflows/oracle8.yml +++ b/.github/workflows/oracle8.yml @@ -8,10 +8,15 @@ on: - develop schedule: - cron: '21 2 * * *' + workflow_call: + inputs: + run-tests: + required: true + type: boolean env: GITHUB_TOKEN: ${{ github.token }} - IS_RELEASE: ${{ github.event_name == 'release' && github.event.action == 'created' }} + IS_RELEASE: ${{ github.event_name == 'workflow_dispatch' }} IS_PUSH: ${{ github.event_name == 'push' }} jobs: @@ -33,7 +38,7 @@ jobs: - name: Install libraries run: | - dnf install -y epel-release git cmake wget rpm-build redhat-lsb-core + dnf install -y epel-release git cmake wget rpm-build redhat-lsb-core dnf install -y unzip libuuid-devel boost-test boost-devel gcc-toolset-10-toolchain zlib-devel - name: Checkout @@ -99,21 +104,18 @@ jobs: with: path: _build/*.rpm - publish_assets: - name: Publish assets - needs: build - runs-on: ubuntu-latest - - steps: - - name: Download all artifacts + - name: Install gh if: ${{ env.IS_RELEASE == 'true' }} - uses: actions/download-artifact@v3 - + run: | + dnf -y install 'dnf-command(config-manager)' + dnf -y config-manager --add-repo https://cli.github.com/packages/rpm/gh-cli.repo + dnf -y install gh - name: Publish assets if: ${{ env.IS_RELEASE == 'true' }} - uses: alexellis/upload-assets@0.4.0 env: - GITHUB_TOKEN: ${{ github.token }} - with: - asset_paths: '["*/*.tar.gz", "*/*.rpm"]' + GITHUB_TOKEN: ${{ github.token }} + tag: ${{ github.event.inputs.release_tag }} + run: | + gh release upload "$tag" _build/*.tar.gz _build/*.rpm + diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index c4525581f5..763590cd8d 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -30,24 +30,18 @@ jobs: name: Build env: ORTOOLS_DIR: ${{ github.workspace }}/or-tools + OS: ubuntu-20.04 - outputs: - os: ${{ matrix.os }} - - runs-on: ${{ matrix.os }} + runs-on: ubuntu-20.04 if: "!contains(github.event.head_commit.message, '[skip ci]')" - strategy: - matrix: - os: [ubuntu-20.04] - test-platform: [ubuntu-20.04] - + steps: - uses: actions/checkout@v3 - name: ccache uses: hendrikmuhs/ccache-action@v1.2 with: - key: ${{ matrix.os }} + key: ${{ runner.name }} - name: Install libraries run: | @@ -72,7 +66,7 @@ jobs: uses: ./.github/workflows/download-extract-precompiled-libraries-tgz with: antares-deps-version: ${{steps.antares-deps-version.outputs.prop}} - os: ${{matrix.os}} + os: ${{env.OS}} ortools-url: ${{env.ORTOOLS_URL}} ortools-dir: ${{env.ORTOOLS_DIR}} @@ -127,7 +121,7 @@ jobs: with: simtest-tag: ${{steps.simtest-version.outputs.prop}} batch-name: valid-named-mps - os: ${{ matrix.test-platform }} + os: ${{ env.OS }} variant: "named-mps" - name: Run unfeasibility-related tests @@ -140,7 +134,7 @@ jobs: if: ${{ env.RUN_SIMPLE_TESTS == 'true' }} run: | cd _build - ctest -C ${{ matrix.buildtype }} --output-on-failure -L "unit|end-to-end" + ctest -C Release --output-on-failure -L "unit|end-to-end" - name: Upload logs for failed tests if: ${{ failure() }} @@ -155,7 +149,7 @@ jobs: with: simtest-tag: ${{steps.simtest-version.outputs.prop}} batch-name: valid-v830 - os: ${{ matrix.test-platform }} + os: ${{ env.OS }} - name: Run MILP with CBC if: ${{ env.RUN_SIMPLE_TESTS == 'true' }} @@ -164,7 +158,7 @@ jobs: simtest-tag: ${{steps.simtest-version.outputs.prop}} batch-name: valid-milp variant: "milp-cbc" - os: ${{ matrix.test-platform }} + os: ${{ env.OS }} - name: Run tests introduced in v860 if: ${{ env.RUN_SIMPLE_TESTS == 'true' }} @@ -172,7 +166,7 @@ jobs: with: simtest-tag: ${{steps.simtest-version.outputs.prop}} batch-name: valid-v860 - os: ${{ matrix.test-platform }} + os: ${{ env.OS }} - name: Run tests introduced in v870 if: ${{ env.RUN_SIMPLE_TESTS == 'true' }} @@ -180,7 +174,7 @@ jobs: with: simtest-tag: ${{steps.simtest-version.outputs.prop}} batch-name: valid-v870 - os: ${{ matrix.test-platform }} + os: ${{ env.OS }} - name: Run short-tests if: ${{ env.RUN_SIMPLE_TESTS == 'true' }} @@ -188,7 +182,7 @@ jobs: with: simtest-tag: ${{steps.simtest-version.outputs.prop}} batch-name: short-tests - os: ${{ matrix.test-platform }} + os: ${{ env.OS }} - name: Run mps tests if: ${{ env.RUN_SIMPLE_TESTS == 'true' }} @@ -196,7 +190,7 @@ jobs: with: simtest-tag: ${{steps.simtest-version.outputs.prop}} batch-name: valid-mps - os: ${{ matrix.test-platform }} + os: ${{ env.OS }} - name: Run tests for adequacy patch (CSR) if: ${{ env.RUN_SIMPLE_TESTS == 'true' }} @@ -204,7 +198,7 @@ jobs: with: simtest-tag: ${{steps.simtest-version.outputs.prop}} batch-name: adequacy-patch-CSR - os: ${{ matrix.test-platform }} + os: ${{ env.OS }} - name: Run parallel tests if: ${{ env.RUN_EXTENDED_TESTS == 'true' }} @@ -212,7 +206,7 @@ jobs: with: simtest-tag: ${{steps.simtest-version.outputs.prop}} batch-name: valid-parallel - os: ${{ matrix.test-platform }} + os: ${{ env.OS }} variant: "parallel" - name: Run medium-tests @@ -221,7 +215,7 @@ jobs: with: simtest-tag: ${{steps.simtest-version.outputs.prop}} batch-name: medium-tests - os: ${{ matrix.test-platform }} + os: ${{ env.OS }} - name: Run long-tests-1 if: ${{ env.RUN_EXTENDED_TESTS == 'true' }} @@ -229,7 +223,7 @@ jobs: with: simtest-tag: ${{steps.simtest-version.outputs.prop}} batch-name: long-tests-1 - os: ${{ matrix.test-platform }} + os: ${{ env.OS }} - name: Run long-tests-2 if: ${{ env.RUN_EXTENDED_TESTS == 'true' }} @@ -237,7 +231,7 @@ jobs: with: simtest-tag: ${{steps.simtest-version.outputs.prop}} batch-name: long-tests-2 - os: ${{ matrix.test-platform }} + os: ${{ env.OS }} - name: Run long-tests-3 if: ${{ env.RUN_EXTENDED_TESTS == 'true' }} @@ -245,7 +239,7 @@ jobs: with: simtest-tag: ${{steps.simtest-version.outputs.prop}} batch-name: long-tests-3 - os: ${{ matrix.test-platform }} + os: ${{ env.OS }} - name: Installer .deb creation run: | @@ -276,11 +270,12 @@ jobs: uses: actions/upload-artifact@v3 with: path: _build/*.deb - + + - name: Publish assets if: ${{ env.IS_RELEASE == 'true' }} - uses: alexellis/upload-assets@0.4.0 env: - GITHUB_TOKEN: ${{ github.token }} - with: - asset_paths: '["_build/*.tar.gz", "_build/*.deb"]' + GITHUB_TOKEN: ${{ github.token }} + tag: ${{ github.event.inputs.release_tag }} + run: | + gh release upload "$tag" _build/*.tar.gz _build/*.deb diff --git a/.github/workflows/windows-vcpkg.yml b/.github/workflows/windows-vcpkg.yml index a7674fd76b..03f82d4fcc 100644 --- a/.github/workflows/windows-vcpkg.yml +++ b/.github/workflows/windows-vcpkg.yml @@ -12,25 +12,33 @@ on: - doc/* schedule: - cron: '21 2 * * *' + workflow_call: + inputs: + run-tests: + required: true + type: boolean + +env: + GITHUB_TOKEN: ${{ github.token }} + IS_RELEASE: ${{ github.event_name == 'workflow_dispatch' }} + RUN_SIMPLE_TESTS: ${{ github.event_name == 'push' || inputs.run-tests == 'true' }} + RUN_EXTENDED_TESTS: ${{ github.event_name == 'schedule' || inputs.run-tests == 'true' }} + jobs: - windows: - - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [windows-latest] - buildtype: [release] - include: - - os: windows-latest - triplet: x64-windows - vcpkgPackages: wxwidgets boost-test - test-platform: windows-2022 + build: + env: # Indicates the location of the vcpkg as a Git submodule of the project repository. VCPKG_ROOT: ${{ github.workspace }}/vcpkg ORTOOLS_DIR: ${{ github.workspace }}/or-tools RUN_EXTENDED_TESTS: ${{ github.event_name == 'schedule'}} + OS: windows-latest + test-platform: windows-2022 + vcpkgPackages: wxwidgets boost-test + triplet: x64-windows + + runs-on: windows-latest steps: - uses: actions/checkout@v3 @@ -82,13 +90,13 @@ jobs: # The key includes: hash of the vcpkg.json file, the hash of the vcpkg Git commit id, and the used vcpkg's triplet. The vcpkg's commit id would suffice, but computing an hash out it does not harm. # Note: given a key, the cache content is immutable. If a cache entry has been created improperly, in order the recreate the right content the key must be changed as well, and it must be brand new (i.e. not existing already). key: | - ${{ hashFiles( 'vcpkg_manifest/vcpkg.json' ) }}-${{ hashFiles( '.git/modules/vcpkg/HEAD' )}}-${{ matrix.triplet }} + ${{ hashFiles( 'vcpkg_manifest/vcpkg.json' ) }}-${{ hashFiles( '.git/modules/vcpkg/HEAD' )}}-${{ env.triplet }} - name : Install deps with VCPKG run: | cd vcpkg ./bootstrap-vcpkg.sh - vcpkg install ${{matrix.vcpkgPackages}} --triplet ${{matrix.triplet}} + vcpkg install ${{env.vcpkgPackages}} --triplet ${{env.triplet}} rm -rf buildtrees packages downloads shell: bash @@ -103,7 +111,7 @@ jobs: uses: ./.github/workflows/download-extract-precompiled-libraries-zip with: antares-deps-version: ${{steps.antares-deps-version.outputs.prop}} - os: ${{matrix.os}} + os: ${{env.OS}} ortools-url: ${{env.ORTOOLS_URL}} ortools-dir: ${{env.ORTOOLS_DIR}} @@ -132,7 +140,7 @@ jobs: -DDEPS_INSTALL_DIR=rte-antares-deps-Release \ -DCMAKE_PREFIX_PATH="${{ env.ORTOOLS_DIR }}/install" \ -DVCPKG_ROOT="${{env.VCPKG_ROOT}}" \ - -DVCPKG_TARGET_TRIPLET=${{ matrix.triplet }} \ + -DVCPKG_TARGET_TRIPLET=${{ env.triplet }} \ -DCMAKE_BUILD_TYPE=release \ -DBUILD_TESTING=ON \ -DBUILD_TOOLS=ON \ @@ -144,16 +152,34 @@ jobs: shell: bash run: | cmake --build _build --config release -j2 + # simtest + - name: Read simtest version + id: simtest-version + uses: notiz-dev/github-action-json-property@release + with: + path: 'simtest.json' + prop_path: 'version' + + - name: Run named mps tests + if: ${{ env.RUN_SIMPLE_TESTS == 'true' }} + uses: ./.github/workflows/run-tests + with: + simtest-tag: ${{steps.simtest-version.outputs.prop}} + batch-name: valid-named-mps + os: ${{ env.test-platform }} + variant: "named-mps" - name: Run unfeasibility-related tests + if: ${{ env.RUN_SIMPLE_TESTS == 'true' }} run: | cd _build ctest -C Release --output-on-failure -R "^unfeasible$" - name: Run unit and end-to-end tests + if: ${{ env.RUN_SIMPLE_TESTS == 'true' }} run: | cd _build - ctest -C ${{ matrix.buildtype }} --output-on-failure -L "unit|end-to-end" -LE ortools + ctest -C Release --output-on-failure -L "unit|end-to-end" -LE ortools - name: Upload build on failure if: ${{ failure() }} @@ -162,73 +188,63 @@ jobs: name: MPS-diff path: ${{ github.workspace }}/src/tests/mps - # simtest - - name: Read simtest version - id: simtest-version - uses: notiz-dev/github-action-json-property@release - with: - path: 'simtest.json' - prop_path: 'version' - - - name: Run named mps tests - uses: ./.github/workflows/run-tests - with: - simtest-tag: ${{steps.simtest-version.outputs.prop}} - batch-name: valid-named-mps - os: ${{ matrix.test-platform }} - variant: "named-mps" - + - name: Run tests for adequacy patch (CSR) + if: ${{ env.RUN_SIMPLE_TESTS == 'true' }} uses: ./.github/workflows/run-tests with: simtest-tag: ${{steps.simtest-version.outputs.prop}} batch-name: adequacy-patch-CSR - os: ${{ matrix.test-platform }} + os: ${{ env.test-platform }} - name: Run tests about infinity on BCs RHS + if: ${{ env.RUN_SIMPLE_TESTS == 'true' }} uses: ./.github/workflows/run-tests with: simtest-tag: ${{steps.simtest-version.outputs.prop}} batch-name: valid-v830 - os: ${{ matrix.test-platform }} + os: ${{ env.test-platform }} - name: Run MILP with CBC - if: ${{ env.IS_PUSH == 'true' }} + if: ${{ env.RUN_SIMPLE_TESTS == 'true' }} uses: ./.github/workflows/run-tests with: simtest-tag: ${{steps.simtest-version.outputs.prop}} batch-name: valid-milp variant: "milp-cbc" - os: ${{ matrix.test-platform }} + os: ${{ env.test-platform }} - name: Run tests introduced in v860 + if: ${{ env.RUN_SIMPLE_TESTS == 'true' }} uses: ./.github/workflows/run-tests with: simtest-tag: ${{steps.simtest-version.outputs.prop}} batch-name: valid-v860 - os: ${{ matrix.test-platform }} + os: ${{ env.test-platform }} - name: Run tests introduced in v870 - if: ${{ env.IS_PUSH == 'true' }} + if: ${{ env.RUN_SIMPLE_TESTS == 'true' }} uses: ./.github/workflows/run-tests with: simtest-tag: ${{steps.simtest-version.outputs.prop}} batch-name: valid-v870 - os: ${{ matrix.test-platform }} + os: ${{ env.test-platform }} - name: Run short-tests + if: ${{ env.RUN_SIMPLE_TESTS == 'true' }} uses: ./.github/workflows/run-tests with: simtest-tag: ${{steps.simtest-version.outputs.prop}} batch-name: short-tests - os: ${{ matrix.test-platform }} + os: ${{ env.test-platform }} - name: Run mps tests + if: ${{ env.RUN_SIMPLE_TESTS == 'true' }} uses: ./.github/workflows/run-tests with: simtest-tag: ${{steps.simtest-version.outputs.prop}} batch-name: valid-mps - os: ${{ matrix.test-platform }} + os: ${{ env.test-platform }} - name: Run parallel tests if: ${{ env.RUN_EXTENDED_TESTS == 'true' }} @@ -236,7 +252,7 @@ jobs: with: simtest-tag: ${{steps.simtest-version.outputs.prop}} batch-name: valid-parallel - os: ${{ matrix.test-platform }} + os: ${{ env.test-platform }} variant: "parallel" - name: Run medium-tests @@ -245,7 +261,7 @@ jobs: with: simtest-tag: ${{steps.simtest-version.outputs.prop}} batch-name: medium-tests - os: ${{ matrix.test-platform }} + os: ${{ env.test-platform }} - name: Run long-tests-1 if: ${{ env.RUN_EXTENDED_TESTS == 'true' }} @@ -253,7 +269,7 @@ jobs: with: simtest-tag: ${{steps.simtest-version.outputs.prop}} batch-name: long-tests-1 - os: ${{ matrix.test-platform }} + os: ${{ env.test-platform }} - name: Run long-tests-2 if: ${{ env.RUN_EXTENDED_TESTS == 'true' }} @@ -261,7 +277,7 @@ jobs: with: simtest-tag: ${{steps.simtest-version.outputs.prop}} batch-name: long-tests-2 - os: ${{ matrix.test-platform }} + os: ${{ env.test-platform }} - name: Run long-tests-3 if: ${{ env.RUN_EXTENDED_TESTS == 'true' }} @@ -269,7 +285,7 @@ jobs: with: simtest-tag: ${{steps.simtest-version.outputs.prop}} batch-name: long-tests-3 - os: ${{ matrix.test-platform }} + os: ${{ env.test-platform }} - name: Solver archive creation shell: bash @@ -303,7 +319,11 @@ jobs: with: path: _build/${{env.NSIS_NAME}} - - name: Archive upload - uses: actions/upload-artifact@v3 - with: - path: _build/*.zip + - name: Publish assets + if: ${{ env.IS_RELEASE == 'true' }} + env: + GITHUB_TOKEN: ${{ github.token }} + tag: ${{ github.event.inputs.release_tag }} + run: | + gh release upload "$tag" _build/*.zip + shell: bash From e4b5762b5e4d0d86bce8f0c2423391912b00b40c Mon Sep 17 00:00:00 2001 From: guilpier-code <62292552+guilpier-code@users.noreply.github.com> Date: Thu, 11 Jan 2024 11:17:40 +0100 Subject: [PATCH 02/14] Simplify TS numbers drawings, fix bug related to refresh & local thermal generation (#1752) We intend to simplify and clarify the TS number management (specially source file **timeseries-numbers.cpp**). For this we did several things : - [x] For generated TS, separate resizing from generation, and call the resizing before drawing TS number, so that we have the definitive TS sizes before we draw the TS numbers : this is the **main leverage** for TS number management simplifications and clarification. - [x] At construction, the 1-d matrix **timeseriesNumbers** is given zeros. This allows many simplifications and code reductions. - [ ] For productions (only for **Load**, **Wind** and **Solar**) that generate null TS (due to the configuration of their TS generator [see prepro capacity]), raise a warning somewhere for user to know. --- src/libs/antares/constants.h | 8 +- src/libs/antares/series/series.cpp | 11 +- src/libs/antares/study/area/area.cpp | 38 +- src/libs/antares/study/area/area.h | 2 +- .../BindingConstraintGroup.cpp | 8 - .../BindingConstraintGroup.h | 1 - .../BindingConstraintGroupRepository.cpp | 8 +- .../BindingConstraintGroupRepository.h | 2 - src/libs/antares/study/parts/hydro/series.cpp | 27 +- src/libs/antares/study/parts/hydro/series.h | 2 +- .../antares/study/parts/solar/container.cpp | 2 +- src/solver/simulation/solver.hxx | 8 +- src/solver/simulation/timeseries-numbers.cpp | 371 ++++-------------- src/solver/simulation/timeseries-numbers.h | 2 +- src/solver/ts-generator/CMakeLists.txt | 1 + src/solver/ts-generator/generator.cpp | 53 +++ src/solver/ts-generator/generator.h | 14 +- src/solver/ts-generator/generator.hxx | 20 +- src/solver/ts-generator/hydro.cpp | 15 +- src/solver/ts-generator/thermal.cpp | 20 +- src/solver/ts-generator/xcast/core.cpp | 3 - src/solver/ts-generator/xcast/gamma-euler.cpp | 3 - src/solver/ts-generator/xcast/gamma-inc.cpp | 3 - src/solver/ts-generator/xcast/math.cpp | 3 - src/solver/ts-generator/xcast/math.hxx | 3 - src/solver/ts-generator/xcast/predicate.hxx | 3 - src/solver/ts-generator/xcast/studydata.cpp | 3 - src/solver/ts-generator/xcast/studydata.h | 4 +- src/solver/ts-generator/xcast/studydata.hxx | 8 - src/solver/ts-generator/xcast/xcast.cpp | 54 +-- src/solver/ts-generator/xcast/xcast.h | 11 +- src/solver/ts-generator/xcast/xcast.hxx | 3 - src/solver/variable/economy/max-mrg.cpp | 1 - .../antares/study/series/timeseries-tests.cpp | 16 +- .../src/solver/simulation/CMakeLists.txt | 1 + .../solver/simulation/tests-ts-numbers.cpp | 23 +- 36 files changed, 246 insertions(+), 509 deletions(-) create mode 100644 src/solver/ts-generator/generator.cpp diff --git a/src/libs/antares/constants.h b/src/libs/antares/constants.h index acb9d975cb..84faf5d305 100644 --- a/src/libs/antares/constants.h +++ b/src/libs/antares/constants.h @@ -35,11 +35,9 @@ /*! Vendor */ #define LOG_APPLICATION_VENDOR "RTE" -/*! Days per year */ -#define DAYS_PER_YEAR 365 - -/*! Hours per year */ -#define HOURS_PER_YEAR 8760 +const unsigned int HOURS_PER_DAY = 24; +const unsigned int DAYS_PER_YEAR = 365; +const unsigned int HOURS_PER_YEAR = 8760; namespace Antares::Constants { diff --git a/src/libs/antares/series/series.cpp b/src/libs/antares/series/series.cpp index 2785ff5a6b..cde487a2d3 100644 --- a/src/libs/antares/series/series.cpp +++ b/src/libs/antares/series/series.cpp @@ -38,8 +38,6 @@ using namespace Yuni; namespace Antares::Data { -const std::vector TimeSeries::emptyColumn(HOURS_PER_YEAR); - TimeSeries::TimeSeries(numbers& tsNumbers) : timeseriesNumbers(tsNumbers) {} @@ -74,24 +72,17 @@ int TimeSeries::saveToFile(const std::string& filename, bool saveEvenIfAllZero) double TimeSeries::getCoefficient(uint32_t year, uint32_t timestep) const { - if (timeSeries.width == 0) - return 0; return timeSeries[getSeriesIndex(year)][timestep]; } const double* TimeSeries::getColumn(uint32_t year) const { - if (timeSeries.width == 0) - return emptyColumn.data(); return timeSeries[getSeriesIndex(year)]; } uint32_t TimeSeries::getSeriesIndex(uint32_t year) const { - if (timeSeries.width == 1) - return 0; - else - return timeseriesNumbers[0][year]; + return timeseriesNumbers[0][year]; } double* TimeSeries::operator[](uint32_t index) diff --git a/src/libs/antares/study/area/area.cpp b/src/libs/antares/study/area/area.cpp index 0c7a33eab8..cfb300a6ff 100644 --- a/src/libs/antares/study/area/area.cpp +++ b/src/libs/antares/study/area/area.cpp @@ -257,39 +257,21 @@ void Area::resetToDefaultValues() invalidateJIT = true; } -void Area::resizeAllTimeseriesNumbers(uint n) +void Area::resizeAllTimeseriesNumbers(uint nbYears) { - assert(n < 200000); // arbitrary number - - // asserts assert(hydro.series and "series must not be nullptr !"); - if (!n) + load.series.timeseriesNumbers.reset(1, nbYears); + solar.series.timeseriesNumbers.reset(1, nbYears); + wind.series.timeseriesNumbers.reset(1, nbYears); + hydro.series->timeseriesNumbers.reset(1, nbYears); + for (auto& namedLink : links) { - load.series.timeseriesNumbers.clear(); - solar.series.timeseriesNumbers.clear(); - wind.series.timeseriesNumbers.clear(); - hydro.series->timeseriesNumbers.clear(); - for (auto& namedLink : links) - { - AreaLink* link = namedLink.second; - link->timeseriesNumbers.clear(); - } - } - else - { - load.series.timeseriesNumbers.resize(1, n); - solar.series.timeseriesNumbers.resize(1, n); - wind.series.timeseriesNumbers.resize(1, n); - hydro.series->timeseriesNumbers.resize(1, n); - for (auto& namedLink : links) - { - AreaLink* link = namedLink.second; - link->timeseriesNumbers.resize(1, n); - } + AreaLink* link = namedLink.second; + link->timeseriesNumbers.reset(1, nbYears); } - thermal.resizeAllTimeseriesNumbers(n); - renewable.resizeAllTimeseriesNumbers(n); + thermal.resizeAllTimeseriesNumbers(nbYears); + renewable.resizeAllTimeseriesNumbers(nbYears); } bool Area::thermalClustersMinStablePowerValidity(std::vector& output) const diff --git a/src/libs/antares/study/area/area.h b/src/libs/antares/study/area/area.h index 1a59fd5346..d2f60d4a0c 100644 --- a/src/libs/antares/study/area/area.h +++ b/src/libs/antares/study/area/area.h @@ -154,7 +154,7 @@ class Area final : private Yuni::NonCopyable ** ** \param n A number of years */ - void resizeAllTimeseriesNumbers(uint n); + void resizeAllTimeseriesNumbers(uint nbYears); /*! ** \brief Check if a link with another area is already established diff --git a/src/libs/antares/study/binding_constraint/BindingConstraintGroup.cpp b/src/libs/antares/study/binding_constraint/BindingConstraintGroup.cpp index 5d955236ff..b4d2a99607 100644 --- a/src/libs/antares/study/binding_constraint/BindingConstraintGroup.cpp +++ b/src/libs/antares/study/binding_constraint/BindingConstraintGroup.cpp @@ -22,14 +22,6 @@ namespace Antares::Data { return constraints_; } - void BindingConstraintGroup::fixTSNumbersWhenWidthIsOne() { - if (std::all_of(constraints_.begin(), constraints_.end(), [](auto constraint){ - return constraint->RHSTimeSeries().width == 1; - })) { - timeseriesNumbers.fillColumn(0, 0); - } - } - unsigned BindingConstraintGroup::numberOfTimeseries() const { //Assume all BC in a group have the same width if (constraints_.empty()) return 0; diff --git a/src/libs/antares/study/binding_constraint/BindingConstraintGroup.h b/src/libs/antares/study/binding_constraint/BindingConstraintGroup.h index 0103fda27d..ca7f829bf3 100644 --- a/src/libs/antares/study/binding_constraint/BindingConstraintGroup.h +++ b/src/libs/antares/study/binding_constraint/BindingConstraintGroup.h @@ -15,7 +15,6 @@ class BindingConstraintGroup { [[nodiscard]] std::string name() { return name_; } void add(const std::shared_ptr& constraint); [[nodiscard]] std::set> constraints() const; - void fixTSNumbersWhenWidthIsOne(); [[nodiscard]] unsigned numberOfTimeseries() const; public: diff --git a/src/libs/antares/study/binding_constraint/BindingConstraintGroupRepository.cpp b/src/libs/antares/study/binding_constraint/BindingConstraintGroupRepository.cpp index 9758b3f35a..a8b500cb8a 100644 --- a/src/libs/antares/study/binding_constraint/BindingConstraintGroupRepository.cpp +++ b/src/libs/antares/study/binding_constraint/BindingConstraintGroupRepository.cpp @@ -54,13 +54,7 @@ namespace Antares::Data { void BindingConstraintGroupRepository::resizeAllTimeseriesNumbers(unsigned int nb_years) { std::for_each(groups_.begin(), groups_.end(), [&](auto &group) { group->timeseriesNumbers.clear(); - group->timeseriesNumbers.resize(1, nb_years); - }); - } - - void BindingConstraintGroupRepository::fixTSNumbersWhenWidthIsOne() { - std::for_each(groups_.begin(), groups_.end(), [](auto& group) { - group->fixTSNumbersWhenWidthIsOne(); + group->timeseriesNumbers.reset(1, nb_years); }); } diff --git a/src/libs/antares/study/binding_constraint/BindingConstraintGroupRepository.h b/src/libs/antares/study/binding_constraint/BindingConstraintGroupRepository.h index c39c62f211..acddaa9765 100644 --- a/src/libs/antares/study/binding_constraint/BindingConstraintGroupRepository.h +++ b/src/libs/antares/study/binding_constraint/BindingConstraintGroupRepository.h @@ -22,8 +22,6 @@ class BindingConstraintGroupRepository { void resizeAllTimeseriesNumbers(unsigned nb_years); - void fixTSNumbersWhenWidthIsOne(); - BindingConstraintGroup* operator[](const std::string& name) const; using iterator = std::vector>::iterator; diff --git a/src/libs/antares/study/parts/hydro/series.cpp b/src/libs/antares/study/parts/hydro/series.cpp index 4bcc2177be..87985e7c06 100644 --- a/src/libs/antares/study/parts/hydro/series.cpp +++ b/src/libs/antares/study/parts/hydro/series.cpp @@ -237,11 +237,30 @@ void DataSeriesHydro::reset() count = 1; } -void DataSeriesHydro::resizeRORandSTORAGE(unsigned int width) +void DataSeriesHydro::resize_ROR_STORAGE_MINGEN_whenGeneratedTS(unsigned int newWidth) { - ror.resize(width, HOURS_PER_YEAR); - storage.resize(width, DAYS_PER_YEAR); - count = width; + // This function is called in case hydro TS are generated. + // ROR ans STORAGE are resized here, and will be overriden at some point. + // MINGEN TS are different : when generating hydro TS, mingen TS are not generated, + // but only resized, so that their size is the same as ROR and STORAGE TS. + // When resizing MINGEN : + // - If we extend mingen TS, we keep already existing TS and fill the extra ones + // with a copy of the first TS + // - if we reduce mingen TS, we remove some existing TS, but we must keep intact + // the remaining ones. + ror.resize(newWidth, HOURS_PER_YEAR); + storage.resize(newWidth, DAYS_PER_YEAR); + + // Resizing mingen (mingen has necessarily at least one column, by construction) + uint mingenOriginalSize = mingen.timeSeries.width; + mingen.timeSeries.resizeWithoutDataLost(newWidth, mingen.timeSeries.height); + if (mingenOriginalSize < newWidth) + { + for (uint col = mingenOriginalSize; col < newWidth; ++col) + mingen.timeSeries.pasteToColumn(col, mingen[0]); + } + + count = newWidth; } void DataSeriesHydro::resizeGenerationTS(unsigned int w, unsigned int h) diff --git a/src/libs/antares/study/parts/hydro/series.h b/src/libs/antares/study/parts/hydro/series.h index 08fc8dff93..6a4ff2e9b6 100644 --- a/src/libs/antares/study/parts/hydro/series.h +++ b/src/libs/antares/study/parts/hydro/series.h @@ -58,7 +58,7 @@ class DataSeriesHydro */ void reset(); - void resizeRORandSTORAGE(unsigned int width); + void resize_ROR_STORAGE_MINGEN_whenGeneratedTS(unsigned int width); void resizeGenerationTS(unsigned int w, unsigned int h); /*! diff --git a/src/libs/antares/study/parts/solar/container.cpp b/src/libs/antares/study/parts/solar/container.cpp index 033a26b4c7..77dd9ea4bf 100644 --- a/src/libs/antares/study/parts/solar/container.cpp +++ b/src/libs/antares/study/parts/solar/container.cpp @@ -70,7 +70,7 @@ uint64_t Container::memoryUsage() const void Container::resetToDefault() { - series.timeSeries.reset(); + series.reset(); if (prepro) prepro->resetToDefault(); } diff --git a/src/solver/simulation/solver.hxx b/src/solver/simulation/solver.hxx index ccca27ec51..6cb1425246 100644 --- a/src/solver/simulation/solver.hxx +++ b/src/solver/simulation/solver.hxx @@ -312,6 +312,8 @@ void ISimulation::run() ImplementationType::setNbPerformedYearsInParallel(pNbMaxPerformedYearsInParallel); + TSGenerator::ResizeGeneratedTimeSeries(study.areas, study.parameters); + if (settings.tsGeneratorsOnly) { // Only the preprocessors can be used @@ -323,7 +325,7 @@ void ISimulation::run() // Destroy the TS Generators if any // It will export the time-series into the output in the same time - Solver::TSGenerator::DestroyAll(study); + TSGenerator::DestroyAll(study); } else { @@ -370,7 +372,7 @@ void ISimulation::run() } // Destroy the TS Generators if any // It will export the time-series into the output in the same time - Solver::TSGenerator::DestroyAll(study); + TSGenerator::DestroyAll(study); // Post operations { @@ -449,7 +451,7 @@ void ISimulation::regenerateTimeSeries(uint year) // * The option "Preprocessor" is checked in the interface _and_ year == 0 // * Both options "Preprocessor" and "Refresh" are checked in the interface // _and_ the refresh must be done for the given year (always done for the first year). - using namespace Solver::TSGenerator; + using namespace TSGenerator; // Load if (pData.haveToRefreshTSLoad && (year % pData.refreshIntervalLoad == 0)) { diff --git a/src/solver/simulation/timeseries-numbers.cpp b/src/solver/simulation/timeseries-numbers.cpp index 30cc4b32dc..6bf8736828 100644 --- a/src/solver/simulation/timeseries-numbers.cpp +++ b/src/solver/simulation/timeseries-numbers.cpp @@ -87,119 +87,56 @@ static bool GenerateDeratedMode(Study& study) logs.info() << " :: using the `derated` mode"; if (study.parameters.useCustomScenario) logs.warning() << "The derated mode is enabled. The custom building mode will be ignored"; - - study.areas.each([&](Area& area) { - area.load.series.timeseriesNumbers.zero(); - area.solar.series.timeseriesNumbers.zero(); - area.wind.series.timeseriesNumbers.zero(); - area.hydro.series->timeseriesNumbers.zero(); - - for (uint i = 0; i != area.thermal.clusterCount(); ++i) - { - auto& cluster = *(area.thermal.clusters[i]); - cluster.series.timeseriesNumbers.zero(); - } - - for (const auto& cluster : area.renewable.list) - cluster->series.timeseriesNumbers.zero(); - }); - return true; } -class areaNumberOfTSretriever +class AreaNumberOfTSretriever { public: - areaNumberOfTSretriever(Study& study) : study_(study) - { - } + virtual ~AreaNumberOfTSretriever() = default; virtual std::vector getAreaTimeSeriesNumber(const Area& area) = 0; - virtual uint getGeneratedTimeSeriesNumber() = 0; - -protected: - Study& study_; }; -class loadAreaNumberOfTSretriever : public areaNumberOfTSretriever +class LoadAreaNumberOfTSretriever : public AreaNumberOfTSretriever { public: - virtual ~loadAreaNumberOfTSretriever() = default; - loadAreaNumberOfTSretriever(Study& study) : areaNumberOfTSretriever(study) - { - } - std::vector getAreaTimeSeriesNumber(const Area& area) - { - std::vector to_return = {area.load.series.timeSeries.width}; - return to_return; - } - uint getGeneratedTimeSeriesNumber() + std::vector getAreaTimeSeriesNumber(const Area& area) override { - return study_.parameters.nbTimeSeriesLoad; + return { area.load.series.timeSeries.width }; } }; -class hydroAreaNumberOfTSretriever : public areaNumberOfTSretriever +class HydroAreaNumberOfTSretriever : public AreaNumberOfTSretriever { public: - virtual ~hydroAreaNumberOfTSretriever() = default; - hydroAreaNumberOfTSretriever(Study& study) : areaNumberOfTSretriever(study) - { - } - std::vector getAreaTimeSeriesNumber(const Area& area) - { - std::vector to_return = {area.hydro.series->TScount()}; - return to_return; - } - uint getGeneratedTimeSeriesNumber() + std::vector getAreaTimeSeriesNumber(const Area& area) override { - return study_.parameters.nbTimeSeriesHydro; + return { area.hydro.series->TScount() }; } }; -class windAreaNumberOfTSretriever : public areaNumberOfTSretriever +class WindAreaNumberOfTSretriever : public AreaNumberOfTSretriever { public: - virtual ~windAreaNumberOfTSretriever() = default; - windAreaNumberOfTSretriever(Study& study) : areaNumberOfTSretriever(study) - { - } - std::vector getAreaTimeSeriesNumber(const Area& area) - { - std::vector to_return = {area.wind.series.timeSeries.width}; - return to_return; - } - uint getGeneratedTimeSeriesNumber() + std::vector getAreaTimeSeriesNumber(const Area& area) override { - return study_.parameters.nbTimeSeriesWind; + return { area.wind.series.timeSeries.width }; } }; -class solarAreaNumberOfTSretriever : public areaNumberOfTSretriever +class SolarAreaNumberOfTSretriever : public AreaNumberOfTSretriever { public: - virtual ~solarAreaNumberOfTSretriever() = default; - solarAreaNumberOfTSretriever(Study& study) : areaNumberOfTSretriever(study) - { - } - std::vector getAreaTimeSeriesNumber(const Area& area) - { - std::vector to_return = {area.solar.series.timeSeries.width}; - return to_return; - } - uint getGeneratedTimeSeriesNumber() + std::vector getAreaTimeSeriesNumber(const Area& area) override { - return study_.parameters.nbTimeSeriesSolar; + return { area.solar.series.timeSeries.width }; } }; -class thermalAreaNumberOfTSretriever : public areaNumberOfTSretriever +class ThermalAreaNumberOfTSretriever : public AreaNumberOfTSretriever { public: - virtual ~thermalAreaNumberOfTSretriever() = default; - thermalAreaNumberOfTSretriever(Study& study) : areaNumberOfTSretriever(study) - { - } - std::vector getAreaTimeSeriesNumber(const Area& area) + std::vector getAreaTimeSeriesNumber(const Area& area) override { std::vector to_return; uint clusterCount = (uint)area.thermal.clusterCount(); @@ -210,20 +147,12 @@ class thermalAreaNumberOfTSretriever : public areaNumberOfTSretriever } return to_return; } - uint getGeneratedTimeSeriesNumber() - { - return study_.parameters.nbTimeSeriesThermal; - } }; -class renewClustersAreaNumberOfTSretriever : public areaNumberOfTSretriever +class RenewClustersAreaNumberOfTSretriever : public AreaNumberOfTSretriever { public: - virtual ~renewClustersAreaNumberOfTSretriever() = default; - renewClustersAreaNumberOfTSretriever(Study& study) : areaNumberOfTSretriever(study) - { - } - std::vector getAreaTimeSeriesNumber(const Area& area) + std::vector getAreaTimeSeriesNumber(const Area& area) override { std::vector to_return; for (const auto& cluster : area.renewable.list) @@ -232,17 +161,11 @@ class renewClustersAreaNumberOfTSretriever : public areaNumberOfTSretriever } return to_return; } - uint getGeneratedTimeSeriesNumber() - { - return 1; - } }; -class areaLinksTransCapaNumberOfTSretriever : public areaNumberOfTSretriever +class AreaLinksTransCapaNumberOfTSretriever : public AreaNumberOfTSretriever { public: - using areaNumberOfTSretriever::areaNumberOfTSretriever; - virtual ~areaLinksTransCapaNumberOfTSretriever() = default; std::vector getAreaTimeSeriesNumber(const Area& area) override { std::vector to_return; @@ -251,63 +174,35 @@ class areaLinksTransCapaNumberOfTSretriever : public areaNumberOfTSretriever { const auto& link = *(it->second); to_return.push_back(link.directCapacities.timeSeries.width); - to_return.push_back(link.indirectCapacities.timeSeries.width); } return to_return; } - uint getGeneratedTimeSeriesNumber() override - { - return 1; - } }; class IntraModalConsistencyChecker { public: IntraModalConsistencyChecker(const TimeSeriesType ts, - const array& isTSintramodal, - const array& isTSgenerated, - areaNumberOfTSretriever* tsCounter, + AreaNumberOfTSretriever* tsCounter, Study& study) : - tsCounter_(tsCounter), study_(study), nbTimeseries_(0) + tsCounter_(tsCounter), study_(study) { - int indexTS = ts_to_tsIndex.at(ts); - isTSintramodal_ = isTSintramodal[indexTS]; - isTSgenerated_ = isTSgenerated[indexTS]; tsTitle_ = ts_to_tsTitle.at(ts); } ~IntraModalConsistencyChecker() = default; - bool check(); + bool checkTSconsistency(); uint getTimeSeriesNumber() { return nbTimeseries_; } private: - bool checkTSconsistency(); - -private: - bool isTSintramodal_; - bool isTSgenerated_; - areaNumberOfTSretriever* tsCounter_; + AreaNumberOfTSretriever* tsCounter_; Study& study_; - uint nbTimeseries_; + uint nbTimeseries_ = 0; string tsTitle_; }; -bool IntraModalConsistencyChecker::check() -{ - if (isTSintramodal_ && not isTSgenerated_) - { - if (not checkTSconsistency()) - return false; - } - else - nbTimeseries_ = tsCounter_->getGeneratedTimeSeriesNumber(); - - return true; -} - bool IntraModalConsistencyChecker::checkTSconsistency() { logs.info() << "Checking intra-modal correlation: " << tsTitle_; @@ -325,60 +220,52 @@ bool IntraModalConsistencyChecker::checkTSconsistency() << "'s numbers of time-series are not equal for all areas"; return false; } + // At this point, all elements are identical or 1 + nbTimeseries_ = *(std::max_element(listNumberTS.begin(), listNumberTS.end())); - auto result = find_if(listNumberTS.begin(), listNumberTS.end(), [](uint x) { return x != 1; }); - if (result == listNumberTS.end()) - { // All elements are equal to 1 or list is empty - nbTimeseries_ = 1; - } - else - { - nbTimeseries_ = *result; - } return true; } bool checkIntraModalConsistency(array& nbTimeseriesByMode, const array& isTSintramodal, - const array& isTSgenerated, Study& study) { // Initialization of a map associating a time-series to an object that retrieves // the number of time series inside an area - using mapTStoRetriever = map>; + using mapTStoRetriever = map>; mapTStoRetriever ts_to_numberOfTSretrievers; - ts_to_numberOfTSretrievers[timeSeriesLoad] = make_shared(study); - ts_to_numberOfTSretrievers[timeSeriesHydro] = make_shared(study); - ts_to_numberOfTSretrievers[timeSeriesWind] = make_shared(study); - ts_to_numberOfTSretrievers[timeSeriesSolar] = make_shared(study); + ts_to_numberOfTSretrievers[timeSeriesLoad] = make_shared(); + ts_to_numberOfTSretrievers[timeSeriesHydro] = make_shared(); + ts_to_numberOfTSretrievers[timeSeriesWind] = make_shared(); + ts_to_numberOfTSretrievers[timeSeriesSolar] = make_shared(); ts_to_numberOfTSretrievers[timeSeriesThermal] - = make_shared(study); + = make_shared(); ts_to_numberOfTSretrievers[timeSeriesRenewable] - = make_shared(study); + = make_shared(); ts_to_numberOfTSretrievers[timeSeriesTransmissionCapacities] - = make_shared(study); + = make_shared(); // Loop over TS kind and check intra-modal consistency mapTStoRetriever::iterator it = ts_to_numberOfTSretrievers.begin(); for (; it != ts_to_numberOfTSretrievers.end(); ++it) { const TimeSeriesType tsKind = it->first; - areaNumberOfTSretriever* tsRetriever = (it->second).get(); + AreaNumberOfTSretriever* tsRetriever = (it->second).get(); int indexTS = ts_to_tsIndex.at(it->first); - IntraModalConsistencyChecker intraModalchecker( - tsKind, isTSintramodal, isTSgenerated, tsRetriever, study); - if (!intraModalchecker.check()) - return false; - nbTimeseriesByMode[indexTS] = intraModalchecker.getTimeSeriesNumber(); + if (isTSintramodal[indexTS]) + { + IntraModalConsistencyChecker intraModalchecker(tsKind, tsRetriever, study); + if (!intraModalchecker.checkTSconsistency()) + return false; + nbTimeseriesByMode[indexTS] = intraModalchecker.getTimeSeriesNumber(); + } } return true; } bool checkInterModalConsistencyForArea(Area& area, - const array& isTSintermodal, - const array& isTSgenerated, - Study& study) + const array& isTSintermodal) { // 1. Making a list of TS numbers : // In this list, we put the numbers of TS of every "inter-modal" mode over the current area. @@ -387,42 +274,32 @@ bool checkInterModalConsistencyForArea(Area& area, // The list containing the numbers of TS of every "inter-modal" mode over the current area std::vector listNumberTsOverArea; - auto& parameters = study.parameters; - // Load : Add load's number of TS in area ... int indexTS = ts_to_tsIndex.at(timeSeriesLoad); if (isTSintermodal[indexTS]) { - uint nbTimeSeries - = isTSgenerated[indexTS] ? parameters.nbTimeSeriesLoad : area.load.series.timeSeries.width; - listNumberTsOverArea.push_back(nbTimeSeries); + listNumberTsOverArea.push_back(area.load.series.timeSeries.width); } // Solar : Add solar's number of TS in area ... indexTS = ts_to_tsIndex.at(timeSeriesSolar); if (isTSintermodal[indexTS]) { - uint nbTimeSeries - = isTSgenerated[indexTS] ? parameters.nbTimeSeriesSolar : area.solar.series.timeSeries.width; - listNumberTsOverArea.push_back(nbTimeSeries); + listNumberTsOverArea.push_back(area.solar.series.timeSeries.width); } // Wind : Add wind's number of TS in area ... indexTS = ts_to_tsIndex.at(timeSeriesWind); if (isTSintermodal[indexTS]) { - uint nbTimeSeries - = isTSgenerated[indexTS] ? parameters.nbTimeSeriesWind : area.wind.series.timeSeries.width; - listNumberTsOverArea.push_back(nbTimeSeries); + listNumberTsOverArea.push_back(area.wind.series.timeSeries.width); } // Hydro : Add hydro's number of TS in area ... indexTS = ts_to_tsIndex.at(timeSeriesHydro); if (isTSintermodal[indexTS]) { - uint nbTimeSeries - = isTSgenerated[indexTS] ? parameters.nbTimeSeriesHydro : area.hydro.series->TScount(); - listNumberTsOverArea.push_back(nbTimeSeries); + listNumberTsOverArea.push_back(area.hydro.series->TScount()); } // Thermal : Add thermal's number of TS of each cluster in area ... @@ -433,9 +310,7 @@ bool checkInterModalConsistencyForArea(Area& area, for (uint j = 0; j != clusterCount; ++j) { auto& cluster = *(area.thermal.clusters[j]); - uint nbTimeSeries = isTSgenerated[indexTS] ? parameters.nbTimeSeriesThermal - : cluster.series.timeSeries.width; - listNumberTsOverArea.push_back(nbTimeSeries); + listNumberTsOverArea.push_back(cluster.series.timeSeries.width); } } @@ -502,7 +377,7 @@ void storeTSnumbersForIntraModal(const array& intramo assert(year < area.load.series.timeseriesNumbers.height); int indexTS = ts_to_tsIndex.at(timeSeriesLoad); - if (isTSintramodal[indexTS]) + if (isTSintramodal[indexTS] && area.load.series.timeSeries.width > 1) area.load.series.timeseriesNumbers[0][year] = intramodal_draws[indexTS]; // ------------- @@ -511,7 +386,7 @@ void storeTSnumbersForIntraModal(const array& intramo assert(year < area.solar.series.timeseriesNumbers.height); indexTS = ts_to_tsIndex.at(timeSeriesSolar); - if (isTSintramodal[indexTS]) + if (isTSintramodal[indexTS] && area.solar.series.timeSeries.width > 1) area.solar.series.timeseriesNumbers[0][year] = intramodal_draws[indexTS]; // ------------- @@ -520,7 +395,7 @@ void storeTSnumbersForIntraModal(const array& intramo assert(year < area.wind.series.timeseriesNumbers.height); indexTS = ts_to_tsIndex.at(timeSeriesWind); - if (isTSintramodal[indexTS]) + if (isTSintramodal[indexTS] && area.wind.series.timeSeries.width > 1) area.wind.series.timeseriesNumbers[0][year] = intramodal_draws[indexTS]; // ------------- @@ -529,7 +404,7 @@ void storeTSnumbersForIntraModal(const array& intramo assert(year < area.hydro.series->timeseriesNumbers.height); indexTS = ts_to_tsIndex.at(timeSeriesHydro); - if (isTSintramodal[indexTS]) + if (isTSintramodal[indexTS] && area.hydro.series->TScount() > 1) area.hydro.series->timeseriesNumbers[0][year] = intramodal_draws[indexTS]; // ------------- @@ -539,11 +414,9 @@ void storeTSnumbersForIntraModal(const array& intramo if (isTSintramodal[indexTS]) { - auto end_th_clusters = area.thermal.list.mapping.end(); - for (auto i = area.thermal.list.mapping.begin(); i != end_th_clusters; ++i) + for (auto [_, cluster] : area.thermal.list.mapping) { - ThermalClusterList::SharedPtr cluster = i->second; - if (cluster->enabled) + if (cluster->enabled && cluster->series.timeSeries.width > 1) cluster->series.timeseriesNumbers[0][year] = intramodal_draws[indexTS]; } } @@ -557,7 +430,7 @@ void storeTSnumbersForIntraModal(const array& intramo { for (auto& cluster : area.renewable.list) { - if (cluster->enabled) + if (cluster->enabled && cluster->series.timeSeries.width > 1) cluster->series.timeseriesNumbers[0][year] = intramodal_draws[indexTS]; } } @@ -572,15 +445,14 @@ void storeTSnumbersForIntraModal(const array& intramo for (auto it = area.links.begin(); it != area.links.end(); ++it) { auto& link = *(it->second); - link.timeseriesNumbers[0][year] = intramodal_draws[indexTS]; + if (link.directCapacities.timeSeries.width > 1) + link.timeseriesNumbers[0][year] = intramodal_draws[indexTS]; } } }); } void drawAndStoreTSnumbersForNOTintraModal(const array& isTSintramodal, - const array& isTSgenerated, - array& nbTimeseriesByMode, uint year, Study& study) { @@ -592,10 +464,8 @@ void drawAndStoreTSnumbersForNOTintraModal(const array& i if (!isTSintramodal[indexTS]) { - uint nbTimeSeries = isTSgenerated[indexTS] ? nbTimeseriesByMode[indexTS] - : area.load.series.timeSeries.width; area.load.series.timeseriesNumbers[0][year] - = (uint32_t)(floor(study.runtime->random[seedTimeseriesNumbers].next() * nbTimeSeries)); + = (uint32_t)(floor(study.runtime->random[seedTimeseriesNumbers].next() * area.load.series.timeSeries.width)); } // ------------- @@ -605,10 +475,8 @@ void drawAndStoreTSnumbersForNOTintraModal(const array& i if (!isTSintramodal[indexTS]) { - uint nbTimeSeries = isTSgenerated[indexTS] ? nbTimeseriesByMode[indexTS] - : area.solar.series.timeSeries.width; area.solar.series.timeseriesNumbers[0][year] - = (uint32_t)(floor(study.runtime->random[seedTimeseriesNumbers].next() * nbTimeSeries)); + = (uint32_t)(floor(study.runtime->random[seedTimeseriesNumbers].next() * area.solar.series.timeSeries.width)); } // ------------- @@ -618,10 +486,8 @@ void drawAndStoreTSnumbersForNOTintraModal(const array& i if (!isTSintramodal[indexTS]) { - uint nbTimeSeries = isTSgenerated[indexTS] ? nbTimeseriesByMode[indexTS] - : area.wind.series.timeSeries.width; area.wind.series.timeseriesNumbers[0][year] - = (uint32_t)(floor(study.runtime->random[seedTimeseriesNumbers].next() * nbTimeSeries)); + = (uint32_t)(floor(study.runtime->random[seedTimeseriesNumbers].next() * area.wind.series.timeSeries.width)); } // ------------- @@ -631,10 +497,8 @@ void drawAndStoreTSnumbersForNOTintraModal(const array& i if (!isTSintramodal[indexTS]) { - uint nbTimeSeries - = isTSgenerated[indexTS] ? nbTimeseriesByMode[indexTS] : area.hydro.series->ror.timeSeries.width; area.hydro.series->timeseriesNumbers[0][year] - = (uint32_t)(floor(study.runtime->random[seedTimeseriesNumbers].next() * nbTimeSeries)); + = (uint32_t)(floor(study.runtime->random[seedTimeseriesNumbers].next() * area.hydro.series->TScount())); } // ------------- @@ -652,10 +516,8 @@ void drawAndStoreTSnumbersForNOTintraModal(const array& i { if (!isTSintramodal[indexTS]) { - uint nbTimeSeries = isTSgenerated[indexTS] ? nbTimeseriesByMode[indexTS] - : cluster->series.timeSeries.width; cluster->series.timeseriesNumbers[0][year] = (uint32_t)( - floor(study.runtime->random[seedTimeseriesNumbers].next() * nbTimeSeries)); + floor(study.runtime->random[seedTimeseriesNumbers].next() * cluster->series.timeSeries.width)); } } } @@ -692,17 +554,10 @@ void drawAndStoreTSnumbersForNOTintraModal(const array& i { auto& link = *(it->second); const uint nbTimeSeries = link.directCapacities.timeSeries.width; - if (nbTimeSeries == 1) - { - // Random generator (mersenne-twister) must not be called here - // in order to avoid a shift in the random generator results - // that would cause a change of Antares results - link.timeseriesNumbers[0][year] = 0; - } - else + if (nbTimeSeries > 1) { link.timeseriesNumbers[0][year] = (uint32_t)( - floor(study.runtime->random[seedTimeseriesNumbers].next() * nbTimeSeries)); + floor(study.runtime->random[seedTimeseriesNumbers].next() * nbTimeSeries)); } } } @@ -711,14 +566,10 @@ void drawAndStoreTSnumbersForNOTintraModal(const array& i for (auto& group: study.bindingConstraintsGroups) { const auto nbTimeSeries = group->numberOfTimeseries(); - auto& value = group->timeseriesNumbers[0][year]; - if (nbTimeSeries == 1) - { - value = 0; - } - else + auto& groupTsNumber = group->timeseriesNumbers[0][year]; + if (nbTimeSeries > 1) { - value = (uint32_t)(floor(study.runtime->random[seedTimeseriesNumbers].next() * nbTimeSeries)); + groupTsNumber = (uint32_t)(floor(study.runtime->random[seedTimeseriesNumbers].next() * nbTimeSeries)); } } } @@ -797,73 +648,10 @@ void applyMatrixDrawsToInterModalModesInArea(Matrix* tsNumbersMtx, } } -// Set tsNumbers to 1 for all years if only one TS is present -static void fixTSNumbersSingleAreaSingleMode(Matrix& tsNumbers, uint width, uint years) -{ - if (width == 1) - { - for (uint year = 0; year < years; year++) - { - tsNumbers[0][year] = 0; - } - } -} - -static void fixTSNumbersWhenWidthIsOne(Study& study) -{ - const uint years = 1 + study.runtime->rangeLimits.year[rangeEnd]; - - study.areas.each([&years](Area& area) { - // Load - fixTSNumbersSingleAreaSingleMode( - area.load.series.timeseriesNumbers, area.load.series.timeSeries.width, years); - // Solar - fixTSNumbersSingleAreaSingleMode( - area.solar.series.timeseriesNumbers, area.solar.series.timeSeries.width, years); - // Wind - fixTSNumbersSingleAreaSingleMode( - area.wind.series.timeseriesNumbers, area.wind.series.timeSeries.width, years); - // Hydro - fixTSNumbersSingleAreaSingleMode( - area.hydro.series->timeseriesNumbers, area.hydro.series->TScount(), years); - - // Thermal - std::for_each(area.thermal.clusters.cbegin(), - area.thermal.clusters.cend(), - [&years](Data::ThermalCluster* cluster) { - fixTSNumbersSingleAreaSingleMode(cluster->series.timeseriesNumbers, - cluster->series.timeSeries.width, - years); - }); - - // Renewables - for (const auto& cluster : area.renewable.list) - fixTSNumbersSingleAreaSingleMode(cluster->series.timeseriesNumbers, - cluster->series.timeSeries.width, - years); - - // NTC - std::for_each(area.links.cbegin(), - area.links.cend(), - [&years](const std::pair& it) { - auto link = it.second; - fixTSNumbersSingleAreaSingleMode( - link->timeseriesNumbers, link->directCapacities.timeSeries.width, years); - }); - }); - study.bindingConstraintsGroups.fixTSNumbersWhenWidthIsOne(); -} - -bool TimeSeriesNumbers::checkAllElementsIdenticalOrOne(const std::vector& w) +bool TimeSeriesNumbers::checkAllElementsIdenticalOrOne(std::vector w) { - std::vector removedOnes; - // Remove all 1 - std::remove_copy(w.begin(), w.end(), std::back_inserter(removedOnes), 1); - // Try to find adjacent elements that are pairwise different - auto result - = std::adjacent_find(removedOnes.begin(), removedOnes.end(), std::not_equal_to()); - // Return "no such pair exists" - return result == removedOnes.end(); + auto first_one = std::remove(w.begin(), w.end(), 1); // Reject all 1 to the end + return std::adjacent_find(w.begin(), first_one, std::not_equal_to()) == first_one; } bool TimeSeriesNumbers::Generate(Study& study) @@ -894,28 +682,18 @@ bool TimeSeriesNumbers::Generate(Study& study) array intramodal_draws; std::fill(intramodal_draws.begin(), intramodal_draws.end(), 0); - const array isTSgenerated - = {(bool)(timeSeriesLoad & parameters.timeSeriesToRefresh), - (bool)(timeSeriesHydro & parameters.timeSeriesToRefresh), - (bool)(timeSeriesWind & parameters.timeSeriesToRefresh), - (bool)(timeSeriesThermal & parameters.timeSeriesToRefresh), - (bool)(timeSeriesSolar & parameters.timeSeriesToRefresh), - false, // TS generation is always disabled for renewables - false}; // TS generation is always disabled for links transmission capacities - - if (not checkIntraModalConsistency(nbTimeseriesByMode, isTSintramodal, isTSgenerated, study)) + if (not checkIntraModalConsistency(nbTimeseriesByMode, isTSintramodal, study)) return false; for (uint year = 0; year < years; ++year) { - // Intra-modal TS : draw and store TS numbres + // Intra-modal TS : draw and store TS numbers drawTSnumbersForIntraModal( intramodal_draws, isTSintramodal, nbTimeseriesByMode, study.runtime->random); storeTSnumbersForIntraModal(intramodal_draws, isTSintramodal, year, study.areas); // NOT intra-modal TS : draw and store TS numbers - drawAndStoreTSnumbersForNOTintraModal( - isTSintramodal, isTSgenerated, nbTimeseriesByMode, year, study); + drawAndStoreTSnumbersForNOTintraModal(isTSintramodal, year, study); } // =============== @@ -945,7 +723,7 @@ bool TimeSeriesNumbers::Generate(Study& study) for (auto i = study.areas.begin(); i != end; ++i) { auto& area = *(i->second); - if (not checkInterModalConsistencyForArea(area, isTSintermodal, isTSgenerated, study)) + if (not checkInterModalConsistencyForArea(area, isTSintermodal)) return false; Matrix* tsNumbersMtx @@ -963,7 +741,6 @@ void TimeSeriesNumbers::StoreTimeSeriesNumbersIntoOuput(Data::Study& study, IRes if (study.parameters.storeTimeseriesNumbers) { - fixTSNumbersWhenWidthIsOne(study); study.storeTimeSeriesNumbers(resultWriter); study.storeTimeSeriesNumbers(resultWriter); study.storeTimeSeriesNumbers(resultWriter); diff --git a/src/solver/simulation/timeseries-numbers.h b/src/solver/simulation/timeseries-numbers.h index 3844d51b24..0c1cd59fd8 100644 --- a/src/solver/simulation/timeseries-numbers.h +++ b/src/solver/simulation/timeseries-numbers.h @@ -42,7 +42,7 @@ bool Generate(Data::Study& study); void StoreTimeSeriesNumbersIntoOuput(Data::Study &study, IResultWriter& resultWriter); // Exported for unit-tests -bool checkAllElementsIdenticalOrOne(const std::vector& w); +bool checkAllElementsIdenticalOrOne(std::vector w); } // namespace Antares::Solver::TimeSeriesNumbers diff --git a/src/solver/ts-generator/CMakeLists.txt b/src/solver/ts-generator/CMakeLists.txt index 86b0e71d55..7b8f80ae2c 100644 --- a/src/solver/ts-generator/CMakeLists.txt +++ b/src/solver/ts-generator/CMakeLists.txt @@ -6,6 +6,7 @@ project(ts-generator) set(SRC_GENERATORS generator.h generator.hxx + generator.cpp thermal.cpp hydro.cpp ) diff --git a/src/solver/ts-generator/generator.cpp b/src/solver/ts-generator/generator.cpp new file mode 100644 index 0000000000..f4e7fa3d35 --- /dev/null +++ b/src/solver/ts-generator/generator.cpp @@ -0,0 +1,53 @@ +#include "generator.h" + +namespace Antares::TSGenerator +{ + +void ResizeGeneratedTimeSeries(Data::AreaList& areas, Data::Parameters& params) +{ + areas.each([&](Data::Area& area) + { + // Load + if (params.timeSeriesToGenerate & Data::timeSeriesLoad) + { + area.load.series.timeSeries.reset(params.nbTimeSeriesLoad, HOURS_PER_YEAR); + } + + // Wind + if (params.timeSeriesToGenerate & Data::timeSeriesWind) + { + area.wind.series.timeSeries.reset(params.nbTimeSeriesWind, HOURS_PER_YEAR); + } + + // Solar + if (params.timeSeriesToGenerate & Data::timeSeriesSolar) + { + area.solar.series.timeSeries.reset(params.nbTimeSeriesSolar, HOURS_PER_YEAR); + } + + // Hydro + if (params.timeSeriesToGenerate & Data::timeSeriesHydro) + { + area.hydro.series->resize_ROR_STORAGE_MINGEN_whenGeneratedTS(params.nbTimeSeriesHydro); + } + + // Thermal + bool globalThermalTSgeneration = params.timeSeriesToGenerate & Data::timeSeriesThermal; + for (auto [_, cluster] : area.thermal.list.mapping) + { + if (cluster->doWeGenerateTS(globalThermalTSgeneration)) + cluster->series.timeSeries.reset(params.nbTimeSeriesThermal, HOURS_PER_YEAR); + } + }); +} + +void DestroyAll(Data::Study& study) +{ + Destroy(study, (uint)-1); + Destroy(study, (uint)-1); + Destroy(study, (uint)-1); + Destroy(study, (uint)-1); + Destroy(study, (uint)-1); +} + +} // Antares::TSGenerator \ No newline at end of file diff --git a/src/solver/ts-generator/generator.h b/src/solver/ts-generator/generator.h index 1f3582fb2c..ebdd8e3bb8 100644 --- a/src/solver/ts-generator/generator.h +++ b/src/solver/ts-generator/generator.h @@ -30,16 +30,16 @@ #include #include #include +#include #include #include #include "xcast/xcast.h" -namespace Antares -{ -namespace Solver -{ -namespace TSGenerator +namespace Antares::TSGenerator { + +void ResizeGeneratedTimeSeries(Data::AreaList& areas, Data::Parameters& params); + /*! ** \brief Regenerate the time-series */ @@ -63,9 +63,7 @@ void DestroyAll(Data::Study& study); template void Destroy(Data::Study& study, uint year); -} // namespace TSGenerator -} // namespace Solver -} // namespace Antares +} // namespace Antares::TSGenerator #include "generator.hxx" diff --git a/src/solver/ts-generator/generator.hxx b/src/solver/ts-generator/generator.hxx index a143ff0d29..0fcb5d5b0a 100644 --- a/src/solver/ts-generator/generator.hxx +++ b/src/solver/ts-generator/generator.hxx @@ -29,12 +29,9 @@ #include -namespace Antares -{ -namespace Solver -{ -namespace TSGenerator +namespace Antares::TSGenerator { + // forward declaration // Hydro - see hydro.cpp bool GenerateHydroTimeSeries(Data::Study& study, uint year, IResultWriter& writer); @@ -148,17 +145,6 @@ void Destroy(Data::Study& study, uint year) } } -inline void DestroyAll(Data::Study& study) -{ - Solver::TSGenerator::Destroy(study, (uint)-1); - Solver::TSGenerator::Destroy(study, (uint)-1); - Solver::TSGenerator::Destroy(study, (uint)-1); - Solver::TSGenerator::Destroy(study, (uint)-1); - Solver::TSGenerator::Destroy(study, (uint)-1); -} - -} // namespace TSGenerator -} // namespace Solver -} // namespace Antares +} // namespace Antares::TSGenerator #endif // __ANTARES_SOLVER_timeSeries_GENERATOR_HXX__ diff --git a/src/solver/ts-generator/hydro.cpp b/src/solver/ts-generator/hydro.cpp index 8368ecf228..50356271dc 100644 --- a/src/solver/ts-generator/hydro.cpp +++ b/src/solver/ts-generator/hydro.cpp @@ -40,18 +40,12 @@ using namespace Yuni; #define EPSILON ((double)1.0e-9) +using namespace Antares::Solver; + namespace Antares { -namespace Solver -{ namespace TSGenerator { -static void PreproHydroInitMatrices(Data::Study& study, uint tsCount) -{ - study.areas.each([&](Data::Area& area) { - area.hydro.series->resizeRORandSTORAGE(tsCount); - }); -} static void PreproRoundAllEntriesPlusDerated(Data::Study& study) { @@ -75,7 +69,7 @@ bool GenerateHydroTimeSeries(Data::Study& study, uint currentYear, IResultWriter { logs.info() << "Generating the hydro time-series"; - Progression::Task progression(study, currentYear, Solver::Progression::sectTSGHydro); + Progression::Task progression(study, currentYear, Progression::sectTSGHydro); auto& studyRTI = *(study.runtime); auto& calendar = study.calendar; @@ -155,8 +149,6 @@ bool GenerateHydroTimeSeries(Data::Study& study, uint currentYear, IResultWriter uint nbTimeseries = study.parameters.nbTimeSeriesHydro; - PreproHydroInitMatrices(study, nbTimeseries); - long cumul = 0; for (uint l = 0; l != nbTimeseries; ++l) @@ -317,5 +309,4 @@ bool GenerateHydroTimeSeries(Data::Study& study, uint currentYear, IResultWriter } } // namespace TSGenerator -} // namespace Solver } // namespace Antares diff --git a/src/solver/ts-generator/thermal.cpp b/src/solver/ts-generator/thermal.cpp index e11d4a056c..5c3f75b137 100644 --- a/src/solver/ts-generator/thermal.cpp +++ b/src/solver/ts-generator/thermal.cpp @@ -48,8 +48,6 @@ using namespace Yuni; namespace Antares { -namespace Solver -{ namespace TSGenerator { namespace @@ -59,7 +57,7 @@ class GeneratorTempData final public: GeneratorTempData(Data::Study& study, Solver::Progression::Task& progr, - IResultWriter& writer); + Solver::IResultWriter& writer); void prepareOutputFoldersForAllAreas(uint year); @@ -72,8 +70,6 @@ class GeneratorTempData final uint currentYear; - uint nbThermalTimeseries; - bool derated; private: @@ -89,6 +85,7 @@ class GeneratorTempData final const T& duration); private: + uint nbThermalTimeseries_; const uint nbHoursPerYear = HOURS_PER_YEAR; const uint daysPerYear = DAYS_PER_YEAR; @@ -115,12 +112,12 @@ class GeneratorTempData final String pTempFilename; Solver::Progression::Task& pProgression; - IResultWriter& pWriter; + Solver::IResultWriter& pWriter; }; GeneratorTempData::GeneratorTempData(Data::Study& study, Solver::Progression::Task& progr, - IResultWriter& writer) : + Solver::IResultWriter& writer) : study(study), rndgenerator(study.runtime->random[Data::seedTsGenThermal]), pProgression(progr), @@ -130,7 +127,7 @@ GeneratorTempData::GeneratorTempData(Data::Study& study, archive = (0 != (parameters.timeSeriesToArchive & Data::timeSeriesThermal)); - nbThermalTimeseries = parameters.nbTimeSeriesThermal; + nbThermalTimeseries_ = parameters.nbTimeSeriesThermal; derated = parameters.derated; } @@ -251,15 +248,11 @@ void GeneratorTempData::operator()(Data::Area& area, Data::ThermalCluster& clust if (0 == cluster.unitCount or 0 == cluster.nominalCapacity) { - cluster.series.timeSeries.reset(1, nbHoursPerYear); - if (archive) writeResultsToDisk(area, cluster); return; } - cluster.series.timeSeries.resize(nbThermalTimeseries, nbHoursPerYear); - const auto& preproData = *(cluster.prepro); int AUN = (int)cluster.unitCount; @@ -355,7 +348,7 @@ void GeneratorTempData::operator()(Data::Area& area, Data::ThermalCluster& clust double* dstSeries = nullptr; - const uint tsCount = nbThermalTimeseries + 2; + const uint tsCount = nbThermalTimeseries_ + 2; for (uint tsIndex = 0; tsIndex != tsCount; ++tsIndex) { uint hour = 0; @@ -645,5 +638,4 @@ bool GenerateThermalTimeSeries(Data::Study& study, } } // namespace TSGenerator -} // namespace Solver } // namespace Antares diff --git a/src/solver/ts-generator/xcast/core.cpp b/src/solver/ts-generator/xcast/core.cpp index 4af0201cc9..7a5fb298f9 100644 --- a/src/solver/ts-generator/xcast/core.cpp +++ b/src/solver/ts-generator/xcast/core.cpp @@ -38,8 +38,6 @@ using namespace Yuni; namespace Antares { -namespace Solver -{ namespace TSGenerator { namespace XCast @@ -556,5 +554,4 @@ bool XCast::generateValuesForTheCurrentDay() } // namespace XCast } // namespace TSGenerator -} // namespace Solver } // namespace Antares diff --git a/src/solver/ts-generator/xcast/gamma-euler.cpp b/src/solver/ts-generator/xcast/gamma-euler.cpp index c933b737e9..4ca836900b 100644 --- a/src/solver/ts-generator/xcast/gamma-euler.cpp +++ b/src/solver/ts-generator/xcast/gamma-euler.cpp @@ -38,8 +38,6 @@ using namespace Yuni; namespace Antares { -namespace Solver -{ namespace TSGenerator { namespace XCast @@ -105,5 +103,4 @@ double XCast::GammaEuler(double z) } // namespace XCast } // namespace TSGenerator -} // namespace Solver } // namespace Antares diff --git a/src/solver/ts-generator/xcast/gamma-inc.cpp b/src/solver/ts-generator/xcast/gamma-inc.cpp index fdc2bcef4f..27dc81ecab 100644 --- a/src/solver/ts-generator/xcast/gamma-inc.cpp +++ b/src/solver/ts-generator/xcast/gamma-inc.cpp @@ -35,8 +35,6 @@ using namespace Yuni; namespace Antares { -namespace Solver -{ namespace TSGenerator { namespace XCast @@ -63,5 +61,4 @@ double XCast::GammaInc(double s, double z) } // namespace XCast } // namespace TSGenerator -} // namespace Solver } // namespace Antares diff --git a/src/solver/ts-generator/xcast/math.cpp b/src/solver/ts-generator/xcast/math.cpp index 2ef43546fd..399ac793b6 100644 --- a/src/solver/ts-generator/xcast/math.cpp +++ b/src/solver/ts-generator/xcast/math.cpp @@ -30,8 +30,6 @@ namespace Antares { -namespace Solver -{ namespace TSGenerator { namespace XCast @@ -59,5 +57,4 @@ void XCast::normal(float& x, float& y) } // namespace XCast } // namespace TSGenerator -} // namespace Solver } // namespace Antares diff --git a/src/solver/ts-generator/xcast/math.hxx b/src/solver/ts-generator/xcast/math.hxx index 42c5105786..effc01d747 100644 --- a/src/solver/ts-generator/xcast/math.hxx +++ b/src/solver/ts-generator/xcast/math.hxx @@ -36,8 +36,6 @@ using namespace Yuni; namespace Antares { -namespace Solver -{ namespace TSGenerator { namespace XCast @@ -344,5 +342,4 @@ static float maxiDiffusion(float a, float b, float g, float d, int l, float t) } // namespace XCast } // namespace TSGenerator -} // namespace Solver } // namespace Antares diff --git a/src/solver/ts-generator/xcast/predicate.hxx b/src/solver/ts-generator/xcast/predicate.hxx index fe8ee799f8..a03145b6e1 100644 --- a/src/solver/ts-generator/xcast/predicate.hxx +++ b/src/solver/ts-generator/xcast/predicate.hxx @@ -35,8 +35,6 @@ namespace Antares { -namespace Solver -{ namespace TSGenerator { namespace Predicate @@ -169,7 +167,6 @@ public: } // namespace Predicate } // namespace TSGenerator -} // namespace Solver } // namespace Antares #endif // __SOLVER_TS_GENERATOR_XCAST_PREDICATE_HXX__ diff --git a/src/solver/ts-generator/xcast/studydata.cpp b/src/solver/ts-generator/xcast/studydata.cpp index b36b889770..a726f185b4 100644 --- a/src/solver/ts-generator/xcast/studydata.cpp +++ b/src/solver/ts-generator/xcast/studydata.cpp @@ -33,8 +33,6 @@ using namespace Yuni; namespace Antares { -namespace Solver -{ namespace TSGenerator { namespace XCast @@ -127,5 +125,4 @@ void StudyData::reloadDataFromAreaList(const Data::Correlation& originalCorrelat } // namespace XCast } // namespace TSGenerator -} // namespace Solver } // namespace Antares diff --git a/src/solver/ts-generator/xcast/studydata.h b/src/solver/ts-generator/xcast/studydata.h index 5a5ebdb223..9ada95a415 100644 --- a/src/solver/ts-generator/xcast/studydata.h +++ b/src/solver/ts-generator/xcast/studydata.h @@ -31,7 +31,7 @@ #include #include //TODO collision -namespace Antares::Solver::TSGenerator::XCast +namespace Antares::TSGenerator::XCast { class StudyData final { @@ -100,7 +100,7 @@ class StudyData final }; // class StudyData -} // namespace Antares::Solver::TSGenerator::XCast +} // namespace Antares::TSGenerator::XCast diff --git a/src/solver/ts-generator/xcast/studydata.hxx b/src/solver/ts-generator/xcast/studydata.hxx index 2d0f5fd495..661febba6d 100644 --- a/src/solver/ts-generator/xcast/studydata.hxx +++ b/src/solver/ts-generator/xcast/studydata.hxx @@ -33,8 +33,6 @@ namespace Antares { -namespace Solver -{ namespace TSGenerator { namespace XCast @@ -57,18 +55,12 @@ void StudyData::loadFromStudy(Data::Study& study, logs.info() << " Added the area '" << area.name << "'"; localareas.push_back(&area); } - else - { - // resize and set the values for the matrix - predicate.matrix(area).reset(1, HOURS_PER_YEAR); - } } reloadDataFromAreaList(correlation); } } // namespace XCast } // namespace TSGenerator -} // namespace Solver } // namespace Antares #endif // __ANTARES_SOLVER_TS_GENERATOR_XCAST_STUDY_DATA_HXX__ diff --git a/src/solver/ts-generator/xcast/xcast.cpp b/src/solver/ts-generator/xcast/xcast.cpp index 9a5c1f0659..31fbb39888 100644 --- a/src/solver/ts-generator/xcast/xcast.cpp +++ b/src/solver/ts-generator/xcast/xcast.cpp @@ -43,12 +43,11 @@ using namespace Yuni; namespace Antares { -namespace Solver -{ namespace TSGenerator { namespace XCast { + enum { alpha = Data::XCast::dataCoeffAlpha, @@ -110,13 +109,8 @@ void XCast::applyTransferFunction(PredicateT& predicate) { enum { - - nbHoursADay = 24, - x = 0, - y = 1, - maxPoints = Data::XCast::conversionMaxPoints, }; @@ -157,7 +151,7 @@ void XCast::applyTransferFunction(PredicateT& predicate) } dailyResults = DATA[s]; - for (h = 0; h != nbHoursADay; ++h) + for (h = 0; h != HOURS_PER_DAY; ++h) { for (i = 0; i != tf.width; ++i) { @@ -370,12 +364,6 @@ void XCast::destroyTemporaryData() template bool XCast::runWithPredicate(PredicateT& predicate, Progression::Task& progression) { - enum - { - - nbHoursADay = 24, - }; - pTSName = predicate.timeSeriesName(); { @@ -395,8 +383,6 @@ bool XCast::runWithPredicate(PredicateT& predicate, Progression::Task& progressi if (pNeverInitialized) { - const uint nbHours = 8760; - loadFromStudy(predicate.correlation(study), predicate); allocateTemporaryData(); @@ -405,7 +391,6 @@ bool XCast::runWithPredicate(PredicateT& predicate, Progression::Task& progressi { auto& area = *(pData.localareas[s]); - predicate.matrix(area).resize(nbTimeseries, nbHours); auto& xcast = predicate.xcastData(area); pUseConversion[s] = (xcast.useConversion && xcast.conversion.width >= 3); @@ -419,7 +404,7 @@ bool XCast::runWithPredicate(PredicateT& predicate, Progression::Task& progressi if (study.areas.size() > pData.localareas.size()) progression - += (nbTimeseries * 365) * ((uint)study.areas.size() - (uint)pData.localareas.size()); + += (nbTimeseries_ * DAYS_PER_YEAR) * ((uint)study.areas.size() - (uint)pData.localareas.size()); if (processCount == 0) { @@ -434,7 +419,7 @@ bool XCast::runWithPredicate(PredicateT& predicate, Progression::Task& progressi pNDPMatrixCount = 0; pLevellingCount = 0; - for (uint tsIndex = 0; tsIndex != nbTimeseries; ++tsIndex) + for (uint tsIndex = 0; tsIndex != nbTimeseries_; ++tsIndex) { uint hourInTheYear = 0; @@ -488,7 +473,7 @@ bool XCast::runWithPredicate(PredicateT& predicate, Progression::Task& progressi MA[s] = +std::numeric_limits::max(); } } - memcpy(FO[s], xcastdata.K[realmonth], sizeof(float) * nbHoursADay); + memcpy(FO[s], xcastdata.K[realmonth], sizeof(float) * HOURS_PER_DAY); } uint nbDaysPerMonth = study.calendar.months[month].days; @@ -503,7 +488,7 @@ bool XCast::runWithPredicate(PredicateT& predicate, Progression::Task& progressi { float* dailyResults = DATA[s]; - for (uint h = 0; h != nbHoursADay; ++h) + for (uint h = 0; h != HOURS_PER_DAY; ++h) { assert(0 == Math::Infinite(dailyResults[h]) && "Infinite value"); } @@ -521,10 +506,10 @@ bool XCast::runWithPredicate(PredicateT& predicate, Progression::Task& progressi auto& column = srcData.translation[0]; float* dailyResults = DATA[s]; - assert(hourInTheYear + nbHoursADay <= srcData.translation.height + assert(hourInTheYear + HOURS_PER_DAY <= srcData.translation.height && "Bound checking"); - for (uint h = 0; h != nbHoursADay; ++h) + for (uint h = 0; h != HOURS_PER_DAY; ++h) { assert(0 == Math::Infinite(dailyResults[h]) && "Infinite value"); dailyResults[h] += (float)column[hourInTheYear + h]; @@ -539,7 +524,7 @@ bool XCast::runWithPredicate(PredicateT& predicate, Progression::Task& progressi { float* dailyResults = DATA[s]; - for (uint h = 0; h != nbHoursADay; ++h) + for (uint h = 0; h != HOURS_PER_DAY; ++h) { assert(0 == Math::Infinite(dailyResults[h]) && "Infinite value"); } @@ -558,7 +543,7 @@ bool XCast::runWithPredicate(PredicateT& predicate, Progression::Task& progressi auto& column = series.column(tsIndex); float* dailyResults = DATA[s]; - for (uint h = 0; h != nbHoursADay; ++h) + for (uint h = 0; h != HOURS_PER_DAY; ++h) { assert(0 == Math::Infinite(dailyResults[h]) && "Infinite value"); dailyResults[h] *= (float)srcData.capacity; @@ -566,21 +551,21 @@ bool XCast::runWithPredicate(PredicateT& predicate, Progression::Task& progressi if (srcData.useTranslation == Data::XCast::tsTranslationAfterConversion) { - assert(hourInTheYear + nbHoursADay <= srcData.translation.height + assert(hourInTheYear + HOURS_PER_DAY <= srcData.translation.height && "Bound checking"); auto& tsavg = srcData.translation[0]; - for (uint h = 0; h != nbHoursADay; ++h) + for (uint h = 0; h != HOURS_PER_DAY; ++h) dailyResults[h] += (float)tsavg[hourInTheYear + h]; } - assert(hourInTheYear + nbHoursADay <= series.height && "Bound checking"); - for (uint h = 0; h != nbHoursADay; ++h) + assert(hourInTheYear + HOURS_PER_DAY <= series.height && "Bound checking"); + for (uint h = 0; h != HOURS_PER_DAY; ++h) column[hourInTheYear + h] = Math::Round(dailyResults[h]); ++progression; } - hourInTheYear += nbHoursADay; + hourInTheYear += HOURS_PER_DAY; pNewMonth = false; } @@ -588,7 +573,7 @@ bool XCast::runWithPredicate(PredicateT& predicate, Progression::Task& progressi } { - uint y = ((pAccuracyOnCorrelation) ? pComputedPointCount : (nbTimeseries * 365)); + uint y = ((pAccuracyOnCorrelation) ? pComputedPointCount : (nbTimeseries_ * 365)); uint z = pNDPMatrixCount; logs.info() << " " << pComputedPointCount << " points calculated, using " << y @@ -640,7 +625,7 @@ bool XCast::run() { Solver::Progression::Task p(study, year, Progression::sectTSGLoad); - nbTimeseries = study.parameters.nbTimeSeriesLoad; + nbTimeseries_ = study.parameters.nbTimeSeriesLoad; Predicate::Load predicate; return runWithPredicate(predicate, p); @@ -649,7 +634,7 @@ bool XCast::run() { Solver::Progression::Task p(study, year, Progression::sectTSGSolar); - nbTimeseries = study.parameters.nbTimeSeriesSolar; + nbTimeseries_ = study.parameters.nbTimeSeriesSolar; Predicate::Solar predicate; return runWithPredicate(predicate, p); @@ -658,7 +643,7 @@ bool XCast::run() { Solver::Progression::Task p(study, year, Progression::sectTSGWind); - nbTimeseries = study.parameters.nbTimeSeriesWind; + nbTimeseries_ = study.parameters.nbTimeSeriesWind; Predicate::Wind predicate; return runWithPredicate(predicate, p); @@ -674,5 +659,4 @@ bool XCast::run() } // namespace XCast } // namespace TSGenerator -} // namespace Solver } // namespace Antares diff --git a/src/solver/ts-generator/xcast/xcast.h b/src/solver/ts-generator/xcast/xcast.h index 7c6efb6d25..ff96272c98 100644 --- a/src/solver/ts-generator/xcast/xcast.h +++ b/src/solver/ts-generator/xcast/xcast.h @@ -30,14 +30,15 @@ #include #include #include +#include #include #include "studydata.h" #include +using namespace Antares::Solver; + namespace Antares { -namespace Solver -{ namespace TSGenerator { namespace XCast @@ -99,8 +100,6 @@ class XCast final : private Yuni::NonCopyable //! The current study Data::Study& study; - //! The number of time-series - uint nbTimeseries; //! The current year uint year; //! The time-series type @@ -177,6 +176,9 @@ class XCast final : private Yuni::NonCopyable void normal(float& x, float& y); private: + //! The number of time-series + uint nbTimeseries_; + //! Some data after transformation StudyData pData; @@ -255,7 +257,6 @@ class XCast final : private Yuni::NonCopyable } // namespace XCast } // namespace TSGenerator -} // namespace Solver } // namespace Antares #include "xcast.hxx" diff --git a/src/solver/ts-generator/xcast/xcast.hxx b/src/solver/ts-generator/xcast/xcast.hxx index 9cc41b84aa..838b9b42a4 100644 --- a/src/solver/ts-generator/xcast/xcast.hxx +++ b/src/solver/ts-generator/xcast/xcast.hxx @@ -29,8 +29,6 @@ namespace Antares { -namespace Solver -{ namespace TSGenerator { namespace XCast @@ -43,7 +41,6 @@ inline void XCast::loadFromStudy(const Data::Correlation& correlation, Predicate } // namespace XCast } // namespace TSGenerator -} // namespace Solver } // namespace Antares #endif // __ANTARES_SOLVER_TS_GENERATOR_XCAST_XCAST_HXX__ diff --git a/src/solver/variable/economy/max-mrg.cpp b/src/solver/variable/economy/max-mrg.cpp index 80f0bbcfb7..8e8e2ee4ee 100644 --- a/src/solver/variable/economy/max-mrg.cpp +++ b/src/solver/variable/economy/max-mrg.cpp @@ -100,7 +100,6 @@ inline void PrepareMaxMRGFor(const State& state, double* opmrg, uint numSpace) double WH = 0.; { // H.STOR - auto& H = weeklyResults.TurbinageHoraire; for (uint i = offset; i != endHour; ++i) WH += H[i]; } diff --git a/src/tests/src/libs/antares/study/series/timeseries-tests.cpp b/src/tests/src/libs/antares/study/series/timeseries-tests.cpp index 7f7410267e..b5e2fadeed 100644 --- a/src/tests/src/libs/antares/study/series/timeseries-tests.cpp +++ b/src/tests/src/libs/antares/study/series/timeseries-tests.cpp @@ -20,8 +20,9 @@ struct Fixture Fixture& operator=(const Fixture&& f) = delete; Fixture() : ts(tsnum) { - ts.resize(1, HOURS_PER_YEAR); + ts.reset(1, HOURS_PER_YEAR); tsnum.resize(1, 1); + tsnum[0][0] = 0; } TimeSeries ts; TimeSeries::numbers tsnum; @@ -65,9 +66,6 @@ BOOST_FIXTURE_TEST_CASE(getSeriesIndex, Fixture) for (unsigned int i = 0; i < 10; i++) tsnum[0][i] = i; - //timeSeries.width == 1 so returns 0 - BOOST_CHECK_EQUAL(ts.getSeriesIndex(5), 0); - ts.resize(2, HOURS_PER_YEAR); for (unsigned int i = 0; i < 10; i++) BOOST_CHECK_EQUAL(ts.getSeriesIndex(i), i); @@ -80,13 +78,6 @@ BOOST_FIXTURE_TEST_CASE(getCoefficientWidth1, Fixture) BOOST_CHECK_EQUAL(ts.getCoefficient(0, 8750), 8750); } -BOOST_FIXTURE_TEST_CASE(getCoefficientWidth0, Fixture) -{ - ts.resize(0, HOURS_PER_YEAR); - BOOST_CHECK_EQUAL(ts.getCoefficient(0, 12), 0); - BOOST_CHECK_EQUAL(ts.getCoefficient(0, 8750), 0); -} - BOOST_FIXTURE_TEST_CASE(getCoefficientNotInitialized, Fixture) { ts.resize(4, HOURS_PER_YEAR); @@ -111,8 +102,7 @@ BOOST_FIXTURE_TEST_CASE(getCoefficientWidthMoreThan1, Fixture) BOOST_FIXTURE_TEST_CASE(getColumn, Fixture) { - ts.resize(0, HOURS_PER_YEAR); - auto col = ts.getColumn(3); //emptyColumn + auto col = ts.getColumn(0); BOOST_CHECK_EQUAL(col[38], 0); BOOST_CHECK_EQUAL(col[7463], 0); diff --git a/src/tests/src/solver/simulation/CMakeLists.txt b/src/tests/src/solver/simulation/CMakeLists.txt index 5a5d18266a..c1876cd4fa 100644 --- a/src/tests/src/solver/simulation/CMakeLists.txt +++ b/src/tests/src/solver/simulation/CMakeLists.txt @@ -22,6 +22,7 @@ target_link_libraries(tests-ts-numbers Boost::unit_test_framework model_antares antares-solver-simulation + antares-solver-ts-generator ) # Storing tests-ts-numbers under the folder Unit-tests in the IDE diff --git a/src/tests/src/solver/simulation/tests-ts-numbers.cpp b/src/tests/src/solver/simulation/tests-ts-numbers.cpp index 34c2fa5c62..c12bf028dd 100644 --- a/src/tests/src/solver/simulation/tests-ts-numbers.cpp +++ b/src/tests/src/solver/simulation/tests-ts-numbers.cpp @@ -6,6 +6,7 @@ #include #include +#include "ts-generator/generator.h" #include // std::adjacent_find @@ -125,6 +126,7 @@ BOOST_AUTO_TEST_CASE(two_areas_with_5_ready_made_ts_on_load___check_intra_modal_ area_2->resizeAllTimeseriesNumbers(1 + study->runtime->rangeLimits.year[rangeEnd]); area_2->load.series.timeSeries.resize(5, 1); + TSGenerator::ResizeGeneratedTimeSeries(study->areas, study->parameters); BOOST_CHECK(Generate(*study)); // intra-modal for load : drawn TS numbers in all areas must be equal @@ -150,6 +152,7 @@ static bool intermodal_load_two_areas(unsigned width_area_1, unsigned width_area area_2->load.series.timeSeries.resize(width_area_2, 1); area_2->resizeAllTimeseriesNumbers(1 + study->runtime->rangeLimits.year[rangeEnd]); + TSGenerator::ResizeGeneratedTimeSeries(study->areas, study->parameters); return Generate(*study); } @@ -196,6 +199,7 @@ BOOST_AUTO_TEST_CASE(two_areas_3_thermal_clusters_with_same_number_of_ready_made area_2->resizeAllTimeseriesNumbers(1 + study->runtime->rangeLimits.year[rangeEnd]); + TSGenerator::ResizeGeneratedTimeSeries(study->areas, study->parameters); BOOST_CHECK(Generate(*study)); // TS number checks @@ -234,6 +238,7 @@ BOOST_AUTO_TEST_CASE(two_areas_2_thermal_clusters_with_respectively_4_4_ready_ma area_2->resizeAllTimeseriesNumbers(1 + study->runtime->rangeLimits.year[rangeEnd]); + TSGenerator::ResizeGeneratedTimeSeries(study->areas, study->parameters); BOOST_CHECK(Generate(*study)); // TS number checks @@ -274,7 +279,7 @@ BOOST_AUTO_TEST_CASE(two_areas_3_thermal_clusters_with_different_number_of_ready area_2->resizeAllTimeseriesNumbers(1 + study->runtime->rangeLimits.year[rangeEnd]); - + TSGenerator::ResizeGeneratedTimeSeries(study->areas, study->parameters); BOOST_CHECK(not Generate(*study)); } @@ -311,6 +316,7 @@ BOOST_AUTO_TEST_CASE(two_areas_3_renew_clusters_with_same_number_of_ready_made_t area_2->resizeAllTimeseriesNumbers(1 + study->runtime->rangeLimits.year[rangeEnd]); + TSGenerator::ResizeGeneratedTimeSeries(study->areas, study->parameters); BOOST_CHECK(Generate(*study)); // TS number checks @@ -350,6 +356,7 @@ BOOST_AUTO_TEST_CASE(two_areas_2_renew_clusters_with_respectively_4_4_ready_made area_2->resizeAllTimeseriesNumbers(1 + study->runtime->rangeLimits.year[rangeEnd]); + TSGenerator::ResizeGeneratedTimeSeries(study->areas, study->parameters); BOOST_CHECK(Generate(*study)); // TS number checks @@ -391,6 +398,7 @@ BOOST_AUTO_TEST_CASE(two_areas_3_renew_clusters_with_different_number_of_ready_m area_2->resizeAllTimeseriesNumbers(1 + study->runtime->rangeLimits.year[rangeEnd]); + TSGenerator::ResizeGeneratedTimeSeries(study->areas, study->parameters); BOOST_CHECK(not Generate(*study)); } @@ -418,7 +426,9 @@ BOOST_AUTO_TEST_CASE(one_area__load_wind_thermal_are_turned_to_inter_modal__same area->wind.series.timeSeries.resize(5, 1); // Ready made TS for wind // ... Thermal + study->parameters.timeSeriesToGenerate |= timeSeriesThermal; // Generated TS for thermal study->parameters.timeSeriesToRefresh |= timeSeriesThermal; // Generated TS for thermal + study->parameters.nbTimeSeriesThermal = 5; // ... ... clusters auto thCluster_1 = addClusterToArea(area, "th-cluster-1"); @@ -426,6 +436,7 @@ BOOST_AUTO_TEST_CASE(one_area__load_wind_thermal_are_turned_to_inter_modal__same area->resizeAllTimeseriesNumbers(1 + study->runtime->rangeLimits.year[rangeEnd]); + TSGenerator::ResizeGeneratedTimeSeries(study->areas, study->parameters); BOOST_CHECK(Generate(*study)); // TS number checks @@ -456,6 +467,7 @@ BOOST_AUTO_TEST_CASE(one_area__load_wind_thermal_are_turned_to_inter_modal__same area->wind.series.timeSeries.resize(5, 1); // Ready made TS for wind // ... Thermal + study->parameters.timeSeriesToGenerate |= timeSeriesThermal; // Generated TS for thermal study->parameters.timeSeriesToRefresh |= timeSeriesThermal; // Generated TS for thermal study->parameters.nbTimeSeriesThermal = 5; // ... ... clusters @@ -464,6 +476,7 @@ BOOST_AUTO_TEST_CASE(one_area__load_wind_thermal_are_turned_to_inter_modal__same area->resizeAllTimeseriesNumbers(1 + study->runtime->rangeLimits.year[rangeEnd]); + TSGenerator::ResizeGeneratedTimeSeries(study->areas, study->parameters); BOOST_CHECK(Generate(*study)); // TS number checks @@ -494,6 +507,7 @@ BOOST_AUTO_TEST_CASE(one_area__load_wind_thermal_are_turned_to_inter_modal__diff area->wind.series.timeSeries.resize(5, 1); // Ready made TS for wind // ... Thermal + study->parameters.timeSeriesToGenerate |= timeSeriesThermal; // Generated TS for thermal study->parameters.timeSeriesToRefresh |= timeSeriesThermal; // Generated TS for thermal study->parameters.nbTimeSeriesThermal = 4; // ... ... clusters @@ -502,6 +516,7 @@ BOOST_AUTO_TEST_CASE(one_area__load_wind_thermal_are_turned_to_inter_modal__diff area->resizeAllTimeseriesNumbers(1 + study->runtime->rangeLimits.year[rangeEnd]); + TSGenerator::ResizeGeneratedTimeSeries(study->areas, study->parameters); BOOST_CHECK(not Generate(*study)); } @@ -530,6 +545,7 @@ BOOST_AUTO_TEST_CASE(one_area__load_renewable_are_turned_to_inter_modal__same_nb area->resizeAllTimeseriesNumbers(1 + study->runtime->rangeLimits.year[rangeEnd]); + TSGenerator::ResizeGeneratedTimeSeries(study->areas, study->parameters); BOOST_CHECK(Generate(*study)); // TS number checks @@ -561,6 +577,7 @@ BOOST_AUTO_TEST_CASE(one_area__load_renewable_are_turned_to_inter_modal__differe area->resizeAllTimeseriesNumbers(1 + study->runtime->rangeLimits.year[rangeEnd]); + TSGenerator::ResizeGeneratedTimeSeries(study->areas, study->parameters); BOOST_CHECK(not Generate(*study)); } @@ -588,6 +605,7 @@ BOOST_AUTO_TEST_CASE(one_area__load_renewable_are_turned_to_inter_modal_with_res area->resizeAllTimeseriesNumbers(1 + study->runtime->rangeLimits.year[rangeEnd]); + TSGenerator::ResizeGeneratedTimeSeries(study->areas, study->parameters); BOOST_CHECK(Generate(*study)); } @@ -612,6 +630,7 @@ BOOST_AUTO_TEST_CASE(load_wind_thermal_in_intra_and_inter_modal____check_all_ts_ study->parameters.interModal |= timeSeriesThermal; // Generated TS for thermal + study->parameters.timeSeriesToGenerate |= timeSeriesThermal; // Generated TS for thermal study->parameters.timeSeriesToRefresh |= timeSeriesThermal; study->parameters.nbTimeSeriesThermal = 5; @@ -641,6 +660,7 @@ BOOST_AUTO_TEST_CASE(load_wind_thermal_in_intra_and_inter_modal____check_all_ts_ area_2->resizeAllTimeseriesNumbers(1 + study->runtime->rangeLimits.year[rangeEnd]); + TSGenerator::ResizeGeneratedTimeSeries(study->areas, study->parameters); BOOST_CHECK(Generate(*study)); // TS number checks : all intra-modal & inter-modal modes have get the same ts number : @@ -694,6 +714,7 @@ BOOST_AUTO_TEST_CASE(check_all_drawn_ts_numbers_are_bounded_between_0_and_nb_of_ bc->RHSTimeSeries().resize(42, 1); study->bindingConstraintsGroups.resizeAllTimeseriesNumbers(1 + study->runtime->rangeLimits.year[rangeEnd]); + TSGenerator::ResizeGeneratedTimeSeries(study->areas, study->parameters); BOOST_CHECK(Generate(*study)); // TS number checks : each energy drawn ts numbers are up-bounded with the number of TS of the related energy From a19f3fac5e40ca7d2057fdb3f1c58ea513a07c8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Omn=C3=A8s?= <26088210+flomnes@users.noreply.github.com> Date: Thu, 11 Jan 2024 11:31:18 +0100 Subject: [PATCH 03/14] Release notes for v8.8.1 (#1871) - Add release notes - Update version number & year --- docs/CHANGELOG.md | 28 ++++++++++++++++++++++++++++ src/CMakeLists.txt | 4 ++-- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 99c6395eaa..268d1b1add 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -6,6 +6,34 @@ Antares Changelog ## New Features * Solver logs can be enabled either by the command-line option (--solver-logs) or in the generaldata.ini by setting solver-logs = true under the optimization section [(#1717)](https://github.com/AntaresSimulatorTeam/Antares_Simulator/pull/1717) +8.8.1 (01/2024) +-------------------- + +## Bugfix +* Simplify TS numbers drawings, fix bug related to refresh & local thermal generation (#1752) + +## Improvements +* Take into account breaking change in OR-Tools's API, enable SCIP & GLPK solvers, bump OR-Tools (#1825). This should improve performances with FICO XPRESS +* Fail if OR-Tools solver is not found (#1851) +* Add possibility to release without running any tests (#1852) + +## Code quality +* Use `std::unordered_map` for tmpDataByArea_ (hydro ventilation) (#1855) +* Remove `mutable` keyword from `PROBLEME_HEBDO` (#1846) +* Remove Study::gotFatalError, throw exceptions instead (#1806) +* Renewable containers (#1809) +* Use modern style for loops, avoid int cast (#1847) +* Remove YUNI_STATIC_ASSERT (#1863) + +## Testing +* Add tests on short-term storage/thermal cluster/renewable cluster removal (#1841) + +## Doc +* Add precision about `enabled` field in ST storage (#1850) +* Use dedicated URL path for Doxygen, instead of root (#1865) +* Fix HTML generation for readthedocs (#1867) +* Add dark mode switch for Doxygen online documentation (#1792) + 8.8.0 (12/2023) -------------------- diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ee5083bebe..f790c854b7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -3,13 +3,13 @@ cmake_minimum_required(VERSION 3.14) # FetchContent_MakeAvailable # Version set(ANTARES_VERSION_HI 8) set(ANTARES_VERSION_LO 8) -set(ANTARES_VERSION_REVISION 0) +set(ANTARES_VERSION_REVISION 1) # Beta release set(ANTARES_BETA 0) set(ANTARES_RC 0) -set(ANTARES_VERSION_YEAR 2023) +set(ANTARES_VERSION_YEAR 2024) project(antares VERSION ${ANTARES_VERSION_HI}.${ANTARES_VERSION_LO}.${ANTARES_VERSION_REVISION}) From 2e22eb8d9f2d2eb99f81db56d9dc9d989c807829 Mon Sep 17 00:00:00 2001 From: payetvin <113102157+payetvin@users.noreply.github.com> Date: Thu, 11 Jan 2024 16:06:30 +0100 Subject: [PATCH 04/14] Clean src/libs/antares/ (#1870) Remove directories net/ and object/ Remove unused functions in stdcxx/ --- src/libs/antares/CMakeLists.txt | 2 - src/libs/antares/Enum.hxx | 4 +- src/libs/antares/net/net.h | 32 ---- src/libs/antares/object/CMakeLists.txt | 19 --- src/libs/antares/object/intrusive-reference.h | 132 ---------------- .../antares/object/intrusive-reference.hxx | 95 ------------ src/libs/antares/object/object.cpp | 63 -------- src/libs/antares/object/object.h | 146 ------------------ src/libs/antares/object/object.hxx | 60 ------- src/libs/antares/object/ref.h | 66 -------- src/libs/antares/stdcxx/CMakeLists.txt | 4 +- .../{net/request.h => stdcxx/class_name.cpp} | 35 ++--- src/libs/antares/stdcxx/demangle.cpp | 79 ---------- .../stdcxx/{demangle.hpp => class_name.h} | 21 +-- src/libs/antares/study/CMakeLists.txt | 1 - src/libs/antares/study/study.h | 3 +- src/ui/action/CMakeLists.txt | 1 - 17 files changed, 22 insertions(+), 741 deletions(-) delete mode 100644 src/libs/antares/net/net.h delete mode 100644 src/libs/antares/object/CMakeLists.txt delete mode 100644 src/libs/antares/object/intrusive-reference.h delete mode 100644 src/libs/antares/object/intrusive-reference.hxx delete mode 100644 src/libs/antares/object/object.cpp delete mode 100644 src/libs/antares/object/object.h delete mode 100644 src/libs/antares/object/object.hxx delete mode 100644 src/libs/antares/object/ref.h rename src/libs/antares/{net/request.h => stdcxx/class_name.cpp} (68%) delete mode 100644 src/libs/antares/stdcxx/demangle.cpp rename src/libs/antares/stdcxx/include/antares/stdcxx/{demangle.hpp => class_name.h} (77%) diff --git a/src/libs/antares/CMakeLists.txt b/src/libs/antares/CMakeLists.txt index a0ef1e2adb..152c780ba4 100644 --- a/src/libs/antares/CMakeLists.txt +++ b/src/libs/antares/CMakeLists.txt @@ -5,8 +5,6 @@ add_subdirectory(args) add_subdirectory(writer) add_subdirectory(memory) -add_subdirectory(object) - add_subdirectory(array) add_subdirectory(correlation) add_subdirectory(concurrency) diff --git a/src/libs/antares/Enum.hxx b/src/libs/antares/Enum.hxx index af78bef493..373c8d0712 100644 --- a/src/libs/antares/Enum.hxx +++ b/src/libs/antares/Enum.hxx @@ -32,7 +32,7 @@ #include #include -#include +#include #include @@ -83,4 +83,4 @@ std::list enumList() -#endif // ANTARES_DATA_ENUM_HXX \ No newline at end of file +#endif // ANTARES_DATA_ENUM_HXX diff --git a/src/libs/antares/net/net.h b/src/libs/antares/net/net.h deleted file mode 100644 index 998c1af806..0000000000 --- a/src/libs/antares/net/net.h +++ /dev/null @@ -1,32 +0,0 @@ -/* -** Copyright 2007-2023 RTE -** Authors: Antares_Simulator Team -** -** This file is part of Antares_Simulator. -** -** Antares_Simulator is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** There are special exceptions to the terms and conditions of the -** license as they are applied to this software. View the full text of -** the exceptions in file COPYING.txt in the directory of this software -** distribution -** -** Antares_Simulator is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with Antares_Simulator. If not, see . -** -** SPDX-License-Identifier: licenceRef-GPL3_WITH_RTE-Exceptions -*/ -#ifndef __ANTARES_LIBS_NET_NET_H__ -#define __ANTARES_LIBS_NET_NET_H__ - -#include - -#endif // __ANTARES_LIBS_NET_NET_H__ diff --git a/src/libs/antares/object/CMakeLists.txt b/src/libs/antares/object/CMakeLists.txt deleted file mode 100644 index 774ec2dfd3..0000000000 --- a/src/libs/antares/object/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -set(SRC_OBJECT - intrusive-reference.h - intrusive-reference.hxx - object.h - object.hxx - object.cpp - ref.h - ) -source_group("object" FILES ${SRC_OBJECT}) - -add_library(object - ${SRC_OBJECT}) -add_library(Antares::object ALIAS object) - -target_link_libraries(object - PRIVATE - yuni-static-core - yuni-static-uuid - ) \ No newline at end of file diff --git a/src/libs/antares/object/intrusive-reference.h b/src/libs/antares/object/intrusive-reference.h deleted file mode 100644 index a30c9fde26..0000000000 --- a/src/libs/antares/object/intrusive-reference.h +++ /dev/null @@ -1,132 +0,0 @@ -/* -** Copyright 2007-2023 RTE -** Authors: Antares_Simulator Team -** -** This file is part of Antares_Simulator. -** -** Antares_Simulator is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** There are special exceptions to the terms and conditions of the -** license as they are applied to this software. View the full text of -** the exceptions in file COPYING.txt in the directory of this software -** distribution -** -** Antares_Simulator is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with Antares_Simulator. If not, see . -** -** SPDX-License-Identifier: licenceRef-GPL3_WITH_RTE-Exceptions -*/ -#ifndef __ANTARES_LIB_ASSEMBLY_INTRUSIVEREFERENCE_H__ -#define __ANTARES_LIB_ASSEMBLY_INTRUSIVEREFERENCE_H__ - -#include "../antares.h" -#include - -namespace Antares -{ -/*! -** \brief Give to inherited classes an intrusive counting through CRTP. -** -** \tparam ChildT Child class type -** \tparam TP Threading policy. Set by default for a single thread -*/ -template class TP = Yuni::Policy::ObjectLevelLockable> -class IIntrusiveReference : public TP> -{ -public: - //! Simplified type name of the instance for the current child type & threading policy. - using IntrusiveRef = IIntrusiveReference; - //! Threading policy type - using ThreadingPolicy = TP; - - /*! - ** \brief Class Helper to determine the most suitable smart pointer for a class - ** according the current threading policy - */ - template - class SmartPtr - { - public: - //! A thread-safe type - using PtrThreadSafe = Yuni::SmartPtr; - //! A default type - using PtrSingleThreaded = Yuni::SmartPtr; - //! The most suitable smart pointer for T - using Ptr = typename Yuni::Static:: - If::ResultType; - }; // class SmartPtr - -public: - //! \name Pointer management - //@{ - //! Increment the internal reference counter - void addRef() const; - //! Decrement the internal reference counter - bool release() const; - //! Get if the object is an unique reference (COW idiom) - bool unique() const; - //@} - - /*! - ** \brief Action to do when the release method is called - ** - ** For now, does nothing. - ** Called by children through static polymorphism (CRTP). - ** \attention Thread safe - */ - void onRelease(); - -protected: - //! \name Constructor & Destructor - //@{ - /*! - ** \brief Default constructor - */ - IIntrusiveReference(); - - /*! - ** \brief Destructor - ** - ** \internal The keyword 'virtual' is mandatory to have a proper call to the - ** destructor - */ - virtual ~IIntrusiveReference(); - - /*! - ** \brief Copy constructor - ** \param rhs Copy source - */ - explicit IIntrusiveReference(const IIntrusiveReference& rhs); - //@} - - /*! - ** \brief Assignment operator - ** \param rhs Assignment source - ** \return Reference to "this" - */ - IIntrusiveReference& operator=(const IIntrusiveReference& rhs) const; - -private: - using ReferenceCounterType = typename ThreadingPolicy::template Volatile::Type; - //! Intrusive reference count - mutable ReferenceCounterType pRefCount; - - // debug - mutable std::list> pTraces; - mutable std::list> pTracesFree; - -}; // class IIntrusiveReference - -} // namespace Antares - -#include "intrusive-reference.hxx" - -#endif // __ANTARES_LIB_ASSEMBLY_INTRUSIVEREFERENCE_H__ diff --git a/src/libs/antares/object/intrusive-reference.hxx b/src/libs/antares/object/intrusive-reference.hxx deleted file mode 100644 index 7bc8a1faea..0000000000 --- a/src/libs/antares/object/intrusive-reference.hxx +++ /dev/null @@ -1,95 +0,0 @@ -/* -** Copyright 2007-2023 RTE -** Authors: Antares_Simulator Team -** -** This file is part of Antares_Simulator. -** -** Antares_Simulator is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** There are special exceptions to the terms and conditions of the -** license as they are applied to this software. View the full text of -** the exceptions in file COPYING.txt in the directory of this software -** distribution -** -** Antares_Simulator is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with Antares_Simulator. If not, see . -** -** SPDX-License-Identifier: licenceRef-GPL3_WITH_RTE-Exceptions -*/ -#ifndef __ANTARES_LIB_ASSEMBLY_INTRUSIVEREFERENCE_HXX__ -#define __ANTARES_LIB_ASSEMBLY_INTRUSIVEREFERENCE_HXX__ - -#include - -namespace Antares -{ -template class TP> -inline IIntrusiveReference::IIntrusiveReference() : pRefCount(0) -{ -} - -template class TP> -inline IIntrusiveReference::~IIntrusiveReference() -{ -} - -template class TP> -inline IIntrusiveReference::IIntrusiveReference( - [[maybe_unused]] const IIntrusiveReference& rhs) : - pRefCount(0) -{ -} - -template class TP> -inline IIntrusiveReference& IIntrusiveReference::operator=( - [[maybe_unused]] const IIntrusiveReference& rhs) const -{ - // Does nothing - return *this; -} - -template class TP> -inline void IIntrusiveReference::onRelease() -{ - static_cast(this)->onRelease(); -} - -template class TP> -inline bool IIntrusiveReference::unique() const -{ - typename ThreadingPolicy::MutexLocker locker(*this); - return pRefCount == 1; -} - -template class TP> -inline void IIntrusiveReference::addRef() const -{ - typename ThreadingPolicy::MutexLocker locker(*this); - ++pRefCount; -} - -template class TP> -inline bool IIntrusiveReference::release() const -{ - { - typename ThreadingPolicy::MutexLocker locker(*this); - assert(pRefCount > 0); - - if (--pRefCount != 0) - return false; - } - static_cast(const_cast*>(this))->onRelease(); - return true; -} - -} // namespace Antares - -#endif // __ANTARES_LIB_ASSEMBLY_INTRUSIVEREFERENCE_HXX__ diff --git a/src/libs/antares/object/object.cpp b/src/libs/antares/object/object.cpp deleted file mode 100644 index 3dcd06024b..0000000000 --- a/src/libs/antares/object/object.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/* -** Copyright 2007-2023 RTE -** Authors: Antares_Simulator Team -** -** This file is part of Antares_Simulator. -** -** Antares_Simulator is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** There are special exceptions to the terms and conditions of the -** license as they are applied to this software. View the full text of -** the exceptions in file COPYING.txt in the directory of this software -** distribution -** -** Antares_Simulator is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with Antares_Simulator. If not, see . -** -** SPDX-License-Identifier: licenceRef-GPL3_WITH_RTE-Exceptions -*/ - -#include "object.h" - -using namespace Yuni; - -namespace Antares -{ -IObject::IObject() : pOID(Ref::fGenerate) // will generate a new uuid -{ - assert(!pOID.null() - and "An object ID must not be NULL ({000000000-0000-0000-0000-0000000000000})"); -} - -IObject::IObject(const Ref& uid) : pOID(uid) -{ - assert(!pOID.null() - and "An object ID must not be NULL ({000000000-0000-0000-0000-0000000000000})"); -} - -IObject::~IObject() -{ - // It would be safer to lock/unlock the inner mutex to prevent - // some rare (and nearly impossible) case where the object is destroyed - // whereas another thread is calling one of our methods. - // The smart pointer should get rid of this issue. - // And anyway, it is pointless here the vtable has been already wiped out - // - // ThreadingPolicy::MutexLocker locker(*this); -} - -void IObject::caption(const AnyString& text) -{ - ThreadingPolicy::MutexLocker locker(*this); - pCaption = text; -} - -} // namespace Antares diff --git a/src/libs/antares/object/object.h b/src/libs/antares/object/object.h deleted file mode 100644 index 3071c13051..0000000000 --- a/src/libs/antares/object/object.h +++ /dev/null @@ -1,146 +0,0 @@ -/* -** Copyright 2007-2023 RTE -** Authors: Antares_Simulator Team -** -** This file is part of Antares_Simulator. -** -** Antares_Simulator is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** There are special exceptions to the terms and conditions of the -** license as they are applied to this software. View the full text of -** the exceptions in file COPYING.txt in the directory of this software -** distribution -** -** Antares_Simulator is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with Antares_Simulator. If not, see . -** -** SPDX-License-Identifier: licenceRef-GPL3_WITH_RTE-Exceptions -*/ -#ifndef __ANTARES_LIB_OBJECT_H__ -#define __ANTARES_LIB_OBJECT_H__ - -#include "../antares.h" -#include -#include -#include "ref.h" -#include "intrusive-reference.h" -#include - -namespace Antares -{ -/*! -** \brief Base assembly abstract object -** -** \note An object is disabled by default to avoid race conditions -** in future algorithms (race condtions while initializing for example) -*/ -class IObject : public Yuni::IIntrusiveSmartPtr -{ -public: - //! Ancestor - using Ancestor = Yuni::IIntrusiveSmartPtr; - //! The current threading policy - using ThreadingPolicy = Ancestor::ThreadingPolicy; - - /*! - ** \brief Class Helper to determine the most suitable smart pointer for a class - ** according the current threading policy - */ - template - class SmartPtr - { - public: - //! The most suitable smart pointer for T - using Ptr = typename Ancestor::template SmartPtrType::Ptr; - }; - - //! The most suitable smart pointer for the this class - using Ptr = Ancestor::SmartPtrType::Ptr; - -public: - //! \name Identifiers - //@{ - /*! - ** \brief Object Identifier - */ - const Ref& oid() const; - //@} - - //! \name Caption - //@{ - /*! - ** \brief Get the object's caption - ** \return Object's caption - */ - YString caption() const; - /*! - ** \brief Set the caption field - ** \param caption String to use as caption. - */ - void caption(const AnyString& caption); - //@} - - //! \name Enabled - //@{ - /*! - ** \brief Get the object's state - ** \return Object's state - */ - bool enabled() const; - /*! - ** \brief Set the object stated (enabled or not) - ** \param state State to set - */ - void enabled(bool state); - //@} - - //! \name Events - //@{ - //! The object is about to be destroyed - virtual void onRelease() const; - //@} - -protected: - //! \name Constructor & Destructor - //@{ - /*! - ** \brief Initialize the new IObject with the given UOID. - */ - IObject(); - /*! - ** \brief Initialize the new IObject with the given assembly name. - */ - explicit IObject(const Ref& oid); - /*! - ** \brief Destructor - */ - virtual ~IObject(); - //@} - -protected: - //! The most suitable type for a bool - using EnableType - = Yuni::Static::If, bool>::ResultType; - - //! Object Identifier - const Ref pOID; - //! Caption - YString pCaption; - //! If the object is enabled. Disabled by default - EnableType pEnabled; - -}; // class IObject - -} // namespace Antares - -#include "object.hxx" - -#endif // __ANTARES_LIB_OBJECT_H__ diff --git a/src/libs/antares/object/object.hxx b/src/libs/antares/object/object.hxx deleted file mode 100644 index 52cdaea434..0000000000 --- a/src/libs/antares/object/object.hxx +++ /dev/null @@ -1,60 +0,0 @@ -/* -** Copyright 2007-2023 RTE -** Authors: Antares_Simulator Team -** -** This file is part of Antares_Simulator. -** -** Antares_Simulator is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** There are special exceptions to the terms and conditions of the -** license as they are applied to this software. View the full text of -** the exceptions in file COPYING.txt in the directory of this software -** distribution -** -** Antares_Simulator is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with Antares_Simulator. If not, see . -** -** SPDX-License-Identifier: licenceRef-GPL3_WITH_RTE-Exceptions -*/ -#ifndef __ANTARES_LIB_OBJECT_HXX__ -#define __ANTARES_LIB_OBJECT_HXX__ - -namespace Antares -{ -inline const Ref& IObject::oid() const -{ - return pOID; -} - -inline YString IObject::caption() const -{ - ThreadingPolicy::MutexLocker locker(*this); - return pCaption; -} - -inline bool IObject::enabled() const -{ - return (pEnabled != 0); -} - -inline void IObject::enabled(bool state) -{ - pEnabled = state; -} - -inline void IObject::onRelease() const -{ - // do nothing -} - -} // namespace Antares - -#endif // __ANTARES_LIB_OBJECT_HXX__ diff --git a/src/libs/antares/object/ref.h b/src/libs/antares/object/ref.h deleted file mode 100644 index 1d7df2be18..0000000000 --- a/src/libs/antares/object/ref.h +++ /dev/null @@ -1,66 +0,0 @@ -/* -** Copyright 2007-2023 RTE -** Authors: Antares_Simulator Team -** -** This file is part of Antares_Simulator. -** -** Antares_Simulator is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** There are special exceptions to the terms and conditions of the -** license as they are applied to this software. View the full text of -** the exceptions in file COPYING.txt in the directory of this software -** distribution -** -** Antares_Simulator is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with Antares_Simulator. If not, see . -** -** SPDX-License-Identifier: licenceRef-GPL3_WITH_RTE-Exceptions -*/ -#ifndef __OPTIMATE_LIB_ASSEMBLY_OID_H__ -#define __OPTIMATE_LIB_ASSEMBLY_OID_H__ - -#include "../antares.h" -#include -#include - -namespace Yuni -{ -class YUNI_DECL UUID; -} - -namespace Antares -{ -//! Object Unique Identifier -using Ref = Yuni::UUID; - -} // namespace Antares - -namespace std -{ -/*! -** \brief Specialization fot std::hash -** -** This specialization is requiered for std::unordered_map -** (or any hash table from the previous tr1) -*/ -template<> -class hash -{ -public: - inline std::size_t operator()(const Yuni::UUID& value) const - { - return value.hash(); - } -}; // class hash - -} // namespace std - -#endif // __OPTIMATE_LIB_ASSEMBLY_OID_H__ diff --git a/src/libs/antares/stdcxx/CMakeLists.txt b/src/libs/antares/stdcxx/CMakeLists.txt index dbff9ebc02..876ed29353 100644 --- a/src/libs/antares/stdcxx/CMakeLists.txt +++ b/src/libs/antares/stdcxx/CMakeLists.txt @@ -1,10 +1,10 @@ set(PROJ stdcxx) set(HEADERS - include/antares/${PROJ}/demangle.hpp + include/antares/${PROJ}/class_name.h ) set(SRC_PROJ ${HEADERS} - demangle.cpp + class_name.cpp ) source_group("stdcxx" FILES ${SRC_STDCXX}) diff --git a/src/libs/antares/net/request.h b/src/libs/antares/stdcxx/class_name.cpp similarity index 68% rename from src/libs/antares/net/request.h rename to src/libs/antares/stdcxx/class_name.cpp index c2232465f9..194ff3fe39 100644 --- a/src/libs/antares/net/request.h +++ b/src/libs/antares/stdcxx/class_name.cpp @@ -24,28 +24,25 @@ ** ** SPDX-License-Identifier: licenceRef-GPL3_WITH_RTE-Exceptions */ -#ifndef __ANTARES_LIBS_NET_REQUEST_H__ -#define __ANTARES_LIBS_NET_REQUEST_H__ -namespace Antares -{ -namespace Net -{ -enum Method +#include + +namespace stdcxx { - rmGET, - rmPOST -}; -//! Event -using EventOnSuccess = Yuni::Bind; +std::string simpleClassName(const char* className) +{ + const std::string& strClassName = className; + std::size_t index = strClassName.find_last_of("::"); -void Request(Method method, - const AnyString& url, - const EventOnSuccess& onSuccess, - const EventOnError& onError); + return (index == std::string::npos) ? strClassName + : strClassName.substr(index + 1, strClassName.size()); +} -} // namespace Net -} // namespace Antares +template<> +std::string simpleClassName(const std::type_info& type) +{ + return simpleClassName(type.name()); +} -#endif // __ANTARES_LIBS_NET_REQUEST_H__ +} // namespace stdcxx diff --git a/src/libs/antares/stdcxx/demangle.cpp b/src/libs/antares/stdcxx/demangle.cpp deleted file mode 100644 index 5f1115d2be..0000000000 --- a/src/libs/antares/stdcxx/demangle.cpp +++ /dev/null @@ -1,79 +0,0 @@ -/* -** Copyright 2007-2023 RTE -** Authors: Antares_Simulator Team -** -** This file is part of Antares_Simulator. -** -** Antares_Simulator is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** There are special exceptions to the terms and conditions of the -** license as they are applied to this software. View the full text of -** the exceptions in file COPYING.txt in the directory of this software -** distribution -** -** Antares_Simulator is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with Antares_Simulator. If not, see . -** -** SPDX-License-Identifier: licenceRef-GPL3_WITH_RTE-Exceptions -*/ - -#include - -namespace stdcxx -{ -std::string demangle(const char* name) -{ - // TODO : for now no boost include, no demangle of class name - /* - #if defined(_WIN32) || defined(WIN32) - // under windows typeid(T).name() does not return a mangled name, but returns : - // - "class T" if T is a class - // - "struct T" if T is a struct - // - "enum T" if T is an enum - // - "union T" if T is an union - // so remove this useless prefix by removing everything found before the last ' ' character - std::string simplifiedName = name; - std::size_t index = simplifiedName.rfind(' '); - if (index != std::string::npos) { - simplifiedName = simplifiedName.substr(index + 1); - } - - return boost::core::demangle(simplifiedName.c_str()); - #else - return boost::core::demangle(name); - #endif - */ - - return name; -} - -template<> -std::string demangle(const std::type_info& type) -{ - return demangle(type.name()); -} - -std::string simpleClassName(const char* className) -{ - const std::string& strClassName = demangle(className); - std::size_t index = strClassName.find_last_of("::"); - - return (index == std::string::npos) ? strClassName - : strClassName.substr(index + 1, strClassName.size()); -} - -template<> -std::string simpleClassName(const std::type_info& type) -{ - return simpleClassName(type.name()); -} - -} // namespace stdcxx \ No newline at end of file diff --git a/src/libs/antares/stdcxx/include/antares/stdcxx/demangle.hpp b/src/libs/antares/stdcxx/include/antares/stdcxx/class_name.h similarity index 77% rename from src/libs/antares/stdcxx/include/antares/stdcxx/demangle.hpp rename to src/libs/antares/stdcxx/include/antares/stdcxx/class_name.h index 5187705b85..1d1e6df653 100644 --- a/src/libs/antares/stdcxx/include/antares/stdcxx/demangle.hpp +++ b/src/libs/antares/stdcxx/include/antares/stdcxx/class_name.h @@ -24,30 +24,13 @@ ** ** SPDX-License-Identifier: licenceRef-GPL3_WITH_RTE-Exceptions */ -#ifndef ANTARES_STDCXX_DEMANGLE_HPP -#define ANTARES_STDCXX_DEMANGLE_HPP +#pragma once #include #include namespace stdcxx { -std::string demangle(const char* name); - -template -std::string demangle() -{ - return demangle(typeid(T).name()); -} - -template -std::string demangle(const T& type) -{ - return demangle(typeid(type).name()); -} - -template<> -std::string demangle(const std::type_info& type); std::string simpleClassName(const char* className); @@ -64,5 +47,3 @@ std::string simpleClassName(const T& type) } } // namespace stdcxx - -#endif // ANTARES_STDCXX_DEMANGLE_HPP \ No newline at end of file diff --git a/src/libs/antares/study/CMakeLists.txt b/src/libs/antares/study/CMakeLists.txt index 81e40b120f..d4259be54c 100644 --- a/src/libs/antares/study/CMakeLists.txt +++ b/src/libs/antares/study/CMakeLists.txt @@ -300,7 +300,6 @@ target_link_libraries(study Antares::path Antares::mersenne Antares::result_writer #study.h - Antares::object Antares::series PRIVATE Antares::exception diff --git a/src/libs/antares/study/study.h b/src/libs/antares/study/study.h index 70ac2b04f6..e377b11ebd 100644 --- a/src/libs/antares/study/study.h +++ b/src/libs/antares/study/study.h @@ -36,7 +36,6 @@ #include #include "../antares.h" -#include "../object/object.h" #include "fwd.h" #include "simulation.h" @@ -63,7 +62,7 @@ namespace Antares::Data */ class UIRuntimeInfo; -class Study: public Yuni::NonCopyable, public IObject, public LayerData +class Study: public Yuni::NonCopyable, public LayerData { public: using Ptr = std::shared_ptr; diff --git a/src/ui/action/CMakeLists.txt b/src/ui/action/CMakeLists.txt index d69627811e..f519b13aa1 100644 --- a/src/ui/action/CMakeLists.txt +++ b/src/ui/action/CMakeLists.txt @@ -132,7 +132,6 @@ target_link_libraries(antares-action Antares::result_writer #study.h Antares::date #parameters Antares::inifile #parameters - Antares::object Antares::study ) From bfdedf65b866d7f407d065d3ec602ef7973c1878 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Omn=C3=A8s?= <26088210+flomnes@users.noreply.github.com> Date: Thu, 11 Jan 2024 16:16:49 +0100 Subject: [PATCH 05/14] Use SimTest 8.8.1 (#1872) Update reference results. They changed after #1752, in the case where thermal refresh is enabled. --- simtest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/simtest.json b/simtest.json index e4be9a9945..8fbede7352 100644 --- a/simtest.json +++ b/simtest.json @@ -1,3 +1,3 @@ { - "version": "v8.8.0" + "version": "v8.8.1" } From a7b9cd73fb01afebd1a3b0b1bbefa6c879696368 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Omn=C3=A8s?= <26088210+flomnes@users.noreply.github.com> Date: Mon, 15 Jan 2024 13:10:44 +0100 Subject: [PATCH 06/14] Fix segfault caused by uninitialized `cluster.series.timeseriesNumbers` (#1876) ```cpp void Area::resizeAllTimeseriesNumbers(uint nbYears) { assert(hydro.series and "series must not be nullptr !"); load.series.timeseriesNumbers.reset(1, nbYears); solar.series.timeseriesNumbers.reset(1, nbYears); wind.series.timeseriesNumbers.reset(1, nbYears); hydro.series->timeseriesNumbers.reset(1, nbYears); for (auto& namedLink : links) { AreaLink* link = namedLink.second; link->timeseriesNumbers.reset(1, nbYears); } thermal.resizeAllTimeseriesNumbers(nbYears); // resize is called here renewable.resizeAllTimeseriesNumbers(nbYears); // resize is called here } ``` --- src/libs/antares/study/parts/common/cluster_list.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/antares/study/parts/common/cluster_list.cpp b/src/libs/antares/study/parts/common/cluster_list.cpp index bc5f8e5aa5..f73ae6bac0 100644 --- a/src/libs/antares/study/parts/common/cluster_list.cpp +++ b/src/libs/antares/study/parts/common/cluster_list.cpp @@ -80,7 +80,7 @@ void ClusterList::clear() template void ClusterList::resizeAllTimeseriesNumbers(uint n) { - each([&](Cluster& cluster) { cluster.series.timeseriesNumbers.resize(1, n); }); + each([&](Cluster& cluster) { cluster.series.timeseriesNumbers.reset(1, n); }); } #define SEP IO::Separator From 6f61deff94909f1b1f047e735e6e77a9e457db98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Omn=C3=A8s?= <26088210+flomnes@users.noreply.github.com> Date: Mon, 15 Jan 2024 14:57:02 +0100 Subject: [PATCH 07/14] [CI] Don't use runner.name as a key for ubuntu's ccache (#1878) `${{runner.name}}` refers to > The name of the runner executing the job. This name may not be unique in a workflow run as runners at the repository and organization levels could use the same name. [source](https://docs.github.com/en/actions/learn-github-actions/contexts#runner-context) It may be too unique since after this change, ccache never finds cached data (hit rate ~ 0%). This defeats the purpose of using a cache. Using a fixed value may lead to a higher hit rate. --- .github/workflows/ubuntu.yml | 32 ++++++++++++++--------------- .github/workflows/windows-vcpkg.yml | 4 ++-- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 763590cd8d..8cdd229984 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -30,7 +30,7 @@ jobs: name: Build env: ORTOOLS_DIR: ${{ github.workspace }}/or-tools - OS: ubuntu-20.04 + os: ubuntu-20.04 runs-on: ubuntu-20.04 if: "!contains(github.event.head_commit.message, '[skip ci]')" @@ -41,7 +41,7 @@ jobs: - name: ccache uses: hendrikmuhs/ccache-action@v1.2 with: - key: ${{ runner.name }} + key: ${{ env.os }} - name: Install libraries run: | @@ -66,7 +66,7 @@ jobs: uses: ./.github/workflows/download-extract-precompiled-libraries-tgz with: antares-deps-version: ${{steps.antares-deps-version.outputs.prop}} - os: ${{env.OS}} + os: ${{env.os}} ortools-url: ${{env.ORTOOLS_URL}} ortools-dir: ${{env.ORTOOLS_DIR}} @@ -121,7 +121,7 @@ jobs: with: simtest-tag: ${{steps.simtest-version.outputs.prop}} batch-name: valid-named-mps - os: ${{ env.OS }} + os: ${{ env.os }} variant: "named-mps" - name: Run unfeasibility-related tests @@ -149,7 +149,7 @@ jobs: with: simtest-tag: ${{steps.simtest-version.outputs.prop}} batch-name: valid-v830 - os: ${{ env.OS }} + os: ${{ env.os }} - name: Run MILP with CBC if: ${{ env.RUN_SIMPLE_TESTS == 'true' }} @@ -158,7 +158,7 @@ jobs: simtest-tag: ${{steps.simtest-version.outputs.prop}} batch-name: valid-milp variant: "milp-cbc" - os: ${{ env.OS }} + os: ${{ env.os }} - name: Run tests introduced in v860 if: ${{ env.RUN_SIMPLE_TESTS == 'true' }} @@ -166,7 +166,7 @@ jobs: with: simtest-tag: ${{steps.simtest-version.outputs.prop}} batch-name: valid-v860 - os: ${{ env.OS }} + os: ${{ env.os }} - name: Run tests introduced in v870 if: ${{ env.RUN_SIMPLE_TESTS == 'true' }} @@ -174,7 +174,7 @@ jobs: with: simtest-tag: ${{steps.simtest-version.outputs.prop}} batch-name: valid-v870 - os: ${{ env.OS }} + os: ${{ env.os }} - name: Run short-tests if: ${{ env.RUN_SIMPLE_TESTS == 'true' }} @@ -182,7 +182,7 @@ jobs: with: simtest-tag: ${{steps.simtest-version.outputs.prop}} batch-name: short-tests - os: ${{ env.OS }} + os: ${{ env.os }} - name: Run mps tests if: ${{ env.RUN_SIMPLE_TESTS == 'true' }} @@ -190,7 +190,7 @@ jobs: with: simtest-tag: ${{steps.simtest-version.outputs.prop}} batch-name: valid-mps - os: ${{ env.OS }} + os: ${{ env.os }} - name: Run tests for adequacy patch (CSR) if: ${{ env.RUN_SIMPLE_TESTS == 'true' }} @@ -198,7 +198,7 @@ jobs: with: simtest-tag: ${{steps.simtest-version.outputs.prop}} batch-name: adequacy-patch-CSR - os: ${{ env.OS }} + os: ${{ env.os }} - name: Run parallel tests if: ${{ env.RUN_EXTENDED_TESTS == 'true' }} @@ -206,7 +206,7 @@ jobs: with: simtest-tag: ${{steps.simtest-version.outputs.prop}} batch-name: valid-parallel - os: ${{ env.OS }} + os: ${{ env.os }} variant: "parallel" - name: Run medium-tests @@ -215,7 +215,7 @@ jobs: with: simtest-tag: ${{steps.simtest-version.outputs.prop}} batch-name: medium-tests - os: ${{ env.OS }} + os: ${{ env.os }} - name: Run long-tests-1 if: ${{ env.RUN_EXTENDED_TESTS == 'true' }} @@ -223,7 +223,7 @@ jobs: with: simtest-tag: ${{steps.simtest-version.outputs.prop}} batch-name: long-tests-1 - os: ${{ env.OS }} + os: ${{ env.os }} - name: Run long-tests-2 if: ${{ env.RUN_EXTENDED_TESTS == 'true' }} @@ -231,7 +231,7 @@ jobs: with: simtest-tag: ${{steps.simtest-version.outputs.prop}} batch-name: long-tests-2 - os: ${{ env.OS }} + os: ${{ env.os }} - name: Run long-tests-3 if: ${{ env.RUN_EXTENDED_TESTS == 'true' }} @@ -239,7 +239,7 @@ jobs: with: simtest-tag: ${{steps.simtest-version.outputs.prop}} batch-name: long-tests-3 - os: ${{ env.OS }} + os: ${{ env.os }} - name: Installer .deb creation run: | diff --git a/.github/workflows/windows-vcpkg.yml b/.github/workflows/windows-vcpkg.yml index 03f82d4fcc..c1940179c9 100644 --- a/.github/workflows/windows-vcpkg.yml +++ b/.github/workflows/windows-vcpkg.yml @@ -33,7 +33,7 @@ jobs: VCPKG_ROOT: ${{ github.workspace }}/vcpkg ORTOOLS_DIR: ${{ github.workspace }}/or-tools RUN_EXTENDED_TESTS: ${{ github.event_name == 'schedule'}} - OS: windows-latest + os: windows-latest test-platform: windows-2022 vcpkgPackages: wxwidgets boost-test triplet: x64-windows @@ -111,7 +111,7 @@ jobs: uses: ./.github/workflows/download-extract-precompiled-libraries-zip with: antares-deps-version: ${{steps.antares-deps-version.outputs.prop}} - os: ${{env.OS}} + os: ${{env.os}} ortools-url: ${{env.ORTOOLS_URL}} ortools-dir: ${{env.ORTOOLS_DIR}} From bdead1b51273d7c8b5eca6467475ad2cb6f5f48a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Omn=C3=A8s?= <26088210+flomnes@users.noreply.github.com> Date: Tue, 16 Jan 2024 13:08:15 +0100 Subject: [PATCH 08/14] Bump OR-Tools (fix crash with XPRESS) (#1873) Since OR-Tools 9.5-rte3.0 does not support `SetStartingLpBasis` (it supports `SetStartingLpBasisInt`), we must use 9.8-rte1.0-beta2 instead. Using XPRESS with Antares Simulator 8.8.0 (OR-Tools 9.5-rte3.0) causes a crash with the following error message ``` W0111 15:00:55.315875 169991 environment.cc:282] Optimizer version: 39.01.01 (OR-Tools was compiled with version 41). [2024-01-11 15:00:55][solver][infos] Solver OR-Tools MPS File: `problem-1-1--optim-nb-2.mps' F0111 15:00:55.821070 169991 linear_solver.h:1766] Not supported by this solver. *** Check failure stack trace: *** Abandon (core dumped) ``` Also, don't convert CMAKE_BUILD_TYPE to lower-case. It causes issues with SCIP and antares-deps. --- docs/build/3-Build.md | 2 +- ortools_tag | 2 +- src/CMakeLists.txt | 2 -- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/docs/build/3-Build.md b/docs/build/3-Build.md index 1cc36392b7..4bb18ce1b9 100644 --- a/docs/build/3-Build.md +++ b/docs/build/3-Build.md @@ -34,7 +34,7 @@ Here is a list of available CMake configure option : |Option | Description | |:-------|-------| -|`CMAKE_BUILD_TYPE` | Define build type. Available values are `release` and `debug` (case insensitive) | +|`CMAKE_BUILD_TYPE` | Define build type. Available values are `Release` and `Debug` | |`BUILD_UI`|Enable or disable Antares Simulator UI compilation (default `ON`)| |`BUILD_ALL`|Enable build of ALL external libraries (default `OFF`)| |`DEPS_INSTALL_DIR`|Define dependencies libraries install directory| diff --git a/ortools_tag b/ortools_tag index a75a3d2f6d..fdaa0174f8 100644 --- a/ortools_tag +++ b/ortools_tag @@ -1 +1 @@ -v9.5-rte3.0 \ No newline at end of file +v9.8-rte1.0 \ No newline at end of file diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f790c854b7..92e1cedaa8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -66,8 +66,6 @@ execute_process(COMMAND OUTPUT_VARIABLE GIT_SHA1_SHORT ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) -string(TOLOWER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE) - # Build Configuration set(ANTARES_TARGET "${CMAKE_BUILD_TYPE}") From b82e7187d64d9d93ffefa69b0981a20a2a8d0029 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Omn=C3=A8s?= <26088210+flomnes@users.noreply.github.com> Date: Tue, 16 Jan 2024 13:55:21 +0100 Subject: [PATCH 09/14] Add changelog info for 8.8.1, 8.8.2 (#1877) - Edit changelog for 8.8.1 - Add changelog for 8.8.2 - Increment revision number 8.8.1 => 8.8.2 --- docs/CHANGELOG.md | 15 ++++++++++++--- src/CMakeLists.txt | 2 +- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 268d1b1add..4f80b0eef7 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -6,8 +6,16 @@ Antares Changelog ## New Features * Solver logs can be enabled either by the command-line option (--solver-logs) or in the generaldata.ini by setting solver-logs = true under the optimization section [(#1717)](https://github.com/AntaresSimulatorTeam/Antares_Simulator/pull/1717) +8.8.2 +-------------------- + +## Bugfix +* Fix segfault caused by uninitialized `cluster.series.timeseriesNumbers` (#1876). This bug was introduced in v8.8.1 by #1752 +* Bump OR-Tools from 9.5 to 9.8 (fix crash with XPRESS) (#1873) + 8.8.1 (01/2024) -------------------- +/!\ This version has known bugs, please use 8.8.2 instead. ## Bugfix * Simplify TS numbers drawings, fix bug related to refresh & local thermal generation (#1752) @@ -15,15 +23,16 @@ Antares Changelog ## Improvements * Take into account breaking change in OR-Tools's API, enable SCIP & GLPK solvers, bump OR-Tools (#1825). This should improve performances with FICO XPRESS * Fail if OR-Tools solver is not found (#1851) +* Normalize simulation mode Expansion, fix logs (#1771) * Add possibility to release without running any tests (#1852) ## Code quality * Use `std::unordered_map` for tmpDataByArea_ (hydro ventilation) (#1855) * Remove `mutable` keyword from `PROBLEME_HEBDO` (#1846) -* Remove Study::gotFatalError, throw exceptions instead (#1806) +* Remove `Study::gotFatalError`, throw exceptions instead (#1806) * Renewable containers (#1809) -* Use modern style for loops, avoid int cast (#1847) -* Remove YUNI_STATIC_ASSERT (#1863) +* Use modern style `for` loops, avoid int cast (#1847) +* Remove `YUNI_STATIC_ASSERT` (#1863) ## Testing * Add tests on short-term storage/thermal cluster/renewable cluster removal (#1841) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 92e1cedaa8..f6c1cdc5f7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.14) # FetchContent_MakeAvailable # Version set(ANTARES_VERSION_HI 8) set(ANTARES_VERSION_LO 8) -set(ANTARES_VERSION_REVISION 1) +set(ANTARES_VERSION_REVISION 2) # Beta release set(ANTARES_BETA 0) From 670628e3a5b8fb2edc235443f313eeb4bc187933 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Omn=C3=A8s?= <26088210+flomnes@users.noreply.github.com> Date: Tue, 16 Jan 2024 17:14:33 +0100 Subject: [PATCH 10/14] Use Release|Debug instead of release|debug for `CMAKE_BUILD_TYPE` (#1879) We no longer change CMAKE_BUILD_TYPE, see #1873. We must use exactly Release or Debug for some of our dependencies (SCIP). ``` CMake Error at /__w/Antares_Simulator/Antares_Simulator/_build/_deps/scip-src/CMakeLists.txt:111 (message): -- Build type: release You have not selected a valid CMAKE_BUILD_TYPE. Please select 'Release' or 'Debug'. ``` See https://github.com/AntaresSimulatorTeam/Antares_Simulator/actions/runs/7541339936/job/20527856062 Also, remove custom "tuning" value, since it is unused and not documented. --- .github/workflows/centos7-system-deps-build.yml | 2 +- .github/workflows/centos7.yml | 2 +- .github/workflows/oracle8.yml | 2 +- .github/workflows/sonarcloud.yml | 2 +- .github/workflows/ubuntu-system-deps-build.yml | 2 +- .github/workflows/ubuntu.yml | 4 ++-- .github/workflows/windows-release.yml | 2 +- .github/workflows/windows-vcpkg.yml | 4 ++-- src/CMakeLists.txt | 12 ++++++------ src/cmake/common-settings.cmake | 14 ++++---------- src/cmake/utils.cmake | 4 +--- src/ext/yuni/src/cmake/common-settings.cmake | 4 ++-- src/ext/yuni/src/cmake/target.cmake | 4 ++-- 13 files changed, 25 insertions(+), 33 deletions(-) diff --git a/.github/workflows/centos7-system-deps-build.yml b/.github/workflows/centos7-system-deps-build.yml index 710c89ba09..1dd906c4d9 100644 --- a/.github/workflows/centos7-system-deps-build.yml +++ b/.github/workflows/centos7-system-deps-build.yml @@ -50,7 +50,7 @@ jobs: source /opt/rh/devtoolset-9/enable #git 2.x must be enabled for Coin compilation with CMake ExternalProject_Add source /opt/rh/rh-git227/enable - cmake -B _build -S src -DCMAKE_BUILD_TYPE=release -DBUILD_TESTING=ON + cmake -B _build -S src -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON - name: Build run: | diff --git a/.github/workflows/centos7.yml b/.github/workflows/centos7.yml index 8ef8ca5a7a..fd0f4ecc27 100644 --- a/.github/workflows/centos7.yml +++ b/.github/workflows/centos7.yml @@ -71,7 +71,7 @@ jobs: -DCMAKE_C_COMPILER_LAUNCHER=ccache \ -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ -DDEPS_INSTALL_DIR=/rte-antares-deps-Release \ - -DCMAKE_BUILD_TYPE=release \ + -DCMAKE_BUILD_TYPE=Release \ -DBUILD_TESTING=ON \ -DBUILD_not_system=OFF \ -DBUILD_TOOLS=OFF \ diff --git a/.github/workflows/oracle8.yml b/.github/workflows/oracle8.yml index 2c0ea15c5e..10e94ddb92 100644 --- a/.github/workflows/oracle8.yml +++ b/.github/workflows/oracle8.yml @@ -58,7 +58,7 @@ jobs: run: | source /opt/rh/gcc-toolset-10/enable cmake -B _build -S src \ - -DCMAKE_BUILD_TYPE=release \ + -DCMAKE_BUILD_TYPE=Release \ -DBUILD_TESTING=ON \ -DBUILD_TOOLS=OFF \ -DBUILD_UI=OFF \ diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index 1b865d081e..7978abc23f 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -88,7 +88,7 @@ jobs: -DCMAKE_CXX_COMPILER=/usr/bin/g++-10 \ -DDEPS_INSTALL_DIR=./rte-antares-deps-Debug \ -DCODE_COVERAGE=ON \ - -DCMAKE_BUILD_TYPE=debug \ + -DCMAKE_BUILD_TYPE=Debug \ -DCMAKE_PREFIX_PATH="../install;${{ env.ORTOOLS_DIR }}/install" \ -DBUILD_TESTING=ON \ -DMZ_CODE_COVERAGE=ON \ diff --git a/.github/workflows/ubuntu-system-deps-build.yml b/.github/workflows/ubuntu-system-deps-build.yml index bd81673e9e..9c73e036a2 100644 --- a/.github/workflows/ubuntu-system-deps-build.yml +++ b/.github/workflows/ubuntu-system-deps-build.yml @@ -43,7 +43,7 @@ jobs: - name: Configure run: | - cmake -B _build -S src -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_C_COMPILER=/usr/bin/gcc-10 -DCMAKE_CXX_COMPILER=/usr/bin/g++-10 -DCMAKE_BUILD_TYPE=release -DBUILD_TESTING=ON + cmake -B _build -S src -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_C_COMPILER=/usr/bin/gcc-10 -DCMAKE_CXX_COMPILER=/usr/bin/g++-10 -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON - name: Build run: | diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 8cdd229984..f85572cdbc 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -94,7 +94,7 @@ jobs: -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ -DCMAKE_CXX_COMPILER=/usr/bin/g++-10 \ -DDEPS_INSTALL_DIR=${{github.workspace}}/rte-antares-deps-Release \ - -DCMAKE_BUILD_TYPE=release \ + -DCMAKE_BUILD_TYPE=Release \ -DBUILD_TESTING=ON \ -DBUILD_not_system=OFF \ -DBUILD_TOOLS=ON \ @@ -103,7 +103,7 @@ jobs: - name: Build run: | - cmake --build _build --config release -j$(nproc) + cmake --build _build -j$(nproc) # simtest diff --git a/.github/workflows/windows-release.yml b/.github/workflows/windows-release.yml index e6e7beed9b..5c0b58fff0 100644 --- a/.github/workflows/windows-release.yml +++ b/.github/workflows/windows-release.yml @@ -100,7 +100,7 @@ jobs: -DCMAKE_PREFIX_PATH="${{env.ORTOOLS_DIR}}/install" \ -DVCPKG_ROOT="${{env.VCPKG_ROOT}}" \ -DVCPKG_TARGET_TRIPLET=${{ matrix.triplet }} \ - -DCMAKE_BUILD_TYPE=release \ + -DCMAKE_BUILD_TYPE=Release \ -DBUILD_TESTING=ON \ -DBUILD_TOOLS=ON \ -DBUILD_not_system=OFF \ diff --git a/.github/workflows/windows-vcpkg.yml b/.github/workflows/windows-vcpkg.yml index c1940179c9..0378a8f074 100644 --- a/.github/workflows/windows-vcpkg.yml +++ b/.github/workflows/windows-vcpkg.yml @@ -141,7 +141,7 @@ jobs: -DCMAKE_PREFIX_PATH="${{ env.ORTOOLS_DIR }}/install" \ -DVCPKG_ROOT="${{env.VCPKG_ROOT}}" \ -DVCPKG_TARGET_TRIPLET=${{ env.triplet }} \ - -DCMAKE_BUILD_TYPE=release \ + -DCMAKE_BUILD_TYPE=Release \ -DBUILD_TESTING=ON \ -DBUILD_TOOLS=ON \ -DBUILD_not_system=OFF \ @@ -151,7 +151,7 @@ jobs: - name: Build shell: bash run: | - cmake --build _build --config release -j2 + cmake --build _build --config Release -j2 # simtest - name: Read simtest version id: simtest-version diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f6c1cdc5f7..9a2b334d3d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -141,7 +141,7 @@ OMESSAGE("") OMESSAGE("") #Display Build Configuration (debug or release) -if("${CMAKE_BUILD_TYPE}" STREQUAL "release" OR "${CMAKE_BUILD_TYPE}" STREQUAL "tuning") +if("${CMAKE_BUILD_TYPE}" STREQUAL "Release") OMESSAGE("{antares} Build Configuration: RELEASE") else() OMESSAGE("{antares} Build Configuration: DEBUG") @@ -150,7 +150,7 @@ endif() # # Yuni Framework # -if("${CMAKE_BUILD_TYPE}" STREQUAL "release" OR "${CMAKE_BUILD_TYPE}" STREQUAL "tuning") +if("${CMAKE_BUILD_TYPE}" STREQUAL "Release") set(YUNI_TARGET_MODE "release") set(ANTARES_VERSION_TARGET "release") else() @@ -197,7 +197,7 @@ endif() # Add DEPS_INSTALL_DIR with antares-xpansion CMAKE_BUILD_TYPE -if ("${CMAKE_BUILD_TYPE}" STREQUAL "release") +if ("${CMAKE_BUILD_TYPE}" STREQUAL "Release") string(REPLACE ${CMAKE_BUILD_TYPE} Release DEPS_INSTALL_DIR_XPANSION @@ -354,11 +354,11 @@ OMESSAGE("") # Informations for NSIS if(WIN32 OR WIN64) if(MSVC) - if("${CMAKE_BUILD_TYPE}" STREQUAL "release" OR "${CMAKE_BUILD_TYPE}" STREQUAL "tuning") + if("${CMAKE_BUILD_TYPE}" STREQUAL "Release") set(NSIS_TARGET "Release") - else("${CMAKE_BUILD_TYPE}" STREQUAL "release" OR "${CMAKE_BUILD_TYPE}" STREQUAL "tuning") + else() set(NSIS_TARGET "Debug") - endif("${CMAKE_BUILD_TYPE}" STREQUAL "release" OR "${CMAKE_BUILD_TYPE}" STREQUAL "tuning") + endif() set(COMPILER_MARK "v") #set(COMPILER_INCLUDE "vs9") else(MSVC) diff --git a/src/cmake/common-settings.cmake b/src/cmake/common-settings.cmake index 8a3f7626fc..3538597f13 100644 --- a/src/cmake/common-settings.cmake +++ b/src/cmake/common-settings.cmake @@ -24,7 +24,7 @@ macro(EMBED_MANIFEST manifestfile target) if(MSVC AND NOT MSVC9) message(STATUS "{antares} :: adding rule for manifest ${manifestfile}") set(ANTARES_UI_BIN_TARGET "Debug\\") - if("${CMAKE_BUILD_TYPE}" STREQUAL "release" OR "${CMAKE_BUILD_TYPE}" STREQUAL "tuning") + if("${CMAKE_BUILD_TYPE}" STREQUAL "Release") set(ANTARES_UI_BIN_TARGET "Release\\") endif() @@ -42,7 +42,7 @@ endmacro() # # Ex: cmake . -DCMAKE_BUILD_TYPE=release # -if("${CMAKE_BUILD_TYPE}" STREQUAL "release" OR "${CMAKE_BUILD_TYPE}" STREQUAL "tuning") +if("${CMAKE_BUILD_TYPE}" STREQUAL "Release") # # Build Configuration: Release @@ -61,12 +61,6 @@ if("${CMAKE_BUILD_TYPE}" STREQUAL "release" OR "${CMAKE_BUILD_TYPE}" STREQUAL "t if (NOT MSVC) set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -std=c99") endif() - - if("${CMAKE_BUILD_TYPE}" STREQUAL "tuning") - set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -pg --no-inline") - set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -pg --no-inline") - endif("${CMAKE_BUILD_TYPE}" STREQUAL "tuning") - else() # @@ -216,7 +210,7 @@ endmacro() macro(executable_strip TARGET) - if("${CMAKE_BUILD_TYPE}" STREQUAL "release") + if("${CMAKE_BUILD_TYPE}" STREQUAL "Release") if(NOT MSVC) if(WIN32) add_custom_command(TARGET ${TARGET} POST_BUILD COMMAND ${CMAKE_STRIP} $) @@ -227,7 +221,7 @@ macro(executable_strip TARGET) endif() endmacro() -if("${CMAKE_BUILD_TYPE}" STREQUAL "release" OR "${CMAKE_BUILD_TYPE}" STREQUAL "tuning") +if("${CMAKE_BUILD_TYPE}" STREQUAL "Release") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_RELEASE}") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS_RELEASE}") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS_RELEASE}") diff --git a/src/cmake/utils.cmake b/src/cmake/utils.cmake index b470a700fc..3e3aeb7e20 100644 --- a/src/cmake/utils.cmake +++ b/src/cmake/utils.cmake @@ -1,10 +1,8 @@ macro(copy_dependency deps target) - if("${CMAKE_BUILD_TYPE}" STREQUAL "release") - + if("${CMAKE_BUILD_TYPE}" STREQUAL "Release") get_target_property( DEP_SHARED_LIB_PATH ${deps} IMPORTED_LOCATION_RELEASE ) else() - get_target_property( DEP_SHARED_LIB_PATH ${deps} IMPORTED_LOCATION_DEBUG ) endif() diff --git a/src/ext/yuni/src/cmake/common-settings.cmake b/src/ext/yuni/src/cmake/common-settings.cmake index 9c8410ad3b..d92357ebde 100644 --- a/src/ext/yuni/src/cmake/common-settings.cmake +++ b/src/ext/yuni/src/cmake/common-settings.cmake @@ -12,7 +12,7 @@ include(CheckCXXCompilerFlag) set_property(GLOBAL PROPERTY USE_FOLDERS true) -if ("${CMAKE_BUILD_TYPE}" STREQUAL "release" OR "${CMAKE_BUILD_TYPE}" STREQUAL "RELEASE") +if ("${CMAKE_BUILD_TYPE}" STREQUAL "Release") set(YUNI_) else() set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_DEBUG}") @@ -305,7 +305,7 @@ if(NOT "${YUNI_CXX_FLAGS_OVERRIDE_ADD_RELWITHDEBINFO}" STREQUAL "") set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} ${YUNI_CXX_FLAGS_OVERRIDE_ADD_RELWITHDEBINFO}") endif() -if ("${CMAKE_BUILD_TYPE}" STREQUAL "release" OR "${CMAKE_BUILD_TYPE}" STREQUAL "RELEASE") +if ("${CMAKE_BUILD_TYPE}" STREQUAL "Release") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_RELEASE}") else() set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_DEBUG}") diff --git a/src/ext/yuni/src/cmake/target.cmake b/src/ext/yuni/src/cmake/target.cmake index b0e23cfff0..3f67bfc489 100644 --- a/src/ext/yuni/src/cmake/target.cmake +++ b/src/ext/yuni/src/cmake/target.cmake @@ -24,8 +24,8 @@ if(NO_BUILD_TYPE) endif() endif() -string(COMPARE EQUAL "${CMAKE_BUILD_TYPE}" "debug" BUILD_TYPE_IS_DEBUG) -string(COMPARE EQUAL "${CMAKE_BUILD_TYPE}" "release" BUILD_TYPE_IS_RELEASE) +string(COMPARE EQUAL "${CMAKE_BUILD_TYPE}" "Debug" BUILD_TYPE_IS_DEBUG) +string(COMPARE EQUAL "${CMAKE_BUILD_TYPE}" "Release" BUILD_TYPE_IS_RELEASE) if(NOT BUILD_TYPE_IS_DEBUG AND NOT BUILD_TYPE_IS_RELEASE) set(CMAKE_BUILD_TYPE "debug") endif() From b85d950c4a9bd3df6661fb6fd7fc36658730e916 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Omn=C3=A8s?= <26088210+flomnes@users.noreply.github.com> Date: Wed, 17 Jan 2024 10:27:43 +0100 Subject: [PATCH 11/14] Bump SimTest -> v8.8.2 (#1885) Because of a segfault and poor error handling on SimTest [fixed](https://github.com/AntaresSimulatorTeam/SimTest/compare/v8.8.2..v8.8.1), some results from SimTest@v8.8.1 are missing. SimTest@v8.8.2 fixes most missing results, with 2 exceptions : hydroPricing and valid-hydro. These two have some failing studies related to infeasible problems caused by hydro hard bounds. --- simtest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/simtest.json b/simtest.json index 8fbede7352..570b89427c 100644 --- a/simtest.json +++ b/simtest.json @@ -1,3 +1,3 @@ { - "version": "v8.8.1" + "version": "v8.8.2" } From 968cdf938938a36a9b37a62ffe7b7fbe18e06143 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Omn=C3=A8s?= <26088210+flomnes@users.noreply.github.com> Date: Fri, 19 Jan 2024 11:37:35 +0100 Subject: [PATCH 12/14] Fix a few compilation warnings (#1880) `HOURS_PER_YEAR` and `DAYS_PER_YEAR` were previously `#define`s, they have been converted to `const unsigned int`. This change created a few compilation warnings, which we fix in this PR. --- src/libs/antares/study/area/links.cpp | 10 +++++----- src/libs/antares/study/parts/hydro/container.cpp | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/libs/antares/study/area/links.cpp b/src/libs/antares/study/area/links.cpp index a685114c8e..5f931de121 100644 --- a/src/libs/antares/study/area/links.cpp +++ b/src/libs/antares/study/area/links.cpp @@ -102,7 +102,7 @@ bool AreaLink::linkLoadTimeSeries_for_version_below_810(const AnyString& folder) } // Store data into link's data container - for (int h = 0; h < HOURS_PER_YEAR; h++) + for (unsigned int h = 0; h < HOURS_PER_YEAR; h++) { directCapacities[0][h] = tmpMatrix[0][h]; indirectCapacities[0][h] = tmpMatrix[1][h]; @@ -502,7 +502,7 @@ bool AreaLinksLoadFromFolder(Study& study, AreaList* l, Area* area, const AnyStr const double* indirectCapacities = link.indirectCapacities[indexTS]; // Checks on direct capacities - for (int h = 0; h < HOURS_PER_YEAR; h++) + for (unsigned int h = 0; h < HOURS_PER_YEAR; h++) { if (directCapacities[h] < 0.) { @@ -517,7 +517,7 @@ bool AreaLinksLoadFromFolder(Study& study, AreaList* l, Area* area, const AnyStr } // Checks on indirect capacities - for (int h = 0; h < HOURS_PER_YEAR; h++) + for (unsigned int h = 0; h < HOURS_PER_YEAR; h++) { if (indirectCapacities[h] < 0.) { @@ -532,7 +532,7 @@ bool AreaLinksLoadFromFolder(Study& study, AreaList* l, Area* area, const AnyStr } } // Checks on hurdle costs - for (int h = 0; h < HOURS_PER_YEAR; h++) + for (unsigned int h = 0; h < HOURS_PER_YEAR; h++) { if (directHurdlesCost[h] + indirectHurdlesCost[h] < 0) { @@ -544,7 +544,7 @@ bool AreaLinksLoadFromFolder(Study& study, AreaList* l, Area* area, const AnyStr } // Checks on P. shift min and max - for (int h = 0; h < HOURS_PER_YEAR; h++) + for (unsigned int h = 0; h < HOURS_PER_YEAR; h++) { if (PShiftPlus[h] < PShiftMinus[h]) { diff --git a/src/libs/antares/study/parts/hydro/container.cpp b/src/libs/antares/study/parts/hydro/container.cpp index 288ec58a44..ae7c6ce40a 100644 --- a/src/libs/antares/study/parts/hydro/container.cpp +++ b/src/libs/antares/study/parts/hydro/container.cpp @@ -191,7 +191,7 @@ bool PartHydro::LoadFromFolder(Study& study, const AnyString& folder) { auto& col = area.hydro.inflowPattern[0]; bool errorInflow = false; - for (int day = 0; day < DAYS_PER_YEAR; day++) + for (unsigned int day = 0; day < DAYS_PER_YEAR; day++) { if (col[day] < 0 && !errorInflow) { @@ -204,7 +204,7 @@ bool PartHydro::LoadFromFolder(Study& study, const AnyString& folder) auto& colMin = area.hydro.reservoirLevel[minimum]; auto& colAvg = area.hydro.reservoirLevel[average]; auto& colMax = area.hydro.reservoirLevel[maximum]; - for (int day = 0; day < DAYS_PER_YEAR; day++) + for (unsigned int day = 0; day < DAYS_PER_YEAR; day++) { if (!errorLevels && (colMin[day] < 0 || colAvg[day] < 0 || colMin[day] > colMax[day] @@ -219,7 +219,7 @@ bool PartHydro::LoadFromFolder(Study& study, const AnyString& folder) for (int i = 0; i < 4; i++) { auto& col = area.hydro.maxPower[i]; - for (int day = 0; day < DAYS_PER_YEAR; day++) + for (unsigned int day = 0; day < DAYS_PER_YEAR; day++) { if (!errorPowers && (col[day] < 0 || (i % 2 /*column hours*/ && col[day] > 24))) { From 34b868c558eb7fc1ca1a40a90e87cde19dd02612 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Omn=C3=A8s?= <26088210+flomnes@users.noreply.github.com> Date: Fri, 19 Jan 2024 11:48:00 +0100 Subject: [PATCH 13/14] Install gh at start of workflows for CentOS 7 & OracleLinux 8 (#1883) If the install fails, the process will end directly. This should avoid the following frustrating scenario in case of failure ``` [OK] Install g++10 [OK] Configure [OK] Build [KO] Install gh [ ] Upload assets <= Not done, assets missing ``` --- .github/workflows/centos7.yml | 16 ++++++++-------- .github/workflows/oracle8.yml | 14 +++++++------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/.github/workflows/centos7.yml b/.github/workflows/centos7.yml index fd0f4ecc27..d8adca7914 100644 --- a/.github/workflows/centos7.yml +++ b/.github/workflows/centos7.yml @@ -64,6 +64,14 @@ jobs: yum install -y centos-release-scl yum install -y devtoolset-10-gcc* + - name: Install gh if needed + if: ${{ env.IS_RELEASE == 'true' }} + run: | + yum -y install dnf + dnf -y install 'dnf-command(config-manager)' + dnf -y config-manager --add-repo https://cli.github.com/packages/rpm/gh-cli.repo + dnf -y install gh + - name: Configure run: | source /opt/rh/devtoolset-10/enable @@ -115,14 +123,6 @@ jobs: with: path: _build/*.rpm - - name: Install gh - if: ${{ env.IS_RELEASE == 'true' }} - run: | - yum -y install dnf - dnf -y install 'dnf-command(config-manager)' - dnf -y config-manager --add-repo https://cli.github.com/packages/rpm/gh-cli.repo - dnf -y install gh - - name: Publish assets if: ${{ env.IS_RELEASE == 'true' }} env: diff --git a/.github/workflows/oracle8.yml b/.github/workflows/oracle8.yml index 10e94ddb92..591ba89b50 100644 --- a/.github/workflows/oracle8.yml +++ b/.github/workflows/oracle8.yml @@ -54,6 +54,13 @@ jobs: run: | pip3 install -r src/tests/examples/requirements.txt + - name: Install gh if needed + if: ${{ env.IS_RELEASE == 'true' }} + run: | + dnf -y install 'dnf-command(config-manager)' + dnf -y config-manager --add-repo https://cli.github.com/packages/rpm/gh-cli.repo + dnf -y install gh + - name: Configure run: | source /opt/rh/gcc-toolset-10/enable @@ -104,13 +111,6 @@ jobs: with: path: _build/*.rpm - - name: Install gh - if: ${{ env.IS_RELEASE == 'true' }} - run: | - dnf -y install 'dnf-command(config-manager)' - dnf -y config-manager --add-repo https://cli.github.com/packages/rpm/gh-cli.repo - dnf -y install gh - - name: Publish assets if: ${{ env.IS_RELEASE == 'true' }} env: From b774fdc38911062f2a4e35944b5555c01a44c800 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Omn=C3=A8s?= <26088210+flomnes@users.noreply.github.com> Date: Fri, 19 Jan 2024 11:55:38 +0100 Subject: [PATCH 14/14] Use reference for variable `NbTermesContraintesPourLesCoutsDeDemarrage` (#1881) Instead of a raw pointer that ignores the constness of `PROBLEME_HEBDO`. --- .../adequacy_patch_csr/csr_quadratic_problem.h | 4 ++-- .../ConsistenceNumberOfDispatchableUnits.cpp | 2 +- .../constraints/ConstraintBuilder.h | 2 +- .../optimisation/constraints/MinDownTime.cpp | 2 +- .../NbDispUnitsMinBoundSinceMinUpTime.cpp | 2 +- .../NbUnitsOutageLessThanNbUnitsStop.cpp | 2 +- .../constraints/PMaxDispatchableGeneration.cpp | 2 +- .../constraints/PMinDispatchableGeneration.cpp | 2 +- .../constraints/constraint_builder_utils.cpp | 9 ++++----- .../constraints/constraint_builder_utils.h | 17 ++++++----------- 10 files changed, 19 insertions(+), 25 deletions(-) diff --git a/src/solver/optimisation/adequacy_patch_csr/csr_quadratic_problem.h b/src/solver/optimisation/adequacy_patch_csr/csr_quadratic_problem.h index 9a61499978..98337baabd 100644 --- a/src/solver/optimisation/adequacy_patch_csr/csr_quadratic_problem.h +++ b/src/solver/optimisation/adequacy_patch_csr/csr_quadratic_problem.h @@ -36,7 +36,7 @@ namespace Antares::Solver::Optimization class CsrQuadraticProblem { public: - CsrQuadraticProblem(const PROBLEME_HEBDO* p, PROBLEME_ANTARES_A_RESOUDRE& pa, HourlyCSRProblem& hourly) : + CsrQuadraticProblem(PROBLEME_HEBDO* p, PROBLEME_ANTARES_A_RESOUDRE& pa, HourlyCSRProblem& hourly) : problemeHebdo_(p), problemeAResoudre_(pa), hourlyCsrProblem_(hourly) { } @@ -44,7 +44,7 @@ class CsrQuadraticProblem void buildConstraintMatrix(); private: - const PROBLEME_HEBDO* problemeHebdo_; + PROBLEME_HEBDO* problemeHebdo_; PROBLEME_ANTARES_A_RESOUDRE& problemeAResoudre_; HourlyCSRProblem& hourlyCsrProblem_; diff --git a/src/solver/optimisation/constraints/ConsistenceNumberOfDispatchableUnits.cpp b/src/solver/optimisation/constraints/ConsistenceNumberOfDispatchableUnits.cpp index 1be75e7501..abd8155113 100644 --- a/src/solver/optimisation/constraints/ConsistenceNumberOfDispatchableUnits.cpp +++ b/src/solver/optimisation/constraints/ConsistenceNumberOfDispatchableUnits.cpp @@ -37,7 +37,7 @@ void ConsistenceNumberOfDispatchableUnits::add(int pays, int index, int pdt) } else { - *builder.data.NbTermesContraintesPourLesCoutsDeDemarrage += 4; + builder.data.NbTermesContraintesPourLesCoutsDeDemarrage += 4; builder.data.nombreDeContraintes++; } } diff --git a/src/solver/optimisation/constraints/ConstraintBuilder.h b/src/solver/optimisation/constraints/ConstraintBuilder.h index 86fde5b4f1..75773d444e 100644 --- a/src/solver/optimisation/constraints/ConstraintBuilder.h +++ b/src/solver/optimisation/constraints/ConstraintBuilder.h @@ -165,7 +165,7 @@ class ConstraintBuilderData const std::vector& NomsDesPays; const uint32_t& weekInTheYear; const uint32_t& NombreDePasDeTemps; - uint32_t* NbTermesContraintesPourLesCoutsDeDemarrage = nullptr; + uint32_t& NbTermesContraintesPourLesCoutsDeDemarrage; }; /*! \verbatim diff --git a/src/solver/optimisation/constraints/MinDownTime.cpp b/src/solver/optimisation/constraints/MinDownTime.cpp index 4f9b2832e4..f798d192ae 100644 --- a/src/solver/optimisation/constraints/MinDownTime.cpp +++ b/src/solver/optimisation/constraints/MinDownTime.cpp @@ -43,7 +43,7 @@ void MinDownTime::add(int pays, int index, int pdt) } else { - *builder.data.NbTermesContraintesPourLesCoutsDeDemarrage + builder.data.NbTermesContraintesPourLesCoutsDeDemarrage += 1 + DureeMinimaleDArretDUnGroupeDuPalierThermique; builder.data.nombreDeContraintes++; } diff --git a/src/solver/optimisation/constraints/NbDispUnitsMinBoundSinceMinUpTime.cpp b/src/solver/optimisation/constraints/NbDispUnitsMinBoundSinceMinUpTime.cpp index 294a274fec..bba7e3f77c 100644 --- a/src/solver/optimisation/constraints/NbDispUnitsMinBoundSinceMinUpTime.cpp +++ b/src/solver/optimisation/constraints/NbDispUnitsMinBoundSinceMinUpTime.cpp @@ -47,7 +47,7 @@ void NbDispUnitsMinBoundSinceMinUpTime::add(int pays, int index, int pdt) } else { - *builder.data.NbTermesContraintesPourLesCoutsDeDemarrage + builder.data.NbTermesContraintesPourLesCoutsDeDemarrage += 1 + 2 * DureeMinimaleDeMarcheDUnGroupeDuPalierThermique; builder.data.nombreDeContraintes++; } diff --git a/src/solver/optimisation/constraints/NbUnitsOutageLessThanNbUnitsStop.cpp b/src/solver/optimisation/constraints/NbUnitsOutageLessThanNbUnitsStop.cpp index 6062938a3a..fee75ee2c2 100644 --- a/src/solver/optimisation/constraints/NbUnitsOutageLessThanNbUnitsStop.cpp +++ b/src/solver/optimisation/constraints/NbUnitsOutageLessThanNbUnitsStop.cpp @@ -29,7 +29,7 @@ void NbUnitsOutageLessThanNbUnitsStop::add(int pays, int index, int pdt) } else { - *builder.data.NbTermesContraintesPourLesCoutsDeDemarrage += 2; + builder.data.NbTermesContraintesPourLesCoutsDeDemarrage += 2; builder.data.nombreDeContraintes++; } } diff --git a/src/solver/optimisation/constraints/PMaxDispatchableGeneration.cpp b/src/solver/optimisation/constraints/PMaxDispatchableGeneration.cpp index 36956d9754..2d4dd7c03a 100644 --- a/src/solver/optimisation/constraints/PMaxDispatchableGeneration.cpp +++ b/src/solver/optimisation/constraints/PMaxDispatchableGeneration.cpp @@ -27,7 +27,7 @@ void PMaxDispatchableGeneration::add(int pays, int index, int pdt) } else { - *builder.data.NbTermesContraintesPourLesCoutsDeDemarrage += 2; + builder.data.NbTermesContraintesPourLesCoutsDeDemarrage += 2; builder.data.nombreDeContraintes++; } } diff --git a/src/solver/optimisation/constraints/PMinDispatchableGeneration.cpp b/src/solver/optimisation/constraints/PMinDispatchableGeneration.cpp index 102727bf26..716faa42ee 100644 --- a/src/solver/optimisation/constraints/PMinDispatchableGeneration.cpp +++ b/src/solver/optimisation/constraints/PMinDispatchableGeneration.cpp @@ -28,7 +28,7 @@ void PMinDispatchableGeneration::add(int pays, int index, int pdt) } else { - *builder.data.NbTermesContraintesPourLesCoutsDeDemarrage += 2; + builder.data.NbTermesContraintesPourLesCoutsDeDemarrage += 2; builder.data.nombreDeContraintes++; } } diff --git a/src/solver/optimisation/constraints/constraint_builder_utils.cpp b/src/solver/optimisation/constraints/constraint_builder_utils.cpp index 1c10a2deb8..fae9c4b5a6 100644 --- a/src/solver/optimisation/constraints/constraint_builder_utils.cpp +++ b/src/solver/optimisation/constraints/constraint_builder_utils.cpp @@ -1,8 +1,7 @@ #include "constraint_builder_utils.h" -ConstraintBuilderData NewGetConstraintBuilderFromProblemHebdoAndProblemAResoudre( - const PROBLEME_HEBDO* problemeHebdo, - PROBLEME_ANTARES_A_RESOUDRE& ProblemeAResoudre) +ConstraintBuilderData NewGetConstraintBuilderFromProblemHebdoAndProblemAResoudre(PROBLEME_HEBDO* problemeHebdo, + PROBLEME_ANTARES_A_RESOUDRE& ProblemeAResoudre) { return {ProblemeAResoudre.Pi, ProblemeAResoudre.Colonne, @@ -24,5 +23,5 @@ ConstraintBuilderData NewGetConstraintBuilderFromProblemHebdoAndProblemAResoudre problemeHebdo->NomsDesPays, problemeHebdo->weekInTheYear, problemeHebdo->NombreDePasDeTemps, - nullptr}; -} \ No newline at end of file + problemeHebdo->NbTermesContraintesPourLesCoutsDeDemarrage}; +} diff --git a/src/solver/optimisation/constraints/constraint_builder_utils.h b/src/solver/optimisation/constraints/constraint_builder_utils.h index 0d1cd87d28..9916967d1f 100644 --- a/src/solver/optimisation/constraints/constraint_builder_utils.h +++ b/src/solver/optimisation/constraints/constraint_builder_utils.h @@ -2,13 +2,11 @@ #include "ConstraintBuilder.h" #include -ConstraintBuilderData NewGetConstraintBuilderFromProblemHebdoAndProblemAResoudre( - const PROBLEME_HEBDO* problemeHebdo, - PROBLEME_ANTARES_A_RESOUDRE& ProblemeAResoudre); +ConstraintBuilderData NewGetConstraintBuilderFromProblemHebdoAndProblemAResoudre(PROBLEME_HEBDO* problemeHebdo, + PROBLEME_ANTARES_A_RESOUDRE& ProblemeAResoudre); -inline ConstraintBuilderData NewGetConstraintBuilderFromProblemHebdoAndProblemAResoudre( - const PROBLEME_HEBDO* problemeHebdo, - std::unique_ptr& ProblemeAResoudre) +inline ConstraintBuilderData NewGetConstraintBuilderFromProblemHebdoAndProblemAResoudre(PROBLEME_HEBDO* problemeHebdo, + std::unique_ptr& ProblemeAResoudre) { /* not good!!!!!!!!!!*/ auto& problemAResoudreRef = *ProblemeAResoudre.get(); @@ -19,9 +17,6 @@ inline ConstraintBuilderData NewGetConstraintBuilderFromProblemHebdoAndProblemAR inline ConstraintBuilderData NewGetConstraintBuilderFromProblemHebdo(PROBLEME_HEBDO* problemeHebdo) { auto& ProblemeAResoudre = problemeHebdo->ProblemeAResoudre; - auto data = NewGetConstraintBuilderFromProblemHebdoAndProblemAResoudre(problemeHebdo, - ProblemeAResoudre); - data.NbTermesContraintesPourLesCoutsDeDemarrage - = &problemeHebdo->NbTermesContraintesPourLesCoutsDeDemarrage; - return data; + return NewGetConstraintBuilderFromProblemHebdoAndProblemAResoudre(problemeHebdo, + ProblemeAResoudre); }