diff --git a/src/libs/antares/constants.h b/src/libs/antares/constants.h index acb9d975cb..84faf5d305 100644 --- a/src/libs/antares/constants.h +++ b/src/libs/antares/constants.h @@ -35,11 +35,9 @@ /*! Vendor */ #define LOG_APPLICATION_VENDOR "RTE" -/*! Days per year */ -#define DAYS_PER_YEAR 365 - -/*! Hours per year */ -#define HOURS_PER_YEAR 8760 +const unsigned int HOURS_PER_DAY = 24; +const unsigned int DAYS_PER_YEAR = 365; +const unsigned int HOURS_PER_YEAR = 8760; namespace Antares::Constants { diff --git a/src/libs/antares/series/series.cpp b/src/libs/antares/series/series.cpp index 2785ff5a6b..cde487a2d3 100644 --- a/src/libs/antares/series/series.cpp +++ b/src/libs/antares/series/series.cpp @@ -38,8 +38,6 @@ using namespace Yuni; namespace Antares::Data { -const std::vector TimeSeries::emptyColumn(HOURS_PER_YEAR); - TimeSeries::TimeSeries(numbers& tsNumbers) : timeseriesNumbers(tsNumbers) {} @@ -74,24 +72,17 @@ int TimeSeries::saveToFile(const std::string& filename, bool saveEvenIfAllZero) double TimeSeries::getCoefficient(uint32_t year, uint32_t timestep) const { - if (timeSeries.width == 0) - return 0; return timeSeries[getSeriesIndex(year)][timestep]; } const double* TimeSeries::getColumn(uint32_t year) const { - if (timeSeries.width == 0) - return emptyColumn.data(); return timeSeries[getSeriesIndex(year)]; } uint32_t TimeSeries::getSeriesIndex(uint32_t year) const { - if (timeSeries.width == 1) - return 0; - else - return timeseriesNumbers[0][year]; + return timeseriesNumbers[0][year]; } double* TimeSeries::operator[](uint32_t index) diff --git a/src/libs/antares/study/area/area.cpp b/src/libs/antares/study/area/area.cpp index 0c7a33eab8..cfb300a6ff 100644 --- a/src/libs/antares/study/area/area.cpp +++ b/src/libs/antares/study/area/area.cpp @@ -257,39 +257,21 @@ void Area::resetToDefaultValues() invalidateJIT = true; } -void Area::resizeAllTimeseriesNumbers(uint n) +void Area::resizeAllTimeseriesNumbers(uint nbYears) { - assert(n < 200000); // arbitrary number - - // asserts assert(hydro.series and "series must not be nullptr !"); - if (!n) + load.series.timeseriesNumbers.reset(1, nbYears); + solar.series.timeseriesNumbers.reset(1, nbYears); + wind.series.timeseriesNumbers.reset(1, nbYears); + hydro.series->timeseriesNumbers.reset(1, nbYears); + for (auto& namedLink : links) { - load.series.timeseriesNumbers.clear(); - solar.series.timeseriesNumbers.clear(); - wind.series.timeseriesNumbers.clear(); - hydro.series->timeseriesNumbers.clear(); - for (auto& namedLink : links) - { - AreaLink* link = namedLink.second; - link->timeseriesNumbers.clear(); - } - } - else - { - load.series.timeseriesNumbers.resize(1, n); - solar.series.timeseriesNumbers.resize(1, n); - wind.series.timeseriesNumbers.resize(1, n); - hydro.series->timeseriesNumbers.resize(1, n); - for (auto& namedLink : links) - { - AreaLink* link = namedLink.second; - link->timeseriesNumbers.resize(1, n); - } + AreaLink* link = namedLink.second; + link->timeseriesNumbers.reset(1, nbYears); } - thermal.resizeAllTimeseriesNumbers(n); - renewable.resizeAllTimeseriesNumbers(n); + thermal.resizeAllTimeseriesNumbers(nbYears); + renewable.resizeAllTimeseriesNumbers(nbYears); } bool Area::thermalClustersMinStablePowerValidity(std::vector& output) const diff --git a/src/libs/antares/study/area/area.h b/src/libs/antares/study/area/area.h index 1a59fd5346..d2f60d4a0c 100644 --- a/src/libs/antares/study/area/area.h +++ b/src/libs/antares/study/area/area.h @@ -154,7 +154,7 @@ class Area final : private Yuni::NonCopyable ** ** \param n A number of years */ - void resizeAllTimeseriesNumbers(uint n); + void resizeAllTimeseriesNumbers(uint nbYears); /*! ** \brief Check if a link with another area is already established diff --git a/src/libs/antares/study/binding_constraint/BindingConstraintGroup.cpp b/src/libs/antares/study/binding_constraint/BindingConstraintGroup.cpp index 5d955236ff..b4d2a99607 100644 --- a/src/libs/antares/study/binding_constraint/BindingConstraintGroup.cpp +++ b/src/libs/antares/study/binding_constraint/BindingConstraintGroup.cpp @@ -22,14 +22,6 @@ namespace Antares::Data { return constraints_; } - void BindingConstraintGroup::fixTSNumbersWhenWidthIsOne() { - if (std::all_of(constraints_.begin(), constraints_.end(), [](auto constraint){ - return constraint->RHSTimeSeries().width == 1; - })) { - timeseriesNumbers.fillColumn(0, 0); - } - } - unsigned BindingConstraintGroup::numberOfTimeseries() const { //Assume all BC in a group have the same width if (constraints_.empty()) return 0; diff --git a/src/libs/antares/study/binding_constraint/BindingConstraintGroup.h b/src/libs/antares/study/binding_constraint/BindingConstraintGroup.h index 0103fda27d..ca7f829bf3 100644 --- a/src/libs/antares/study/binding_constraint/BindingConstraintGroup.h +++ b/src/libs/antares/study/binding_constraint/BindingConstraintGroup.h @@ -15,7 +15,6 @@ class BindingConstraintGroup { [[nodiscard]] std::string name() { return name_; } void add(const std::shared_ptr& constraint); [[nodiscard]] std::set> constraints() const; - void fixTSNumbersWhenWidthIsOne(); [[nodiscard]] unsigned numberOfTimeseries() const; public: diff --git a/src/libs/antares/study/binding_constraint/BindingConstraintGroupRepository.cpp b/src/libs/antares/study/binding_constraint/BindingConstraintGroupRepository.cpp index 9758b3f35a..a8b500cb8a 100644 --- a/src/libs/antares/study/binding_constraint/BindingConstraintGroupRepository.cpp +++ b/src/libs/antares/study/binding_constraint/BindingConstraintGroupRepository.cpp @@ -54,13 +54,7 @@ namespace Antares::Data { void BindingConstraintGroupRepository::resizeAllTimeseriesNumbers(unsigned int nb_years) { std::for_each(groups_.begin(), groups_.end(), [&](auto &group) { group->timeseriesNumbers.clear(); - group->timeseriesNumbers.resize(1, nb_years); - }); - } - - void BindingConstraintGroupRepository::fixTSNumbersWhenWidthIsOne() { - std::for_each(groups_.begin(), groups_.end(), [](auto& group) { - group->fixTSNumbersWhenWidthIsOne(); + group->timeseriesNumbers.reset(1, nb_years); }); } diff --git a/src/libs/antares/study/binding_constraint/BindingConstraintGroupRepository.h b/src/libs/antares/study/binding_constraint/BindingConstraintGroupRepository.h index c39c62f211..acddaa9765 100644 --- a/src/libs/antares/study/binding_constraint/BindingConstraintGroupRepository.h +++ b/src/libs/antares/study/binding_constraint/BindingConstraintGroupRepository.h @@ -22,8 +22,6 @@ class BindingConstraintGroupRepository { void resizeAllTimeseriesNumbers(unsigned nb_years); - void fixTSNumbersWhenWidthIsOne(); - BindingConstraintGroup* operator[](const std::string& name) const; using iterator = std::vector>::iterator; diff --git a/src/libs/antares/study/parts/hydro/series.cpp b/src/libs/antares/study/parts/hydro/series.cpp index 1263e732b7..1598cf6a65 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 08fc8dff93..6a4ff2e9b6 100644 --- a/src/libs/antares/study/parts/hydro/series.h +++ b/src/libs/antares/study/parts/hydro/series.h @@ -58,7 +58,7 @@ class DataSeriesHydro */ void reset(); - void resizeRORandSTORAGE(unsigned int width); + void resize_ROR_STORAGE_MINGEN_whenGeneratedTS(unsigned int width); void resizeGenerationTS(unsigned int w, unsigned int h); /*! diff --git a/src/libs/antares/study/parts/solar/container.cpp b/src/libs/antares/study/parts/solar/container.cpp index 033a26b4c7..77dd9ea4bf 100644 --- a/src/libs/antares/study/parts/solar/container.cpp +++ b/src/libs/antares/study/parts/solar/container.cpp @@ -70,7 +70,7 @@ uint64_t Container::memoryUsage() const void Container::resetToDefault() { - series.timeSeries.reset(); + series.reset(); if (prepro) prepro->resetToDefault(); } diff --git a/src/solver/simulation/solver.hxx b/src/solver/simulation/solver.hxx index ccca27ec51..6cb1425246 100644 --- a/src/solver/simulation/solver.hxx +++ b/src/solver/simulation/solver.hxx @@ -312,6 +312,8 @@ void ISimulation::run() ImplementationType::setNbPerformedYearsInParallel(pNbMaxPerformedYearsInParallel); + TSGenerator::ResizeGeneratedTimeSeries(study.areas, study.parameters); + if (settings.tsGeneratorsOnly) { // Only the preprocessors can be used @@ -323,7 +325,7 @@ void ISimulation::run() // Destroy the TS Generators if any // It will export the time-series into the output in the same time - Solver::TSGenerator::DestroyAll(study); + TSGenerator::DestroyAll(study); } else { @@ -370,7 +372,7 @@ void ISimulation::run() } // Destroy the TS Generators if any // It will export the time-series into the output in the same time - Solver::TSGenerator::DestroyAll(study); + TSGenerator::DestroyAll(study); // Post operations { @@ -449,7 +451,7 @@ void ISimulation::regenerateTimeSeries(uint year) // * The option "Preprocessor" is checked in the interface _and_ year == 0 // * Both options "Preprocessor" and "Refresh" are checked in the interface // _and_ the refresh must be done for the given year (always done for the first year). - using namespace Solver::TSGenerator; + using namespace TSGenerator; // Load if (pData.haveToRefreshTSLoad && (year % pData.refreshIntervalLoad == 0)) { diff --git a/src/solver/simulation/timeseries-numbers.cpp b/src/solver/simulation/timeseries-numbers.cpp index 30cc4b32dc..6bf8736828 100644 --- a/src/solver/simulation/timeseries-numbers.cpp +++ b/src/solver/simulation/timeseries-numbers.cpp @@ -87,119 +87,56 @@ static bool GenerateDeratedMode(Study& study) logs.info() << " :: using the `derated` mode"; if (study.parameters.useCustomScenario) logs.warning() << "The derated mode is enabled. The custom building mode will be ignored"; - - study.areas.each([&](Area& area) { - area.load.series.timeseriesNumbers.zero(); - area.solar.series.timeseriesNumbers.zero(); - area.wind.series.timeseriesNumbers.zero(); - area.hydro.series->timeseriesNumbers.zero(); - - for (uint i = 0; i != area.thermal.clusterCount(); ++i) - { - auto& cluster = *(area.thermal.clusters[i]); - cluster.series.timeseriesNumbers.zero(); - } - - for (const auto& cluster : area.renewable.list) - cluster->series.timeseriesNumbers.zero(); - }); - return true; } -class areaNumberOfTSretriever +class AreaNumberOfTSretriever { public: - areaNumberOfTSretriever(Study& study) : study_(study) - { - } + virtual ~AreaNumberOfTSretriever() = default; virtual std::vector getAreaTimeSeriesNumber(const Area& area) = 0; - virtual uint getGeneratedTimeSeriesNumber() = 0; - -protected: - Study& study_; }; -class loadAreaNumberOfTSretriever : public areaNumberOfTSretriever +class LoadAreaNumberOfTSretriever : public AreaNumberOfTSretriever { public: - virtual ~loadAreaNumberOfTSretriever() = default; - loadAreaNumberOfTSretriever(Study& study) : areaNumberOfTSretriever(study) - { - } - std::vector getAreaTimeSeriesNumber(const Area& area) - { - std::vector to_return = {area.load.series.timeSeries.width}; - return to_return; - } - uint getGeneratedTimeSeriesNumber() + std::vector getAreaTimeSeriesNumber(const Area& area) override { - return study_.parameters.nbTimeSeriesLoad; + return { area.load.series.timeSeries.width }; } }; -class hydroAreaNumberOfTSretriever : public areaNumberOfTSretriever +class HydroAreaNumberOfTSretriever : public AreaNumberOfTSretriever { public: - virtual ~hydroAreaNumberOfTSretriever() = default; - hydroAreaNumberOfTSretriever(Study& study) : areaNumberOfTSretriever(study) - { - } - std::vector getAreaTimeSeriesNumber(const Area& area) - { - std::vector to_return = {area.hydro.series->TScount()}; - return to_return; - } - uint getGeneratedTimeSeriesNumber() + std::vector getAreaTimeSeriesNumber(const Area& area) override { - return study_.parameters.nbTimeSeriesHydro; + return { area.hydro.series->TScount() }; } }; -class windAreaNumberOfTSretriever : public areaNumberOfTSretriever +class WindAreaNumberOfTSretriever : public AreaNumberOfTSretriever { public: - virtual ~windAreaNumberOfTSretriever() = default; - windAreaNumberOfTSretriever(Study& study) : areaNumberOfTSretriever(study) - { - } - std::vector getAreaTimeSeriesNumber(const Area& area) - { - std::vector to_return = {area.wind.series.timeSeries.width}; - return to_return; - } - uint getGeneratedTimeSeriesNumber() + std::vector getAreaTimeSeriesNumber(const Area& area) override { - return study_.parameters.nbTimeSeriesWind; + return { area.wind.series.timeSeries.width }; } }; -class solarAreaNumberOfTSretriever : public areaNumberOfTSretriever +class SolarAreaNumberOfTSretriever : public AreaNumberOfTSretriever { public: - virtual ~solarAreaNumberOfTSretriever() = default; - solarAreaNumberOfTSretriever(Study& study) : areaNumberOfTSretriever(study) - { - } - std::vector getAreaTimeSeriesNumber(const Area& area) - { - std::vector to_return = {area.solar.series.timeSeries.width}; - return to_return; - } - uint getGeneratedTimeSeriesNumber() + std::vector getAreaTimeSeriesNumber(const Area& area) override { - return study_.parameters.nbTimeSeriesSolar; + return { area.solar.series.timeSeries.width }; } }; -class thermalAreaNumberOfTSretriever : public areaNumberOfTSretriever +class ThermalAreaNumberOfTSretriever : public AreaNumberOfTSretriever { public: - virtual ~thermalAreaNumberOfTSretriever() = default; - thermalAreaNumberOfTSretriever(Study& study) : areaNumberOfTSretriever(study) - { - } - std::vector getAreaTimeSeriesNumber(const Area& area) + std::vector getAreaTimeSeriesNumber(const Area& area) override { std::vector to_return; uint clusterCount = (uint)area.thermal.clusterCount(); @@ -210,20 +147,12 @@ class thermalAreaNumberOfTSretriever : public areaNumberOfTSretriever } return to_return; } - uint getGeneratedTimeSeriesNumber() - { - return study_.parameters.nbTimeSeriesThermal; - } }; -class renewClustersAreaNumberOfTSretriever : public areaNumberOfTSretriever +class RenewClustersAreaNumberOfTSretriever : public AreaNumberOfTSretriever { public: - virtual ~renewClustersAreaNumberOfTSretriever() = default; - renewClustersAreaNumberOfTSretriever(Study& study) : areaNumberOfTSretriever(study) - { - } - std::vector getAreaTimeSeriesNumber(const Area& area) + std::vector getAreaTimeSeriesNumber(const Area& area) override { std::vector to_return; for (const auto& cluster : area.renewable.list) @@ -232,17 +161,11 @@ class renewClustersAreaNumberOfTSretriever : public areaNumberOfTSretriever } return to_return; } - uint getGeneratedTimeSeriesNumber() - { - return 1; - } }; -class areaLinksTransCapaNumberOfTSretriever : public areaNumberOfTSretriever +class AreaLinksTransCapaNumberOfTSretriever : public AreaNumberOfTSretriever { public: - using areaNumberOfTSretriever::areaNumberOfTSretriever; - virtual ~areaLinksTransCapaNumberOfTSretriever() = default; std::vector getAreaTimeSeriesNumber(const Area& area) override { std::vector to_return; @@ -251,63 +174,35 @@ class areaLinksTransCapaNumberOfTSretriever : public areaNumberOfTSretriever { const auto& link = *(it->second); to_return.push_back(link.directCapacities.timeSeries.width); - to_return.push_back(link.indirectCapacities.timeSeries.width); } return to_return; } - uint getGeneratedTimeSeriesNumber() override - { - return 1; - } }; class IntraModalConsistencyChecker { public: IntraModalConsistencyChecker(const TimeSeriesType ts, - const array& isTSintramodal, - const array& isTSgenerated, - areaNumberOfTSretriever* tsCounter, + AreaNumberOfTSretriever* tsCounter, Study& study) : - tsCounter_(tsCounter), study_(study), nbTimeseries_(0) + tsCounter_(tsCounter), study_(study) { - int indexTS = ts_to_tsIndex.at(ts); - isTSintramodal_ = isTSintramodal[indexTS]; - isTSgenerated_ = isTSgenerated[indexTS]; tsTitle_ = ts_to_tsTitle.at(ts); } ~IntraModalConsistencyChecker() = default; - bool check(); + bool checkTSconsistency(); uint getTimeSeriesNumber() { return nbTimeseries_; } private: - bool checkTSconsistency(); - -private: - bool isTSintramodal_; - bool isTSgenerated_; - areaNumberOfTSretriever* tsCounter_; + AreaNumberOfTSretriever* tsCounter_; Study& study_; - uint nbTimeseries_; + uint nbTimeseries_ = 0; string tsTitle_; }; -bool IntraModalConsistencyChecker::check() -{ - if (isTSintramodal_ && not isTSgenerated_) - { - if (not checkTSconsistency()) - return false; - } - else - nbTimeseries_ = tsCounter_->getGeneratedTimeSeriesNumber(); - - return true; -} - bool IntraModalConsistencyChecker::checkTSconsistency() { logs.info() << "Checking intra-modal correlation: " << tsTitle_; @@ -325,60 +220,52 @@ bool IntraModalConsistencyChecker::checkTSconsistency() << "'s numbers of time-series are not equal for all areas"; return false; } + // At this point, all elements are identical or 1 + nbTimeseries_ = *(std::max_element(listNumberTS.begin(), listNumberTS.end())); - auto result = find_if(listNumberTS.begin(), listNumberTS.end(), [](uint x) { return x != 1; }); - if (result == listNumberTS.end()) - { // All elements are equal to 1 or list is empty - nbTimeseries_ = 1; - } - else - { - nbTimeseries_ = *result; - } return true; } bool checkIntraModalConsistency(array& nbTimeseriesByMode, const array& isTSintramodal, - const array& isTSgenerated, Study& study) { // Initialization of a map associating a time-series to an object that retrieves // the number of time series inside an area - using mapTStoRetriever = map>; + using mapTStoRetriever = map>; mapTStoRetriever ts_to_numberOfTSretrievers; - ts_to_numberOfTSretrievers[timeSeriesLoad] = make_shared(study); - ts_to_numberOfTSretrievers[timeSeriesHydro] = make_shared(study); - ts_to_numberOfTSretrievers[timeSeriesWind] = make_shared(study); - ts_to_numberOfTSretrievers[timeSeriesSolar] = make_shared(study); + ts_to_numberOfTSretrievers[timeSeriesLoad] = make_shared(); + ts_to_numberOfTSretrievers[timeSeriesHydro] = make_shared(); + ts_to_numberOfTSretrievers[timeSeriesWind] = make_shared(); + ts_to_numberOfTSretrievers[timeSeriesSolar] = make_shared(); ts_to_numberOfTSretrievers[timeSeriesThermal] - = make_shared(study); + = make_shared(); ts_to_numberOfTSretrievers[timeSeriesRenewable] - = make_shared(study); + = make_shared(); ts_to_numberOfTSretrievers[timeSeriesTransmissionCapacities] - = make_shared(study); + = make_shared(); // Loop over TS kind and check intra-modal consistency mapTStoRetriever::iterator it = ts_to_numberOfTSretrievers.begin(); for (; it != ts_to_numberOfTSretrievers.end(); ++it) { const TimeSeriesType tsKind = it->first; - areaNumberOfTSretriever* tsRetriever = (it->second).get(); + AreaNumberOfTSretriever* tsRetriever = (it->second).get(); int indexTS = ts_to_tsIndex.at(it->first); - IntraModalConsistencyChecker intraModalchecker( - tsKind, isTSintramodal, isTSgenerated, tsRetriever, study); - if (!intraModalchecker.check()) - return false; - nbTimeseriesByMode[indexTS] = intraModalchecker.getTimeSeriesNumber(); + if (isTSintramodal[indexTS]) + { + IntraModalConsistencyChecker intraModalchecker(tsKind, tsRetriever, study); + if (!intraModalchecker.checkTSconsistency()) + return false; + nbTimeseriesByMode[indexTS] = intraModalchecker.getTimeSeriesNumber(); + } } return true; } bool checkInterModalConsistencyForArea(Area& area, - const array& isTSintermodal, - const array& isTSgenerated, - Study& study) + const array& isTSintermodal) { // 1. Making a list of TS numbers : // In this list, we put the numbers of TS of every "inter-modal" mode over the current area. @@ -387,42 +274,32 @@ bool checkInterModalConsistencyForArea(Area& area, // The list containing the numbers of TS of every "inter-modal" mode over the current area std::vector listNumberTsOverArea; - auto& parameters = study.parameters; - // Load : Add load's number of TS in area ... int indexTS = ts_to_tsIndex.at(timeSeriesLoad); if (isTSintermodal[indexTS]) { - uint nbTimeSeries - = isTSgenerated[indexTS] ? parameters.nbTimeSeriesLoad : area.load.series.timeSeries.width; - listNumberTsOverArea.push_back(nbTimeSeries); + listNumberTsOverArea.push_back(area.load.series.timeSeries.width); } // Solar : Add solar's number of TS in area ... indexTS = ts_to_tsIndex.at(timeSeriesSolar); if (isTSintermodal[indexTS]) { - uint nbTimeSeries - = isTSgenerated[indexTS] ? parameters.nbTimeSeriesSolar : area.solar.series.timeSeries.width; - listNumberTsOverArea.push_back(nbTimeSeries); + listNumberTsOverArea.push_back(area.solar.series.timeSeries.width); } // Wind : Add wind's number of TS in area ... indexTS = ts_to_tsIndex.at(timeSeriesWind); if (isTSintermodal[indexTS]) { - uint nbTimeSeries - = isTSgenerated[indexTS] ? parameters.nbTimeSeriesWind : area.wind.series.timeSeries.width; - listNumberTsOverArea.push_back(nbTimeSeries); + listNumberTsOverArea.push_back(area.wind.series.timeSeries.width); } // Hydro : Add hydro's number of TS in area ... indexTS = ts_to_tsIndex.at(timeSeriesHydro); if (isTSintermodal[indexTS]) { - uint nbTimeSeries - = isTSgenerated[indexTS] ? parameters.nbTimeSeriesHydro : area.hydro.series->TScount(); - listNumberTsOverArea.push_back(nbTimeSeries); + listNumberTsOverArea.push_back(area.hydro.series->TScount()); } // Thermal : Add thermal's number of TS of each cluster in area ... @@ -433,9 +310,7 @@ bool checkInterModalConsistencyForArea(Area& area, for (uint j = 0; j != clusterCount; ++j) { auto& cluster = *(area.thermal.clusters[j]); - uint nbTimeSeries = isTSgenerated[indexTS] ? parameters.nbTimeSeriesThermal - : cluster.series.timeSeries.width; - listNumberTsOverArea.push_back(nbTimeSeries); + listNumberTsOverArea.push_back(cluster.series.timeSeries.width); } } @@ -502,7 +377,7 @@ void storeTSnumbersForIntraModal(const array& intramo assert(year < area.load.series.timeseriesNumbers.height); int indexTS = ts_to_tsIndex.at(timeSeriesLoad); - if (isTSintramodal[indexTS]) + if (isTSintramodal[indexTS] && area.load.series.timeSeries.width > 1) area.load.series.timeseriesNumbers[0][year] = intramodal_draws[indexTS]; // ------------- @@ -511,7 +386,7 @@ void storeTSnumbersForIntraModal(const array& intramo assert(year < area.solar.series.timeseriesNumbers.height); indexTS = ts_to_tsIndex.at(timeSeriesSolar); - if (isTSintramodal[indexTS]) + if (isTSintramodal[indexTS] && area.solar.series.timeSeries.width > 1) area.solar.series.timeseriesNumbers[0][year] = intramodal_draws[indexTS]; // ------------- @@ -520,7 +395,7 @@ void storeTSnumbersForIntraModal(const array& intramo assert(year < area.wind.series.timeseriesNumbers.height); indexTS = ts_to_tsIndex.at(timeSeriesWind); - if (isTSintramodal[indexTS]) + if (isTSintramodal[indexTS] && area.wind.series.timeSeries.width > 1) area.wind.series.timeseriesNumbers[0][year] = intramodal_draws[indexTS]; // ------------- @@ -529,7 +404,7 @@ void storeTSnumbersForIntraModal(const array& intramo assert(year < area.hydro.series->timeseriesNumbers.height); indexTS = ts_to_tsIndex.at(timeSeriesHydro); - if (isTSintramodal[indexTS]) + if (isTSintramodal[indexTS] && area.hydro.series->TScount() > 1) area.hydro.series->timeseriesNumbers[0][year] = intramodal_draws[indexTS]; // ------------- @@ -539,11 +414,9 @@ void storeTSnumbersForIntraModal(const array& intramo if (isTSintramodal[indexTS]) { - auto end_th_clusters = area.thermal.list.mapping.end(); - for (auto i = area.thermal.list.mapping.begin(); i != end_th_clusters; ++i) + for (auto [_, cluster] : area.thermal.list.mapping) { - ThermalClusterList::SharedPtr cluster = i->second; - if (cluster->enabled) + if (cluster->enabled && cluster->series.timeSeries.width > 1) cluster->series.timeseriesNumbers[0][year] = intramodal_draws[indexTS]; } } @@ -557,7 +430,7 @@ void storeTSnumbersForIntraModal(const array& intramo { for (auto& cluster : area.renewable.list) { - if (cluster->enabled) + if (cluster->enabled && cluster->series.timeSeries.width > 1) cluster->series.timeseriesNumbers[0][year] = intramodal_draws[indexTS]; } } @@ -572,15 +445,14 @@ void storeTSnumbersForIntraModal(const array& intramo for (auto it = area.links.begin(); it != area.links.end(); ++it) { auto& link = *(it->second); - link.timeseriesNumbers[0][year] = intramodal_draws[indexTS]; + if (link.directCapacities.timeSeries.width > 1) + link.timeseriesNumbers[0][year] = intramodal_draws[indexTS]; } } }); } void drawAndStoreTSnumbersForNOTintraModal(const array& isTSintramodal, - const array& isTSgenerated, - array& nbTimeseriesByMode, uint year, Study& study) { @@ -592,10 +464,8 @@ void drawAndStoreTSnumbersForNOTintraModal(const array& i if (!isTSintramodal[indexTS]) { - uint nbTimeSeries = isTSgenerated[indexTS] ? nbTimeseriesByMode[indexTS] - : area.load.series.timeSeries.width; area.load.series.timeseriesNumbers[0][year] - = (uint32_t)(floor(study.runtime->random[seedTimeseriesNumbers].next() * nbTimeSeries)); + = (uint32_t)(floor(study.runtime->random[seedTimeseriesNumbers].next() * area.load.series.timeSeries.width)); } // ------------- @@ -605,10 +475,8 @@ void drawAndStoreTSnumbersForNOTintraModal(const array& i if (!isTSintramodal[indexTS]) { - uint nbTimeSeries = isTSgenerated[indexTS] ? nbTimeseriesByMode[indexTS] - : area.solar.series.timeSeries.width; area.solar.series.timeseriesNumbers[0][year] - = (uint32_t)(floor(study.runtime->random[seedTimeseriesNumbers].next() * nbTimeSeries)); + = (uint32_t)(floor(study.runtime->random[seedTimeseriesNumbers].next() * area.solar.series.timeSeries.width)); } // ------------- @@ -618,10 +486,8 @@ void drawAndStoreTSnumbersForNOTintraModal(const array& i if (!isTSintramodal[indexTS]) { - uint nbTimeSeries = isTSgenerated[indexTS] ? nbTimeseriesByMode[indexTS] - : area.wind.series.timeSeries.width; area.wind.series.timeseriesNumbers[0][year] - = (uint32_t)(floor(study.runtime->random[seedTimeseriesNumbers].next() * nbTimeSeries)); + = (uint32_t)(floor(study.runtime->random[seedTimeseriesNumbers].next() * area.wind.series.timeSeries.width)); } // ------------- @@ -631,10 +497,8 @@ void drawAndStoreTSnumbersForNOTintraModal(const array& i if (!isTSintramodal[indexTS]) { - uint nbTimeSeries - = isTSgenerated[indexTS] ? nbTimeseriesByMode[indexTS] : area.hydro.series->ror.timeSeries.width; area.hydro.series->timeseriesNumbers[0][year] - = (uint32_t)(floor(study.runtime->random[seedTimeseriesNumbers].next() * nbTimeSeries)); + = (uint32_t)(floor(study.runtime->random[seedTimeseriesNumbers].next() * area.hydro.series->TScount())); } // ------------- @@ -652,10 +516,8 @@ void drawAndStoreTSnumbersForNOTintraModal(const array& i { if (!isTSintramodal[indexTS]) { - uint nbTimeSeries = isTSgenerated[indexTS] ? nbTimeseriesByMode[indexTS] - : cluster->series.timeSeries.width; cluster->series.timeseriesNumbers[0][year] = (uint32_t)( - floor(study.runtime->random[seedTimeseriesNumbers].next() * nbTimeSeries)); + floor(study.runtime->random[seedTimeseriesNumbers].next() * cluster->series.timeSeries.width)); } } } @@ -692,17 +554,10 @@ void drawAndStoreTSnumbersForNOTintraModal(const array& i { auto& link = *(it->second); const uint nbTimeSeries = link.directCapacities.timeSeries.width; - if (nbTimeSeries == 1) - { - // Random generator (mersenne-twister) must not be called here - // in order to avoid a shift in the random generator results - // that would cause a change of Antares results - link.timeseriesNumbers[0][year] = 0; - } - else + if (nbTimeSeries > 1) { link.timeseriesNumbers[0][year] = (uint32_t)( - floor(study.runtime->random[seedTimeseriesNumbers].next() * nbTimeSeries)); + floor(study.runtime->random[seedTimeseriesNumbers].next() * nbTimeSeries)); } } } @@ -711,14 +566,10 @@ void drawAndStoreTSnumbersForNOTintraModal(const array& i for (auto& group: study.bindingConstraintsGroups) { const auto nbTimeSeries = group->numberOfTimeseries(); - auto& value = group->timeseriesNumbers[0][year]; - if (nbTimeSeries == 1) - { - value = 0; - } - else + auto& groupTsNumber = group->timeseriesNumbers[0][year]; + if (nbTimeSeries > 1) { - value = (uint32_t)(floor(study.runtime->random[seedTimeseriesNumbers].next() * nbTimeSeries)); + groupTsNumber = (uint32_t)(floor(study.runtime->random[seedTimeseriesNumbers].next() * nbTimeSeries)); } } } @@ -797,73 +648,10 @@ void applyMatrixDrawsToInterModalModesInArea(Matrix* tsNumbersMtx, } } -// Set tsNumbers to 1 for all years if only one TS is present -static void fixTSNumbersSingleAreaSingleMode(Matrix& tsNumbers, uint width, uint years) -{ - if (width == 1) - { - for (uint year = 0; year < years; year++) - { - tsNumbers[0][year] = 0; - } - } -} - -static void fixTSNumbersWhenWidthIsOne(Study& study) -{ - const uint years = 1 + study.runtime->rangeLimits.year[rangeEnd]; - - study.areas.each([&years](Area& area) { - // Load - fixTSNumbersSingleAreaSingleMode( - area.load.series.timeseriesNumbers, area.load.series.timeSeries.width, years); - // Solar - fixTSNumbersSingleAreaSingleMode( - area.solar.series.timeseriesNumbers, area.solar.series.timeSeries.width, years); - // Wind - fixTSNumbersSingleAreaSingleMode( - area.wind.series.timeseriesNumbers, area.wind.series.timeSeries.width, years); - // Hydro - fixTSNumbersSingleAreaSingleMode( - area.hydro.series->timeseriesNumbers, area.hydro.series->TScount(), years); - - // Thermal - std::for_each(area.thermal.clusters.cbegin(), - area.thermal.clusters.cend(), - [&years](Data::ThermalCluster* cluster) { - fixTSNumbersSingleAreaSingleMode(cluster->series.timeseriesNumbers, - cluster->series.timeSeries.width, - years); - }); - - // Renewables - for (const auto& cluster : area.renewable.list) - fixTSNumbersSingleAreaSingleMode(cluster->series.timeseriesNumbers, - cluster->series.timeSeries.width, - years); - - // NTC - std::for_each(area.links.cbegin(), - area.links.cend(), - [&years](const std::pair& it) { - auto link = it.second; - fixTSNumbersSingleAreaSingleMode( - link->timeseriesNumbers, link->directCapacities.timeSeries.width, years); - }); - }); - study.bindingConstraintsGroups.fixTSNumbersWhenWidthIsOne(); -} - -bool TimeSeriesNumbers::checkAllElementsIdenticalOrOne(const std::vector& w) +bool TimeSeriesNumbers::checkAllElementsIdenticalOrOne(std::vector w) { - std::vector removedOnes; - // Remove all 1 - std::remove_copy(w.begin(), w.end(), std::back_inserter(removedOnes), 1); - // Try to find adjacent elements that are pairwise different - auto result - = std::adjacent_find(removedOnes.begin(), removedOnes.end(), std::not_equal_to()); - // Return "no such pair exists" - return result == removedOnes.end(); + auto first_one = std::remove(w.begin(), w.end(), 1); // Reject all 1 to the end + return std::adjacent_find(w.begin(), first_one, std::not_equal_to()) == first_one; } bool TimeSeriesNumbers::Generate(Study& study) @@ -894,28 +682,18 @@ bool TimeSeriesNumbers::Generate(Study& study) array intramodal_draws; std::fill(intramodal_draws.begin(), intramodal_draws.end(), 0); - const array isTSgenerated - = {(bool)(timeSeriesLoad & parameters.timeSeriesToRefresh), - (bool)(timeSeriesHydro & parameters.timeSeriesToRefresh), - (bool)(timeSeriesWind & parameters.timeSeriesToRefresh), - (bool)(timeSeriesThermal & parameters.timeSeriesToRefresh), - (bool)(timeSeriesSolar & parameters.timeSeriesToRefresh), - false, // TS generation is always disabled for renewables - false}; // TS generation is always disabled for links transmission capacities - - if (not checkIntraModalConsistency(nbTimeseriesByMode, isTSintramodal, isTSgenerated, study)) + if (not checkIntraModalConsistency(nbTimeseriesByMode, isTSintramodal, study)) return false; for (uint year = 0; year < years; ++year) { - // Intra-modal TS : draw and store TS numbres + // Intra-modal TS : draw and store TS numbers drawTSnumbersForIntraModal( intramodal_draws, isTSintramodal, nbTimeseriesByMode, study.runtime->random); storeTSnumbersForIntraModal(intramodal_draws, isTSintramodal, year, study.areas); // NOT intra-modal TS : draw and store TS numbers - drawAndStoreTSnumbersForNOTintraModal( - isTSintramodal, isTSgenerated, nbTimeseriesByMode, year, study); + drawAndStoreTSnumbersForNOTintraModal(isTSintramodal, year, study); } // =============== @@ -945,7 +723,7 @@ bool TimeSeriesNumbers::Generate(Study& study) for (auto i = study.areas.begin(); i != end; ++i) { auto& area = *(i->second); - if (not checkInterModalConsistencyForArea(area, isTSintermodal, isTSgenerated, study)) + if (not checkInterModalConsistencyForArea(area, isTSintermodal)) return false; Matrix* tsNumbersMtx @@ -963,7 +741,6 @@ void TimeSeriesNumbers::StoreTimeSeriesNumbersIntoOuput(Data::Study& study, IRes if (study.parameters.storeTimeseriesNumbers) { - fixTSNumbersWhenWidthIsOne(study); study.storeTimeSeriesNumbers(resultWriter); study.storeTimeSeriesNumbers(resultWriter); study.storeTimeSeriesNumbers(resultWriter); diff --git a/src/solver/simulation/timeseries-numbers.h b/src/solver/simulation/timeseries-numbers.h index 3844d51b24..0c1cd59fd8 100644 --- a/src/solver/simulation/timeseries-numbers.h +++ b/src/solver/simulation/timeseries-numbers.h @@ -42,7 +42,7 @@ bool Generate(Data::Study& study); void StoreTimeSeriesNumbersIntoOuput(Data::Study &study, IResultWriter& resultWriter); // Exported for unit-tests -bool checkAllElementsIdenticalOrOne(const std::vector& w); +bool checkAllElementsIdenticalOrOne(std::vector w); } // namespace Antares::Solver::TimeSeriesNumbers diff --git a/src/solver/ts-generator/CMakeLists.txt b/src/solver/ts-generator/CMakeLists.txt index 86b0e71d55..7b8f80ae2c 100644 --- a/src/solver/ts-generator/CMakeLists.txt +++ b/src/solver/ts-generator/CMakeLists.txt @@ -6,6 +6,7 @@ project(ts-generator) set(SRC_GENERATORS generator.h generator.hxx + generator.cpp thermal.cpp hydro.cpp ) diff --git a/src/solver/ts-generator/generator.cpp b/src/solver/ts-generator/generator.cpp new file mode 100644 index 0000000000..f4e7fa3d35 --- /dev/null +++ b/src/solver/ts-generator/generator.cpp @@ -0,0 +1,53 @@ +#include "generator.h" + +namespace Antares::TSGenerator +{ + +void ResizeGeneratedTimeSeries(Data::AreaList& areas, Data::Parameters& params) +{ + areas.each([&](Data::Area& area) + { + // Load + if (params.timeSeriesToGenerate & Data::timeSeriesLoad) + { + area.load.series.timeSeries.reset(params.nbTimeSeriesLoad, HOURS_PER_YEAR); + } + + // Wind + if (params.timeSeriesToGenerate & Data::timeSeriesWind) + { + area.wind.series.timeSeries.reset(params.nbTimeSeriesWind, HOURS_PER_YEAR); + } + + // Solar + if (params.timeSeriesToGenerate & Data::timeSeriesSolar) + { + area.solar.series.timeSeries.reset(params.nbTimeSeriesSolar, HOURS_PER_YEAR); + } + + // Hydro + if (params.timeSeriesToGenerate & Data::timeSeriesHydro) + { + area.hydro.series->resize_ROR_STORAGE_MINGEN_whenGeneratedTS(params.nbTimeSeriesHydro); + } + + // Thermal + bool globalThermalTSgeneration = params.timeSeriesToGenerate & Data::timeSeriesThermal; + for (auto [_, cluster] : area.thermal.list.mapping) + { + if (cluster->doWeGenerateTS(globalThermalTSgeneration)) + cluster->series.timeSeries.reset(params.nbTimeSeriesThermal, HOURS_PER_YEAR); + } + }); +} + +void DestroyAll(Data::Study& study) +{ + Destroy(study, (uint)-1); + Destroy(study, (uint)-1); + Destroy(study, (uint)-1); + Destroy(study, (uint)-1); + Destroy(study, (uint)-1); +} + +} // Antares::TSGenerator \ No newline at end of file diff --git a/src/solver/ts-generator/generator.h b/src/solver/ts-generator/generator.h index 1f3582fb2c..ebdd8e3bb8 100644 --- a/src/solver/ts-generator/generator.h +++ b/src/solver/ts-generator/generator.h @@ -30,16 +30,16 @@ #include #include #include +#include #include #include #include "xcast/xcast.h" -namespace Antares -{ -namespace Solver -{ -namespace TSGenerator +namespace Antares::TSGenerator { + +void ResizeGeneratedTimeSeries(Data::AreaList& areas, Data::Parameters& params); + /*! ** \brief Regenerate the time-series */ @@ -63,9 +63,7 @@ void DestroyAll(Data::Study& study); template void Destroy(Data::Study& study, uint year); -} // namespace TSGenerator -} // namespace Solver -} // namespace Antares +} // namespace Antares::TSGenerator #include "generator.hxx" diff --git a/src/solver/ts-generator/generator.hxx b/src/solver/ts-generator/generator.hxx index a143ff0d29..0fcb5d5b0a 100644 --- a/src/solver/ts-generator/generator.hxx +++ b/src/solver/ts-generator/generator.hxx @@ -29,12 +29,9 @@ #include -namespace Antares -{ -namespace Solver -{ -namespace TSGenerator +namespace Antares::TSGenerator { + // forward declaration // Hydro - see hydro.cpp bool GenerateHydroTimeSeries(Data::Study& study, uint year, IResultWriter& writer); @@ -148,17 +145,6 @@ void Destroy(Data::Study& study, uint year) } } -inline void DestroyAll(Data::Study& study) -{ - Solver::TSGenerator::Destroy(study, (uint)-1); - Solver::TSGenerator::Destroy(study, (uint)-1); - Solver::TSGenerator::Destroy(study, (uint)-1); - Solver::TSGenerator::Destroy(study, (uint)-1); - Solver::TSGenerator::Destroy(study, (uint)-1); -} - -} // namespace TSGenerator -} // namespace Solver -} // namespace Antares +} // namespace Antares::TSGenerator #endif // __ANTARES_SOLVER_timeSeries_GENERATOR_HXX__ diff --git a/src/solver/ts-generator/hydro.cpp b/src/solver/ts-generator/hydro.cpp index 8368ecf228..50356271dc 100644 --- a/src/solver/ts-generator/hydro.cpp +++ b/src/solver/ts-generator/hydro.cpp @@ -40,18 +40,12 @@ using namespace Yuni; #define EPSILON ((double)1.0e-9) +using namespace Antares::Solver; + namespace Antares { -namespace Solver -{ namespace TSGenerator { -static void PreproHydroInitMatrices(Data::Study& study, uint tsCount) -{ - study.areas.each([&](Data::Area& area) { - area.hydro.series->resizeRORandSTORAGE(tsCount); - }); -} static void PreproRoundAllEntriesPlusDerated(Data::Study& study) { @@ -75,7 +69,7 @@ bool GenerateHydroTimeSeries(Data::Study& study, uint currentYear, IResultWriter { logs.info() << "Generating the hydro time-series"; - Progression::Task progression(study, currentYear, Solver::Progression::sectTSGHydro); + Progression::Task progression(study, currentYear, Progression::sectTSGHydro); auto& studyRTI = *(study.runtime); auto& calendar = study.calendar; @@ -155,8 +149,6 @@ bool GenerateHydroTimeSeries(Data::Study& study, uint currentYear, IResultWriter uint nbTimeseries = study.parameters.nbTimeSeriesHydro; - PreproHydroInitMatrices(study, nbTimeseries); - long cumul = 0; for (uint l = 0; l != nbTimeseries; ++l) @@ -317,5 +309,4 @@ bool GenerateHydroTimeSeries(Data::Study& study, uint currentYear, IResultWriter } } // namespace TSGenerator -} // namespace Solver } // namespace Antares diff --git a/src/solver/ts-generator/thermal.cpp b/src/solver/ts-generator/thermal.cpp index e11d4a056c..5c3f75b137 100644 --- a/src/solver/ts-generator/thermal.cpp +++ b/src/solver/ts-generator/thermal.cpp @@ -48,8 +48,6 @@ using namespace Yuni; namespace Antares { -namespace Solver -{ namespace TSGenerator { namespace @@ -59,7 +57,7 @@ class GeneratorTempData final public: GeneratorTempData(Data::Study& study, Solver::Progression::Task& progr, - IResultWriter& writer); + Solver::IResultWriter& writer); void prepareOutputFoldersForAllAreas(uint year); @@ -72,8 +70,6 @@ class GeneratorTempData final uint currentYear; - uint nbThermalTimeseries; - bool derated; private: @@ -89,6 +85,7 @@ class GeneratorTempData final const T& duration); private: + uint nbThermalTimeseries_; const uint nbHoursPerYear = HOURS_PER_YEAR; const uint daysPerYear = DAYS_PER_YEAR; @@ -115,12 +112,12 @@ class GeneratorTempData final String pTempFilename; Solver::Progression::Task& pProgression; - IResultWriter& pWriter; + Solver::IResultWriter& pWriter; }; GeneratorTempData::GeneratorTempData(Data::Study& study, Solver::Progression::Task& progr, - IResultWriter& writer) : + Solver::IResultWriter& writer) : study(study), rndgenerator(study.runtime->random[Data::seedTsGenThermal]), pProgression(progr), @@ -130,7 +127,7 @@ GeneratorTempData::GeneratorTempData(Data::Study& study, archive = (0 != (parameters.timeSeriesToArchive & Data::timeSeriesThermal)); - nbThermalTimeseries = parameters.nbTimeSeriesThermal; + nbThermalTimeseries_ = parameters.nbTimeSeriesThermal; derated = parameters.derated; } @@ -251,15 +248,11 @@ void GeneratorTempData::operator()(Data::Area& area, Data::ThermalCluster& clust if (0 == cluster.unitCount or 0 == cluster.nominalCapacity) { - cluster.series.timeSeries.reset(1, nbHoursPerYear); - if (archive) writeResultsToDisk(area, cluster); return; } - cluster.series.timeSeries.resize(nbThermalTimeseries, nbHoursPerYear); - const auto& preproData = *(cluster.prepro); int AUN = (int)cluster.unitCount; @@ -355,7 +348,7 @@ void GeneratorTempData::operator()(Data::Area& area, Data::ThermalCluster& clust double* dstSeries = nullptr; - const uint tsCount = nbThermalTimeseries + 2; + const uint tsCount = nbThermalTimeseries_ + 2; for (uint tsIndex = 0; tsIndex != tsCount; ++tsIndex) { uint hour = 0; @@ -645,5 +638,4 @@ bool GenerateThermalTimeSeries(Data::Study& study, } } // namespace TSGenerator -} // namespace Solver } // namespace Antares diff --git a/src/solver/ts-generator/xcast/core.cpp b/src/solver/ts-generator/xcast/core.cpp index 4af0201cc9..7a5fb298f9 100644 --- a/src/solver/ts-generator/xcast/core.cpp +++ b/src/solver/ts-generator/xcast/core.cpp @@ -38,8 +38,6 @@ using namespace Yuni; namespace Antares { -namespace Solver -{ namespace TSGenerator { namespace XCast @@ -556,5 +554,4 @@ bool XCast::generateValuesForTheCurrentDay() } // namespace XCast } // namespace TSGenerator -} // namespace Solver } // namespace Antares diff --git a/src/solver/ts-generator/xcast/gamma-euler.cpp b/src/solver/ts-generator/xcast/gamma-euler.cpp index c933b737e9..4ca836900b 100644 --- a/src/solver/ts-generator/xcast/gamma-euler.cpp +++ b/src/solver/ts-generator/xcast/gamma-euler.cpp @@ -38,8 +38,6 @@ using namespace Yuni; namespace Antares { -namespace Solver -{ namespace TSGenerator { namespace XCast @@ -105,5 +103,4 @@ double XCast::GammaEuler(double z) } // namespace XCast } // namespace TSGenerator -} // namespace Solver } // namespace Antares diff --git a/src/solver/ts-generator/xcast/gamma-inc.cpp b/src/solver/ts-generator/xcast/gamma-inc.cpp index fdc2bcef4f..27dc81ecab 100644 --- a/src/solver/ts-generator/xcast/gamma-inc.cpp +++ b/src/solver/ts-generator/xcast/gamma-inc.cpp @@ -35,8 +35,6 @@ using namespace Yuni; namespace Antares { -namespace Solver -{ namespace TSGenerator { namespace XCast @@ -63,5 +61,4 @@ double XCast::GammaInc(double s, double z) } // namespace XCast } // namespace TSGenerator -} // namespace Solver } // namespace Antares diff --git a/src/solver/ts-generator/xcast/math.cpp b/src/solver/ts-generator/xcast/math.cpp index 2ef43546fd..399ac793b6 100644 --- a/src/solver/ts-generator/xcast/math.cpp +++ b/src/solver/ts-generator/xcast/math.cpp @@ -30,8 +30,6 @@ namespace Antares { -namespace Solver -{ namespace TSGenerator { namespace XCast @@ -59,5 +57,4 @@ void XCast::normal(float& x, float& y) } // namespace XCast } // namespace TSGenerator -} // namespace Solver } // namespace Antares diff --git a/src/solver/ts-generator/xcast/math.hxx b/src/solver/ts-generator/xcast/math.hxx index 42c5105786..effc01d747 100644 --- a/src/solver/ts-generator/xcast/math.hxx +++ b/src/solver/ts-generator/xcast/math.hxx @@ -36,8 +36,6 @@ using namespace Yuni; namespace Antares { -namespace Solver -{ namespace TSGenerator { namespace XCast @@ -344,5 +342,4 @@ static float maxiDiffusion(float a, float b, float g, float d, int l, float t) } // namespace XCast } // namespace TSGenerator -} // namespace Solver } // namespace Antares diff --git a/src/solver/ts-generator/xcast/predicate.hxx b/src/solver/ts-generator/xcast/predicate.hxx index fe8ee799f8..a03145b6e1 100644 --- a/src/solver/ts-generator/xcast/predicate.hxx +++ b/src/solver/ts-generator/xcast/predicate.hxx @@ -35,8 +35,6 @@ namespace Antares { -namespace Solver -{ namespace TSGenerator { namespace Predicate @@ -169,7 +167,6 @@ public: } // namespace Predicate } // namespace TSGenerator -} // namespace Solver } // namespace Antares #endif // __SOLVER_TS_GENERATOR_XCAST_PREDICATE_HXX__ diff --git a/src/solver/ts-generator/xcast/studydata.cpp b/src/solver/ts-generator/xcast/studydata.cpp index b36b889770..a726f185b4 100644 --- a/src/solver/ts-generator/xcast/studydata.cpp +++ b/src/solver/ts-generator/xcast/studydata.cpp @@ -33,8 +33,6 @@ using namespace Yuni; namespace Antares { -namespace Solver -{ namespace TSGenerator { namespace XCast @@ -127,5 +125,4 @@ void StudyData::reloadDataFromAreaList(const Data::Correlation& originalCorrelat } // namespace XCast } // namespace TSGenerator -} // namespace Solver } // namespace Antares diff --git a/src/solver/ts-generator/xcast/studydata.h b/src/solver/ts-generator/xcast/studydata.h index 5a5ebdb223..9ada95a415 100644 --- a/src/solver/ts-generator/xcast/studydata.h +++ b/src/solver/ts-generator/xcast/studydata.h @@ -31,7 +31,7 @@ #include #include //TODO collision -namespace Antares::Solver::TSGenerator::XCast +namespace Antares::TSGenerator::XCast { class StudyData final { @@ -100,7 +100,7 @@ class StudyData final }; // class StudyData -} // namespace Antares::Solver::TSGenerator::XCast +} // namespace Antares::TSGenerator::XCast diff --git a/src/solver/ts-generator/xcast/studydata.hxx b/src/solver/ts-generator/xcast/studydata.hxx index 2d0f5fd495..661febba6d 100644 --- a/src/solver/ts-generator/xcast/studydata.hxx +++ b/src/solver/ts-generator/xcast/studydata.hxx @@ -33,8 +33,6 @@ namespace Antares { -namespace Solver -{ namespace TSGenerator { namespace XCast @@ -57,18 +55,12 @@ void StudyData::loadFromStudy(Data::Study& study, logs.info() << " Added the area '" << area.name << "'"; localareas.push_back(&area); } - else - { - // resize and set the values for the matrix - predicate.matrix(area).reset(1, HOURS_PER_YEAR); - } } reloadDataFromAreaList(correlation); } } // namespace XCast } // namespace TSGenerator -} // namespace Solver } // namespace Antares #endif // __ANTARES_SOLVER_TS_GENERATOR_XCAST_STUDY_DATA_HXX__ diff --git a/src/solver/ts-generator/xcast/xcast.cpp b/src/solver/ts-generator/xcast/xcast.cpp index 9a5c1f0659..31fbb39888 100644 --- a/src/solver/ts-generator/xcast/xcast.cpp +++ b/src/solver/ts-generator/xcast/xcast.cpp @@ -43,12 +43,11 @@ using namespace Yuni; namespace Antares { -namespace Solver -{ namespace TSGenerator { namespace XCast { + enum { alpha = Data::XCast::dataCoeffAlpha, @@ -110,13 +109,8 @@ void XCast::applyTransferFunction(PredicateT& predicate) { enum { - - nbHoursADay = 24, - x = 0, - y = 1, - maxPoints = Data::XCast::conversionMaxPoints, }; @@ -157,7 +151,7 @@ void XCast::applyTransferFunction(PredicateT& predicate) } dailyResults = DATA[s]; - for (h = 0; h != nbHoursADay; ++h) + for (h = 0; h != HOURS_PER_DAY; ++h) { for (i = 0; i != tf.width; ++i) { @@ -370,12 +364,6 @@ void XCast::destroyTemporaryData() template bool XCast::runWithPredicate(PredicateT& predicate, Progression::Task& progression) { - enum - { - - nbHoursADay = 24, - }; - pTSName = predicate.timeSeriesName(); { @@ -395,8 +383,6 @@ bool XCast::runWithPredicate(PredicateT& predicate, Progression::Task& progressi if (pNeverInitialized) { - const uint nbHours = 8760; - loadFromStudy(predicate.correlation(study), predicate); allocateTemporaryData(); @@ -405,7 +391,6 @@ bool XCast::runWithPredicate(PredicateT& predicate, Progression::Task& progressi { auto& area = *(pData.localareas[s]); - predicate.matrix(area).resize(nbTimeseries, nbHours); auto& xcast = predicate.xcastData(area); pUseConversion[s] = (xcast.useConversion && xcast.conversion.width >= 3); @@ -419,7 +404,7 @@ bool XCast::runWithPredicate(PredicateT& predicate, Progression::Task& progressi if (study.areas.size() > pData.localareas.size()) progression - += (nbTimeseries * 365) * ((uint)study.areas.size() - (uint)pData.localareas.size()); + += (nbTimeseries_ * DAYS_PER_YEAR) * ((uint)study.areas.size() - (uint)pData.localareas.size()); if (processCount == 0) { @@ -434,7 +419,7 @@ bool XCast::runWithPredicate(PredicateT& predicate, Progression::Task& progressi pNDPMatrixCount = 0; pLevellingCount = 0; - for (uint tsIndex = 0; tsIndex != nbTimeseries; ++tsIndex) + for (uint tsIndex = 0; tsIndex != nbTimeseries_; ++tsIndex) { uint hourInTheYear = 0; @@ -488,7 +473,7 @@ bool XCast::runWithPredicate(PredicateT& predicate, Progression::Task& progressi MA[s] = +std::numeric_limits::max(); } } - memcpy(FO[s], xcastdata.K[realmonth], sizeof(float) * nbHoursADay); + memcpy(FO[s], xcastdata.K[realmonth], sizeof(float) * HOURS_PER_DAY); } uint nbDaysPerMonth = study.calendar.months[month].days; @@ -503,7 +488,7 @@ bool XCast::runWithPredicate(PredicateT& predicate, Progression::Task& progressi { float* dailyResults = DATA[s]; - for (uint h = 0; h != nbHoursADay; ++h) + for (uint h = 0; h != HOURS_PER_DAY; ++h) { assert(0 == Math::Infinite(dailyResults[h]) && "Infinite value"); } @@ -521,10 +506,10 @@ bool XCast::runWithPredicate(PredicateT& predicate, Progression::Task& progressi auto& column = srcData.translation[0]; float* dailyResults = DATA[s]; - assert(hourInTheYear + nbHoursADay <= srcData.translation.height + assert(hourInTheYear + HOURS_PER_DAY <= srcData.translation.height && "Bound checking"); - for (uint h = 0; h != nbHoursADay; ++h) + for (uint h = 0; h != HOURS_PER_DAY; ++h) { assert(0 == Math::Infinite(dailyResults[h]) && "Infinite value"); dailyResults[h] += (float)column[hourInTheYear + h]; @@ -539,7 +524,7 @@ bool XCast::runWithPredicate(PredicateT& predicate, Progression::Task& progressi { float* dailyResults = DATA[s]; - for (uint h = 0; h != nbHoursADay; ++h) + for (uint h = 0; h != HOURS_PER_DAY; ++h) { assert(0 == Math::Infinite(dailyResults[h]) && "Infinite value"); } @@ -558,7 +543,7 @@ bool XCast::runWithPredicate(PredicateT& predicate, Progression::Task& progressi auto& column = series.column(tsIndex); float* dailyResults = DATA[s]; - for (uint h = 0; h != nbHoursADay; ++h) + for (uint h = 0; h != HOURS_PER_DAY; ++h) { assert(0 == Math::Infinite(dailyResults[h]) && "Infinite value"); dailyResults[h] *= (float)srcData.capacity; @@ -566,21 +551,21 @@ bool XCast::runWithPredicate(PredicateT& predicate, Progression::Task& progressi if (srcData.useTranslation == Data::XCast::tsTranslationAfterConversion) { - assert(hourInTheYear + nbHoursADay <= srcData.translation.height + assert(hourInTheYear + HOURS_PER_DAY <= srcData.translation.height && "Bound checking"); auto& tsavg = srcData.translation[0]; - for (uint h = 0; h != nbHoursADay; ++h) + for (uint h = 0; h != HOURS_PER_DAY; ++h) dailyResults[h] += (float)tsavg[hourInTheYear + h]; } - assert(hourInTheYear + nbHoursADay <= series.height && "Bound checking"); - for (uint h = 0; h != nbHoursADay; ++h) + assert(hourInTheYear + HOURS_PER_DAY <= series.height && "Bound checking"); + for (uint h = 0; h != HOURS_PER_DAY; ++h) column[hourInTheYear + h] = Math::Round(dailyResults[h]); ++progression; } - hourInTheYear += nbHoursADay; + hourInTheYear += HOURS_PER_DAY; pNewMonth = false; } @@ -588,7 +573,7 @@ bool XCast::runWithPredicate(PredicateT& predicate, Progression::Task& progressi } { - uint y = ((pAccuracyOnCorrelation) ? pComputedPointCount : (nbTimeseries * 365)); + uint y = ((pAccuracyOnCorrelation) ? pComputedPointCount : (nbTimeseries_ * 365)); uint z = pNDPMatrixCount; logs.info() << " " << pComputedPointCount << " points calculated, using " << y @@ -640,7 +625,7 @@ bool XCast::run() { Solver::Progression::Task p(study, year, Progression::sectTSGLoad); - nbTimeseries = study.parameters.nbTimeSeriesLoad; + nbTimeseries_ = study.parameters.nbTimeSeriesLoad; Predicate::Load predicate; return runWithPredicate(predicate, p); @@ -649,7 +634,7 @@ bool XCast::run() { Solver::Progression::Task p(study, year, Progression::sectTSGSolar); - nbTimeseries = study.parameters.nbTimeSeriesSolar; + nbTimeseries_ = study.parameters.nbTimeSeriesSolar; Predicate::Solar predicate; return runWithPredicate(predicate, p); @@ -658,7 +643,7 @@ bool XCast::run() { Solver::Progression::Task p(study, year, Progression::sectTSGWind); - nbTimeseries = study.parameters.nbTimeSeriesWind; + nbTimeseries_ = study.parameters.nbTimeSeriesWind; Predicate::Wind predicate; return runWithPredicate(predicate, p); @@ -674,5 +659,4 @@ bool XCast::run() } // namespace XCast } // namespace TSGenerator -} // namespace Solver } // namespace Antares diff --git a/src/solver/ts-generator/xcast/xcast.h b/src/solver/ts-generator/xcast/xcast.h index 7c6efb6d25..ff96272c98 100644 --- a/src/solver/ts-generator/xcast/xcast.h +++ b/src/solver/ts-generator/xcast/xcast.h @@ -30,14 +30,15 @@ #include #include #include +#include #include #include "studydata.h" #include +using namespace Antares::Solver; + namespace Antares { -namespace Solver -{ namespace TSGenerator { namespace XCast @@ -99,8 +100,6 @@ class XCast final : private Yuni::NonCopyable //! The current study Data::Study& study; - //! The number of time-series - uint nbTimeseries; //! The current year uint year; //! The time-series type @@ -177,6 +176,9 @@ class XCast final : private Yuni::NonCopyable void normal(float& x, float& y); private: + //! The number of time-series + uint nbTimeseries_; + //! Some data after transformation StudyData pData; @@ -255,7 +257,6 @@ class XCast final : private Yuni::NonCopyable } // namespace XCast } // namespace TSGenerator -} // namespace Solver } // namespace Antares #include "xcast.hxx" diff --git a/src/solver/ts-generator/xcast/xcast.hxx b/src/solver/ts-generator/xcast/xcast.hxx index 9cc41b84aa..838b9b42a4 100644 --- a/src/solver/ts-generator/xcast/xcast.hxx +++ b/src/solver/ts-generator/xcast/xcast.hxx @@ -29,8 +29,6 @@ namespace Antares { -namespace Solver -{ namespace TSGenerator { namespace XCast @@ -43,7 +41,6 @@ inline void XCast::loadFromStudy(const Data::Correlation& correlation, Predicate } // namespace XCast } // namespace TSGenerator -} // namespace Solver } // namespace Antares #endif // __ANTARES_SOLVER_TS_GENERATOR_XCAST_XCAST_HXX__ diff --git a/src/solver/variable/economy/max-mrg.cpp b/src/solver/variable/economy/max-mrg.cpp index 80f0bbcfb7..8e8e2ee4ee 100644 --- a/src/solver/variable/economy/max-mrg.cpp +++ b/src/solver/variable/economy/max-mrg.cpp @@ -100,7 +100,6 @@ inline void PrepareMaxMRGFor(const State& state, double* opmrg, uint numSpace) double WH = 0.; { // H.STOR - auto& H = weeklyResults.TurbinageHoraire; for (uint i = offset; i != endHour; ++i) WH += H[i]; } diff --git a/src/tests/src/libs/antares/study/series/timeseries-tests.cpp b/src/tests/src/libs/antares/study/series/timeseries-tests.cpp index 7f7410267e..b5e2fadeed 100644 --- a/src/tests/src/libs/antares/study/series/timeseries-tests.cpp +++ b/src/tests/src/libs/antares/study/series/timeseries-tests.cpp @@ -20,8 +20,9 @@ struct Fixture Fixture& operator=(const Fixture&& f) = delete; Fixture() : ts(tsnum) { - ts.resize(1, HOURS_PER_YEAR); + ts.reset(1, HOURS_PER_YEAR); tsnum.resize(1, 1); + tsnum[0][0] = 0; } TimeSeries ts; TimeSeries::numbers tsnum; @@ -65,9 +66,6 @@ BOOST_FIXTURE_TEST_CASE(getSeriesIndex, Fixture) for (unsigned int i = 0; i < 10; i++) tsnum[0][i] = i; - //timeSeries.width == 1 so returns 0 - BOOST_CHECK_EQUAL(ts.getSeriesIndex(5), 0); - ts.resize(2, HOURS_PER_YEAR); for (unsigned int i = 0; i < 10; i++) BOOST_CHECK_EQUAL(ts.getSeriesIndex(i), i); @@ -80,13 +78,6 @@ BOOST_FIXTURE_TEST_CASE(getCoefficientWidth1, Fixture) BOOST_CHECK_EQUAL(ts.getCoefficient(0, 8750), 8750); } -BOOST_FIXTURE_TEST_CASE(getCoefficientWidth0, Fixture) -{ - ts.resize(0, HOURS_PER_YEAR); - BOOST_CHECK_EQUAL(ts.getCoefficient(0, 12), 0); - BOOST_CHECK_EQUAL(ts.getCoefficient(0, 8750), 0); -} - BOOST_FIXTURE_TEST_CASE(getCoefficientNotInitialized, Fixture) { ts.resize(4, HOURS_PER_YEAR); @@ -111,8 +102,7 @@ BOOST_FIXTURE_TEST_CASE(getCoefficientWidthMoreThan1, Fixture) BOOST_FIXTURE_TEST_CASE(getColumn, Fixture) { - ts.resize(0, HOURS_PER_YEAR); - auto col = ts.getColumn(3); //emptyColumn + auto col = ts.getColumn(0); BOOST_CHECK_EQUAL(col[38], 0); BOOST_CHECK_EQUAL(col[7463], 0); diff --git a/src/tests/src/solver/simulation/CMakeLists.txt b/src/tests/src/solver/simulation/CMakeLists.txt index 5a5d18266a..c1876cd4fa 100644 --- a/src/tests/src/solver/simulation/CMakeLists.txt +++ b/src/tests/src/solver/simulation/CMakeLists.txt @@ -22,6 +22,7 @@ target_link_libraries(tests-ts-numbers Boost::unit_test_framework model_antares antares-solver-simulation + antares-solver-ts-generator ) # Storing tests-ts-numbers under the folder Unit-tests in the IDE diff --git a/src/tests/src/solver/simulation/tests-ts-numbers.cpp b/src/tests/src/solver/simulation/tests-ts-numbers.cpp index 34c2fa5c62..c12bf028dd 100644 --- a/src/tests/src/solver/simulation/tests-ts-numbers.cpp +++ b/src/tests/src/solver/simulation/tests-ts-numbers.cpp @@ -6,6 +6,7 @@ #include #include +#include "ts-generator/generator.h" #include // std::adjacent_find @@ -125,6 +126,7 @@ BOOST_AUTO_TEST_CASE(two_areas_with_5_ready_made_ts_on_load___check_intra_modal_ area_2->resizeAllTimeseriesNumbers(1 + study->runtime->rangeLimits.year[rangeEnd]); area_2->load.series.timeSeries.resize(5, 1); + TSGenerator::ResizeGeneratedTimeSeries(study->areas, study->parameters); BOOST_CHECK(Generate(*study)); // intra-modal for load : drawn TS numbers in all areas must be equal @@ -150,6 +152,7 @@ static bool intermodal_load_two_areas(unsigned width_area_1, unsigned width_area area_2->load.series.timeSeries.resize(width_area_2, 1); area_2->resizeAllTimeseriesNumbers(1 + study->runtime->rangeLimits.year[rangeEnd]); + TSGenerator::ResizeGeneratedTimeSeries(study->areas, study->parameters); return Generate(*study); } @@ -196,6 +199,7 @@ BOOST_AUTO_TEST_CASE(two_areas_3_thermal_clusters_with_same_number_of_ready_made area_2->resizeAllTimeseriesNumbers(1 + study->runtime->rangeLimits.year[rangeEnd]); + TSGenerator::ResizeGeneratedTimeSeries(study->areas, study->parameters); BOOST_CHECK(Generate(*study)); // TS number checks @@ -234,6 +238,7 @@ BOOST_AUTO_TEST_CASE(two_areas_2_thermal_clusters_with_respectively_4_4_ready_ma area_2->resizeAllTimeseriesNumbers(1 + study->runtime->rangeLimits.year[rangeEnd]); + TSGenerator::ResizeGeneratedTimeSeries(study->areas, study->parameters); BOOST_CHECK(Generate(*study)); // TS number checks @@ -274,7 +279,7 @@ BOOST_AUTO_TEST_CASE(two_areas_3_thermal_clusters_with_different_number_of_ready area_2->resizeAllTimeseriesNumbers(1 + study->runtime->rangeLimits.year[rangeEnd]); - + TSGenerator::ResizeGeneratedTimeSeries(study->areas, study->parameters); BOOST_CHECK(not Generate(*study)); } @@ -311,6 +316,7 @@ BOOST_AUTO_TEST_CASE(two_areas_3_renew_clusters_with_same_number_of_ready_made_t area_2->resizeAllTimeseriesNumbers(1 + study->runtime->rangeLimits.year[rangeEnd]); + TSGenerator::ResizeGeneratedTimeSeries(study->areas, study->parameters); BOOST_CHECK(Generate(*study)); // TS number checks @@ -350,6 +356,7 @@ BOOST_AUTO_TEST_CASE(two_areas_2_renew_clusters_with_respectively_4_4_ready_made area_2->resizeAllTimeseriesNumbers(1 + study->runtime->rangeLimits.year[rangeEnd]); + TSGenerator::ResizeGeneratedTimeSeries(study->areas, study->parameters); BOOST_CHECK(Generate(*study)); // TS number checks @@ -391,6 +398,7 @@ BOOST_AUTO_TEST_CASE(two_areas_3_renew_clusters_with_different_number_of_ready_m area_2->resizeAllTimeseriesNumbers(1 + study->runtime->rangeLimits.year[rangeEnd]); + TSGenerator::ResizeGeneratedTimeSeries(study->areas, study->parameters); BOOST_CHECK(not Generate(*study)); } @@ -418,7 +426,9 @@ BOOST_AUTO_TEST_CASE(one_area__load_wind_thermal_are_turned_to_inter_modal__same area->wind.series.timeSeries.resize(5, 1); // Ready made TS for wind // ... Thermal + study->parameters.timeSeriesToGenerate |= timeSeriesThermal; // Generated TS for thermal study->parameters.timeSeriesToRefresh |= timeSeriesThermal; // Generated TS for thermal + study->parameters.nbTimeSeriesThermal = 5; // ... ... clusters auto thCluster_1 = addClusterToArea(area, "th-cluster-1"); @@ -426,6 +436,7 @@ BOOST_AUTO_TEST_CASE(one_area__load_wind_thermal_are_turned_to_inter_modal__same area->resizeAllTimeseriesNumbers(1 + study->runtime->rangeLimits.year[rangeEnd]); + TSGenerator::ResizeGeneratedTimeSeries(study->areas, study->parameters); BOOST_CHECK(Generate(*study)); // TS number checks @@ -456,6 +467,7 @@ BOOST_AUTO_TEST_CASE(one_area__load_wind_thermal_are_turned_to_inter_modal__same area->wind.series.timeSeries.resize(5, 1); // Ready made TS for wind // ... Thermal + study->parameters.timeSeriesToGenerate |= timeSeriesThermal; // Generated TS for thermal study->parameters.timeSeriesToRefresh |= timeSeriesThermal; // Generated TS for thermal study->parameters.nbTimeSeriesThermal = 5; // ... ... clusters @@ -464,6 +476,7 @@ BOOST_AUTO_TEST_CASE(one_area__load_wind_thermal_are_turned_to_inter_modal__same area->resizeAllTimeseriesNumbers(1 + study->runtime->rangeLimits.year[rangeEnd]); + TSGenerator::ResizeGeneratedTimeSeries(study->areas, study->parameters); BOOST_CHECK(Generate(*study)); // TS number checks @@ -494,6 +507,7 @@ BOOST_AUTO_TEST_CASE(one_area__load_wind_thermal_are_turned_to_inter_modal__diff area->wind.series.timeSeries.resize(5, 1); // Ready made TS for wind // ... Thermal + study->parameters.timeSeriesToGenerate |= timeSeriesThermal; // Generated TS for thermal study->parameters.timeSeriesToRefresh |= timeSeriesThermal; // Generated TS for thermal study->parameters.nbTimeSeriesThermal = 4; // ... ... clusters @@ -502,6 +516,7 @@ BOOST_AUTO_TEST_CASE(one_area__load_wind_thermal_are_turned_to_inter_modal__diff area->resizeAllTimeseriesNumbers(1 + study->runtime->rangeLimits.year[rangeEnd]); + TSGenerator::ResizeGeneratedTimeSeries(study->areas, study->parameters); BOOST_CHECK(not Generate(*study)); } @@ -530,6 +545,7 @@ BOOST_AUTO_TEST_CASE(one_area__load_renewable_are_turned_to_inter_modal__same_nb area->resizeAllTimeseriesNumbers(1 + study->runtime->rangeLimits.year[rangeEnd]); + TSGenerator::ResizeGeneratedTimeSeries(study->areas, study->parameters); BOOST_CHECK(Generate(*study)); // TS number checks @@ -561,6 +577,7 @@ BOOST_AUTO_TEST_CASE(one_area__load_renewable_are_turned_to_inter_modal__differe area->resizeAllTimeseriesNumbers(1 + study->runtime->rangeLimits.year[rangeEnd]); + TSGenerator::ResizeGeneratedTimeSeries(study->areas, study->parameters); BOOST_CHECK(not Generate(*study)); } @@ -588,6 +605,7 @@ BOOST_AUTO_TEST_CASE(one_area__load_renewable_are_turned_to_inter_modal_with_res area->resizeAllTimeseriesNumbers(1 + study->runtime->rangeLimits.year[rangeEnd]); + TSGenerator::ResizeGeneratedTimeSeries(study->areas, study->parameters); BOOST_CHECK(Generate(*study)); } @@ -612,6 +630,7 @@ BOOST_AUTO_TEST_CASE(load_wind_thermal_in_intra_and_inter_modal____check_all_ts_ study->parameters.interModal |= timeSeriesThermal; // Generated TS for thermal + study->parameters.timeSeriesToGenerate |= timeSeriesThermal; // Generated TS for thermal study->parameters.timeSeriesToRefresh |= timeSeriesThermal; study->parameters.nbTimeSeriesThermal = 5; @@ -641,6 +660,7 @@ BOOST_AUTO_TEST_CASE(load_wind_thermal_in_intra_and_inter_modal____check_all_ts_ area_2->resizeAllTimeseriesNumbers(1 + study->runtime->rangeLimits.year[rangeEnd]); + TSGenerator::ResizeGeneratedTimeSeries(study->areas, study->parameters); BOOST_CHECK(Generate(*study)); // TS number checks : all intra-modal & inter-modal modes have get the same ts number : @@ -694,6 +714,7 @@ BOOST_AUTO_TEST_CASE(check_all_drawn_ts_numbers_are_bounded_between_0_and_nb_of_ bc->RHSTimeSeries().resize(42, 1); study->bindingConstraintsGroups.resizeAllTimeseriesNumbers(1 + study->runtime->rangeLimits.year[rangeEnd]); + TSGenerator::ResizeGeneratedTimeSeries(study->areas, study->parameters); BOOST_CHECK(Generate(*study)); // TS number checks : each energy drawn ts numbers are up-bounded with the number of TS of the related energy