diff --git a/src/libs/antares/study/include/antares/study/parts/common/cluster_list.h b/src/libs/antares/study/include/antares/study/parts/common/cluster_list.h index 780faf2997..30b11b08ee 100644 --- a/src/libs/antares/study/include/antares/study/parts/common/cluster_list.h +++ b/src/libs/antares/study/include/antares/study/parts/common/cluster_list.h @@ -119,6 +119,16 @@ class ClusterList unsigned int index) const; /*! +** @brief Get the reserve and spilled/unsupplied status and names for a given index of reserveParticipation +** @param area The area where to look for the reserveParticipation +** @param index Global index of the reserveParicipation +** @return the status and reserve names +*/ + std::pair reserveParticipationUnsuppliedSpilledAt( + const Area* area, + unsigned int index) const; + + /*! ** \brief Resize all matrices dedicated to the sampled timeseries numbers ** ** \param n A number of years diff --git a/src/libs/antares/study/include/antares/study/parts/thermal/cluster.h b/src/libs/antares/study/include/antares/study/parts/thermal/cluster.h index ac53ab3b75..5cb331230c 100644 --- a/src/libs/antares/study/include/antares/study/parts/thermal/cluster.h +++ b/src/libs/antares/study/include/antares/study/parts/thermal/cluster.h @@ -94,6 +94,17 @@ enum ThermalDispatchableGroup groupMax }; +enum ThermalUnsuppliedSpilled +{ + //! Spilled + ThermalUnsuppliedSpilledSpilled = 0, + //! Unsupplied + ThermalUnsuppliedSpilledUnsupplied, + + //! The highest value + unsuppliedSpilledMax +}; + /*! ** \brief A single thermal cluster */ diff --git a/src/libs/antares/study/parts/common/cluster_list.cpp b/src/libs/antares/study/parts/common/cluster_list.cpp index dfc11f688e..5ab34ca02b 100644 --- a/src/libs/antares/study/parts/common/cluster_list.cpp +++ b/src/libs/antares/study/parts/common/cluster_list.cpp @@ -123,6 +123,34 @@ std::pair "reserve participations"); } +template +std::pair +ClusterList::reserveParticipationUnsuppliedSpilledAt(const Area* area, unsigned int index) const +{ + int column = 0; + for (auto [reserveName, _] : area->allCapacityReservations.areaCapacityReservationsUp) + { + for (int indexUnsuppliedSpilled = 0; indexUnsuppliedSpilled < Data::unsuppliedSpilledMax; indexUnsuppliedSpilled++) + { + if (column == index) + return { static_cast(indexUnsuppliedSpilled), reserveName }; + column++; + } + } + for (auto [reserveName, _] : area->allCapacityReservations.areaCapacityReservationsDown) + { + for (int indexUnsuppliedSpilled = 0; indexUnsuppliedSpilled < Data::unsuppliedSpilledMax; indexUnsuppliedSpilled++) + { + if (column == index) + return { static_cast(indexUnsuppliedSpilled), reserveName }; + column++; + } + } + throw std::out_of_range("This reserve status index has not been found in all the " + "reserve participations"); +} + + template ClusterT* ClusterList::findInAll(std::string_view id) const { diff --git a/src/solver/variable/CMakeLists.txt b/src/solver/variable/CMakeLists.txt index 292ce8ed35..5db18dc13c 100644 --- a/src/solver/variable/CMakeLists.txt +++ b/src/solver/variable/CMakeLists.txt @@ -130,7 +130,10 @@ set(SRC_VARIABLE_ECONOMY include/antares/solver/variable/economy/reserveParticipationCost.h include/antares/solver/variable/economy/reserveParticipationByDispatchablePlant.h include/antares/solver/variable/economy/vCardReserveParticipationByDispatchablePlant.h + include/antares/solver/variable/economy/reserveParticipationUnsuppliedSpilled.h + include/antares/solver/variable/economy/vCardReserveParticipationUnsuppliedSpilled.h include/antares/solver/variable/economy/reserveParticipationByGroup.h + include/antares/solver/variable/economy/vCardreserveParticipationByGroup.h # Links include/antares/solver/variable/economy/links/flowLinear.h diff --git a/src/solver/variable/include/antares/solver/variable/economy/VCardReserveParticipationUnsuppliedSpilled.h b/src/solver/variable/include/antares/solver/variable/economy/VCardReserveParticipationUnsuppliedSpilled.h new file mode 100644 index 0000000000..a5c093220c --- /dev/null +++ b/src/solver/variable/include/antares/solver/variable/economy/VCardReserveParticipationUnsuppliedSpilled.h @@ -0,0 +1,117 @@ +/* +** Copyright 2007-2023 RTE +** Authors: Antares_Simulator Team +** +** This file is part of Antares_Simulator. +** +** Antares_Simulator is free software: you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation, either version 3 of the License, or +** (at your option) any later version. +** +** There are special exceptions to the terms and conditions of the +** license as they are applied to this software. View the full text of +** the exceptions in file COPYING.txt in the directory of this software +** distribution +** +** Antares_Simulator is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with Antares_Simulator. If not, see . +** +** SPDX-License-Identifier: licenceRef-GPL3_WITH_RTE-Exceptions +*/ +#ifndef __SOLVER_VARIABLE_ECONOMY_VCardReserveParticipationUnsuppliedSpilled_H__ +#define __SOLVER_VARIABLE_ECONOMY_VCardReserveParticipationUnsuppliedSpilled_H__ + +#include "../storage/results.h" + +namespace Antares +{ +namespace Solver +{ +namespace Variable +{ +namespace Economy +{ +struct VCardReserveParticipationUnsuppliedSpilled +{ + //! Caption + static std::string Caption() + { + return "RESERVE UNSUPPLIED OR SPILLED ENERGY"; + } + //! Unit + static std::string Unit() + { + return "MWh"; + } + + //! The short description of the variable + static std::string Description() + { + return "Reserve unsupplied or spilled Power"; + } + + //! The expected results + typedef Results> + ResultsType; + + //! The VCard to look for for calculating spatial aggregates + typedef VCardReserveParticipationUnsuppliedSpilled 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 = 0, + //! Number of columns used by the variable + columnCount = Category::dynamicColumns, + //! The Spatial aggregation + spatialAggregate = Category::spatialAggregateSum, + spatialAggregateMode = Category::spatialAggregateEachYear, + spatialAggregatePostProcessing = 0, + //! Intermediate values + hasIntermediateValues = 1, + //! Can this variable be non applicable (0 : no, 1 : yes) + isPossiblyNonApplicable = 0, + }; + + typedef IntermediateValues IntermediateValuesDeepType; + typedef IntermediateValues* IntermediateValuesBaseType; + typedef IntermediateValuesBaseType* IntermediateValuesType; + + // typedef IntermediateValues IntermediateValuesType; + +}; // class VCard + +static std::string thermalUnsuppliedSpilledToString(Data::ThermalUnsuppliedSpilled idx) +{ + switch (idx) + { + case 0: + return "UNSP."; + case 1: + return "SPIL."; + default: + return ""; + } +} + +} // namespace Economy +} // namespace Variable +} // namespace Solver +} // namespace Antares + +#endif //__SOLVER_VARIABLE_ECONOMY_VCardReserveParticipationUnsuppliedSpilled_H__ \ No newline at end of file diff --git a/src/solver/variable/include/antares/solver/variable/economy/all.h b/src/solver/variable/include/antares/solver/variable/economy/all.h index 150f0afb5e..d6dfa246bc 100644 --- a/src/solver/variable/include/antares/solver/variable/economy/all.h +++ b/src/solver/variable/include/antares/solver/variable/economy/all.h @@ -61,6 +61,8 @@ #include "dtgMarginAfterCsr.h" #include "spilledEnergy.h" #include "reserveParticipationCost.h" +#include "reserveParticipationByGroup.h" +#include "reserveParticipationUnsuppliedSpilled.h" #include "lold.h" #include "lolp.h" @@ -75,7 +77,7 @@ #include "nbOfDispatchedUnitsByPlant.h" #include "profitByPlant.h" #include "reserveParticipationByDispatchablePlant.h" -#include "reserveParticipationByGroup.h" + // By RES plant #include "productionByRenewablePlant.h" @@ -174,9 +176,10 @@ typedef // Prices >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> VariablesPerArea; /*! diff --git a/src/solver/variable/include/antares/solver/variable/economy/overallCost.h b/src/solver/variable/include/antares/solver/variable/economy/overallCost.h index 3628a6580e..3a9db96798 100644 --- a/src/solver/variable/include/antares/solver/variable/economy/overallCost.h +++ b/src/solver/variable/include/antares/solver/variable/economy/overallCost.h @@ -259,8 +259,6 @@ class OverallCost : public Variable::IVariable, NextT, VCardO * (state.hourlyResults->TurbinageHoraire[state.hourInTheWeek] - state.area->hydro.pumpingEfficiency * state.hourlyResults->PompageHoraire[state.hourInTheWeek])); - Yuni::String buffer; - buffer << "Hour : " << state.hourInTheYear << "\n"; for (const auto& thermalReserves : state.problemeHebdo->allReserves.thermalAreaReserves) { for (const auto& reserveUp : thermalReserves.areaCapacityReservationsUp) @@ -272,9 +270,6 @@ class OverallCost : public Variable::IVariable, NextT, VCardO + state.hourlyResults->ReserveThermique[state.hourInTheWeek] .ValeursHorairesInternalExcessReserve[reserveUp.globalReserveIndex] * reserveUp.spillageCost; - buffer << " Reserve : " << reserveUp.reserveName << " Unsupplied : " << state.hourlyResults->ReserveThermique[state.hourInTheWeek] - .ValeursHorairesInternalUnsatisfied[reserveUp.globalReserveIndex] << " mw, Spilled : " << state.hourlyResults->ReserveThermique[state.hourInTheWeek] - .ValeursHorairesInternalExcessReserve[reserveUp.globalReserveIndex] << " mw. \n"; } for (const auto& reserveDown : thermalReserves.areaCapacityReservationsDown) { @@ -285,35 +280,11 @@ class OverallCost : public Variable::IVariable, NextT, VCardO + state.hourlyResults->ReserveThermique[state.hourInTheWeek] .ValeursHorairesInternalExcessReserve[reserveDown.globalReserveIndex] * reserveDown.spillageCost; - buffer << " Reserve : " << reserveDown.reserveName << " Unsupplied : " << state.hourlyResults->ReserveThermique[state.hourInTheWeek] - .ValeursHorairesInternalUnsatisfied[reserveDown.globalReserveIndex] << " mw, Spilled : " << state.hourlyResults->ReserveThermique[state.hourInTheWeek] - .ValeursHorairesInternalExcessReserve[reserveDown.globalReserveIndex] << " mw. \n"; } } - state.spilledUnsupplied << buffer; + pValuesForTheCurrentYear[numSpace][state.hourInTheYear] += costForSpilledOrUnsuppliedEnergy; - if (state.hourInTheYear == state.study.runtime->rangeLimits.hour[Data::rangeEnd]) - { - Yuni::String path; - path << state.study.folderOutput << SEP << "reserves" << SEP << state.area->name << ".txt"; - Yuni::IO::File::Stream file; - Yuni::String pathFolder = state.study.folderOutput; - pathFolder << SEP << "reserves"; - if (Yuni::IO::Directory::Exists(pathFolder) || Yuni::IO::Directory::Create(pathFolder)) - { - if (file.openRW(path)) - { - file << state.spilledUnsupplied; - file.close(); - } - } - else - { - logs.error() << "Reserves : impossible to write " << path; - } - } - // Incrementing annual system cost (to be printed in output into a separate file) state.annualSystemCost += costForSpilledOrUnsuppliedEnergy; diff --git a/src/solver/variable/include/antares/solver/variable/economy/reserveParticipationUnsuppliedSpilled.h b/src/solver/variable/include/antares/solver/variable/economy/reserveParticipationUnsuppliedSpilled.h new file mode 100644 index 0000000000..0cebcd3efa --- /dev/null +++ b/src/solver/variable/include/antares/solver/variable/economy/reserveParticipationUnsuppliedSpilled.h @@ -0,0 +1,328 @@ +/* +** Copyright 2007-2023 RTE +** Authors: Antares_Simulator Team +** +** This file is part of Antares_Simulator. +** +** Antares_Simulator is free software: you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation, either version 3 of the License, or +** (at your option) any later version. +** +** There are special exceptions to the terms and conditions of the +** license as they are applied to this software. View the full text of +** the exceptions in file COPYING.txt in the directory of this software +** distribution +** +** Antares_Simulator is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with Antares_Simulator. If not, see . +** +** SPDX-License-Identifier: licenceRef-GPL3_WITH_RTE-Exceptions +*/ +#ifndef __SOLVER_VARIABLE_ECONOMY_ReserveParticipationUnsuppliedSpilled_H__ +#define __SOLVER_VARIABLE_ECONOMY_ReserveParticipationUnsuppliedSpilled_H__ + +#include "../variable.h" +#include "./vCardReserveParticipationUnsuppliedSpilled.h" + +namespace Antares +{ +namespace Solver +{ +namespace Variable +{ +namespace Economy +{ + +/*! +** \brief Reserve participation unsupplied and spilled volumes for an area +*/ +template +class ReserveParticipationUnsuppliedSpilled : public Variable::IVariable, + NextT, + VCardReserveParticipationUnsuppliedSpilled> +{ +public: + //! Type of the next static variable + typedef NextT NextType; + //! VCard + typedef VCardReserveParticipationUnsuppliedSpilled 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: + ReserveParticipationUnsuppliedSpilled() : pValuesForTheCurrentYear(NULL), pSize(0) + { + } + + ~ReserveParticipationUnsuppliedSpilled() + { + for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++) + delete[] pValuesForTheCurrentYear[numSpace]; + delete[] pValuesForTheCurrentYear; + } + + void initializeFromStudy(Data::Study& study) + { + // Next + NextType::initializeFromStudy(study); + } + + void initializeFromArea(Data::Study* study, Data::Area* area) + { + // Get the number of years in parallel + pNbYearsParallel = study->maxNbYearsInParallel; + pValuesForTheCurrentYear = new VCardType::IntermediateValuesBaseType[pNbYearsParallel]; + + // Get the area + pSize = 0; + for (auto res : area->allCapacityReservations.areaCapacityReservationsUp) + { + pSize += 2; + } + for (auto res : area->allCapacityReservations.areaCapacityReservationsDown) + { + pSize += 2; + } + if (pSize) + { + AncestorType::pResults.resize(pSize); + + for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++) + pValuesForTheCurrentYear[numSpace] + = new VCardType::IntermediateValuesDeepType[pSize]; + + // Minimum power values of the cluster for the whole year - from the solver in the + // accurate mode not to be displayed in the output \todo think of a better place like + // the DispatchableMarginForAllAreas done at the beginning of the year + + for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++) + for (unsigned int i = 0; i != pSize; ++i) + pValuesForTheCurrentYear[numSpace][i].initializeFromStudy(*study); + + for (unsigned int i = 0; i != pSize; ++i) + { + AncestorType::pResults[i].initializeFromStudy(*study); + AncestorType::pResults[i].reset(); + } + } + else + { + for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++) + { + pValuesForTheCurrentYear[numSpace] = nullptr; + } + AncestorType::pResults.clear(); + } + // Next + NextType::initializeFromArea(study, area); + } + + size_t getMaxNumberColumns() const + { + return pSize * ResultsType::count; + } + + void initializeFromLink(Data::Study* study, Data::AreaLink* link) + { + // Next + NextType::initializeFromAreaLink(study, link); + } + + void simulationBegin() + { + // Next + NextType::simulationBegin(); + } + + void simulationEnd() + { + NextType::simulationEnd(); + } + + void yearBegin(unsigned int year, unsigned int numSpace) + { + // Reset the values for the current year + for (unsigned int i = 0; i != pSize; ++i) + pValuesForTheCurrentYear[numSpace][i].reset(); + + // Next variable + NextType::yearBegin(year, numSpace); + } + + void yearEndBuildForEachThermalCluster(State& state, uint year, unsigned int numSpace) + { + // Next variable + NextType::yearEndBuildForEachThermalCluster(state, year, numSpace); + } + + void yearEndBuild(State& state, unsigned int year) + { + // Next variable + NextType::yearEndBuild(state, year); + } + + void yearEnd(unsigned int year, unsigned int numSpace) + { + // Merge all results for all thermal clusters + { + for (unsigned int i = 0; i < pSize; ++i) + { + // Compute all statistics for the current year (daily,weekly,monthly) + pValuesForTheCurrentYear[numSpace][i].computeStatisticsForTheCurrentYear(); + } + } + // Next variable + NextType::yearEnd(year, numSpace); + } + + void computeSummary(std::map& numSpaceToYear, + unsigned int nbYearsForCurrentSummary) + { + for (unsigned int numSpace = 0; numSpace < nbYearsForCurrentSummary; ++numSpace) + { + for (unsigned int i = 0; i < pSize; ++i) + { + // Merge all those values with the global results + AncestorType::pResults[i].merge(numSpaceToYear[numSpace], + pValuesForTheCurrentYear[numSpace][i]); + } + } + + // Next variable + NextType::computeSummary(numSpaceToYear, nbYearsForCurrentSummary); + } + + void hourBegin(unsigned int hourInTheYear) + { + // Next variable + NextType::hourBegin(hourInTheYear); + } + + void hourForEachArea(State& state, unsigned int numSpace) + { + auto& area = state.area; + auto& thermal = state.thermal; + int column = 0; + for (const auto& thermalReserves : state.problemeHebdo->allReserves.thermalAreaReserves) + { + for (const auto& reserveUp : thermalReserves.areaCapacityReservationsUp) + { + pValuesForTheCurrentYear[numSpace][column++].hour[state.hourInTheYear] + += state.hourlyResults->ReserveThermique[state.hourInTheWeek] + .ValeursHorairesInternalUnsatisfied[reserveUp.globalReserveIndex]; + pValuesForTheCurrentYear[numSpace][column++].hour[state.hourInTheYear] + += state.hourlyResults->ReserveThermique[state.hourInTheWeek] + .ValeursHorairesInternalExcessReserve[reserveUp.globalReserveIndex]; + } + for (const auto& reserveDown : thermalReserves.areaCapacityReservationsDown) + { + pValuesForTheCurrentYear[numSpace][column++].hour[state.hourInTheYear] + += state.hourlyResults->ReserveThermique[state.hourInTheWeek] + .ValeursHorairesInternalUnsatisfied[reserveDown.globalReserveIndex]; + pValuesForTheCurrentYear[numSpace][column++].hour[state.hourInTheYear] + += state.hourlyResults->ReserveThermique[state.hourInTheWeek] + .ValeursHorairesInternalExcessReserve[reserveDown.globalReserveIndex]; + } + } + + // Next variable + NextType::hourForEachArea(state, numSpace); + } + + Antares::Memory::Stored::ConstReturnType retrieveRawHourlyValuesForCurrentYear( + unsigned int, + 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]) + { + assert(NULL != results.data.area); + const auto& thermal = results.data.area->thermal; + results.variableUnit = VCardType::Unit(); + // Write the data for the current year + int column = 0; + for (const auto& reserveUp : results.data.area->allCapacityReservations.areaCapacityReservationsUp) + { + // Write the data for the current year + Yuni::String caption = reserveUp.first; + caption << "_UNSP. ENRG"; + results.variableCaption = caption; // VCardType::Caption(); + pValuesForTheCurrentYear[numSpace][column++].template buildAnnualSurveyReport( + results, fileLevel, precision); + caption = reserveUp.first; + caption << "_SPIL. ENRG"; + results.variableCaption = caption; // VCardType::Caption(); + pValuesForTheCurrentYear[numSpace][column++].template buildAnnualSurveyReport( + results, fileLevel, precision); + } + for (const auto& reserveDown : results.data.area->allCapacityReservations.areaCapacityReservationsDown) + { + // Write the data for the current year + Yuni::String caption = reserveDown.first; + caption << "_UNSP. ENRG"; + results.variableCaption = caption; // VCardType::Caption(); + pValuesForTheCurrentYear[numSpace][column++].template buildAnnualSurveyReport( + results, fileLevel, precision); + caption = reserveDown.first; + caption << "_SPIL. ENRG"; + results.variableCaption = caption; // VCardType::Caption(); + pValuesForTheCurrentYear[numSpace][column++].template buildAnnualSurveyReport( + results, fileLevel, precision); + } + } + } + +private: + //! Intermediate values for each year + typename VCardType::IntermediateValuesType pValuesForTheCurrentYear; + size_t pSize; + unsigned int pNbYearsParallel; + +}; // class ReserveParticipationUnsuppliedSpilled + +} // namespace Economy +} // namespace Variable +} // namespace Solver +} // namespace Antares + +#endif // __SOLVER_VARIABLE_ECONOMY_ReserveUnsuppliedSpilled_H__ \ No newline at end of file diff --git a/src/solver/variable/include/antares/solver/variable/economy/vCardReserveParticipationByDispatchablePlant.h b/src/solver/variable/include/antares/solver/variable/economy/vCardReserveParticipationByDispatchablePlant.h index d773aafa16..53f0ec174b 100644 --- a/src/solver/variable/include/antares/solver/variable/economy/vCardReserveParticipationByDispatchablePlant.h +++ b/src/solver/variable/include/antares/solver/variable/economy/vCardReserveParticipationByDispatchablePlant.h @@ -47,7 +47,7 @@ struct VCardReserveParticipationByDispatchablePlant //! Unit static std::string Unit() { - return "Reserve Participation Power - MW"; + return "Reserve Participation Power - MWh"; } //! The short description of the variable diff --git a/src/solver/variable/include/antares/solver/variable/info.h b/src/solver/variable/include/antares/solver/variable/info.h index 2b3874aa14..f7b46ad292 100644 --- a/src/solver/variable/include/antares/solver/variable/info.h +++ b/src/solver/variable/include/antares/solver/variable/info.h @@ -24,6 +24,7 @@ #include #include "./economy/vCardReserveParticipationByDispatchablePlant.h" #include "./economy/vCardReserveParticipationByGroup.h" +#include "./economy/vCardReserveParticipationUnsuppliedSpilled.h" namespace Antares { @@ -381,6 +382,12 @@ struct VariableAccessor = thermal.list.reserveParticipationGroupAt(results.data.area, i); results.variableCaption = reserveName + "_" + Economy::thermalDispatchableGroupToString(groupName); } + else if (typeid(VCardT) == typeid(Economy::VCardReserveParticipationUnsuppliedSpilled)) + { + auto [unsuppliedOrSpilled, reserveName] + = thermal.list.reserveParticipationGroupAt(results.data.area, i); + results.variableCaption = reserveName + "_" + Economy::thermalDispatchableGroupToString(unsuppliedOrSpilled); + } else results.variableCaption = thermal.list.enabledClusterAt(i)->name(); @@ -466,6 +473,13 @@ struct VariableAccessor results.variableCaption = reserveName + "_" + Economy::thermalDispatchableGroupToString(groupName); res = true; } + else if (typeid(VCardType) == typeid(Economy::VCardReserveParticipationUnsuppliedSpilled)) + { + auto [unsuppliedOrSpilled, reserveName] + = thermal.list.reserveParticipationUnsuppliedSpilledAt(results.data.area, i); + results.variableCaption = reserveName + "_" + Economy::thermalUnsuppliedSpilledToString(unsuppliedOrSpilled); + res = true; + } else res = setClusterCaption(results, fileLevel, i); if (!res) diff --git a/src/solver/variable/include/antares/solver/variable/state.h b/src/solver/variable/include/antares/solver/variable/state.h index 0735d28e23..aae5c6f61c 100644 --- a/src/solver/variable/include/antares/solver/variable/state.h +++ b/src/solver/variable/include/antares/solver/variable/state.h @@ -154,7 +154,6 @@ class State //! Current hour from the begining of the simulation unsigned int hourInTheSimulation; - Yuni::String spilledUnsupplied; //! The current area Data::Area* area; diff --git a/src/solver/variable/state.cpp b/src/solver/variable/state.cpp index ceac1f6ddf..77edbb012f 100644 --- a/src/solver/variable/state.cpp +++ b/src/solver/variable/state.cpp @@ -417,44 +417,10 @@ void State::yearEndBuildCalculateReserveParticipationCosts( uint startHourForCurrentYear = study.runtime->rangeLimits.hour[Data::rangeBegin]; uint endHourForCurrentYear = startHourForCurrentYear + study.runtime->rangeLimits.hour[Data::rangeCount]; - Yuni::IO::File::Stream file; - Yuni::String pathFolder = study.folderOutput; - pathFolder << SEP << "reserves"; - if (Yuni::IO::Directory::Exists(pathFolder) || Yuni::IO::Directory::Create(pathFolder)) + for (uint h = startHourForCurrentYear; h < endHourForCurrentYear; ++h) { - pathFolder << SEP << thermalCluster->parentArea->name; - if (Yuni::IO::Directory::Exists(pathFolder) || Yuni::IO::Directory::Create(pathFolder)) - { - Yuni::String path; - path << pathFolder << SEP << thermalCluster->name() << ".txt"; - if (file.openRW(path)) - { - for (uint h = startHourForCurrentYear; h < endHourForCurrentYear; ++h) - { - thermalClusterOperatingCostForYear[h] - += thermalClusterReserveParticipationCostForYear[h]; - std::vector clusterReserves = thermalCluster->listOfParticipatingReserves(); - - for (auto res : clusterReserves) - { - file << "Hour " << h + 1 << " : cluster " << thermalCluster->name() << " is participating to reserve " << res << " for " << thermalReserveParticipationPerGroupForYear[h][thermalCluster->groupID][res] << " mw\n"; - } - } - file.close(); - } - else - { - logs.error() << "Reserves : impossible to write " << path; - } - } - else - { - logs.error() << "Reserves : impossible to write " << pathFolder; - } - } - else - { - logs.error() << "Reserves : impossible to write " << pathFolder; + thermalClusterOperatingCostForYear[h] + += thermalClusterReserveParticipationCostForYear[h]; } } }