diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index ee335104af..217a8adc75 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -25,8 +25,8 @@ on: env: GITHUB_TOKEN: ${{ github.token }} IS_RELEASE: ${{ github.event_name == 'workflow_dispatch' }} - RUN_SIMPLE_TESTS: false - RUN_EXTENDED_TESTS: false + RUN_SIMPLE_TESTS: ${{ github.event_name == 'push' || inputs.run-tests == 'true' }} + RUN_EXTENDED_TESTS: ${{ github.event_name == 'schedule' || inputs.run-tests == 'true' }} REF: ${{ inputs.target_branch =='' && github.ref || inputs.target_branch}} VCPKG_ROOT: ${{ github.workspace }}/vcpkg vcpkgPackages: yaml-cpp antlr4 diff --git a/.github/workflows/windows-vcpkg.yml b/.github/workflows/windows-vcpkg.yml index dfe0b5c3ed..5cf34f7b00 100644 --- a/.github/workflows/windows-vcpkg.yml +++ b/.github/workflows/windows-vcpkg.yml @@ -25,8 +25,8 @@ on: env: GITHUB_TOKEN: ${{ github.token }} IS_RELEASE: ${{ github.event_name == 'workflow_dispatch' }} - RUN_SIMPLE_TESTS: false - RUN_EXTENDED_TESTS: false + RUN_SIMPLE_TESTS: ${{ github.event_name == 'push' || inputs.run-tests == 'true' }} + RUN_EXTENDED_TESTS: ${{ github.event_name == 'schedule' || inputs.run-tests == 'true' }} REF: ${{ inputs.target_branch =='' && github.ref || inputs.target_branch}} diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index fb93c068fb..4efb35468d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -3,11 +3,11 @@ cmake_minimum_required(VERSION 3.14) # FetchContent_MakeAvailable # Version set(ANTARES_VERSION_HI 8) set(ANTARES_VERSION_LO 8) -set(ANTARES_VERSION_REVISION 11) +set(ANTARES_VERSION_REVISION 12) # Beta release set(ANTARES_BETA 0) -set(ANTARES_RC 0) +set(ANTARES_RC 3) set(ANTARES_VERSION_YEAR 2024) diff --git a/src/libs/antares/study/parameters/adq-patch-params.cpp b/src/libs/antares/study/parameters/adq-patch-params.cpp index 9e0f543247..30f2339bb9 100644 --- a/src/libs/antares/study/parameters/adq-patch-params.cpp +++ b/src/libs/antares/study/parameters/adq-patch-params.cpp @@ -154,6 +154,7 @@ void AdqPatchParams::addExcludedVariables(std::vector& out) const out.emplace_back("LOLP CSR"); out.emplace_back("MAX MRG CSR"); out.emplace_back("OV. COST CSR"); + out.emplace_back("MRG. PRICE CSR"); } } diff --git a/src/solver/optimisation/adequacy_patch_csr/adq_patch_post_process_list.cpp b/src/solver/optimisation/adequacy_patch_csr/adq_patch_post_process_list.cpp index 2e6ec81ab8..5f00281cca 100644 --- a/src/solver/optimisation/adequacy_patch_csr/adq_patch_post_process_list.cpp +++ b/src/solver/optimisation/adequacy_patch_csr/adq_patch_post_process_list.cpp @@ -21,11 +21,10 @@ AdqPatchPostProcessList::AdqPatchPostProcessList(const AdqPatchParams& adqPatchP problemeHebdo_, areas, sheddingPolicy, splxOptimization, thread_number)); post_process_list.push_back(std::make_unique( adqPatchParams, problemeHebdo_, areas, thread_number_)); - post_process_list.push_back(std::make_unique(problemeHebdo_, - areas, - thread_number)); - post_process_list.push_back(std::make_unique( - problemeHebdo_, areas, thread_number)); + post_process_list.push_back( + std::make_unique(problemeHebdo_, areas, thread_number)); + post_process_list.push_back( + std::make_unique(problemeHebdo_, areas, thread_number)); post_process_list.push_back( std::make_unique(problemeHebdo_, areas, true, false)); post_process_list.push_back( diff --git a/src/solver/optimisation/post_process_commands.cpp b/src/solver/optimisation/post_process_commands.cpp index 397015b46f..0f177e8d9e 100644 --- a/src/solver/optimisation/post_process_commands.cpp +++ b/src/solver/optimisation/post_process_commands.cpp @@ -134,13 +134,27 @@ void UpdateMrgPriceAfterCSRcmd::execute(const optRuntimeData&) auto& hourlyResults = problemeHebdo_->ResultatsHoraires[Area]; const auto& scratchpad = area_list_[Area]->scratchpad[thread_number_]; const double unsuppliedEnergyCost = area_list_[Area]->thermal.unsuppliedEnergyCost; - const bool areaInside = problemeHebdo_->adequacyPatchRuntimeData->areaMode[Area] == physicalAreaInsideAdqPatch; + const bool areaInside + = problemeHebdo_->adequacyPatchRuntimeData->areaMode[Area] == physicalAreaInsideAdqPatch; for (uint hour = 0; hour < nbHoursInWeek; hour++) { - const bool isHourTriggeredByCsr = problemeHebdo_->adequacyPatchRuntimeData - ->wasCSRTriggeredAtAreaHour(Area, hour); + const bool isHourTriggeredByCsr + = problemeHebdo_->adequacyPatchRuntimeData->wasCSRTriggeredAtAreaHour(Area, hour); - if (isHourTriggeredByCsr && hourlyResults.ValeursHorairesDeDefaillancePositive[hour] > 0.5 && areaInside) + // IF UNSP. ENR CSR == 0, MRG. PRICE CSR = MRG. PRICE + // ELSE, MRG. PRICE CSR = “Unsupplied Energy Cost” + if (hourlyResults.ValeursHorairesDeDefaillancePositiveCSR[hour] > 0.5 && areaInside) + { + hourlyResults.CoutsMarginauxHorairesCSR[hour] = -unsuppliedEnergyCost; + } + else + { + hourlyResults.CoutsMarginauxHorairesCSR[hour] + = hourlyResults.CoutsMarginauxHoraires[hour]; + } + + if (isHourTriggeredByCsr + && hourlyResults.ValeursHorairesDeDefaillancePositive[hour] > 0.5 && areaInside) { hourlyResults.CoutsMarginauxHoraires[hour] = -unsuppliedEnergyCost; } diff --git a/src/solver/simulation/sim_alloc_probleme_hebdo.cpp b/src/solver/simulation/sim_alloc_probleme_hebdo.cpp index 5ee3b74e92..aaee139cbd 100644 --- a/src/solver/simulation/sim_alloc_probleme_hebdo.cpp +++ b/src/solver/simulation/sim_alloc_probleme_hebdo.cpp @@ -449,6 +449,8 @@ void SIM_AllocateAreas(PROBLEME_HEBDO& problem, .assign(NombreDePasDeTemps, 0.); problem.ResultatsHoraires[k].CoutsMarginauxHoraires .assign(NombreDePasDeTemps, 0.); + problem.ResultatsHoraires[k].CoutsMarginauxHorairesCSR + .assign(NombreDePasDeTemps, 0.); problem.ResultatsHoraires[k].niveauxHoraires .assign(NombreDePasDeTemps, 0.); problem.ResultatsHoraires[k].valeurH2oHoraire diff --git a/src/solver/simulation/sim_structure_probleme_economique.h b/src/solver/simulation/sim_structure_probleme_economique.h index e4326862ed..c49ae546ca 100644 --- a/src/solver/simulation/sim_structure_probleme_economique.h +++ b/src/solver/simulation/sim_structure_probleme_economique.h @@ -454,6 +454,7 @@ struct RESULTATS_HORAIRES std::vector debordementsHoraires; std::vector CoutsMarginauxHoraires; + std::vector CoutsMarginauxHorairesCSR; std::vector ProductionThermique; // index is pdtHebdo std::vector<::ShortTermStorage::RESULTS> ShortTermStorage; diff --git a/src/solver/variable/economy/all.h b/src/solver/variable/economy/all.h index 2abbd91a14..20b90856b8 100644 --- a/src/solver/variable/economy/all.h +++ b/src/solver/variable/economy/all.h @@ -50,6 +50,7 @@ #include "renewableGeneration.h" #include "overallCost.h" #include "overallCostCsr.h" +#include "priceCSR.h" #include "operatingCost.h" #include "nonProportionalCost.h" #include "nbOfDispatchedUnits.h" @@ -129,67 +130,61 @@ class Links; /*! ** \brief All variables for a single area (economy) */ -typedef // Prices - OverallCost // Overall Cost (Op. Cost + Unsupplied Eng.) - >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +typedef // Prices + OverallCost // Overall Cost (Op. Cost + Unsupplied Eng.) + >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> VariablesPerArea; /*! @@ -253,35 +248,35 @@ typedef // Prices LMRViolations, Common::SpatialAggregate< SpilledEnergy, + Common::SpatialAggregate< + LOLD, Common::SpatialAggregate< - LOLD, + LOLP, Common::SpatialAggregate< - LOLP, + AvailableDispatchGen, Common::SpatialAggregate< - AvailableDispatchGen, + DispatchableGenMargin, Common::SpatialAggregate< - DispatchableGenMargin, + DtgMarginCsr, Common::SpatialAggregate< - DtgMarginCsr, + Marge, + + // Detail Prices Common::SpatialAggregate< - Marge, + NonProportionalCost, // MBO + // 13/05/2014 + // - + // refs: + // #21 - // Detail Prices + // Number Of Dispatched Units Common::SpatialAggregate< - NonProportionalCost, // MBO - // 13/05/2014 - // - - // refs: - // #21 - - // Number Of Dispatched Units - Common::SpatialAggregate< - NbOfDispatchedUnits // MBO - // 25/02/2016 - // - - // refs: - // #55 - >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + NbOfDispatchedUnits // MBO + // 25/02/2016 + // - + // refs: + // #55 + >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> VariablesPerSetOfAreas; typedef BindingConstMarginCost< // Marginal cost for a binding constraint diff --git a/src/solver/variable/economy/priceCSR.h b/src/solver/variable/economy/priceCSR.h new file mode 100644 index 0000000000..93876a5003 --- /dev/null +++ b/src/solver/variable/economy/priceCSR.h @@ -0,0 +1,276 @@ +/* +** Copyright 2007-2023 RTE +** Authors: Antares_Simulator Team +** +** This file is part of Antares_Simulator. +** +** Antares_Simulator is free software: you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation, either version 3 of the License, or +** (at your option) any later version. +** +** There are special exceptions to the terms and conditions of the +** license as they are applied to this software. View the full text of +** the exceptions in file COPYING.txt in the directory of this software +** distribution +** +** Antares_Simulator is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with Antares_Simulator. If not, see . +** +** SPDX-License-Identifier: licenceRef-GPL3_WITH_RTE-Exceptions +*/ +#pragma once + +#include "yuni/yuni.h" +#include "../variable.h" + +namespace Antares +{ +namespace Solver +{ +namespace Variable +{ +namespace Economy +{ +struct VCardPriceCSR +{ + //! Caption + static std::string Caption() + { + return "MRG. PRICE CSR"; + } + //! Unit + static std::string Unit() + { + return "Euro"; + } + + //! The short description of the variable + static std::string Description() + { + return "Marginal Price CSR, throughout all MC years"; + } + + //! The expecte results + typedef Results>>>> + ResultsType; + + //! The VCard to look for for calculating spatial aggregates + typedef VCardPrice VCardForSpatialAggregate; + + enum + { + //! Data Level + categoryDataLevel = Category::area, + //! File level (provided by the type of the results) + categoryFileLevel = ResultsType::categoryFile & (Category::id | Category::va), + //! Precision (views) + precision = Category::all, + //! Indentation (GUI) + nodeDepthForGUI = +0, + //! Decimal precision + decimal = 2, + //! Number of columns used by the variable (One ResultsType per column) + columnCount = 1, + //! The Spatial aggregation + spatialAggregate = Category::spatialAggregateAverage, + spatialAggregateMode = Category::spatialAggregateEachYear, + spatialAggregatePostProcessing = Category::spatialAggregatePostProcessingPrice, + //! Intermediate values + hasIntermediateValues = 1, + //! Can this variable be non applicable (0 : no, 1 : yes) + isPossiblyNonApplicable = 0, + }; + + typedef IntermediateValues IntermediateValuesBaseType; + typedef IntermediateValues* IntermediateValuesType; + + typedef IntermediateValuesBaseType* IntermediateValuesTypeForSpatialAg; + +}; // class VCard + +/*! +** \brief Marginal Price +*/ +template +class PriceCSR : public Variable::IVariable, NextT, VCardPriceCSR> +{ +public: + //! Type of the next static variable + typedef NextT NextType; + //! VCard + typedef VCardPriceCSR VCardType; + //! Ancestor + typedef Variable::IVariable, NextT, VCardType> AncestorType; + + //! List of expected results + typedef typename VCardType::ResultsType ResultsType; + + typedef VariableAccessor VariableAccessorType; + + enum + { + //! How many items have we got + count = 1 + NextT::count, + }; + + template + struct Statistics + { + enum + { + count + = ((VCardType::categoryDataLevel & CDataLevel && VCardType::categoryFileLevel & CFile) + ? (NextType::template Statistics::count + + VCardType::columnCount * ResultsType::count) + : NextType::template Statistics::count), + }; + }; + +public: + ~PriceCSR() + { + delete[] pValuesForTheCurrentYear; + } + + void initializeFromStudy(Data::Study& study) + { + pNbYearsParallel = study.maxNbYearsInParallel; + + // Average thoughout all years + InitializeResultsFromStudy(AncestorType::pResults, study); + + // Intermediate values + pValuesForTheCurrentYear = new VCardType::IntermediateValuesBaseType[pNbYearsParallel]; + for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++) + pValuesForTheCurrentYear[numSpace].initializeFromStudy(study); + + // Next + NextType::initializeFromStudy(study); + } + + template + static void InitializeResultsFromStudy(R& results, Data::Study& study) + { + VariableAccessorType::InitializeAndReset(results, study); + } + + void initializeFromArea(Data::Study* study, Data::Area* area) + { + // Next + NextType::initializeFromArea(study, area); + } + + void initializeFromLink(Data::Study* study, Data::AreaLink* link) + { + // Next + NextType::initializeFromAreaLink(study, link); + } + + void simulationBegin() + { + // Next + NextType::simulationBegin(); + } + + void simulationEnd() + { + NextType::simulationEnd(); + } + + void yearBegin(uint year, unsigned int numSpace) + { + // Reset the values for the current year + pValuesForTheCurrentYear[numSpace].reset(); + // Next variable + NextType::yearBegin(year, numSpace); + } + + void yearEndBuild(State& state, unsigned int year) + { + // Next variable + NextType::yearEndBuild(state, year); + } + + void yearEnd(uint year, unsigned int numSpace) + { + // Compute all statistics for the current year (daily,weekly,monthly) + pValuesForTheCurrentYear[numSpace].computeAveragesForCurrentYearFromHourlyResults(); + + // Next variable + NextType::yearEnd(year, numSpace); + } + + void computeSummary(std::map& numSpaceToYear, + unsigned int nbYearsForCurrentSummary) + { + for (unsigned int numSpace = 0; numSpace < nbYearsForCurrentSummary; ++numSpace) + { + // Merge all those values with the global results + AncestorType::pResults.merge(numSpaceToYear[numSpace] /*year*/, + pValuesForTheCurrentYear[numSpace]); + } + + // Next variable + NextType::computeSummary(numSpaceToYear, nbYearsForCurrentSummary); + } + + void hourBegin(uint hourInTheYear) + { + // Next variable + NextType::hourBegin(hourInTheYear); + } + + void hourForEachArea(State& state, unsigned int numSpace) + { + pValuesForTheCurrentYear[numSpace][state.hourInTheYear] + = -state.hourlyResults->CoutsMarginauxHorairesCSR[state.hourInTheWeek]; + // Next variable + NextType::hourForEachArea(state, numSpace); + } + + Antares::Memory::Stored::ConstReturnType retrieveRawHourlyValuesForCurrentYear( + uint, + unsigned int numSpace) const + { + return pValuesForTheCurrentYear[numSpace].hour; + } + + void localBuildAnnualSurveyReport(SurveyResults& results, + int fileLevel, + int precision, + unsigned int numSpace) const + { + // Initializing external pointer on current variable non applicable status + results.isCurrentVarNA = AncestorType::isNonApplicable; + + if (AncestorType::isPrinted[0]) + { + // Write the data for the current year + results.variableCaption = VCardType::Caption(); + results.variableUnit = VCardType::Unit(); + pValuesForTheCurrentYear[numSpace].template buildAnnualSurveyReport( + results, fileLevel, precision); + } + } + +private: + //! Intermediate values for each year + typename VCardType::IntermediateValuesType pValuesForTheCurrentYear; + unsigned int pNbYearsParallel; + +}; // class PriceCSR + +} // namespace Economy +} // namespace Variable +} // namespace Solver +} // namespace Antares