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-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 418d7c09de..d8adca7914 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: @@ -59,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 @@ -66,7 +79,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 \ @@ -110,21 +123,12 @@ jobs: with: path: _build/*.rpm - publish_assets: - name: Publish assets - needs: build - runs-on: ubuntu-latest - - steps: - - name: Download all artifacts - if: ${{ env.IS_RELEASE == 'true' }} - uses: actions/download-artifact@v3 - - - 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..591ba89b50 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 @@ -49,11 +54,18 @@ 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 cmake -B _build -S src \ - -DCMAKE_BUILD_TYPE=release \ + -DCMAKE_BUILD_TYPE=Release \ -DBUILD_TESTING=ON \ -DBUILD_TOOLS=OFF \ -DBUILD_UI=OFF \ @@ -99,21 +111,11 @@ jobs: with: path: _build/*.rpm - publish_assets: - name: Publish assets - needs: build - runs-on: ubuntu-latest - - steps: - - name: Download all artifacts - if: ${{ env.IS_RELEASE == 'true' }} - uses: actions/download-artifact@v3 - - - 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/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 c4525581f5..f85572cdbc 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: ${{ env.os }} - 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}} @@ -100,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 \ @@ -109,7 +103,7 @@ jobs: - name: Build run: | - cmake --build _build --config release -j$(nproc) + cmake --build _build -j$(nproc) # simtest @@ -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-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 a7674fd76b..0378a8f074 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,8 +140,8 @@ 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 }} \ - -DCMAKE_BUILD_TYPE=release \ + -DVCPKG_TARGET_TRIPLET=${{ env.triplet }} \ + -DCMAKE_BUILD_TYPE=Release \ -DBUILD_TESTING=ON \ -DBUILD_TOOLS=ON \ -DBUILD_not_system=OFF \ @@ -143,17 +151,35 @@ 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 + 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 diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 99c6395eaa..4f80b0eef7 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -6,6 +6,43 @@ 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) + +## 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) +* 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/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/simtest.json b/simtest.json index e4be9a9945..570b89427c 100644 --- a/simtest.json +++ b/simtest.json @@ -1,3 +1,3 @@ { - "version": "v8.8.0" + "version": "v8.8.2" } diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ee5083bebe..9a2b334d3d 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 2) # 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}) @@ -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}") @@ -143,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") @@ -152,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() @@ -199,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 @@ -356,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() 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 f707628d65..7b301d6a2b 100644 --- a/src/libs/antares/Enum.hxx +++ b/src/libs/antares/Enum.hxx @@ -31,7 +31,7 @@ #include #include -#include +#include #include @@ -82,4 +82,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/constants.h b/src/libs/antares/constants.h index 00bf54c457..99e18aadb3 100644 --- a/src/libs/antares/constants.h +++ b/src/libs/antares/constants.h @@ -60,11 +60,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/net/net.h b/src/libs/antares/net/net.h deleted file mode 100644 index 121fbfcf8d..0000000000 --- a/src/libs/antares/net/net.h +++ /dev/null @@ -1,31 +0,0 @@ -/* -** Copyright 2007-2024, RTE (https://www.rte-france.com) -** See AUTHORS.txt -** SPDX-License-Identifier: MPL-2.0 -** This file is part of Antares-Simulator, -** Adequacy and Performance assessment for interconnected energy networks. -** -** Antares_Simulator is free software: you can redistribute it and/or modify -** it under the terms of the Mozilla Public Licence 2.0 as published by -** the Mozilla Foundation, either version 2 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 -** Mozilla Public Licence 2.0 for more details. -** -** You should have received a copy of the Mozilla Public Licence 2.0 -** along with Antares_Simulator. If not, see . -*/ -#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 25af707c3d..0000000000 --- a/src/libs/antares/object/intrusive-reference.h +++ /dev/null @@ -1,131 +0,0 @@ -/* -** Copyright 2007-2024, RTE (https://www.rte-france.com) -** See AUTHORS.txt -** SPDX-License-Identifier: MPL-2.0 -** This file is part of Antares-Simulator, -** Adequacy and Performance assessment for interconnected energy networks. -** -** Antares_Simulator is free software: you can redistribute it and/or modify -** it under the terms of the Mozilla Public Licence 2.0 as published by -** the Mozilla Foundation, either version 2 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 -** Mozilla Public Licence 2.0 for more details. -** -** You should have received a copy of the Mozilla Public Licence 2.0 -** along with Antares_Simulator. If not, see . -*/ -#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 7dab5746fd..0000000000 --- a/src/libs/antares/object/intrusive-reference.hxx +++ /dev/null @@ -1,94 +0,0 @@ -/* -** Copyright 2007-2024, RTE (https://www.rte-france.com) -** See AUTHORS.txt -** SPDX-License-Identifier: MPL-2.0 -** This file is part of Antares-Simulator, -** Adequacy and Performance assessment for interconnected energy networks. -** -** Antares_Simulator is free software: you can redistribute it and/or modify -** it under the terms of the Mozilla Public Licence 2.0 as published by -** the Mozilla Foundation, either version 2 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 -** Mozilla Public Licence 2.0 for more details. -** -** You should have received a copy of the Mozilla Public Licence 2.0 -** along with Antares_Simulator. If not, see . -*/ -#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 d9d77b5bce..0000000000 --- a/src/libs/antares/object/object.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/* -** Copyright 2007-2024, RTE (https://www.rte-france.com) -** See AUTHORS.txt -** SPDX-License-Identifier: MPL-2.0 -** This file is part of Antares-Simulator, -** Adequacy and Performance assessment for interconnected energy networks. -** -** Antares_Simulator is free software: you can redistribute it and/or modify -** it under the terms of the Mozilla Public Licence 2.0 as published by -** the Mozilla Foundation, either version 2 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 -** Mozilla Public Licence 2.0 for more details. -** -** You should have received a copy of the Mozilla Public Licence 2.0 -** along with Antares_Simulator. If not, see . -*/ - -#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 0b899527a3..0000000000 --- a/src/libs/antares/object/object.h +++ /dev/null @@ -1,145 +0,0 @@ -/* -** Copyright 2007-2024, RTE (https://www.rte-france.com) -** See AUTHORS.txt -** SPDX-License-Identifier: MPL-2.0 -** This file is part of Antares-Simulator, -** Adequacy and Performance assessment for interconnected energy networks. -** -** Antares_Simulator is free software: you can redistribute it and/or modify -** it under the terms of the Mozilla Public Licence 2.0 as published by -** the Mozilla Foundation, either version 2 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 -** Mozilla Public Licence 2.0 for more details. -** -** You should have received a copy of the Mozilla Public Licence 2.0 -** along with Antares_Simulator. If not, see . -*/ -#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 2489d6f71e..0000000000 --- a/src/libs/antares/object/object.hxx +++ /dev/null @@ -1,59 +0,0 @@ -/* -** Copyright 2007-2024, RTE (https://www.rte-france.com) -** See AUTHORS.txt -** SPDX-License-Identifier: MPL-2.0 -** This file is part of Antares-Simulator, -** Adequacy and Performance assessment for interconnected energy networks. -** -** Antares_Simulator is free software: you can redistribute it and/or modify -** it under the terms of the Mozilla Public Licence 2.0 as published by -** the Mozilla Foundation, either version 2 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 -** Mozilla Public Licence 2.0 for more details. -** -** You should have received a copy of the Mozilla Public Licence 2.0 -** along with Antares_Simulator. If not, see . -*/ -#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 cbe86af117..0000000000 --- a/src/libs/antares/object/ref.h +++ /dev/null @@ -1,65 +0,0 @@ -/* -** Copyright 2007-2024, RTE (https://www.rte-france.com) -** See AUTHORS.txt -** SPDX-License-Identifier: MPL-2.0 -** This file is part of Antares-Simulator, -** Adequacy and Performance assessment for interconnected energy networks. -** -** Antares_Simulator is free software: you can redistribute it and/or modify -** it under the terms of the Mozilla Public Licence 2.0 as published by -** the Mozilla Foundation, either version 2 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 -** Mozilla Public Licence 2.0 for more details. -** -** You should have received a copy of the Mozilla Public Licence 2.0 -** along with Antares_Simulator. If not, see . -*/ -#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/series/series.cpp b/src/libs/antares/series/series.cpp index 65dddaf553..e61f47df4c 100644 --- a/src/libs/antares/series/series.cpp +++ b/src/libs/antares/series/series.cpp @@ -37,8 +37,6 @@ using namespace Yuni; namespace Antares::Data { -const std::vector TimeSeries::emptyColumn(HOURS_PER_YEAR); - TimeSeries::TimeSeries(numbers& tsNumbers) : timeseriesNumbers(tsNumbers) {} @@ -73,24 +71,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/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 69% rename from src/libs/antares/net/request.h rename to src/libs/antares/stdcxx/class_name.cpp index cc04ea9440..c04abd7ff2 100644 --- a/src/libs/antares/net/request.h +++ b/src/libs/antares/stdcxx/class_name.cpp @@ -23,28 +23,25 @@ ** You should have received a copy of the Mozilla Public Licence 2.0 ** along with Antares_Simulator. If not, see . */ -#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 b1a3c65540..0000000000 --- a/src/libs/antares/stdcxx/demangle.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/* -** Copyright 2007-2024, RTE (https://www.rte-france.com) -** See AUTHORS.txt -** SPDX-License-Identifier: MPL-2.0 -** This file is part of Antares-Simulator, -** Adequacy and Performance assessment for interconnected energy networks. -** -** Antares_Simulator is free software: you can redistribute it and/or modify -** it under the terms of the Mozilla Public Licence 2.0 as published by -** the Mozilla Foundation, either version 2 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 -** Mozilla Public Licence 2.0 for more details. -** -** You should have received a copy of the Mozilla Public Licence 2.0 -** along with Antares_Simulator. If not, see . -*/ - -#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 7152a390c0..761e497dc9 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: MPL-2.0 */ -#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/area/area.cpp b/src/libs/antares/study/area/area.cpp index 18ed7671c1..1dd925ca94 100644 --- a/src/libs/antares/study/area/area.cpp +++ b/src/libs/antares/study/area/area.cpp @@ -256,39 +256,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 6ad4469408..c473f06a0b 100644 --- a/src/libs/antares/study/area/area.h +++ b/src/libs/antares/study/area/area.h @@ -153,7 +153,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/area/links.cpp b/src/libs/antares/study/area/links.cpp index b33c1317a0..6538e4eb6d 100644 --- a/src/libs/antares/study/area/links.cpp +++ b/src/libs/antares/study/area/links.cpp @@ -101,7 +101,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]; @@ -501,7 +501,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.) { @@ -516,7 +516,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.) { @@ -531,7 +531,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) { @@ -543,7 +543,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/binding_constraint/BindingConstraintGroup.cpp b/src/libs/antares/study/binding_constraint/BindingConstraintGroup.cpp index b8286a54d9..15145f3783 100644 --- a/src/libs/antares/study/binding_constraint/BindingConstraintGroup.cpp +++ b/src/libs/antares/study/binding_constraint/BindingConstraintGroup.cpp @@ -47,14 +47,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 7975be6744..b3bd2d8dec 100644 --- a/src/libs/antares/study/binding_constraint/BindingConstraintGroup.h +++ b/src/libs/antares/study/binding_constraint/BindingConstraintGroup.h @@ -40,7 +40,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 7970f4bfae..4624af2547 100644 --- a/src/libs/antares/study/binding_constraint/BindingConstraintGroupRepository.cpp +++ b/src/libs/antares/study/binding_constraint/BindingConstraintGroupRepository.cpp @@ -79,13 +79,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 2835df523e..a36ac127a6 100644 --- a/src/libs/antares/study/binding_constraint/BindingConstraintGroupRepository.h +++ b/src/libs/antares/study/binding_constraint/BindingConstraintGroupRepository.h @@ -47,8 +47,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/common/cluster_list.cpp b/src/libs/antares/study/parts/common/cluster_list.cpp index f3a4c70c41..9608abbcc3 100644 --- a/src/libs/antares/study/parts/common/cluster_list.cpp +++ b/src/libs/antares/study/parts/common/cluster_list.cpp @@ -105,7 +105,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 diff --git a/src/libs/antares/study/parts/hydro/container.cpp b/src/libs/antares/study/parts/hydro/container.cpp index efaa225032..6ef4369134 100644 --- a/src/libs/antares/study/parts/hydro/container.cpp +++ b/src/libs/antares/study/parts/hydro/container.cpp @@ -190,7 +190,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) { @@ -203,7 +203,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] @@ -218,7 +218,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))) { diff --git a/src/libs/antares/study/parts/hydro/series.cpp b/src/libs/antares/study/parts/hydro/series.cpp index b6a68636d0..06fb23b4ed 100644 --- a/src/libs/antares/study/parts/hydro/series.cpp +++ b/src/libs/antares/study/parts/hydro/series.cpp @@ -236,11 +236,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 c5d4eb1e3d..5c3d563740 100644 --- a/src/libs/antares/study/parts/hydro/series.h +++ b/src/libs/antares/study/parts/hydro/series.h @@ -57,7 +57,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 c295f991b2..a7c503a1af 100644 --- a/src/libs/antares/study/parts/solar/container.cpp +++ b/src/libs/antares/study/parts/solar/container.cpp @@ -69,7 +69,7 @@ uint64_t Container::memoryUsage() const void Container::resetToDefault() { - series.timeSeries.reset(); + series.reset(); if (prepro) prepro->resetToDefault(); } diff --git a/src/libs/antares/study/study.h b/src/libs/antares/study/study.h index 46002b44ac..c5e65c0c83 100644 --- a/src/libs/antares/study/study.h +++ b/src/libs/antares/study/study.h @@ -35,7 +35,6 @@ #include #include "../antares.h" -#include "../object/object.h" #include "fwd.h" #include "simulation.h" @@ -62,7 +61,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/solver/optimisation/adequacy_patch_csr/csr_quadratic_problem.h b/src/solver/optimisation/adequacy_patch_csr/csr_quadratic_problem.h index 045aee54db..7e522dc158 100644 --- a/src/solver/optimisation/adequacy_patch_csr/csr_quadratic_problem.h +++ b/src/solver/optimisation/adequacy_patch_csr/csr_quadratic_problem.h @@ -35,7 +35,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) { } @@ -43,7 +43,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 508f13bb7b..4e49b0137d 100644 --- a/src/solver/optimisation/constraints/ConsistenceNumberOfDispatchableUnits.cpp +++ b/src/solver/optimisation/constraints/ConsistenceNumberOfDispatchableUnits.cpp @@ -62,7 +62,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 0d81a25dc2..5bb6f8b38c 100644 --- a/src/solver/optimisation/constraints/ConstraintBuilder.h +++ b/src/solver/optimisation/constraints/ConstraintBuilder.h @@ -190,7 +190,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 803ab2f786..4637c5cb87 100644 --- a/src/solver/optimisation/constraints/MinDownTime.cpp +++ b/src/solver/optimisation/constraints/MinDownTime.cpp @@ -68,7 +68,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 38cda0a8c3..0c9bca53c9 100644 --- a/src/solver/optimisation/constraints/NbDispUnitsMinBoundSinceMinUpTime.cpp +++ b/src/solver/optimisation/constraints/NbDispUnitsMinBoundSinceMinUpTime.cpp @@ -72,7 +72,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 f3012f504d..dbd6761eb2 100644 --- a/src/solver/optimisation/constraints/NbUnitsOutageLessThanNbUnitsStop.cpp +++ b/src/solver/optimisation/constraints/NbUnitsOutageLessThanNbUnitsStop.cpp @@ -54,7 +54,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 f1c7d0f012..9c357f3e73 100644 --- a/src/solver/optimisation/constraints/PMaxDispatchableGeneration.cpp +++ b/src/solver/optimisation/constraints/PMaxDispatchableGeneration.cpp @@ -52,7 +52,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 320bdc7700..5393da8eb4 100644 --- a/src/solver/optimisation/constraints/PMinDispatchableGeneration.cpp +++ b/src/solver/optimisation/constraints/PMinDispatchableGeneration.cpp @@ -53,7 +53,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); } diff --git a/src/solver/simulation/solver.hxx b/src/solver/simulation/solver.hxx index fbbdaac7e2..590b80154a 100644 --- a/src/solver/simulation/solver.hxx +++ b/src/solver/simulation/solver.hxx @@ -311,6 +311,8 @@ void ISimulation::run() ImplementationType::setNbPerformedYearsInParallel(pNbMaxPerformedYearsInParallel); + TSGenerator::ResizeGeneratedTimeSeries(study.areas, study.parameters); + if (settings.tsGeneratorsOnly) { // Only the preprocessors can be used @@ -322,7 +324,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 { @@ -369,7 +371,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 { @@ -448,7 +450,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 d4441f8b37..bcdd7f0af7 100644 --- a/src/solver/simulation/timeseries-numbers.cpp +++ b/src/solver/simulation/timeseries-numbers.cpp @@ -86,119 +86,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(); @@ -209,20 +146,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) @@ -231,17 +160,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; @@ -250,63 +173,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_; @@ -324,60 +219,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. @@ -386,42 +273,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 ... @@ -432,9 +309,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); } } @@ -501,7 +376,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]; // ------------- @@ -510,7 +385,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]; // ------------- @@ -519,7 +394,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]; // ------------- @@ -528,7 +403,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]; // ------------- @@ -538,11 +413,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]; } } @@ -556,7 +429,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]; } } @@ -571,15 +444,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) { @@ -591,10 +463,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)); } // ------------- @@ -604,10 +474,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)); } // ------------- @@ -617,10 +485,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)); } // ------------- @@ -630,10 +496,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())); } // ------------- @@ -651,10 +515,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)); } } } @@ -691,17 +553,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)); } } } @@ -710,14 +565,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)); } } } @@ -796,73 +647,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) @@ -893,28 +681,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); } // =============== @@ -944,7 +722,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 @@ -962,7 +740,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 24ce32e016..34796db03e 100644 --- a/src/solver/simulation/timeseries-numbers.h +++ b/src/solver/simulation/timeseries-numbers.h @@ -41,7 +41,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 8ff47ea6f3..7a7809a5db 100644 --- a/src/solver/ts-generator/generator.h +++ b/src/solver/ts-generator/generator.h @@ -29,16 +29,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 */ @@ -62,9 +62,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 7a803701a7..ec03ebf476 100644 --- a/src/solver/ts-generator/generator.hxx +++ b/src/solver/ts-generator/generator.hxx @@ -28,12 +28,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); @@ -147,17 +144,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 1903dc8ba3..b3a4aa2b70 100644 --- a/src/solver/ts-generator/hydro.cpp +++ b/src/solver/ts-generator/hydro.cpp @@ -39,18 +39,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) { @@ -74,7 +68,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; @@ -154,8 +148,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) @@ -316,5 +308,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 7c4b68382d..c57dc534a7 100644 --- a/src/solver/ts-generator/thermal.cpp +++ b/src/solver/ts-generator/thermal.cpp @@ -47,8 +47,6 @@ using namespace Yuni; namespace Antares { -namespace Solver -{ namespace TSGenerator { namespace @@ -58,7 +56,7 @@ class GeneratorTempData final public: GeneratorTempData(Data::Study& study, Solver::Progression::Task& progr, - IResultWriter& writer); + Solver::IResultWriter& writer); void prepareOutputFoldersForAllAreas(uint year); @@ -71,8 +69,6 @@ class GeneratorTempData final uint currentYear; - uint nbThermalTimeseries; - bool derated; private: @@ -88,6 +84,7 @@ class GeneratorTempData final const T& duration); private: + uint nbThermalTimeseries_; const uint nbHoursPerYear = HOURS_PER_YEAR; const uint daysPerYear = DAYS_PER_YEAR; @@ -114,12 +111,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), @@ -129,7 +126,7 @@ GeneratorTempData::GeneratorTempData(Data::Study& study, archive = (0 != (parameters.timeSeriesToArchive & Data::timeSeriesThermal)); - nbThermalTimeseries = parameters.nbTimeSeriesThermal; + nbThermalTimeseries_ = parameters.nbTimeSeriesThermal; derated = parameters.derated; } @@ -250,15 +247,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; @@ -354,7 +347,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; @@ -644,5 +637,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 8d6466e9b3..126c868de0 100644 --- a/src/solver/ts-generator/xcast/core.cpp +++ b/src/solver/ts-generator/xcast/core.cpp @@ -37,8 +37,6 @@ using namespace Yuni; namespace Antares { -namespace Solver -{ namespace TSGenerator { namespace XCast @@ -555,5 +553,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 8def48ab92..528c3e3a60 100644 --- a/src/solver/ts-generator/xcast/gamma-euler.cpp +++ b/src/solver/ts-generator/xcast/gamma-euler.cpp @@ -37,8 +37,6 @@ using namespace Yuni; namespace Antares { -namespace Solver -{ namespace TSGenerator { namespace XCast @@ -104,5 +102,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 cbfc14acc8..b84c6f7807 100644 --- a/src/solver/ts-generator/xcast/gamma-inc.cpp +++ b/src/solver/ts-generator/xcast/gamma-inc.cpp @@ -34,8 +34,6 @@ using namespace Yuni; namespace Antares { -namespace Solver -{ namespace TSGenerator { namespace XCast @@ -62,5 +60,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 7d1e197147..f7fb5ac4e7 100644 --- a/src/solver/ts-generator/xcast/math.cpp +++ b/src/solver/ts-generator/xcast/math.cpp @@ -29,8 +29,6 @@ namespace Antares { -namespace Solver -{ namespace TSGenerator { namespace XCast @@ -58,5 +56,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 bed88fb75d..709b4c5424 100644 --- a/src/solver/ts-generator/xcast/math.hxx +++ b/src/solver/ts-generator/xcast/math.hxx @@ -35,8 +35,6 @@ using namespace Yuni; namespace Antares { -namespace Solver -{ namespace TSGenerator { namespace XCast @@ -343,5 +341,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 ba3dbc41aa..f99fe61d3b 100644 --- a/src/solver/ts-generator/xcast/predicate.hxx +++ b/src/solver/ts-generator/xcast/predicate.hxx @@ -34,8 +34,6 @@ namespace Antares { -namespace Solver -{ namespace TSGenerator { namespace Predicate @@ -168,7 +166,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 a47c54b345..8f9505af07 100644 --- a/src/solver/ts-generator/xcast/studydata.cpp +++ b/src/solver/ts-generator/xcast/studydata.cpp @@ -32,8 +32,6 @@ using namespace Yuni; namespace Antares { -namespace Solver -{ namespace TSGenerator { namespace XCast @@ -126,5 +124,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 6541be9b6f..204c90a6a5 100644 --- a/src/solver/ts-generator/xcast/studydata.h +++ b/src/solver/ts-generator/xcast/studydata.h @@ -30,7 +30,7 @@ #include #include //TODO collision -namespace Antares::Solver::TSGenerator::XCast +namespace Antares::TSGenerator::XCast { class StudyData final { @@ -99,7 +99,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 ce2b810bda..59678d39f6 100644 --- a/src/solver/ts-generator/xcast/studydata.hxx +++ b/src/solver/ts-generator/xcast/studydata.hxx @@ -32,8 +32,6 @@ namespace Antares { -namespace Solver -{ namespace TSGenerator { namespace XCast @@ -56,18 +54,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 fa9851787a..aec58fda14 100644 --- a/src/solver/ts-generator/xcast/xcast.cpp +++ b/src/solver/ts-generator/xcast/xcast.cpp @@ -42,12 +42,11 @@ using namespace Yuni; namespace Antares { -namespace Solver -{ namespace TSGenerator { namespace XCast { + enum { alpha = Data::XCast::dataCoeffAlpha, @@ -109,13 +108,8 @@ void XCast::applyTransferFunction(PredicateT& predicate) { enum { - - nbHoursADay = 24, - x = 0, - y = 1, - maxPoints = Data::XCast::conversionMaxPoints, }; @@ -156,7 +150,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) { @@ -369,12 +363,6 @@ void XCast::destroyTemporaryData() template bool XCast::runWithPredicate(PredicateT& predicate, Progression::Task& progression) { - enum - { - - nbHoursADay = 24, - }; - pTSName = predicate.timeSeriesName(); { @@ -394,8 +382,6 @@ bool XCast::runWithPredicate(PredicateT& predicate, Progression::Task& progressi if (pNeverInitialized) { - const uint nbHours = 8760; - loadFromStudy(predicate.correlation(study), predicate); allocateTemporaryData(); @@ -404,7 +390,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); @@ -418,7 +403,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) { @@ -433,7 +418,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; @@ -487,7 +472,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; @@ -502,7 +487,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"); } @@ -520,10 +505,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]; @@ -538,7 +523,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"); } @@ -557,7 +542,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; @@ -565,21 +550,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; } @@ -587,7 +572,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 @@ -639,7 +624,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); @@ -648,7 +633,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); @@ -657,7 +642,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); @@ -673,5 +658,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 8c67a12c39..f036fc106a 100644 --- a/src/solver/ts-generator/xcast/xcast.h +++ b/src/solver/ts-generator/xcast/xcast.h @@ -29,14 +29,15 @@ #include #include #include +#include #include #include "studydata.h" #include +using namespace Antares::Solver; + namespace Antares { -namespace Solver -{ namespace TSGenerator { namespace XCast @@ -98,8 +99,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 @@ -176,6 +175,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; @@ -254,7 +256,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 9ea4db2b97..db564ec3f0 100644 --- a/src/solver/ts-generator/xcast/xcast.hxx +++ b/src/solver/ts-generator/xcast/xcast.hxx @@ -28,8 +28,6 @@ namespace Antares { -namespace Solver -{ namespace TSGenerator { namespace XCast @@ -42,7 +40,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 d436a4a064..42ec243ffd 100644 --- a/src/solver/variable/economy/max-mrg.cpp +++ b/src/solver/variable/economy/max-mrg.cpp @@ -99,7 +99,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 43ac1ac78a..b2ba3c619f 100644 --- a/src/tests/src/libs/antares/study/series/timeseries-tests.cpp +++ b/src/tests/src/libs/antares/study/series/timeseries-tests.cpp @@ -45,8 +45,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; @@ -90,9 +91,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); @@ -105,13 +103,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); @@ -136,8 +127,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 e202afc4aa..c7eff6ac5f 100644 --- a/src/tests/src/solver/simulation/tests-ts-numbers.cpp +++ b/src/tests/src/solver/simulation/tests-ts-numbers.cpp @@ -31,6 +31,7 @@ #include #include +#include "ts-generator/generator.h" #include // std::adjacent_find @@ -150,6 +151,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 @@ -175,6 +177,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); } @@ -221,6 +224,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 @@ -259,6 +263,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 @@ -299,7 +304,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)); } @@ -336,6 +341,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 @@ -375,6 +381,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 @@ -416,6 +423,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)); } @@ -443,7 +451,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"); @@ -451,6 +461,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 @@ -481,6 +492,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 @@ -489,6 +501,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 @@ -519,6 +532,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 @@ -527,6 +541,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)); } @@ -555,6 +570,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 @@ -586,6 +602,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)); } @@ -613,6 +630,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)); } @@ -637,6 +655,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; @@ -666,6 +685,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 : @@ -719,6 +739,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 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 )