diff --git a/src/libs/antares/study/include/antares/study/parameters.h b/src/libs/antares/study/include/antares/study/parameters.h index 1b2ce027d9..7210ebc4b0 100644 --- a/src/libs/antares/study/include/antares/study/parameters.h +++ b/src/libs/antares/study/include/antares/study/parameters.h @@ -137,11 +137,6 @@ class Parameters final void validateOptions(const StudyLoadOptions&); - /*! - ** \brief Try to detect then fix refresh intervals - */ - void fixRefreshIntervals(); - /*! ** \brief Try to detect then fix TS generation/refresh parameters * for NTC @@ -258,28 +253,6 @@ class Parameters final uint nbTimeSeriesSolar; //@} - //! \name Time-series refresh - //@{ - /*! - ** \brief Time series to refresh on-line - ** - ** This value is a mask bits for timeSeries - ** \see TimeSeries - */ - uint timeSeriesToRefresh; - - //! Refresh interval (in years) for timeSeries : Load - uint refreshIntervalLoad; - //! Refresh interval (in years) for timeSeries : Hydro - uint refreshIntervalHydro; - //! Refresh interval (in years) for timeSeries : Wind - uint refreshIntervalWind; - //! Refresh interval (in years) for timeSeries : Thermal - uint refreshIntervalThermal; - //! Refresh interval (in years) for timeSeries : Solar - uint refreshIntervalSolar; - //@} - //! \name Archives //@{ /*! diff --git a/src/libs/antares/study/load.cpp b/src/libs/antares/study/load.cpp index c6b61a6e61..cf603c9372 100644 --- a/src/libs/antares/study/load.cpp +++ b/src/libs/antares/study/load.cpp @@ -115,12 +115,6 @@ void Study::parameterFiller(const StudyLoadOptions& options) parameters.synthesis = false; } - if (options.loadOnlyNeeded && !parameters.timeSeriesToGenerate) - { - // Nothing to refresh - parameters.timeSeriesToRefresh = 0; - } - // We can not run the simulation if the study folder is not in the latest // version and that we would like to re-importe the generated timeseries if (usedByTheSolver) @@ -235,8 +229,7 @@ bool Study::internalLoadFromFolder(const fs::path& path, const StudyLoadOptions& bool Study::internalLoadCorrelationMatrices(const StudyLoadOptions& options) { // Load - if (!options.loadOnlyNeeded || timeSeriesLoad & parameters.timeSeriesToRefresh - || timeSeriesLoad & parameters.timeSeriesToGenerate) + if (!options.loadOnlyNeeded || timeSeriesLoad & parameters.timeSeriesToGenerate) { buffer.clear() << folderInput << SEP << "load" << SEP << "prepro" << SEP << "correlation.ini"; @@ -244,8 +237,7 @@ bool Study::internalLoadCorrelationMatrices(const StudyLoadOptions& options) } // Solar - if (!options.loadOnlyNeeded || timeSeriesSolar & parameters.timeSeriesToRefresh - || timeSeriesSolar & parameters.timeSeriesToGenerate) + if (!options.loadOnlyNeeded || timeSeriesSolar & parameters.timeSeriesToGenerate) { buffer.clear() << folderInput << SEP << "solar" << SEP << "prepro" << SEP << "correlation.ini"; @@ -254,8 +246,7 @@ bool Study::internalLoadCorrelationMatrices(const StudyLoadOptions& options) // Wind { - if (!options.loadOnlyNeeded || timeSeriesWind & parameters.timeSeriesToRefresh - || timeSeriesWind & parameters.timeSeriesToGenerate) + if (!options.loadOnlyNeeded || timeSeriesWind & parameters.timeSeriesToGenerate) { buffer.clear() << folderInput << SEP << "wind" << SEP << "prepro" << SEP << "correlation.ini"; @@ -265,8 +256,7 @@ bool Study::internalLoadCorrelationMatrices(const StudyLoadOptions& options) // Hydro { - if (!options.loadOnlyNeeded || (timeSeriesHydro & parameters.timeSeriesToRefresh) - || (timeSeriesHydro & parameters.timeSeriesToGenerate)) + if (!options.loadOnlyNeeded || timeSeriesHydro & parameters.timeSeriesToGenerate) { buffer.clear() << folderInput << SEP << "hydro" << SEP << "prepro" << SEP << "correlation.ini"; diff --git a/src/libs/antares/study/parameters.cpp b/src/libs/antares/study/parameters.cpp index 72be2dd7b4..e94accc728 100644 --- a/src/libs/antares/study/parameters.cpp +++ b/src/libs/antares/study/parameters.cpp @@ -281,13 +281,6 @@ void Parameters::reset() nbTimeSeriesHydro = 1; nbTimeSeriesWind = 1; nbTimeSeriesThermal = 1; - // Time-series refresh - timeSeriesToRefresh = 0; // None - refreshIntervalLoad = 100; - refreshIntervalSolar = 100; - refreshIntervalHydro = 100; - refreshIntervalWind = 100; - refreshIntervalThermal = 100; // Archive timeSeriesToArchive = 0; // None // Pre-Processor @@ -534,32 +527,6 @@ static bool SGDIntLoadFamily_General(Parameters& d, // Only by TS generator. We skip it here (otherwise, we get a reading error). return true; } - // Interval values - if (key == "refreshintervalload") - { - return value.to(d.refreshIntervalLoad); - } - if (key == "refreshintervalhydro") - { - return value.to(d.refreshIntervalHydro); - } - if (key == "refreshintervalwind") - { - return value.to(d.refreshIntervalWind); - } - if (key == "refreshintervalthermal") - { - return value.to(d.refreshIntervalThermal); - } - if (key == "refreshintervalsolar") - { - return value.to(d.refreshIntervalSolar); - } - // What timeSeries to refresh ? - if (key == "refreshtimeseries") - { - return ConvertCStrToListTimeSeries(value, d.timeSeriesToRefresh); - } // readonly if (key == "readonly") { @@ -1139,6 +1106,14 @@ static bool SGDIntLoadFamily_Legacy(Parameters& d, return true; } + // ignored since 9.3 + if (key == "refreshtimeseries" || key == "refreshintervalload" || key == "refreshintervalhydro" + || key == "refreshintervalwind" || key == "refreshintervalthermal" + || key == "refreshintervalsolar") + { + return true; + } + return false; } @@ -1218,8 +1193,6 @@ bool Parameters::loadFromINI(const IniFile& ini, const StudyVersion& version) } } - fixRefreshIntervals(); - fixGenRefreshForNTC(); // We currently always returns true to not block any loading process @@ -1238,29 +1211,6 @@ void Parameters::handleOptimizationOptions(const StudyLoadOptions& options) optOptions.solverLogs = options.optOptions.solverLogs || optOptions.solverLogs; } -void Parameters::fixRefreshIntervals() -{ - using T = std::tuple; - const std::list timeSeriesToCheck = {{refreshIntervalLoad, timeSeriesLoad, "load"}, - {refreshIntervalSolar, timeSeriesSolar, "solar"}, - {refreshIntervalHydro, timeSeriesHydro, "hydro"}, - {refreshIntervalWind, timeSeriesWind, "wind"}, - {refreshIntervalThermal, timeSeriesThermal, "thermal"}}; - - for (const auto& [refreshInterval, ts, label]: timeSeriesToCheck) - { - if (ts & timeSeriesToRefresh && 0 == refreshInterval) - { - refreshInterval = 1; - logs.error() << "The " << label - << " time-series must be refreshed but the interval is equal to 0. " - "Auto-Reset to a safe value (1)."; - } - } -} - void Parameters::fixGenRefreshForNTC() { if ((timeSeriesTransmissionCapacities & timeSeriesToGenerate) != 0) @@ -1269,12 +1219,6 @@ void Parameters::fixGenRefreshForNTC() logs.error() << "Time-series generation is not available for transmission capacities. It " "will be automatically disabled."; } - if ((timeSeriesTransmissionCapacities & timeSeriesToRefresh) != 0) - { - timeSeriesToRefresh &= ~timeSeriesTransmissionCapacities; - logs.error() << "Time-series refresh is not available for transmission capacities. It will " - "be automatically disabled."; - } if ((timeSeriesTransmissionCapacities & interModal) != 0) { interModal &= ~timeSeriesTransmissionCapacities; @@ -1592,64 +1536,6 @@ void Parameters::prepareForSimulation(const StudyLoadOptions& options) interModal = 0; } - // Preprocessors - if (!timeSeriesToGenerate) - { - // Nothing to refresh - timeSeriesToRefresh = 0; - } - else - { - // Removing `refresh` - if (!(timeSeriesToGenerate & timeSeriesLoad)) - { - timeSeriesToRefresh &= ~timeSeriesLoad; - } - if (!(timeSeriesToGenerate & timeSeriesSolar)) - { - timeSeriesToRefresh &= ~timeSeriesSolar; - } - if (!(timeSeriesToGenerate & timeSeriesWind)) - { - timeSeriesToRefresh &= ~timeSeriesWind; - } - if (!(timeSeriesToGenerate & timeSeriesHydro)) - { - timeSeriesToRefresh &= ~timeSeriesHydro; - } - if (!(timeSeriesToGenerate & timeSeriesThermal)) - { - timeSeriesToRefresh &= ~timeSeriesThermal; - } - - // Force mode refresh if the timeseries must be regenerated - if (timeSeriesToGenerate & timeSeriesLoad && !(timeSeriesToRefresh & timeSeriesLoad)) - { - timeSeriesToRefresh |= timeSeriesLoad; - refreshIntervalLoad = UINT_MAX; - } - if (timeSeriesToGenerate & timeSeriesSolar && !(timeSeriesToRefresh & timeSeriesSolar)) - { - timeSeriesToRefresh |= timeSeriesSolar; - refreshIntervalSolar = UINT_MAX; - } - if (timeSeriesToGenerate & timeSeriesWind && !(timeSeriesToRefresh & timeSeriesWind)) - { - timeSeriesToRefresh |= timeSeriesWind; - refreshIntervalWind = UINT_MAX; - } - if (timeSeriesToGenerate & timeSeriesHydro && !(timeSeriesToRefresh & timeSeriesHydro)) - { - timeSeriesToRefresh |= timeSeriesHydro; - refreshIntervalHydro = UINT_MAX; - } - if (timeSeriesToGenerate & timeSeriesThermal && !(timeSeriesToRefresh & timeSeriesThermal)) - { - timeSeriesToRefresh |= timeSeriesThermal; - refreshIntervalThermal = UINT_MAX; - } - } - if (options.noTimeseriesImportIntoInput && timeSeriesToArchive != 0) { logs.info() << " :: ignoring timeseries importation to input"; @@ -1792,14 +1678,8 @@ void Parameters::saveToINI(IniFile& ini) const section->add("nbTimeSeriesSolar", nbTimeSeriesSolar); // Refresh - ParametersSaveTimeSeries(section, "refreshTimeSeries", timeSeriesToRefresh); ParametersSaveTimeSeries(section, "intra-modal", intraModal); ParametersSaveTimeSeries(section, "inter-modal", interModal); - section->add("refreshIntervalLoad", refreshIntervalLoad); - section->add("refreshIntervalHydro", refreshIntervalHydro); - section->add("refreshIntervalWind", refreshIntervalWind); - section->add("refreshIntervalThermal", refreshIntervalThermal); - section->add("refreshIntervalSolar", refreshIntervalSolar); // Readonly section->add("readonly", readonly); diff --git a/src/libs/antares/study/runtime/runtime.cpp b/src/libs/antares/study/runtime/runtime.cpp index bef958919d..8637d66a52 100644 --- a/src/libs/antares/study/runtime/runtime.cpp +++ b/src/libs/antares/study/runtime/runtime.cpp @@ -78,10 +78,7 @@ static void StudyRuntimeInfosInitializeAllAreas(Study& study, StudyRuntimeInfos& } // Spinning - Economic Only - If no prepro - if (!(timeSeriesThermal & study.parameters.timeSeriesToRefresh)) - { - area.thermal.list.calculationOfSpinning(); - } + area.thermal.list.calculationOfSpinning(); area.scratchpad.reserve(nbYearsInParallel); for (uint numSpace = 0; numSpace < nbYearsInParallel; numSpace++) diff --git a/src/libs/antares/study/study.cpp b/src/libs/antares/study/study.cpp index 1b5493e750..17744a947e 100644 --- a/src/libs/antares/study/study.cpp +++ b/src/libs/antares/study/study.cpp @@ -212,7 +212,7 @@ unsigned Study::getNumberOfCoresPerMode(unsigned nbLogicalCores, int ncMode) if (!nbLogicalCores) { logs.fatal() << "Number of logical cores available is 0."; - return 0; + return 1; } switch (ncMode) @@ -232,17 +232,13 @@ unsigned Study::getNumberOfCoresPerMode(unsigned nbLogicalCores, int ncMode) break; } - return 0; + return 1; } +/// Getting the number of parallel years based on the number of cores level void Study::getNumberOfCores(const bool forceParallel, const uint nbYearsParallelForced) { - /* - Getting the number of parallel years based on the number - of cores level. - This number is limited by the smallest refresh span (if at least - one type of time series is generated) - */ + auto& p = parameters; unsigned nbLogicalCores = std::thread::hardware_concurrency(); maxNbYearsInParallel = getNumberOfCoresPerMode(nbLogicalCores, parameters.nbCores.ncMode); @@ -252,35 +248,6 @@ void Study::getNumberOfCores(const bool forceParallel, const uint nbYearsParalle maxNbYearsInParallel = nbYearsParallelForced; } - // Limiting the number of parallel years by the smallest refresh span - auto& p = parameters; - uint TSlimit = UINT_MAX; - if ((p.timeSeriesToGenerate & timeSeriesLoad) && (p.timeSeriesToRefresh & timeSeriesLoad)) - { - TSlimit = p.refreshIntervalLoad; - } - if ((p.timeSeriesToGenerate & timeSeriesSolar) && (p.timeSeriesToRefresh & timeSeriesSolar)) - { - TSlimit = (p.refreshIntervalSolar < TSlimit) ? p.refreshIntervalSolar : TSlimit; - } - if ((p.timeSeriesToGenerate & timeSeriesHydro) && (p.timeSeriesToRefresh & timeSeriesHydro)) - { - TSlimit = (p.refreshIntervalHydro < TSlimit) ? p.refreshIntervalHydro : TSlimit; - } - if ((p.timeSeriesToGenerate & timeSeriesWind) && (p.timeSeriesToRefresh & timeSeriesWind)) - { - TSlimit = (p.refreshIntervalWind < TSlimit) ? p.refreshIntervalWind : TSlimit; - } - if ((p.timeSeriesToGenerate & timeSeriesThermal) && (p.timeSeriesToRefresh & timeSeriesThermal)) - { - TSlimit = (p.refreshIntervalThermal < TSlimit) ? p.refreshIntervalThermal : TSlimit; - } - - if (TSlimit < maxNbYearsInParallel) - { - maxNbYearsInParallel = TSlimit; - } - // Limiting the number of parallel years by the total number of years if (p.nbYears < maxNbYearsInParallel) { @@ -290,102 +257,13 @@ void Study::getNumberOfCores(const bool forceParallel, const uint nbYearsParalle // Getting the minimum number of years in a set of parallel years. // To get this number, we have to divide all years into sets of parallel // years and pick the size of the smallest set. - - std::vector* set = nullptr; - bool buildNewSet = true; - std::vector> setsOfParallelYears; - - for (uint y = 0; y < p.nbYears; ++y) - { - bool performCalculations = true; - if (p.userPlaylist) - { - performCalculations = p.yearsFilter[y]; - } - - // Do we have to refresh ? - bool refreshing = false; - refreshing = (p.timeSeriesToGenerate & timeSeriesLoad) - && (p.timeSeriesToRefresh & timeSeriesLoad) - && (!y || ((y % p.refreshIntervalLoad) == 0)); - refreshing = refreshing - || ((p.timeSeriesToGenerate & timeSeriesSolar) - && (p.timeSeriesToRefresh & timeSeriesSolar) - && (!y || ((y % p.refreshIntervalSolar) == 0))); - refreshing = refreshing - || ((p.timeSeriesToGenerate & timeSeriesWind) - && (p.timeSeriesToRefresh & timeSeriesWind) - && (!y || ((y % p.refreshIntervalWind) == 0))); - refreshing = refreshing - || ((p.timeSeriesToGenerate & timeSeriesHydro) - && (p.timeSeriesToRefresh & timeSeriesHydro) - && (!y || ((y % p.refreshIntervalHydro) == 0))); - refreshing = refreshing - || ((p.timeSeriesToGenerate & timeSeriesThermal) - && (p.timeSeriesToRefresh & timeSeriesThermal) - && (!y || ((y % p.refreshIntervalThermal) == 0))); - - buildNewSet = buildNewSet || refreshing; - - // We build a new set of parallel years if one of these conditions is fulfilled : - // - We have to refresh (or regenerate) some or all time series before running the - // current year - // - This is the first year after the previous set is full with years to be actually - // executed (not skipped). That is : in the previous set filled, the max number of - // years to be actually run is reached. - if (buildNewSet) - { - std::vector setToCreate; - setsOfParallelYears.push_back(setToCreate); - set = &(setsOfParallelYears.back()); - } - - if (performCalculations) - { - set->push_back(y); - } - - // Do we build a new set at next iteration (for years to be executed or not) ? - if (set->size() == maxNbYearsInParallel) - { - buildNewSet = true; - } - else - { - buildNewSet = false; - } - } // End of loop over years - - // Now finding the smallest size among all sets. - minNbYearsInParallel = maxNbYearsInParallel; - for (uint s = 0; s < setsOfParallelYears.size(); s++) - { - uint setSize = (uint)setsOfParallelYears[s].size(); - // Empty sets are not taken into account because, on the solver side, - // they will contain only skipped years - if (setSize && (setSize < minNbYearsInParallel)) - { - minNbYearsInParallel = setSize; - } - } + unsigned minYears = p.userPlaylist ? p.yearsFilter.size() % maxNbYearsInParallel + : p.nbYears % maxNbYearsInParallel; // GUI : storing minimum number of parallel years (in a set of parallel years). // Useful in the run window's simulation cores field in case parallel mode is enabled // by user. - minNbYearsInParallel_save = minNbYearsInParallel; - - // The max number of years to run in parallel is limited by the max number years in a set of - // parallel years. This latter number can be limited by the smallest interval between 2 refresh - // points and determined by the unrun MC years in case of play-list. - uint maxNbYearsOverAllSets = 0; - for (uint s = 0; s < setsOfParallelYears.size(); s++) - { - if (setsOfParallelYears[s].size() > maxNbYearsOverAllSets) - { - maxNbYearsOverAllSets = (uint)setsOfParallelYears[s].size(); - } - } - maxNbYearsInParallel = maxNbYearsOverAllSets; + minNbYearsInParallel_save = minYears; // GUI : storing max nb of parallel years (in a set of parallel years) in case parallel mode is // enabled. @@ -1002,37 +880,6 @@ void Study::ensureDataAreLoadedForAllBindingConstraints() } } -namespace // anonymous -{ -template -struct TS final -{ - static bool IsNeeded(const Study& s, const uint y) - { - if (not(T & s.parameters.timeSeriesToRefresh)) - { - return false; - } - - switch (T) - { - case timeSeriesLoad: - return (!(y % s.parameters.refreshIntervalLoad)); - case timeSeriesSolar: - return (!(y % s.parameters.refreshIntervalSolar)); - case timeSeriesWind: - return (!(y % s.parameters.refreshIntervalWind)); - case timeSeriesHydro: - return (!(y % s.parameters.refreshIntervalHydro)); - case timeSeriesThermal: - return (!(y % s.parameters.refreshIntervalThermal)); - } - return false; - } -}; - -} // anonymous namespace - void Study::initializeProgressMeter(bool tsGeneratorOnly) { uint years = tsGeneratorOnly ? 1 : (runtime.rangeLimits.year[rangeEnd] + 1); @@ -1056,54 +903,6 @@ void Study::initializeProgressMeter(bool tsGeneratorOnly) for (uint y = 0; y != years; ++y) { - if (TS::IsNeeded(*this, y)) - { - n = parameters.nbTimeSeriesLoad * areas.size() * 365; - if (0 != (timeSeriesLoad & parameters.timeSeriesToArchive)) - { - n += areas.size(); - } - progression.add(y, Solver::Progression::sectTSGLoad, n); - } - if (TS::IsNeeded(*this, y)) - { - n = parameters.nbTimeSeriesSolar * areas.size() * 365; - if (0 != (timeSeriesSolar & parameters.timeSeriesToArchive)) - { - n += areas.size(); - } - progression.add(y, Solver::Progression::sectTSGSolar, n); - } - if (TS::IsNeeded(*this, y)) - { - n = parameters.nbTimeSeriesWind * areas.size() * 365; - if (0 != (timeSeriesWind & parameters.timeSeriesToArchive)) - { - n += areas.size(); - } - progression.add(y, Solver::Progression::sectTSGWind, n); - } - if (TS::IsNeeded(*this, y)) - { - // n += parameters.nbTimeSeriesHydro * areas.size() * 12; - n = parameters.nbTimeSeriesHydro; - if (0 != (timeSeriesHydro & parameters.timeSeriesToArchive)) - { - n += areas.size(); - } - progression.add(y, Solver::Progression::sectTSGHydro, n); - } - if (TS::IsNeeded(*this, y)) - { - n = runtime.thermalPlantTotalCount; - if (0 != (timeSeriesThermal & parameters.timeSeriesToArchive)) - { - n += runtime.thermalPlantTotalCount; - n += runtime.thermalPlantTotalCountMustRun; - } - progression.add(y, Solver::Progression::sectTSGThermal, n); - } - progression.add(y, Solver::Progression::sectYear, ticksPerYear); if (parameters.yearByYear) diff --git a/src/solver/simulation/CMakeLists.txt b/src/solver/simulation/CMakeLists.txt index 17e511fac5..e7cadd3e49 100644 --- a/src/solver/simulation/CMakeLists.txt +++ b/src/solver/simulation/CMakeLists.txt @@ -22,8 +22,6 @@ set(SRC_SIMULATION solver_utils.cpp include/antares/solver/simulation/solver.h include/antares/solver/simulation/solver.hxx - include/antares/solver/simulation/solver.data.h - solver.data.cpp include/antares/solver/simulation/simulation-run.h simulation-run.cpp include/antares/solver/simulation/common-eco-adq.h diff --git a/src/solver/simulation/include/antares/solver/simulation/solver.data.h b/src/solver/simulation/include/antares/solver/simulation/solver.data.h deleted file mode 100644 index bb30ec4173..0000000000 --- a/src/solver/simulation/include/antares/solver/simulation/solver.data.h +++ /dev/null @@ -1,63 +0,0 @@ -/* -** Copyright 2007-2024, RTE (https://www.rte-france.com) -** See AUTHORS.txt -** SPDX-License-Identifier: MPL-2.0 -** This file is part of Antares-Simulator, -** Adequacy and Performance assessment for interconnected energy networks. -** -** Antares_Simulator is free software: you can redistribute it and/or modify -** it under the terms of the Mozilla Public Licence 2.0 as published by -** the Mozilla Foundation, either version 2 of the License, or -** (at your option) any later version. -** -** Antares_Simulator is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** Mozilla Public Licence 2.0 for more details. -** -** You should have received a copy of the Mozilla Public Licence 2.0 -** along with Antares_Simulator. If not, see . -*/ -#ifndef __SOLVER_SIMULATION_SOLVER_DATA_H__ -#define __SOLVER_SIMULATION_SOLVER_DATA_H__ - -#include - -namespace Antares::Solver::Private::Simulation -{ -class CacheData -{ -public: - /*! - ** \brief Re-Initialize the inner variables - */ - void initialize(const Antares::Data::Parameters& parameters); - -public: - //! True if the prepro `load` must be used - bool haveToRefreshTSLoad; - //! True if the prepro `solar` must be used - bool haveToRefreshTSSolar; - //! True if the prepro `wind` must be used - bool haveToRefreshTSWind; - //! True if the prepro `hydro` must be used - bool haveToRefreshTSHydro; - //! True if the prepro `thermal` must be used - bool haveToRefreshTSThermal; - - //! Refresh time interval for Load - unsigned int refreshIntervalLoad; - //! Refresh time interval for Solar - unsigned int refreshIntervalSolar; - //! Refresh time interval for Hydro - unsigned int refreshIntervalHydro; - //! Refresh time interval for wind - unsigned int refreshIntervalWind; - //! Refresh time interval for thermal - unsigned int refreshIntervalThermal; - -}; // class CacheData - -} // namespace Antares::Solver::Private::Simulation - -#endif // __SOLVER_SIMULATION_SOLVER_H__ diff --git a/src/solver/simulation/include/antares/solver/simulation/solver.h b/src/solver/simulation/include/antares/solver/simulation/solver.h index 4ea45461d8..ad342a7e1e 100644 --- a/src/solver/simulation/include/antares/solver/simulation/solver.h +++ b/src/solver/simulation/include/antares/solver/simulation/solver.h @@ -30,7 +30,6 @@ #include #include "antares/solver/hydro/management/management.h" #include "antares/solver/misc/options.h" -#include "antares/solver/simulation/solver.data.h" #include "antares/solver/simulation/solver_utils.h" #include "antares/solver/variable/state.h" @@ -83,11 +82,6 @@ class ISimulation: public Impl const ::Settings& settings; private: - /*! - ** \brief Regenerate time-series if required for a given year - */ - void regenerateTimeSeries(uint year); - /*! ** \brief Builds sets of parallel years ** @@ -136,8 +130,6 @@ class ISimulation: public Impl */ void loopThroughYears(uint firstYear, uint endYear, std::vector& state); - //! Some temporary to avoid performing useless complex checks - Solver::Private::Simulation::CacheData pData; //! uint pNbYearsReallyPerformed; //! Max number of years performed in parallel diff --git a/src/solver/simulation/include/antares/solver/simulation/solver.hxx b/src/solver/simulation/include/antares/solver/simulation/solver.hxx index 7f4a63ab82..6b6c2bb568 100644 --- a/src/solver/simulation/include/antares/solver/simulation/solver.hxx +++ b/src/solver/simulation/include/antares/solver/simulation/solver.hxx @@ -286,73 +286,53 @@ void ISimulation::run() ImplementationType::variables.template provideInformations(c); } - // Preprocessors - // Determine if we have to use the preprocessors at least one time. - pData.initialize(study.parameters); - ImplementationType::setNbPerformedYearsInParallel(pNbMaxPerformedYearsInParallel); - if (settings.tsGeneratorsOnly) - { - // Only the preprocessors can be used - // We only have to regenerate time-series according the settings - // in general data of the study. - logs.info() << " Only the preprocessors are enabled."; - - regenerateTimeSeries(0); + // Export ts-numbers into output + TimeSeriesNumbers::StoreTimeSeriesNumbersIntoOuput(study, pResultWriter); - // Destroy the TS Generators if any - // It will export the time-series into the output in the same time - TSGenerator::DestroyAll(study); - } - else + if (not ImplementationType::simulationBegin()) { - // Export ts-numbers into output - TimeSeriesNumbers::StoreTimeSeriesNumbersIntoOuput(study, pResultWriter); - - if (not ImplementationType::simulationBegin()) - { - return; - } - // Allocating the memory - ImplementationType::variables.simulationBegin(); + return; + } + // Allocating the memory + ImplementationType::variables.simulationBegin(); - // For beauty - logs.info(); + // For beauty + logs.info(); - // Launching the simulation for all years - logs.info() << "MC-Years : [" << (study.runtime.rangeLimits.year[Data::rangeBegin] + 1) - << " .. " << (1 + study.runtime.rangeLimits.year[Data::rangeEnd]) - << "], total: " << study.runtime.rangeLimits.year[Data::rangeCount]; + // Launching the simulation for all years + logs.info() << "MC-Years : [" << (study.runtime.rangeLimits.year[Data::rangeBegin] + 1) + << " .. " << (1 + study.runtime.rangeLimits.year[Data::rangeEnd]) + << "], total: " << study.runtime.rangeLimits.year[Data::rangeCount]; - // Current state - std::vector state(pNbMaxPerformedYearsInParallel, Variable::State(study)); - // Initializing states for parallel actually performed years - for (uint numSpace = 0; numSpace != pNbMaxPerformedYearsInParallel; ++numSpace) - { - ImplementationType::initializeState(state[numSpace], numSpace); - } + // Current state + std::vector state(pNbMaxPerformedYearsInParallel, Variable::State(study)); + // Initializing states for parallel actually performed years + for (uint numSpace = 0; numSpace != pNbMaxPerformedYearsInParallel; ++numSpace) + { + ImplementationType::initializeState(state[numSpace], numSpace); + } - uint finalYear = 1 + study.runtime.rangeLimits.year[Data::rangeEnd]; - { - pDurationCollector("mc_years") - << [finalYear, &state, this] { loopThroughYears(0, finalYear, state); }; - } - // Destroy the TS Generators if any - // It will export the time-series into the output in the same time - TSGenerator::DestroyAll(study); + uint finalYear = 1 + study.runtime.rangeLimits.year[Data::rangeEnd]; + { + pDurationCollector("mc_years") + << [finalYear, &state, this] { loopThroughYears(0, finalYear, state); }; + } + // Destroy the TS Generators if any + // It will export the time-series into the output in the same time + TSGenerator::DestroyAll(study); - // Post operations - pDurationCollector("post_processing") << [this] { ImplementationType::simulationEnd(); }; + // Post operations + pDurationCollector("post_processing") << [this] { ImplementationType::simulationEnd(); }; - ImplementationType::variables.simulationEnd(); + ImplementationType::variables.simulationEnd(); - // Spatial clusters - // Notifying all variables to perform the final spatial clusters. - // This must be done only when all variables have finished to compute their - // own data. - ImplementationType::variables.simulationEndSpatialAggregates(ImplementationType::variables); - } + // Spatial clusters + // Notifying all variables to perform the final spatial clusters. + // This must be done only when all variables have finished to compute their + // own data. + ImplementationType::variables.simulationEndSpatialAggregates(ImplementationType::variables); } template @@ -408,69 +388,6 @@ void ISimulation::writeResults(bool synthesis, uint year, ui } } -template -void ISimulation::regenerateTimeSeries(uint year) -{ - // A preprocessor can be launched for several reasons: - // * 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 TSGenerator; - // Load - if (pData.haveToRefreshTSLoad && (year % pData.refreshIntervalLoad == 0)) - { - pDurationCollector("tsgen_load") - << [year, this] { GenerateTimeSeries(study, year, pResultWriter); }; - } - // Solar - if (pData.haveToRefreshTSSolar && (year % pData.refreshIntervalSolar == 0)) - { - pDurationCollector("tsgen_solar") << [year, this] - { GenerateTimeSeries(study, year, pResultWriter); }; - } - // Wind - if (pData.haveToRefreshTSWind && (year % pData.refreshIntervalWind == 0)) - { - pDurationCollector("tsgen_wind") - << [year, this] { GenerateTimeSeries(study, year, pResultWriter); }; - } - // Hydro - if (pData.haveToRefreshTSHydro && (year % pData.refreshIntervalHydro == 0)) - { - pDurationCollector("tsgen_hydro") << [year, this] - { GenerateTimeSeries(study, year, pResultWriter); }; - } - - // Thermal - const bool refreshTSonCurrentYear = (year % pData.refreshIntervalThermal == 0); - - pDurationCollector("tsgen_thermal") << [refreshTSonCurrentYear, year, this] - { - if (refreshTSonCurrentYear) - { - auto clusters = getAllClustersToGen(study.areas, pData.haveToRefreshTSThermal); - generateThermalTimeSeries(study, - clusters, - study.runtime.random[Data::seedTsGenThermal]); - - bool archive = study.parameters.timeSeriesToArchive & Data::timeSeriesThermal; - bool doWeWrite = archive && !study.parameters.noOutput; - if (doWeWrite) - { - fs::path savePath = study.folderOutput / "ts-generator" / "thermal" / "mc-" - / std::to_string(year); - writeThermalTimeSeries(clusters, savePath); - } - - // apply the spinning if we generated some in memory clusters - for (auto* cluster: clusters) - { - cluster->calculationOfSpinning(); - } - } - }; -} - template uint ISimulation::buildSetsOfParallelYears( uint firstYear, @@ -493,31 +410,10 @@ uint ISimulation::buildSetsOfParallelYears( unsigned int indexSpace = 999999; bool performCalculations = yearsFilter[y]; - // Do we refresh just before this year ? If yes a new set of parallel years has to be - // created - bool refreshing = false; - refreshing = pData.haveToRefreshTSLoad && (y % pData.refreshIntervalLoad == 0); - refreshing = refreshing - || (pData.haveToRefreshTSSolar && (y % pData.refreshIntervalSolar == 0)); - refreshing = refreshing - || (pData.haveToRefreshTSWind && (y % pData.refreshIntervalWind == 0)); - refreshing = refreshing - || (pData.haveToRefreshTSHydro && (y % pData.refreshIntervalHydro == 0)); - - // Some thermal clusters may override the global parameter. - // Therefore, we may want to refresh TS even if pData.haveToRefreshTSThermal == false - bool haveToRefreshTSThermal = pData.haveToRefreshTSThermal - || study.runtime.thermalTSRefresh; - refreshing = refreshing - || (haveToRefreshTSThermal && (y % pData.refreshIntervalThermal == 0)); - // We build a new set of parallel years if one of these conditions is fulfilled : - // - We have to refresh (or regenerate) some or all time series before running the - // current year // - This is the first year (to be executed or not) after the previous set is full with // years to be executed. That is : in the previous set filled, the max number of // years to be actually run is reached. - buildNewSet = buildNewSet || refreshing; if (buildNewSet) { @@ -528,16 +424,6 @@ uint ISimulation::buildSetsOfParallelYears( // Initializations set->nbPerformedYears = 0; set->nbYears = 0; - set->regenerateTS = false; - set->yearForTSgeneration = 999999; - - // In case we have to regenerate times series before run the current set of parallel - // years - if (refreshing) - { - set->regenerateTS = true; - set->yearForTSgeneration = y; - } } set->yearsIndices.push_back(y); @@ -965,10 +851,6 @@ void ISimulation::loopThroughYears(uint firstYear, // Loop over sets of parallel years to check hydro inputs for (const auto& batch: setsOfParallelYears) { - if (batch.regenerateTS) - { - break; - } for (auto year: batch.yearsIndices) { hydroInputsChecker.Execute(year); @@ -981,13 +863,6 @@ void ISimulation::loopThroughYears(uint firstYear, // Loop over sets of parallel years to run the simulation for (auto& batch: setsOfParallelYears) { - // 1 - We may want to regenerate the time-series this year. - // This is the case when the preprocessors are enabled from the - // interface and/or the refresh is enabled. - if (batch.regenerateTS) - { - regenerateTimeSeries(batch.yearForTSgeneration); - } computeRandomNumbers(randomForParallelYears, batch.yearsIndices, batch.isYearPerformed, diff --git a/src/solver/simulation/include/antares/solver/simulation/solver_utils.h b/src/solver/simulation/include/antares/solver/simulation/solver_utils.h index a920ef1f47..cee694bfc0 100644 --- a/src/solver/simulation/include/antares/solver/simulation/solver_utils.h +++ b/src/solver/simulation/include/antares/solver/simulation/solver_utils.h @@ -60,12 +60,6 @@ struct setOfParallelYears // Nbre d'années en parallele jouées ou non pour ce lot unsigned int nbYears; - - // Regenere-t-on des times series avant de jouer les annees du lot courant - bool regenerateTS; - - // Annee a passer a la fonction "regenerateTimeSeries(y)" (si regenerateTS is "true") - unsigned int yearForTSgeneration; }; class costStatistics diff --git a/src/solver/simulation/solver.data.cpp b/src/solver/simulation/solver.data.cpp deleted file mode 100644 index 80c4f6ee9f..0000000000 --- a/src/solver/simulation/solver.data.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/* -** Copyright 2007-2024, RTE (https://www.rte-france.com) -** See AUTHORS.txt -** SPDX-License-Identifier: MPL-2.0 -** This file is part of Antares-Simulator, -** Adequacy and Performance assessment for interconnected energy networks. -** -** Antares_Simulator is free software: you can redistribute it and/or modify -** it under the terms of the Mozilla Public Licence 2.0 as published by -** the Mozilla Foundation, either version 2 of the License, or -** (at your option) any later version. -** -** Antares_Simulator is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** Mozilla Public Licence 2.0 for more details. -** -** You should have received a copy of the Mozilla Public Licence 2.0 -** along with Antares_Simulator. If not, see . -*/ - -#include "antares/solver/simulation/solver.data.h" - -#include - -namespace Antares::Solver::Private::Simulation -{ -namespace -{ -template -inline static bool CheckTSToRefresh(const Antares::Data::Parameters& g) -{ - return (TS & g.timeSeriesToRefresh) && (TS & g.timeSeriesToGenerate); -} - -} // namespace - -void CacheData::initialize(const Antares::Data::Parameters& parameters) -{ - haveToRefreshTSLoad = CheckTSToRefresh(parameters); - haveToRefreshTSSolar = CheckTSToRefresh(parameters) - && parameters.renewableGeneration.isAggregated(); - haveToRefreshTSHydro = CheckTSToRefresh(parameters); - haveToRefreshTSWind = CheckTSToRefresh(parameters) - && parameters.renewableGeneration.isAggregated(); - haveToRefreshTSThermal = CheckTSToRefresh(parameters); - - refreshIntervalLoad = parameters.refreshIntervalLoad; - refreshIntervalSolar = parameters.refreshIntervalSolar; - refreshIntervalHydro = parameters.refreshIntervalHydro; - refreshIntervalWind = parameters.refreshIntervalWind; - refreshIntervalThermal = parameters.refreshIntervalThermal; -} - -} // namespace Antares::Solver::Private::Simulation diff --git a/src/solver/ts-generator/generator.cpp b/src/solver/ts-generator/generator.cpp index c682e412ab..d6708bd972 100644 --- a/src/solver/ts-generator/generator.cpp +++ b/src/solver/ts-generator/generator.cpp @@ -67,11 +67,11 @@ void ResizeGeneratedTimeSeries(Data::AreaList& areas, Data::Parameters& params) 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); + Destroy(study); + Destroy(study); + Destroy(study); + Destroy(study); + Destroy(study); } } // namespace Antares::TSGenerator diff --git a/src/solver/ts-generator/include/antares/solver/ts-generator/generator.h b/src/solver/ts-generator/include/antares/solver/ts-generator/generator.h index 5ffea85100..b9a7c4a4d7 100644 --- a/src/solver/ts-generator/include/antares/solver/ts-generator/generator.h +++ b/src/solver/ts-generator/include/antares/solver/ts-generator/generator.h @@ -127,7 +127,7 @@ void DestroyAll(Data::Study& study); ** \brief Destroy a TS generator if it exists and no longer needed */ template -void Destroy(Data::Study& study, uint year); +void Destroy(Data::Study& study); } // namespace Antares::TSGenerator diff --git a/src/solver/ts-generator/include/antares/solver/ts-generator/generator.hxx b/src/solver/ts-generator/include/antares/solver/ts-generator/generator.hxx index 7455c1accc..c18085ddcd 100644 --- a/src/solver/ts-generator/include/antares/solver/ts-generator/generator.hxx +++ b/src/solver/ts-generator/include/antares/solver/ts-generator/generator.hxx @@ -81,8 +81,9 @@ bool GenerateTimeSeries(Data::Study& study, uint year, IResultWriter& writer) return r; } +// TODO REMOVE template -void Destroy(Data::Study& study, uint year) +void Destroy(Data::Study& study) { auto* xcast = reinterpret_cast( study.cacheTSGenerator[Data::TimeSeriesBitPatternIntoIndex::value]); @@ -94,51 +95,11 @@ void Destroy(Data::Study& study, uint year) // releasing auto& parameters = study.parameters; - bool shouldDestroy; - switch (T) - { - case Data::timeSeriesLoad: - { - shouldDestroy = (parameters.refreshIntervalLoad > parameters.nbYears) - || year + parameters.refreshIntervalLoad > parameters.nbYears; - break; - } - case Data::timeSeriesSolar: - { - shouldDestroy = (parameters.refreshIntervalSolar > parameters.nbYears) - || year + parameters.refreshIntervalSolar > parameters.nbYears; - break; - } - case Data::timeSeriesHydro: - { - shouldDestroy = (parameters.refreshIntervalHydro > parameters.nbYears) - || year + parameters.refreshIntervalHydro > parameters.nbYears; - break; - } - case Data::timeSeriesWind: - { - shouldDestroy = (parameters.refreshIntervalWind > parameters.nbYears) - || year + parameters.refreshIntervalWind > parameters.nbYears; - break; - } - case Data::timeSeriesThermal: - { - shouldDestroy = (parameters.refreshIntervalThermal > parameters.nbYears) - || year + parameters.refreshIntervalThermal > parameters.nbYears; - break; - } - default: - shouldDestroy = true; - } - - if (shouldDestroy) - { - logs.info() << " Releasing the " << Data::TimeSeriesToCStr::Value() << " TS Generator"; - study.cacheTSGenerator[Data::TimeSeriesBitPatternIntoIndex::value] = nullptr; - study.destroyTSGeneratorData(); - delete xcast; - xcast = nullptr; - } + logs.info() << " Releasing the " << Data::TimeSeriesToCStr::Value() << " TS Generator"; + study.cacheTSGenerator[Data::TimeSeriesBitPatternIntoIndex::value] = nullptr; + study.destroyTSGeneratorData(); + delete xcast; + xcast = nullptr; } } // namespace Antares::TSGenerator diff --git a/src/tests/src/libs/antares/study/test_study.cpp b/src/tests/src/libs/antares/study/test_study.cpp index fa0348467d..9ba0f815b3 100644 --- a/src/tests/src/libs/antares/study/test_study.cpp +++ b/src/tests/src/libs/antares/study/test_study.cpp @@ -320,8 +320,8 @@ BOOST_FIXTURE_TEST_CASE(cpu_count, OneAreaStudy) BOOST_CHECK_EQUAL(study->getNumberOfCoresPerMode(128, ncMax), 128); // error cases - BOOST_CHECK_EQUAL(study->getNumberOfCoresPerMode(0, ncMax), 0); - BOOST_CHECK_EQUAL(study->getNumberOfCoresPerMode(10, 120), 0); + BOOST_CHECK_EQUAL(study->getNumberOfCoresPerMode(0, ncMax), 1); + BOOST_CHECK_EQUAL(study->getNumberOfCoresPerMode(10, 120), 1); } BOOST_AUTO_TEST_SUITE_END() // version diff --git a/src/tests/src/solver/simulation/test-store-timeseries-number.cpp b/src/tests/src/solver/simulation/test-store-timeseries-number.cpp index 1e68ef95be..7a0717e281 100644 --- a/src/tests/src/solver/simulation/test-store-timeseries-number.cpp +++ b/src/tests/src/solver/simulation/test-store-timeseries-number.cpp @@ -52,7 +52,6 @@ void initializeStudy(Study& study) study.parameters.intraModal = 0; study.parameters.interModal = 0; - study.parameters.timeSeriesToRefresh = 0; } BOOST_AUTO_TEST_CASE(BC_group_TestGroup_has_output_file) diff --git a/src/tests/src/solver/simulation/test-time_series.cpp b/src/tests/src/solver/simulation/test-time_series.cpp index b999c17b48..db3b970fb2 100644 --- a/src/tests/src/solver/simulation/test-time_series.cpp +++ b/src/tests/src/solver/simulation/test-time_series.cpp @@ -48,7 +48,6 @@ void initializeStudy(Study& study) study.parameters.intraModal = 0; study.parameters.interModal = 0; - study.parameters.timeSeriesToRefresh = 0; } class PublicStudy: public Study diff --git a/src/tests/src/solver/simulation/tests-ts-numbers.cpp b/src/tests/src/solver/simulation/tests-ts-numbers.cpp index 8dbd450d53..99ac9a27bb 100644 --- a/src/tests/src/solver/simulation/tests-ts-numbers.cpp +++ b/src/tests/src/solver/simulation/tests-ts-numbers.cpp @@ -45,7 +45,6 @@ void initializeStudy(Study::Ptr study, unsigned int nbYears = 1) study->parameters.intraModal = 0; study->parameters.interModal = 0; - study->parameters.timeSeriesToRefresh = 0; } // ======================== diff --git a/src/ui/simulator/toolbox/components/datagrid/renderer/cell.cpp b/src/ui/simulator/toolbox/components/datagrid/renderer/cell.cpp index dfe09e1e46..79e0e7490b 100644 --- a/src/ui/simulator/toolbox/components/datagrid/renderer/cell.cpp +++ b/src/ui/simulator/toolbox/components/datagrid/renderer/cell.cpp @@ -264,12 +264,12 @@ RefreshTsCell::RefreshTsCell(TimeSeriesType ts) : Cell(ts) wxString RefreshTsCell::cellValue() const { - return (0 != (study_->parameters.timeSeriesToRefresh & tsKind_)) ? wxT("Yes") : wxT("No"); + return "No"; } double RefreshTsCell::cellNumericValue() const { - return (0 != (study_->parameters.timeSeriesToRefresh & tsKind_)) ? 1. : 0.; + return 0; } bool RefreshTsCell::setCellValue(const String& value) @@ -278,10 +278,6 @@ bool RefreshTsCell::setCellValue(const String& value) if (not convertToDouble(value, valueDouble)) return false; - if (Math::Zero(valueDouble)) - study_->parameters.timeSeriesToRefresh &= ~tsKind_; - else - study_->parameters.timeSeriesToRefresh |= tsKind_; return true; } @@ -301,11 +297,6 @@ RefreshSpanCell::RefreshSpanCell(TimeSeriesType ts) : Cell(ts) void RefreshSpanCell::onStudyLoaded() { - tsToRefreshSpan_[timeSeriesLoad] = &(study_->parameters.refreshIntervalLoad); - tsToRefreshSpan_[timeSeriesThermal] = &(study_->parameters.refreshIntervalThermal); - tsToRefreshSpan_[timeSeriesHydro] = &(study_->parameters.refreshIntervalHydro); - tsToRefreshSpan_[timeSeriesWind] = &(study_->parameters.refreshIntervalWind); - tsToRefreshSpan_[timeSeriesSolar] = &(study_->parameters.refreshIntervalSolar); } wxString RefreshSpanCell::cellValue() const @@ -343,9 +334,7 @@ bool RefreshSpanCell::setCellValue(const String& value) IRenderer::CellStyle RefreshSpanCell::cellStyle() const { - return (isTSgeneratorOn() && 0 != (study_->parameters.timeSeriesToRefresh & tsKind_)) - ? IRenderer::cellStyleDefault - : IRenderer::cellStyleDefaultDisabled; + return IRenderer::cellStyleDefaultDisabled; } // ============================ // Seasonal correlation cell