From 86bff273b98b42d64c15bd7905606a6fe356a504 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Omn=C3=A8s?= Date: Thu, 23 Jan 2025 15:55:04 +0100 Subject: [PATCH 01/12] Remove new/delete from analyzer (#2590) --- src/analyzer/atsp/atsp.cpp | 9 ++------- src/analyzer/atsp/atsp.h | 5 ++--- src/analyzer/atsp/cache.cpp | 8 +------- src/analyzer/atsp/correlations.cpp | 19 +++++++------------ src/analyzer/atsp/load.cpp | 22 +++++++++++----------- src/analyzer/atsp/preflight.cpp | 8 ++++---- src/tools/updater/main.cpp | 3 +-- 7 files changed, 28 insertions(+), 46 deletions(-) diff --git a/src/analyzer/atsp/atsp.cpp b/src/analyzer/atsp/atsp.cpp index 2f990c00c8..b5dfb7fac6 100644 --- a/src/analyzer/atsp/atsp.cpp +++ b/src/analyzer/atsp/atsp.cpp @@ -45,11 +45,6 @@ ATSP::ATSP(): ATSP::~ATSP() { - for (uint i = 0; i != pArea.size(); ++i) - { - delete pArea[i]; - } - if (pAutoClean) { logs.info() << "Cleaning..."; @@ -116,7 +111,7 @@ void ATSP::printSummary() const for (uint i = 0; i != pArea.size(); ++i) { - const AreaInfo& info = *pArea[i]; + const AreaInfo& info = pArea[i]; if (info.rawData) { logs.info() << " " << info.name << ": law '" @@ -163,7 +158,7 @@ bool ATSP::writeMoments() const for (uint i = 0; i < pArea.size(); ++i) { - const AreaInfo& info = *(pArea[i]); + const AreaInfo& info = pArea[i]; if (!info.enabled) { continue; diff --git a/src/analyzer/atsp/atsp.h b/src/analyzer/atsp/atsp.h index c64b2a5f43..06a7d336b5 100644 --- a/src/analyzer/atsp/atsp.h +++ b/src/analyzer/atsp/atsp.h @@ -67,7 +67,7 @@ class ATSP final { public: //! Vector - using Vector = std::vector; + using Vector = std::vector; public: bool enabled; @@ -200,7 +200,6 @@ class ATSP final bool writeMoments() const; void cacheCreate(); - void cacheDestroy(); void cacheClear(); bool cacheFetch(uint index, Matrix<>& out) const; @@ -289,7 +288,7 @@ class ATSP final uint64_t pLimitMemory; uint64_t pCacheMemoryUsed; uint pCacheLastValidIndex; - Matrix<>* pCacheMatrix; + std::vector> pCacheMatrix; Yuni::String::Vector folderPerArea; //! Temporary string mainly used for filename manipulation diff --git a/src/analyzer/atsp/cache.cpp b/src/analyzer/atsp/cache.cpp index dbc4d1132c..0843b19f03 100644 --- a/src/analyzer/atsp/cache.cpp +++ b/src/analyzer/atsp/cache.cpp @@ -25,17 +25,11 @@ namespace Antares { void ATSP::cacheCreate() { - pCacheMatrix = new Matrix<>[pArea.size()]; + pCacheMatrix.resize(pArea.size()); pCacheMemoryUsed = sizeof(Matrix<>) * pArea.size(); pCacheLastValidIndex = 0; } -void ATSP::cacheDestroy() -{ - delete[] pCacheMatrix; - pCacheMatrix = nullptr; -} - void ATSP::cacheClear() { for (uint i = 0; i != pCacheLastValidIndex; ++i) diff --git a/src/analyzer/atsp/correlations.cpp b/src/analyzer/atsp/correlations.cpp index 120d9d8465..d8ab267c68 100644 --- a/src/analyzer/atsp/correlations.cpp +++ b/src/analyzer/atsp/correlations.cpp @@ -75,13 +75,13 @@ bool ATSP::computeMonthlyCorrelations() // Initialize mapping, to skip areas which has been disabled // the real number of items is `realAreaCount` - uint* mapping = new uint[pArea.size()]; + std::vector mapping(pArea.size()); { uint z = 0; for (uint i = 0; i != pArea.size(); ++i) { mapping[i] = (uint)-1; - if (pArea[i]->enabled) + if (pArea[i].enabled) { mapping[z] = i; ++z; @@ -168,8 +168,8 @@ bool ATSP::computeMonthlyCorrelations() logs.info() << "Correlation: month: " << Antares::Date::MonthToString(m) << ", area " << (1 + iZ) << '/' << realAreaCount << ": " - << pArea[i]->name << " with area " << (1 + jZ) << '/' << realAreaCount - << ": " << pArea[j]->name; + << pArea[i].name << " with area " << (1 + jZ) << '/' << realAreaCount + << ": " << pArea[j].name; if (!cacheFetch(j, SERIE_P)) { @@ -442,7 +442,6 @@ bool ATSP::computeMonthlyCorrelations() moments_centr_net.clear(); moments_centr_raw.clear(); hidden_hours.clear(); - cacheDestroy(); // Rounding annual correlation coefficients -zero excluded for (uint i = 1; i < CORR_YNP.width; ++i) @@ -614,7 +613,7 @@ bool ATSP::computeMonthlyCorrelations() if (!Utils::isZero(col[jZ])) { const uint j = mapping[jZ]; - f << pArea[i]->name << '%' << pArea[j]->name << " = " << col[jZ] << '\n'; + f << pArea[i].name << '%' << pArea[j].name << " = " << col[jZ] << '\n'; } } } @@ -650,8 +649,7 @@ bool ATSP::computeMonthlyCorrelations() if (!Utils::isZero(col[jZ])) { const uint j = mapping[jZ]; - f << pArea[i]->name << '%' << pArea[j]->name << " = " << col[jZ] - << '\n'; + f << pArea[i].name << '%' << pArea[j].name << " = " << col[jZ] << '\n'; } } } @@ -669,7 +667,7 @@ bool ATSP::computeMonthlyCorrelations() for (uint iZ = 0; iZ != realAreaCount; ++iZ) { const uint i = mapping[iZ]; - f << pArea[i]->name << '\n'; + f << pArea[i].name << '\n'; } } else @@ -678,9 +676,6 @@ bool ATSP::computeMonthlyCorrelations() } } - // removing the mapping list - delete[] mapping; - return true; } diff --git a/src/analyzer/atsp/load.cpp b/src/analyzer/atsp/load.cpp index b23f86f551..0f016c7f57 100644 --- a/src/analyzer/atsp/load.cpp +++ b/src/analyzer/atsp/load.cpp @@ -173,11 +173,11 @@ bool ATSP::loadFromINIFile(const String& filename) } else { - AreaInfo* info = new AreaInfo(); - info->name = section->name; - info->name.toLower(); - info->enabled = true; - info->distribution = Data::XCast::dtBeta; + AreaInfo info; + info.name = section->name; + info.name.toLower(); + info.enabled = true; + info.distribution = Data::XCast::dtBeta; IniFile::Property* p = section->firstProperty; for (; p; p = p->next) @@ -187,30 +187,30 @@ bool ATSP::loadFromINIFile(const String& filename) if (key == "file") { - info->filename = p->value; + info.filename = p->value; continue; } if (key == "data") { key = p->value; key.toLower(); - info->rawData = (key == "raw"); + info.rawData = (key == "raw"); continue; } if (key == "distribution") { - info->distribution = Data::XCast::StringToDistribution(p->value); - if (info->distribution == Data::XCast::dtNone) + info.distribution = Data::XCast::StringToDistribution(p->value); + if (info.distribution == Data::XCast::dtNone) { logs.error() << "invalid distribution for " << section->name << " ('beta' will be used)"; - info->distribution = Data::XCast::dtBeta; + info.distribution = Data::XCast::dtBeta; } continue; } } - pArea.push_back(info); + pArea.push_back(std::move(info)); } } diff --git a/src/analyzer/atsp/preflight.cpp b/src/analyzer/atsp/preflight.cpp index 359d481182..b6069b5343 100644 --- a/src/analyzer/atsp/preflight.cpp +++ b/src/analyzer/atsp/preflight.cpp @@ -43,7 +43,7 @@ bool ATSP::preflight() for (uint i = 0; i != pArea.size(); ++i) { String& folder = folderPerArea[i]; - folder.clear() << pTemp << SEP << tsName << SEP << (i / 256) << SEP << pArea[i]->name; + folder.clear() << pTemp << SEP << tsName << SEP << (i / 256) << SEP << pArea[i].name; if (!IO::Directory::Create(folder)) { logs.error() << "impossible to create the directory " << folder; @@ -67,8 +67,8 @@ bool ATSP::preflight() { if (!preflight(i)) { - pArea[i]->enabled = false; - logs.info() << " The area '" << pArea[i]->name << "' has been removed"; + pArea[i].enabled = false; + logs.info() << " The area '" << pArea[i].name << "' has been removed"; } else { @@ -102,7 +102,7 @@ bool ATSP::preflight() bool ATSP::preflight(const uint areaIndex) { // Alias to the current area info - const AreaInfo& info = *(pArea[areaIndex]); + const AreaInfo& info = pArea[areaIndex]; // The folder for the current area const String& folder = folderPerArea[areaIndex]; diff --git a/src/tools/updater/main.cpp b/src/tools/updater/main.cpp index c32007cce3..c49e256f1d 100644 --- a/src/tools/updater/main.cpp +++ b/src/tools/updater/main.cpp @@ -105,13 +105,12 @@ class MyStudyFinder final: public Data::StudyFinder if (cleanup) { - auto* cleaner = new Data::StudyCleaningInfos(folder.c_str()); + auto cleaner = std::make_unique(folder.c_str()); cleaner->onProgress = &onProgress; if (cleaner->analyze()) { cleaner->performCleanup(); } - delete cleaner; } logs.info(); From a5d90c3992021840e0e653b68a64141066585477 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Omn=C3=A8s?= Date: Fri, 24 Jan 2025 11:52:06 +0100 Subject: [PATCH 02/12] Remove new/delete for AreaUI (#2589) --- src/libs/antares/study/area/area.cpp | 5 +---- src/libs/antares/study/area/list.cpp | 2 +- src/libs/antares/study/include/antares/study/area/area.h | 2 +- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/libs/antares/study/area/area.cpp b/src/libs/antares/study/area/area.cpp index 6573a23e14..3374465608 100644 --- a/src/libs/antares/study/area/area.cpp +++ b/src/libs/antares/study/area/area.cpp @@ -40,7 +40,7 @@ void Area::internalInitialize() // Make sure we have if (JIT::usedFromGUI) { - ui = new AreaUI(); + ui = std::make_unique(); } } @@ -76,9 +76,6 @@ Area::~Area() reserves.clear(); miscGen.clear(); - - delete ui; - ui = nullptr; } void Area::clearAllLinks() diff --git a/src/libs/antares/study/area/list.cpp b/src/libs/antares/study/area/list.cpp index c91ecc1e38..3f0cb4a12a 100644 --- a/src/libs/antares/study/area/list.cpp +++ b/src/libs/antares/study/area/list.cpp @@ -886,7 +886,7 @@ static bool AreaListLoadFromFolderSingleArea(Study& study, { if (!area.ui) { - area.ui = new AreaUI(); + area.ui = std::make_unique(); } buffer.clear() << study.folderInput << SEP << "areas" << SEP << area.id << SEP << "ui.ini"; diff --git a/src/libs/antares/study/include/antares/study/area/area.h b/src/libs/antares/study/include/antares/study/area/area.h index 7567bb25ca..c3d7a34ae7 100644 --- a/src/libs/antares/study/include/antares/study/area/area.h +++ b/src/libs/antares/study/include/antares/study/area/area.h @@ -301,7 +301,7 @@ class Area final: private Yuni::NonCopyable //! \name UI //@{ //! Information for the UI - AreaUI* ui = nullptr; + std::unique_ptr ui; //@} //! \name Dynamic From 4a8c7eff1bdecadbca3448bd047a59fc5823c39f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Omn=C3=A8s?= Date: Fri, 24 Jan 2025 14:58:35 +0100 Subject: [PATCH 03/12] Rename encoders.hxx -> decoders.hxx (#2591) --- src/solver/CMakeLists.txt | 1 - src/solver/modelParser/CMakeLists.txt | 2 +- src/solver/modelParser/{encoders.hxx => decoders.hxx} | 0 src/solver/modelParser/parser.cpp | 2 +- src/solver/systemParser/CMakeLists.txt | 2 +- src/solver/systemParser/{encoders.hxx => decoders.hxx} | 0 src/solver/systemParser/parser.cpp | 2 +- 7 files changed, 4 insertions(+), 5 deletions(-) rename src/solver/modelParser/{encoders.hxx => decoders.hxx} (100%) rename src/solver/systemParser/{encoders.hxx => decoders.hxx} (100%) diff --git a/src/solver/CMakeLists.txt b/src/solver/CMakeLists.txt index b37cb7f1cf..01c4dd23a2 100644 --- a/src/solver/CMakeLists.txt +++ b/src/solver/CMakeLists.txt @@ -59,7 +59,6 @@ add_library(solver-lib INTERFACE add_executable(antares-solver main.cpp ${SRCS} - modelParser/encoders.hxx ) set_target_properties(antares-solver PROPERTIES OUTPUT_NAME ${exec_name}) diff --git a/src/solver/modelParser/CMakeLists.txt b/src/solver/modelParser/CMakeLists.txt index 55eae9b706..7a52e152ad 100644 --- a/src/solver/modelParser/CMakeLists.txt +++ b/src/solver/modelParser/CMakeLists.txt @@ -1,6 +1,6 @@ set(SOURCES parser.cpp - encoders.hxx + decoders.hxx include/antares/solver/modelParser/parser.h ) diff --git a/src/solver/modelParser/encoders.hxx b/src/solver/modelParser/decoders.hxx similarity index 100% rename from src/solver/modelParser/encoders.hxx rename to src/solver/modelParser/decoders.hxx diff --git a/src/solver/modelParser/parser.cpp b/src/solver/modelParser/parser.cpp index 13d1b120eb..df1b940a13 100644 --- a/src/solver/modelParser/parser.cpp +++ b/src/solver/modelParser/parser.cpp @@ -23,7 +23,7 @@ #include "antares/solver/modelParser/Library.h" -#include "encoders.hxx" +#include "decoders.hxx" namespace Antares::Solver::ModelParser { diff --git a/src/solver/systemParser/CMakeLists.txt b/src/solver/systemParser/CMakeLists.txt index e0c16fea65..1991f182a4 100644 --- a/src/solver/systemParser/CMakeLists.txt +++ b/src/solver/systemParser/CMakeLists.txt @@ -1,7 +1,7 @@ set(SOURCES parser.cpp converter.cpp - encoders.hxx + decoders.hxx include/antares/solver/systemParser/parser.h include/antares/solver/systemParser/converter.h include/antares/solver/systemParser/system.h diff --git a/src/solver/systemParser/encoders.hxx b/src/solver/systemParser/decoders.hxx similarity index 100% rename from src/solver/systemParser/encoders.hxx rename to src/solver/systemParser/decoders.hxx diff --git a/src/solver/systemParser/parser.cpp b/src/solver/systemParser/parser.cpp index 76f7fa15d5..ff5aa46542 100644 --- a/src/solver/systemParser/parser.cpp +++ b/src/solver/systemParser/parser.cpp @@ -23,7 +23,7 @@ #include "antares/solver/systemParser/system.h" -#include "encoders.hxx" +#include "decoders.hxx" namespace Antares::Solver::SystemParser { From 433bac5b88769a194b59f4aac187fee95b8ef3d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Omn=C3=A8s?= Date: Fri, 24 Jan 2025 14:59:50 +0100 Subject: [PATCH 04/12] Remove manual allocations for set of areas, simplify code (#2588) --- .../antares/solver/variable/setofareas.h | 10 ++---- .../antares/solver/variable/setofareas.hxx | 31 +++---------------- 2 files changed, 8 insertions(+), 33 deletions(-) diff --git a/src/solver/variable/include/antares/solver/variable/setofareas.h b/src/solver/variable/include/antares/solver/variable/setofareas.h index 74c68528ba..e6fb86ae5a 100644 --- a/src/solver/variable/include/antares/solver/variable/setofareas.h +++ b/src/solver/variable/include/antares/solver/variable/setofareas.h @@ -115,9 +115,9 @@ class SetsOfAreas /*! ** \brief Default Constructor */ - SetsOfAreas(); + SetsOfAreas() = default; //! Destructor - ~SetsOfAreas(); + ~SetsOfAreas() = default; //@} void initializeFromStudy(Data::Study& study); @@ -198,15 +198,11 @@ class SetsOfAreas public: //! Area list - typedef std::vector SetOfAreasVector; + typedef std::vector> SetOfAreasVector; //! Area list SetOfAreasVector pSetsOfAreas; //! Reference to the origina set std::vector pOriginalSets; - //! An iterator for the begining of the list - typename SetOfAreasVector::iterator pBegin; - //! An iterator to the end of the list - typename SetOfAreasVector::iterator pEnd; //! The study const Data::Study* pStudy; diff --git a/src/solver/variable/include/antares/solver/variable/setofareas.hxx b/src/solver/variable/include/antares/solver/variable/setofareas.hxx index 19e60f2997..e133b06a55 100644 --- a/src/solver/variable/include/antares/solver/variable/setofareas.hxx +++ b/src/solver/variable/include/antares/solver/variable/setofareas.hxx @@ -27,22 +27,6 @@ namespace Solver { namespace Variable { -template -inline SetsOfAreas::SetsOfAreas() -{ - // Do nothing -} - -template -inline SetsOfAreas::~SetsOfAreas() -{ - // Releasing the memory occupied by the areas - for (typename SetOfAreasVector::iterator i = pBegin; i != pEnd; ++i) - { - delete *i; - } -} - template void SetsOfAreas::initializeFromStudy(Data::Study& study) { @@ -74,8 +58,7 @@ void SetsOfAreas::initializeFromStudy(Data::Study& study) continue; } - // Instancing a new set of variables of the area - NextType* n = new NextType(); + auto n = std::make_unique(); // Initialize the variables // From the study @@ -90,8 +73,8 @@ void SetsOfAreas::initializeFromStudy(Data::Study& study) // is variable's column(s) printed in output (set of areas) reports ? n->getPrintStatusFromStudy(study); - // Adding the variables for the area in the list - pSetsOfAreas.push_back(n); + pSetsOfAreas.push_back(std::move(n)); + auto* originalSet = &sets[setIndex]; assert(originalSet != NULL); assert(!originalSet->empty()); @@ -99,10 +82,6 @@ void SetsOfAreas::initializeFromStudy(Data::Study& study) pNames.push_back(setname); } - - // Initializing iterators - pBegin = pSetsOfAreas.begin(); - pEnd = pSetsOfAreas.end(); } template @@ -255,12 +234,12 @@ void SetsOfAreas::buildDigest(SurveyResults& results, int digestLevel, in results.data.area = nullptr; results.data.rowIndex = 0; - for (auto i = pBegin; i != pEnd; ++i) + for (auto& set: pSetsOfAreas) { results.data.columnIndex = 0; results.data.rowCaptions[results.data.rowIndex].clear() << "@ " << pNames[results.data.rowIndex]; - (*i)->buildDigest(results, digestLevel, dataLevel); + set->buildDigest(results, digestLevel, dataLevel); ++results.data.rowIndex; } } From ce04ec6a4fc36daf666743766fb32fb48913008e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Omn=C3=A8s?= Date: Mon, 27 Jan 2025 15:02:49 +0100 Subject: [PATCH 05/12] Reserve out vectors to avoid copies and reallocations (#2592) On a vector, `push_back` triggers reallocations and copies/moves if the vector capacity is too small. This degrades performance and can be avoided easily by using `reserve`. --- src/solver/modelConverter/modelConverter.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/solver/modelConverter/modelConverter.cpp b/src/solver/modelConverter/modelConverter.cpp index c946fc1095..d44201fcdc 100644 --- a/src/solver/modelConverter/modelConverter.cpp +++ b/src/solver/modelConverter/modelConverter.cpp @@ -50,6 +50,7 @@ std::vector convertTypes( { // Convert portTypes to Antares::Study::SystemModel::PortType std::vector out; + out.reserve(library.port_types.size()); for (const auto& portType: library.port_types) { std::vector fields; @@ -77,6 +78,7 @@ std::vector convertParameters( { namespace SM = Antares::Study::SystemModel; std::vector parameters; + parameters.reserve(model.parameters.size()); for (const auto& parameter: model.parameters) { parameters.emplace_back(parameter.id, @@ -119,7 +121,7 @@ std::vector convertVariables(const ModelP namespace SM = Antares::Study::SystemModel; std::vector variables; - + variables.reserve(model.variables.size()); for (const auto& variable: model.variables) { SM::Expression lb(variable.lower_bound, @@ -153,6 +155,7 @@ std::vector convertConstraints( const Antares::Solver::ModelParser::Model& model) { std::vector constraints; + constraints.reserve(model.constraints.size()); for (const auto& constraint: model.constraints) { auto nodeRegistry = convertExpressionToNode(constraint.expression, model); @@ -173,6 +176,7 @@ std::vector convertModels( const Antares::Solver::ModelParser::Library& library) { std::vector models; + models.reserve(library.models.size()); for (const auto& model: library.models) { Antares::Study::SystemModel::ModelBuilder modelBuilder; From da7ed4584651ba70d63abd4be601f858276d8b8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Omn=C3=A8s?= Date: Mon, 27 Jan 2025 15:48:54 +0100 Subject: [PATCH 06/12] Remove a few new/delete in src/solver/variable (#2595) - Remove most `new[]` and `delete[]` from output variables - Remove constructor & destructor declarations & definitions (the default constructor is now used) - Make class `IntermediateValues` copyable and assignable, since it is required for `std::vector::resize` Some `new[]` / `delete[]` remain. They are more difficult to remove due to template shenanigans. This is the case for variables with dynamic columns, or spatial agregation. --- .../solver/variable/adequacy/overallCost.h | 9 ++---- .../solver/variable/adequacy/spilledEnergy.h | 9 ++---- .../antares/solver/variable/commons/hydro.h | 5 ++-- .../antares/solver/variable/commons/load.h | 9 ++---- .../variable/commons/miscGenMinusRowPSP.h | 9 ++---- .../antares/solver/variable/commons/psp.h | 9 ++---- .../antares/solver/variable/commons/solar.h | 9 ++---- .../variable/commons/spatial-aggregate.h | 9 ------ .../antares/solver/variable/commons/wind.h | 9 ++---- .../solver/variable/economy/STSbyGroup.h | 28 +++---------------- .../economy/STStorageCashFlowByCluster.h | 25 ++++------------- .../economy/STStorageInjectionByCluster.h | 28 +++---------------- .../economy/STStorageLevelsByCluster.h | 28 +++---------------- .../economy/STStorageWithdrawalByCluster.h | 28 +++---------------- .../economy/avail-dispatchable-generation.h | 9 ++---- .../antares/solver/variable/economy/balance.h | 5 ++-- .../bindingConstraintsMarginalCost.h | 14 ++-------- .../economy/dispatchable-generation-margin.h | 9 ++---- .../economy/domesticUnsuppliedEnergy.h | 9 ++---- .../variable/economy/dtgMarginAfterCsr.h | 9 ++---- .../solver/variable/economy/hydroCost.h | 9 ++---- .../solver/variable/economy/hydrostorage.h | 9 ++---- .../antares/solver/variable/economy/inflow.h | 9 ++---- .../variable/economy/links/congestionFee.h | 9 ++---- .../variable/economy/links/congestionFeeAbs.h | 9 ++---- .../variable/economy/links/flowLinear.h | 9 ++---- .../variable/economy/links/flowLinearAbs.h | 9 ++---- .../variable/economy/links/hurdleCosts.h | 9 ++---- .../variable/economy/links/marginalCost.h | 9 ++---- .../economy/localMatchingRuleViolations.h | 9 ++---- .../antares/solver/variable/economy/lold.h | 9 ++---- .../antares/solver/variable/economy/loldCsr.h | 9 ++---- .../antares/solver/variable/economy/lolp.h | 9 ++---- .../antares/solver/variable/economy/lolpCsr.h | 9 ++---- .../solver/variable/economy/max-mrg-csr.h | 9 ++---- .../antares/solver/variable/economy/max-mrg.h | 9 ++---- .../variable/economy/nbOfDispatchedUnits.h | 9 ++---- .../economy/nbOfDispatchedUnitsByPlant.h | 28 ++++--------------- .../variable/economy/nonProportionalCost.h | 9 ++---- .../economy/npCostByDispatchablePlant.h | 28 ++++--------------- .../solver/variable/economy/operatingCost.h | 9 ++---- .../solver/variable/economy/overallCost.h | 9 ++---- .../solver/variable/economy/overallCostCsr.h | 9 ++---- .../solver/variable/economy/overflow.h | 9 ++---- .../antares/solver/variable/economy/price.h | 9 ++---- .../solver/variable/economy/priceCSR.h | 9 ++---- .../economy/productionByDispatchablePlant.h | 17 +++-------- .../economy/productionByRenewablePlant.h | 24 +++------------- .../solver/variable/economy/profitByPlant.h | 26 ++++------------- .../antares/solver/variable/economy/pumping.h | 9 ++---- .../solver/variable/economy/reservoirlevel.h | 9 ++---- .../solver/variable/economy/spilledEnergy.h | 9 ++---- .../solver/variable/economy/unsupliedEnergy.h | 9 ++---- .../variable/economy/unsupliedEnergyCsr.h | 9 ++---- .../solver/variable/economy/waterValue.h | 9 ++---- .../solver/variable/storage/intermediate.h | 12 -------- 56 files changed, 134 insertions(+), 540 deletions(-) diff --git a/src/solver/variable/include/antares/solver/variable/adequacy/overallCost.h b/src/solver/variable/include/antares/solver/variable/adequacy/overallCost.h index 8d73a400c8..4985aaf6ea 100644 --- a/src/solver/variable/include/antares/solver/variable/adequacy/overallCost.h +++ b/src/solver/variable/include/antares/solver/variable/adequacy/overallCost.h @@ -85,7 +85,7 @@ struct VCardOverallCost static constexpr uint8_t isPossiblyNonApplicable = 0; typedef IntermediateValues IntermediateValuesBaseType; - typedef IntermediateValues* IntermediateValuesType; + typedef std::vector IntermediateValuesType; typedef IntermediateValuesBaseType* IntermediateValuesTypeForSpatialAg; @@ -131,11 +131,6 @@ class OverallCost: public Variable::IVariable, NextT, VCardOv }; public: - ~OverallCost() - { - delete[] pValuesForTheCurrentYear; - } - void initializeFromStudy(Data::Study& study) { pNbYearsParallel = study.maxNbYearsInParallel; @@ -144,7 +139,7 @@ class OverallCost: public Variable::IVariable, NextT, VCardOv InitializeResultsFromStudy(AncestorType::pResults, study); // Intermediate values - pValuesForTheCurrentYear = new VCardType::IntermediateValuesBaseType[pNbYearsParallel]; + pValuesForTheCurrentYear.resize(pNbYearsParallel); for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++) { pValuesForTheCurrentYear[numSpace].initializeFromStudy(study); diff --git a/src/solver/variable/include/antares/solver/variable/adequacy/spilledEnergy.h b/src/solver/variable/include/antares/solver/variable/adequacy/spilledEnergy.h index 7d447e1697..d984454678 100644 --- a/src/solver/variable/include/antares/solver/variable/adequacy/spilledEnergy.h +++ b/src/solver/variable/include/antares/solver/variable/adequacy/spilledEnergy.h @@ -86,7 +86,7 @@ struct VCardSpilledEnergy static constexpr uint8_t isPossiblyNonApplicable = 0; typedef IntermediateValues IntermediateValuesBaseType; - typedef IntermediateValues* IntermediateValuesType; + typedef std::vector IntermediateValuesType; typedef IntermediateValuesBaseType* IntermediateValuesTypeForSpatialAg; @@ -132,11 +132,6 @@ class SpilledEnergy: public Variable::IVariable, NextT, VCa }; public: - ~SpilledEnergy() - { - delete[] pValuesForTheCurrentYear; - } - void initializeFromStudy(Data::Study& study) { pNbYearsParallel = study.maxNbYearsInParallel; @@ -144,7 +139,7 @@ class SpilledEnergy: public Variable::IVariable, NextT, VCa // Intermediate values InitializeResultsFromStudy(AncestorType::pResults, study); - pValuesForTheCurrentYear = new VCardType::IntermediateValuesBaseType[pNbYearsParallel]; + pValuesForTheCurrentYear.resize(pNbYearsParallel); for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++) { pValuesForTheCurrentYear[numSpace].initializeFromStudy(study); diff --git a/src/solver/variable/include/antares/solver/variable/commons/hydro.h b/src/solver/variable/include/antares/solver/variable/commons/hydro.h index 46f45aebf3..eeae4fd017 100644 --- a/src/solver/variable/include/antares/solver/variable/commons/hydro.h +++ b/src/solver/variable/include/antares/solver/variable/commons/hydro.h @@ -86,7 +86,7 @@ struct VCardTimeSeriesValuesHydro static constexpr uint8_t isPossiblyNonApplicable = 0; typedef IntermediateValues IntermediateValuesBaseType; - typedef IntermediateValues* IntermediateValuesType; + typedef std::vector IntermediateValuesType; typedef IntermediateValuesBaseType* IntermediateValuesTypeForSpatialAg; @@ -134,7 +134,6 @@ class TimeSeriesValuesHydro public: ~TimeSeriesValuesHydro() { - delete[] pValuesForTheCurrentYear; delete[] pFatalValues; } @@ -150,7 +149,7 @@ class TimeSeriesValuesHydro InitializeResultsFromStudy(AncestorType::pResults, study); - pValuesForTheCurrentYear = new VCardType::IntermediateValuesBaseType[pNbYearsParallel]; + pValuesForTheCurrentYear.resize(pNbYearsParallel); for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++) { pValuesForTheCurrentYear[numSpace].initializeFromStudy(study); diff --git a/src/solver/variable/include/antares/solver/variable/commons/load.h b/src/solver/variable/include/antares/solver/variable/commons/load.h index 46b7681e55..9bce01a29b 100644 --- a/src/solver/variable/include/antares/solver/variable/commons/load.h +++ b/src/solver/variable/include/antares/solver/variable/commons/load.h @@ -86,7 +86,7 @@ struct VCardTimeSeriesValuesLoad static constexpr uint8_t isPossiblyNonApplicable = 0; typedef IntermediateValues IntermediateValuesBaseType; - typedef IntermediateValues* IntermediateValuesType; + typedef std::vector IntermediateValuesType; typedef IntermediateValuesBaseType* IntermediateValuesTypeForSpatialAg; @@ -132,18 +132,13 @@ class TimeSeriesValuesLoad }; public: - ~TimeSeriesValuesLoad() - { - delete[] pValuesForTheCurrentYear; - } - void initializeFromStudy(Data::Study& study) { pNbYearsParallel = study.maxNbYearsInParallel; InitializeResultsFromStudy(AncestorType::pResults, study); - pValuesForTheCurrentYear = new VCardType::IntermediateValuesBaseType[pNbYearsParallel]; + pValuesForTheCurrentYear.resize(pNbYearsParallel); for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++) { pValuesForTheCurrentYear[numSpace].initializeFromStudy(study); diff --git a/src/solver/variable/include/antares/solver/variable/commons/miscGenMinusRowPSP.h b/src/solver/variable/include/antares/solver/variable/commons/miscGenMinusRowPSP.h index cd7f7d6ba5..08f385011d 100644 --- a/src/solver/variable/include/antares/solver/variable/commons/miscGenMinusRowPSP.h +++ b/src/solver/variable/include/antares/solver/variable/commons/miscGenMinusRowPSP.h @@ -84,7 +84,7 @@ struct VCardMiscGenMinusRowPSP static constexpr uint8_t isPossiblyNonApplicable = 0; typedef IntermediateValues IntermediateValuesBaseType; - typedef IntermediateValues* IntermediateValuesType; + typedef std::vector IntermediateValuesType; typedef IntermediateValuesBaseType* IntermediateValuesTypeForSpatialAg; }; // class VCard @@ -129,11 +129,6 @@ class MiscGenMinusRowPSP }; public: - ~MiscGenMinusRowPSP() - { - delete[] pValuesForTheCurrentYear; - } - void initializeFromStudy(Data::Study& study) { pNbYearsParallel = study.maxNbYearsInParallel; @@ -142,7 +137,7 @@ class MiscGenMinusRowPSP InitializeResultsFromStudy(AncestorType::pResults, study); // Intermediate values - pValuesForTheCurrentYear = new VCardType::IntermediateValuesBaseType[pNbYearsParallel]; + pValuesForTheCurrentYear.resize(pNbYearsParallel); for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++) { pValuesForTheCurrentYear[numSpace].initializeFromStudy(study); diff --git a/src/solver/variable/include/antares/solver/variable/commons/psp.h b/src/solver/variable/include/antares/solver/variable/commons/psp.h index 856a4ac529..da717ac6f1 100644 --- a/src/solver/variable/include/antares/solver/variable/commons/psp.h +++ b/src/solver/variable/include/antares/solver/variable/commons/psp.h @@ -84,7 +84,7 @@ struct VCardPSP static constexpr uint8_t isPossiblyNonApplicable = 0; typedef IntermediateValues IntermediateValuesBaseType; - typedef IntermediateValues* IntermediateValuesType; + typedef std::vector IntermediateValuesType; typedef IntermediateValuesBaseType* IntermediateValuesTypeForSpatialAg; }; // class VCard @@ -128,11 +128,6 @@ class PSP: public Variable::IVariable, NextT, VCardPSP> }; public: - ~PSP() - { - delete[] pValuesForTheCurrentYear; - } - void initializeFromStudy(Data::Study& study) { pNbYearsParallel = study.maxNbYearsInParallel; @@ -141,7 +136,7 @@ class PSP: public Variable::IVariable, NextT, VCardPSP> InitializeResultsFromStudy(AncestorType::pResults, study); // Intermediate values - pValuesForTheCurrentYear = new VCardType::IntermediateValuesBaseType[pNbYearsParallel]; + pValuesForTheCurrentYear.resize(pNbYearsParallel); for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++) { pValuesForTheCurrentYear[numSpace].initializeFromStudy(study); diff --git a/src/solver/variable/include/antares/solver/variable/commons/solar.h b/src/solver/variable/include/antares/solver/variable/commons/solar.h index ad5f6ca679..deaf4acafa 100644 --- a/src/solver/variable/include/antares/solver/variable/commons/solar.h +++ b/src/solver/variable/include/antares/solver/variable/commons/solar.h @@ -86,7 +86,7 @@ struct VCardTimeSeriesValuesSolar static constexpr uint8_t isPossiblyNonApplicable = 0; typedef IntermediateValues IntermediateValuesBaseType; - typedef IntermediateValues* IntermediateValuesType; + typedef std::vector IntermediateValuesType; typedef IntermediateValuesBaseType* IntermediateValuesTypeForSpatialAg; @@ -132,18 +132,13 @@ class TimeSeriesValuesSolar }; public: - ~TimeSeriesValuesSolar() - { - delete[] pValuesForTheCurrentYear; - } - void initializeFromStudy(Data::Study& study) { pNbYearsParallel = study.maxNbYearsInParallel; InitializeResultsFromStudy(AncestorType::pResults, study); - pValuesForTheCurrentYear = new VCardType::IntermediateValuesBaseType[pNbYearsParallel]; + pValuesForTheCurrentYear.resize(pNbYearsParallel); for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++) { pValuesForTheCurrentYear[numSpace].initializeFromStudy(study); diff --git a/src/solver/variable/include/antares/solver/variable/commons/spatial-aggregate.h b/src/solver/variable/include/antares/solver/variable/commons/spatial-aggregate.h index 851dbb9999..e065f1ba96 100644 --- a/src/solver/variable/include/antares/solver/variable/commons/spatial-aggregate.h +++ b/src/solver/variable/include/antares/solver/variable/commons/spatial-aggregate.h @@ -198,15 +198,6 @@ class SpatialAggregate }; public: - SpatialAggregate() - { - } - - ~SpatialAggregate() - { - delete[] pValuesForTheCurrentYear; - } - void initializeFromStudy(Data::Study& study) { typedef diff --git a/src/solver/variable/include/antares/solver/variable/commons/wind.h b/src/solver/variable/include/antares/solver/variable/commons/wind.h index d545311fef..61907fac23 100644 --- a/src/solver/variable/include/antares/solver/variable/commons/wind.h +++ b/src/solver/variable/include/antares/solver/variable/commons/wind.h @@ -86,7 +86,7 @@ struct VCardTimeSeriesValuesWind static constexpr uint8_t isPossiblyNonApplicable = 0; typedef IntermediateValues IntermediateValuesBaseType; - typedef IntermediateValues* IntermediateValuesType; + typedef std::vector IntermediateValuesType; typedef IntermediateValuesBaseType* IntermediateValuesTypeForSpatialAg; @@ -132,18 +132,13 @@ class TimeSeriesValuesWind }; public: - ~TimeSeriesValuesWind() - { - delete[] pValuesForTheCurrentYear; - } - void initializeFromStudy(Data::Study& study) { pNbYearsParallel = study.maxNbYearsInParallel; InitializeResultsFromStudy(AncestorType::pResults, study); - pValuesForTheCurrentYear = new VCardType::IntermediateValuesBaseType[pNbYearsParallel]; + pValuesForTheCurrentYear.resize(pNbYearsParallel); for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++) { pValuesForTheCurrentYear[numSpace].initializeFromStudy(study); diff --git a/src/solver/variable/include/antares/solver/variable/economy/STSbyGroup.h b/src/solver/variable/include/antares/solver/variable/economy/STSbyGroup.h index 5ea9c01af4..dbfc8a16f9 100644 --- a/src/solver/variable/include/antares/solver/variable/economy/STSbyGroup.h +++ b/src/solver/variable/include/antares/solver/variable/economy/STSbyGroup.h @@ -105,8 +105,8 @@ struct VCardSTSbyGroup static constexpr uint8_t isPossiblyNonApplicable = 0; typedef IntermediateValues IntermediateValuesDeepType; - typedef IntermediateValues* IntermediateValuesBaseType; - typedef IntermediateValuesBaseType* IntermediateValuesType; + typedef std::vector IntermediateValuesBaseType; + typedef std::vector IntermediateValuesType; }; // class VCard @@ -157,25 +157,11 @@ class STSbyGroup: public Variable::IVariable, NextT, VCardSTSb }; public: - STSbyGroup(): - pValuesForTheCurrentYear(nullptr) - { - } - - ~STSbyGroup() - { - for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++) - { - delete[] pValuesForTheCurrentYear[numSpace]; - } - delete[] pValuesForTheCurrentYear; - } - void initializeFromArea(Data::Study* study, Data::Area* area) { // Get the number of years in parallel pNbYearsParallel = study->maxNbYearsInParallel; - pValuesForTheCurrentYear = new VCardType::IntermediateValuesBaseType[pNbYearsParallel]; + pValuesForTheCurrentYear.resize(pNbYearsParallel); // Building the vector of group names the clusters belong to. groupNames_ = sortedUniqueGroups(area->shortTermStorage.storagesByIndex); @@ -189,8 +175,7 @@ class STSbyGroup: public Variable::IVariable, NextT, VCardSTSb for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++) { - pValuesForTheCurrentYear[numSpace] = new VCardType::IntermediateValuesDeepType - [nbColumns_]; + pValuesForTheCurrentYear[numSpace].resize(nbColumns_); } for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++) @@ -209,11 +194,6 @@ class STSbyGroup: public Variable::IVariable, NextT, VCardSTSb } else { - for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++) - { - pValuesForTheCurrentYear[numSpace] = nullptr; - } - AncestorType::pResults.clear(); } // Next diff --git a/src/solver/variable/include/antares/solver/variable/economy/STStorageCashFlowByCluster.h b/src/solver/variable/include/antares/solver/variable/economy/STStorageCashFlowByCluster.h index 9893049943..115f091169 100644 --- a/src/solver/variable/include/antares/solver/variable/economy/STStorageCashFlowByCluster.h +++ b/src/solver/variable/include/antares/solver/variable/economy/STStorageCashFlowByCluster.h @@ -75,8 +75,8 @@ struct VCardSTstorageCashFlowByCluster static constexpr uint8_t isPossiblyNonApplicable = 0; typedef IntermediateValues IntermediateValuesDeepType; - typedef IntermediateValues* IntermediateValuesBaseType; - typedef IntermediateValuesBaseType* IntermediateValuesType; + typedef std::vector IntermediateValuesBaseType; + typedef std::vector IntermediateValuesType; }; // class VCard @@ -119,20 +119,11 @@ class STstorageCashFlowByCluster: public Variable::IVariablemaxNbYearsInParallel; - pValuesForTheCurrentYear = new VCardType::IntermediateValuesBaseType[pNbYearsParallel]; + pValuesForTheCurrentYear.resize(pNbYearsParallel); // Get the area nbClusters_ = area->shortTermStorage.count(); @@ -142,8 +133,7 @@ class STstorageCashFlowByCluster: public Variable::IVariable IntermediateValuesBaseType; + typedef std::vector IntermediateValuesType; }; // class VCard @@ -121,25 +121,11 @@ class STstorageInjectionByCluster: public Variable::IVariablemaxNbYearsInParallel; - pValuesForTheCurrentYear = new VCardType::IntermediateValuesBaseType[pNbYearsParallel]; + pValuesForTheCurrentYear.resize(pNbYearsParallel); // Get the area nbClusters_ = area->shortTermStorage.count(); @@ -149,8 +135,7 @@ class STstorageInjectionByCluster: public Variable::IVariable IntermediateValuesBaseType; + typedef std::vector IntermediateValuesType; }; // class VCard @@ -121,25 +121,11 @@ class STstorageLevelsByCluster: public Variable::IVariablemaxNbYearsInParallel; - pValuesForTheCurrentYear = new VCardType::IntermediateValuesBaseType[pNbYearsParallel]; + pValuesForTheCurrentYear.resize(pNbYearsParallel); // Get the area nbClusters_ = area->shortTermStorage.count(); @@ -149,8 +135,7 @@ class STstorageLevelsByCluster: public Variable::IVariable IntermediateValuesBaseType; + typedef std::vector IntermediateValuesType; }; // class VCard @@ -121,25 +121,11 @@ class STstorageWithdrawalByCluster: public Variable::IVariablemaxNbYearsInParallel; - pValuesForTheCurrentYear = new VCardType::IntermediateValuesBaseType[pNbYearsParallel]; + pValuesForTheCurrentYear.resize(pNbYearsParallel); // Get the area nbClusters_ = area->shortTermStorage.count(); @@ -149,8 +135,7 @@ class STstorageWithdrawalByCluster: public Variable::IVariable IntermediateValuesType; typedef IntermediateValuesBaseType* IntermediateValuesTypeForSpatialAg; @@ -132,11 +132,6 @@ class AvailableDispatchGen }; public: - ~AvailableDispatchGen() - { - delete[] pValuesForTheCurrentYear; - } - void initializeFromStudy(Data::Study& study) { pNbYearsParallel = study.maxNbYearsInParallel; @@ -145,7 +140,7 @@ class AvailableDispatchGen InitializeResultsFromStudy(AncestorType::pResults, study); // Intermediate values - pValuesForTheCurrentYear = new VCardType::IntermediateValuesBaseType[pNbYearsParallel]; + pValuesForTheCurrentYear.resize(pNbYearsParallel); for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++) { pValuesForTheCurrentYear[numSpace].initializeFromStudy(study); diff --git a/src/solver/variable/include/antares/solver/variable/economy/balance.h b/src/solver/variable/include/antares/solver/variable/economy/balance.h index 6dda7c7b5c..c903138971 100644 --- a/src/solver/variable/include/antares/solver/variable/economy/balance.h +++ b/src/solver/variable/include/antares/solver/variable/economy/balance.h @@ -86,7 +86,7 @@ struct VCardBalance static constexpr uint8_t isPossiblyNonApplicable = 0; typedef IntermediateValues IntermediateValuesBaseType; - typedef IntermediateValues* IntermediateValuesType; + typedef std::vector IntermediateValuesType; typedef IntermediateValuesBaseType* IntermediateValuesTypeForSpatialAg; @@ -133,7 +133,6 @@ class Balance: public Variable::IVariable, NextT, VCardBalance> public: ~Balance() { - delete[] pValuesForTheCurrentYear; delete[] bilanPays; delete[] pInterco; } @@ -144,7 +143,7 @@ class Balance: public Variable::IVariable, NextT, VCardBalance> InitializeResultsFromStudy(AncestorType::pResults, study); - pValuesForTheCurrentYear = new VCardType::IntermediateValuesBaseType[pNbYearsParallel]; + pValuesForTheCurrentYear.resize(pNbYearsParallel); for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++) { pValuesForTheCurrentYear[numSpace].initializeFromStudy(study); diff --git a/src/solver/variable/include/antares/solver/variable/economy/bindingConstraints/bindingConstraintsMarginalCost.h b/src/solver/variable/include/antares/solver/variable/economy/bindingConstraints/bindingConstraintsMarginalCost.h index 8a1f97676f..9c8f171cb8 100644 --- a/src/solver/variable/include/antares/solver/variable/economy/bindingConstraints/bindingConstraintsMarginalCost.h +++ b/src/solver/variable/include/antares/solver/variable/economy/bindingConstraints/bindingConstraintsMarginalCost.h @@ -79,7 +79,7 @@ struct VCardBindingConstMarginCost static constexpr uint8_t isPossiblyNonApplicable = 1; typedef IntermediateValues IntermediateValuesBaseType; - typedef IntermediateValues* IntermediateValuesType; + typedef std::vector IntermediateValuesType; }; // class VCard @@ -129,14 +129,6 @@ class BindingConstMarginCost public: BindingConstMarginCost() = default; - ~BindingConstMarginCost() - { - if (pValuesForTheCurrentYear) - { - delete[] pValuesForTheCurrentYear; - } - } - void simulationBegin() { NextType::simulationBegin(); @@ -155,7 +147,7 @@ class BindingConstMarginCost InitializeResultsFromStudy(AncestorType::pResults, study); // Intermediate values - pValuesForTheCurrentYear = new VCardType::IntermediateValuesBaseType[pNbYearsParallel]; + pValuesForTheCurrentYear.resize(pNbYearsParallel); for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++) { pValuesForTheCurrentYear[numSpace].initializeFromStudy(study); @@ -469,7 +461,7 @@ class BindingConstMarginCost // Private data mambers // ---------------------- //! Intermediate values for each year - typename VCardType::IntermediateValuesType pValuesForTheCurrentYear = nullptr; + typename VCardType::IntermediateValuesType pValuesForTheCurrentYear; unsigned int pNbYearsParallel = 0; std::shared_ptr associatedBC_ = nullptr; uint nbCount_ = 0; // Number of inequality BCs diff --git a/src/solver/variable/include/antares/solver/variable/economy/dispatchable-generation-margin.h b/src/solver/variable/include/antares/solver/variable/economy/dispatchable-generation-margin.h index 76b2b5418a..26ec57ebe0 100644 --- a/src/solver/variable/include/antares/solver/variable/economy/dispatchable-generation-margin.h +++ b/src/solver/variable/include/antares/solver/variable/economy/dispatchable-generation-margin.h @@ -87,7 +87,7 @@ struct VCardDispatchableGenMargin static constexpr uint8_t isPossiblyNonApplicable = 0; typedef IntermediateValues IntermediateValuesBaseType; - typedef IntermediateValues* IntermediateValuesType; + typedef std::vector IntermediateValuesType; typedef IntermediateValuesBaseType* IntermediateValuesTypeForSpatialAg; @@ -133,11 +133,6 @@ class DispatchableGenMargin }; public: - ~DispatchableGenMargin() - { - delete[] pValuesForTheCurrentYear; - } - void initializeFromStudy(Data::Study& study) { pNbYearsParallel = study.maxNbYearsInParallel; @@ -146,7 +141,7 @@ class DispatchableGenMargin InitializeResultsFromStudy(AncestorType::pResults, study); // Intermediate values - pValuesForTheCurrentYear = new VCardType::IntermediateValuesBaseType[pNbYearsParallel]; + pValuesForTheCurrentYear.resize(pNbYearsParallel); for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++) { pValuesForTheCurrentYear[numSpace].initializeFromStudy(study); diff --git a/src/solver/variable/include/antares/solver/variable/economy/domesticUnsuppliedEnergy.h b/src/solver/variable/include/antares/solver/variable/economy/domesticUnsuppliedEnergy.h index ab73f1a2b2..b27495ac65 100644 --- a/src/solver/variable/include/antares/solver/variable/economy/domesticUnsuppliedEnergy.h +++ b/src/solver/variable/include/antares/solver/variable/economy/domesticUnsuppliedEnergy.h @@ -87,7 +87,7 @@ struct VCardDomesticUnsuppliedEnergy static constexpr uint8_t isPossiblyNonApplicable = 0; typedef IntermediateValues IntermediateValuesBaseType; - typedef IntermediateValues* IntermediateValuesType; + typedef std::vector IntermediateValuesType; typedef IntermediateValuesBaseType* IntermediateValuesTypeForSpatialAg; @@ -135,11 +135,6 @@ class DomesticUnsuppliedEnergy: public Variable::IVariable IntermediateValuesType; typedef IntermediateValuesBaseType* IntermediateValuesTypeForSpatialAg; @@ -125,11 +125,6 @@ class DtgMarginCsr: public Variable::IVariable, NextT, VCard }; }; - ~DtgMarginCsr() - { - delete[] pValuesForTheCurrentYear; - } - void initializeFromStudy(Data::Study& study) { pNbYearsParallel = study.maxNbYearsInParallel; @@ -137,7 +132,7 @@ class DtgMarginCsr: public Variable::IVariable, NextT, VCard // Intermediate values InitializeResultsFromStudy(AncestorType::pResults, study); - pValuesForTheCurrentYear = new VCardType::IntermediateValuesBaseType[pNbYearsParallel]; + pValuesForTheCurrentYear.resize(pNbYearsParallel); for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++) { pValuesForTheCurrentYear[numSpace].initializeFromStudy(study); diff --git a/src/solver/variable/include/antares/solver/variable/economy/hydroCost.h b/src/solver/variable/include/antares/solver/variable/economy/hydroCost.h index 1edf42e14f..66b313600b 100644 --- a/src/solver/variable/include/antares/solver/variable/economy/hydroCost.h +++ b/src/solver/variable/include/antares/solver/variable/economy/hydroCost.h @@ -88,7 +88,7 @@ struct VCardHydroCost static constexpr uint8_t isPossiblyNonApplicable = 0; typedef IntermediateValues IntermediateValuesBaseType; - typedef IntermediateValues* IntermediateValuesType; + typedef std::vector IntermediateValuesType; typedef IntermediateValuesBaseType* IntermediateValuesTypeForSpatialAg; @@ -133,18 +133,13 @@ class HydroCost: public Variable::IVariable, NextT, VCardHydroC }; public: - ~HydroCost() - { - delete[] pValuesForTheCurrentYear; - } - void initializeFromStudy(Data::Study& study) { pNbYearsParallel = study.maxNbYearsInParallel; InitializeResultsFromStudy(AncestorType::pResults, study); - pValuesForTheCurrentYear = new VCardType::IntermediateValuesBaseType[pNbYearsParallel]; + pValuesForTheCurrentYear.resize(pNbYearsParallel); for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++) { pValuesForTheCurrentYear[numSpace].initializeFromStudy(study); diff --git a/src/solver/variable/include/antares/solver/variable/economy/hydrostorage.h b/src/solver/variable/include/antares/solver/variable/economy/hydrostorage.h index be56b970b6..aa92462fa8 100644 --- a/src/solver/variable/include/antares/solver/variable/economy/hydrostorage.h +++ b/src/solver/variable/include/antares/solver/variable/economy/hydrostorage.h @@ -86,7 +86,7 @@ struct VCardHydroStorage static constexpr uint8_t isPossiblyNonApplicable = 0; typedef IntermediateValues IntermediateValuesBaseType; - typedef IntermediateValues* IntermediateValuesType; + typedef std::vector IntermediateValuesType; typedef IntermediateValuesBaseType* IntermediateValuesTypeForSpatialAg; @@ -132,18 +132,13 @@ class HydroStorage: public Variable::IVariable, NextT, VCard }; public: - ~HydroStorage() - { - delete[] pValuesForTheCurrentYear; - } - void initializeFromStudy(Data::Study& study) { pNbYearsParallel = study.maxNbYearsInParallel; InitializeResultsFromStudy(AncestorType::pResults, study); - pValuesForTheCurrentYear = new VCardType::IntermediateValuesBaseType[pNbYearsParallel]; + pValuesForTheCurrentYear.resize(pNbYearsParallel); for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++) { pValuesForTheCurrentYear[numSpace].initializeFromStudy(study); diff --git a/src/solver/variable/include/antares/solver/variable/economy/inflow.h b/src/solver/variable/include/antares/solver/variable/economy/inflow.h index 136bd8410e..cb843c0fe9 100644 --- a/src/solver/variable/include/antares/solver/variable/economy/inflow.h +++ b/src/solver/variable/include/antares/solver/variable/economy/inflow.h @@ -86,7 +86,7 @@ struct VCardInflows static constexpr uint8_t isPossiblyNonApplicable = 0; typedef IntermediateValues IntermediateValuesBaseType; - typedef IntermediateValues* IntermediateValuesType; + typedef std::vector IntermediateValuesType; typedef IntermediateValuesBaseType* IntermediateValuesTypeForSpatialAg; @@ -131,18 +131,13 @@ class Inflows: public Variable::IVariable, NextT, VCardInflows> }; public: - ~Inflows() - { - delete[] pValuesForTheCurrentYear; - } - void initializeFromStudy(Data::Study& study) { pNbYearsParallel = study.maxNbYearsInParallel; InitializeResultsFromStudy(AncestorType::pResults, study); - pValuesForTheCurrentYear = new VCardType::IntermediateValuesBaseType[pNbYearsParallel]; + pValuesForTheCurrentYear.resize(pNbYearsParallel); for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++) { pValuesForTheCurrentYear[numSpace].initializeFromStudy(study); diff --git a/src/solver/variable/include/antares/solver/variable/economy/links/congestionFee.h b/src/solver/variable/include/antares/solver/variable/economy/links/congestionFee.h index 6e2c2200d0..81a0c960d0 100644 --- a/src/solver/variable/include/antares/solver/variable/economy/links/congestionFee.h +++ b/src/solver/variable/include/antares/solver/variable/economy/links/congestionFee.h @@ -83,7 +83,7 @@ struct VCardCongestionFee static constexpr uint8_t isPossiblyNonApplicable = 0; typedef IntermediateValues IntermediateValuesBaseType; - typedef IntermediateValues* IntermediateValuesType; + typedef std::vector IntermediateValuesType; }; // class VCard @@ -126,11 +126,6 @@ class CongestionFee: public Variable::IVariable, NextT, VCa }; public: - ~CongestionFee() - { - delete[] pValuesForTheCurrentYear; - } - void initializeFromStudy(Data::Study& study) { pNbYearsParallel = study.maxNbYearsInParallel; @@ -140,7 +135,7 @@ class CongestionFee: public Variable::IVariable, NextT, VCa AncestorType::pResults.reset(); // Intermediate values - pValuesForTheCurrentYear = new VCardType::IntermediateValuesBaseType[pNbYearsParallel]; + pValuesForTheCurrentYear.resize(pNbYearsParallel); for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++) { pValuesForTheCurrentYear[numSpace].initializeFromStudy(study); diff --git a/src/solver/variable/include/antares/solver/variable/economy/links/congestionFeeAbs.h b/src/solver/variable/include/antares/solver/variable/economy/links/congestionFeeAbs.h index d6468f5e88..91312298e1 100644 --- a/src/solver/variable/include/antares/solver/variable/economy/links/congestionFeeAbs.h +++ b/src/solver/variable/include/antares/solver/variable/economy/links/congestionFeeAbs.h @@ -85,7 +85,7 @@ struct VCardCongestionFeeAbs static constexpr uint8_t isPossiblyNonApplicable = 0; typedef IntermediateValues IntermediateValuesBaseType; - typedef IntermediateValues* IntermediateValuesType; + typedef std::vector IntermediateValuesType; }; // class VCard @@ -129,11 +129,6 @@ class CongestionFeeAbs }; public: - ~CongestionFeeAbs() - { - delete[] pValuesForTheCurrentYear; - } - void initializeFromStudy(Data::Study& study) { pNbYearsParallel = study.maxNbYearsInParallel; @@ -143,7 +138,7 @@ class CongestionFeeAbs AncestorType::pResults.reset(); // Intermediate values - pValuesForTheCurrentYear = new VCardType::IntermediateValuesBaseType[pNbYearsParallel]; + pValuesForTheCurrentYear.resize(pNbYearsParallel); for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++) { pValuesForTheCurrentYear[numSpace].initializeFromStudy(study); diff --git a/src/solver/variable/include/antares/solver/variable/economy/links/flowLinear.h b/src/solver/variable/include/antares/solver/variable/economy/links/flowLinear.h index 5d89ae75cd..47269cf3c0 100644 --- a/src/solver/variable/include/antares/solver/variable/economy/links/flowLinear.h +++ b/src/solver/variable/include/antares/solver/variable/economy/links/flowLinear.h @@ -83,7 +83,7 @@ struct VCardFlowLinear static constexpr uint8_t isPossiblyNonApplicable = 0; typedef IntermediateValues IntermediateValuesBaseType; - typedef IntermediateValues* IntermediateValuesType; + typedef std::vector IntermediateValuesType; }; // class VCard @@ -126,11 +126,6 @@ class FlowLinear: public Variable::IVariable, NextT, VCardFlow }; public: - ~FlowLinear() - { - delete[] pValuesForTheCurrentYear; - } - void initializeFromStudy(Data::Study& study) { pNbYearsParallel = study.maxNbYearsInParallel; @@ -140,7 +135,7 @@ class FlowLinear: public Variable::IVariable, NextT, VCardFlow AncestorType::pResults.reset(); // Intermediate values - pValuesForTheCurrentYear = new VCardType::IntermediateValuesBaseType[pNbYearsParallel]; + pValuesForTheCurrentYear.resize(pNbYearsParallel); for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++) { pValuesForTheCurrentYear[numSpace].initializeFromStudy(study); diff --git a/src/solver/variable/include/antares/solver/variable/economy/links/flowLinearAbs.h b/src/solver/variable/include/antares/solver/variable/economy/links/flowLinearAbs.h index c7ca4ba60e..664b51b459 100644 --- a/src/solver/variable/include/antares/solver/variable/economy/links/flowLinearAbs.h +++ b/src/solver/variable/include/antares/solver/variable/economy/links/flowLinearAbs.h @@ -85,7 +85,7 @@ struct VCardFlowLinearAbs static constexpr uint8_t isPossiblyNonApplicable = 0; typedef IntermediateValues IntermediateValuesBaseType; - typedef IntermediateValues* IntermediateValuesType; + typedef std::vector IntermediateValuesType; }; // class VCard @@ -128,11 +128,6 @@ class FlowLinearAbs: public Variable::IVariable, NextT, VCa }; public: - ~FlowLinearAbs() - { - delete[] pValuesForTheCurrentYear; - } - void initializeFromStudy(Data::Study& study) { pNbYearsParallel = study.maxNbYearsInParallel; @@ -142,7 +137,7 @@ class FlowLinearAbs: public Variable::IVariable, NextT, VCa AncestorType::pResults.reset(); // Intermediate values - pValuesForTheCurrentYear = new VCardType::IntermediateValuesBaseType[pNbYearsParallel]; + pValuesForTheCurrentYear.resize(pNbYearsParallel); for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++) { pValuesForTheCurrentYear[numSpace].initializeFromStudy(study); diff --git a/src/solver/variable/include/antares/solver/variable/economy/links/hurdleCosts.h b/src/solver/variable/include/antares/solver/variable/economy/links/hurdleCosts.h index a4b1c0c4de..c70791c1b9 100644 --- a/src/solver/variable/include/antares/solver/variable/economy/links/hurdleCosts.h +++ b/src/solver/variable/include/antares/solver/variable/economy/links/hurdleCosts.h @@ -83,7 +83,7 @@ struct VCardHurdleCosts static constexpr uint8_t isPossiblyNonApplicable = 0; typedef IntermediateValues IntermediateValuesBaseType; - typedef IntermediateValues* IntermediateValuesType; + typedef std::vector IntermediateValuesType; }; // class VCard @@ -126,11 +126,6 @@ class HurdleCosts: public Variable::IVariable, NextT, VCardHu }; public: - ~HurdleCosts() - { - delete[] pValuesForTheCurrentYear; - } - void initializeFromStudy(Data::Study& study) { pNbYearsParallel = study.maxNbYearsInParallel; @@ -140,7 +135,7 @@ class HurdleCosts: public Variable::IVariable, NextT, VCardHu AncestorType::pResults.reset(); // Intermediate values - pValuesForTheCurrentYear = new VCardType::IntermediateValuesBaseType[pNbYearsParallel]; + pValuesForTheCurrentYear.resize(pNbYearsParallel); for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++) { pValuesForTheCurrentYear[numSpace].initializeFromStudy(study); diff --git a/src/solver/variable/include/antares/solver/variable/economy/links/marginalCost.h b/src/solver/variable/include/antares/solver/variable/economy/links/marginalCost.h index 0b267870a3..6e4192e73d 100644 --- a/src/solver/variable/include/antares/solver/variable/economy/links/marginalCost.h +++ b/src/solver/variable/include/antares/solver/variable/economy/links/marginalCost.h @@ -85,7 +85,7 @@ struct VCardMarginalCost static constexpr uint8_t isPossiblyNonApplicable = 0; typedef IntermediateValues IntermediateValuesBaseType; - typedef IntermediateValues* IntermediateValuesType; + typedef std::vector IntermediateValuesType; }; // class VCard @@ -128,11 +128,6 @@ class MarginalCost: public Variable::IVariable, NextT, VCard }; public: - ~MarginalCost() - { - delete[] pValuesForTheCurrentYear; - } - void initializeFromStudy(Data::Study& study) { pNbYearsParallel = study.maxNbYearsInParallel; @@ -142,7 +137,7 @@ class MarginalCost: public Variable::IVariable, NextT, VCard AncestorType::pResults.reset(); // Intermediate values - pValuesForTheCurrentYear = new VCardType::IntermediateValuesBaseType[pNbYearsParallel]; + pValuesForTheCurrentYear.resize(pNbYearsParallel); for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++) { pValuesForTheCurrentYear[numSpace].initializeFromStudy(study); diff --git a/src/solver/variable/include/antares/solver/variable/economy/localMatchingRuleViolations.h b/src/solver/variable/include/antares/solver/variable/economy/localMatchingRuleViolations.h index 868588f271..896a97dc26 100644 --- a/src/solver/variable/include/antares/solver/variable/economy/localMatchingRuleViolations.h +++ b/src/solver/variable/include/antares/solver/variable/economy/localMatchingRuleViolations.h @@ -77,7 +77,7 @@ struct VCardLMRViolations static constexpr uint8_t isPossiblyNonApplicable = 0; typedef IntermediateValues IntermediateValuesBaseType; - typedef IntermediateValues* IntermediateValuesType; + typedef std::vector IntermediateValuesType; typedef IntermediateValuesBaseType* IntermediateValuesTypeForSpatialAg; @@ -122,11 +122,6 @@ class LMRViolations: public Variable::IVariable, NextT, VCa }; }; - ~LMRViolations() - { - delete[] pValuesForTheCurrentYear; - } - void initializeFromStudy(Data::Study& study) { pNbYearsParallel = study.maxNbYearsInParallel; @@ -134,7 +129,7 @@ class LMRViolations: public Variable::IVariable, NextT, VCa // Intermediate values InitializeResultsFromStudy(AncestorType::pResults, study); - pValuesForTheCurrentYear = new VCardType::IntermediateValuesBaseType[pNbYearsParallel]; + pValuesForTheCurrentYear.resize(pNbYearsParallel); for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++) { pValuesForTheCurrentYear[numSpace].initializeFromStudy(study); diff --git a/src/solver/variable/include/antares/solver/variable/economy/lold.h b/src/solver/variable/include/antares/solver/variable/economy/lold.h index 875408a060..394cf0adab 100644 --- a/src/solver/variable/include/antares/solver/variable/economy/lold.h +++ b/src/solver/variable/include/antares/solver/variable/economy/lold.h @@ -87,7 +87,7 @@ struct VCardLOLD static constexpr uint8_t isPossiblyNonApplicable = 0; typedef IntermediateValues IntermediateValuesBaseType; - typedef IntermediateValues* IntermediateValuesType; + typedef std::vector IntermediateValuesType; typedef IntermediateValuesBaseType* IntermediateValuesTypeForSpatialAg; @@ -132,11 +132,6 @@ class LOLD: public Variable::IVariable, NextT, VCardLOLD> }; public: - ~LOLD() - { - delete[] pValuesForTheCurrentYear; - } - void initializeFromStudy(Data::Study& study) { pNbYearsParallel = study.maxNbYearsInParallel; @@ -144,7 +139,7 @@ class LOLD: public Variable::IVariable, NextT, VCardLOLD> // Intermediate values InitializeResultsFromStudy(AncestorType::pResults, study); - pValuesForTheCurrentYear = new VCardType::IntermediateValuesBaseType[pNbYearsParallel]; + pValuesForTheCurrentYear.resize(pNbYearsParallel); for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++) { pValuesForTheCurrentYear[numSpace].initializeFromStudy(study); diff --git a/src/solver/variable/include/antares/solver/variable/economy/loldCsr.h b/src/solver/variable/include/antares/solver/variable/economy/loldCsr.h index 299e83b94f..c752a90a21 100644 --- a/src/solver/variable/include/antares/solver/variable/economy/loldCsr.h +++ b/src/solver/variable/include/antares/solver/variable/economy/loldCsr.h @@ -82,7 +82,7 @@ struct VCardLOLD_CSR static constexpr uint8_t isPossiblyNonApplicable = 0; typedef IntermediateValues IntermediateValuesBaseType; - typedef IntermediateValues* IntermediateValuesType; + typedef std::vector IntermediateValuesType; typedef IntermediateValuesBaseType* IntermediateValuesTypeForSpatialAg; @@ -127,11 +127,6 @@ class LOLD_CSR: public Variable::IVariable, NextT, VCardLOLD_CSR }; public: - ~LOLD_CSR() - { - delete[] pValuesForTheCurrentYear; - } - void initializeFromStudy(Data::Study& study) { pNbYearsParallel = study.maxNbYearsInParallel; @@ -139,7 +134,7 @@ class LOLD_CSR: public Variable::IVariable, NextT, VCardLOLD_CSR // Intermediate values InitializeResultsFromStudy(AncestorType::pResults, study); - pValuesForTheCurrentYear = new VCardType::IntermediateValuesBaseType[pNbYearsParallel]; + pValuesForTheCurrentYear.resize(pNbYearsParallel); for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++) { pValuesForTheCurrentYear[numSpace].initializeFromStudy(study); diff --git a/src/solver/variable/include/antares/solver/variable/economy/lolp.h b/src/solver/variable/include/antares/solver/variable/economy/lolp.h index 95602b0030..9a2c80c352 100644 --- a/src/solver/variable/include/antares/solver/variable/economy/lolp.h +++ b/src/solver/variable/include/antares/solver/variable/economy/lolp.h @@ -83,7 +83,7 @@ struct VCardLOLP static constexpr uint8_t isPossiblyNonApplicable = 0; typedef IntermediateValues IntermediateValuesBaseType; - typedef IntermediateValues* IntermediateValuesType; + typedef std::vector IntermediateValuesType; typedef IntermediateValuesBaseType* IntermediateValuesTypeForSpatialAg; @@ -128,11 +128,6 @@ class LOLP: public Variable::IVariable, NextT, VCardLOLP> }; public: - ~LOLP() - { - delete[] pValuesForTheCurrentYear; - } - void initializeFromStudy(Data::Study& study) { pNbYearsParallel = study.maxNbYearsInParallel; @@ -140,7 +135,7 @@ class LOLP: public Variable::IVariable, NextT, VCardLOLP> // Intermediate values InitializeResultsFromStudy(AncestorType::pResults, study); - pValuesForTheCurrentYear = new VCardType::IntermediateValuesBaseType[pNbYearsParallel]; + pValuesForTheCurrentYear.resize(pNbYearsParallel); for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++) { pValuesForTheCurrentYear[numSpace].initializeFromStudy(study); diff --git a/src/solver/variable/include/antares/solver/variable/economy/lolpCsr.h b/src/solver/variable/include/antares/solver/variable/economy/lolpCsr.h index 45d9ed61ac..cabf88b6ad 100644 --- a/src/solver/variable/include/antares/solver/variable/economy/lolpCsr.h +++ b/src/solver/variable/include/antares/solver/variable/economy/lolpCsr.h @@ -81,7 +81,7 @@ struct VCardLOLP_CSR static constexpr uint8_t isPossiblyNonApplicable = 0; typedef IntermediateValues IntermediateValuesBaseType; - typedef IntermediateValues* IntermediateValuesType; + typedef std::vector IntermediateValuesType; typedef IntermediateValuesBaseType* IntermediateValuesTypeForSpatialAg; @@ -126,11 +126,6 @@ class LOLP_CSR: public Variable::IVariable, NextT, VCardLOLP_CSR }; public: - ~LOLP_CSR() - { - delete[] pValuesForTheCurrentYear; - } - void initializeFromStudy(Data::Study& study) { pNbYearsParallel = study.maxNbYearsInParallel; @@ -138,7 +133,7 @@ class LOLP_CSR: public Variable::IVariable, NextT, VCardLOLP_CSR // Intermediate values InitializeResultsFromStudy(AncestorType::pResults, study); - pValuesForTheCurrentYear = new VCardType::IntermediateValuesBaseType[pNbYearsParallel]; + pValuesForTheCurrentYear.resize(pNbYearsParallel); for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++) { pValuesForTheCurrentYear[numSpace].initializeFromStudy(study); diff --git a/src/solver/variable/include/antares/solver/variable/economy/max-mrg-csr.h b/src/solver/variable/include/antares/solver/variable/economy/max-mrg-csr.h index 2ff8edc89d..fe2d001c87 100644 --- a/src/solver/variable/include/antares/solver/variable/economy/max-mrg-csr.h +++ b/src/solver/variable/include/antares/solver/variable/economy/max-mrg-csr.h @@ -85,7 +85,7 @@ struct VCardMAX_MRG_CSR static constexpr uint8_t isPossiblyNonApplicable = 0; typedef IntermediateValues IntermediateValuesBaseType; - typedef IntermediateValues* IntermediateValuesType; + typedef std::vector IntermediateValuesType; typedef IntermediateValuesBaseType* IntermediateValuesTypeForSpatialAg; @@ -136,11 +136,6 @@ class MaxMrgCsr: public Variable::IVariable, NextT, VCardMAX_MR }; public: - ~MaxMrgCsr() - { - delete[] pValuesForTheCurrentYear; - } - void initializeFromStudy(Data::Study& study) { pNbYearsParallel = study.maxNbYearsInParallel; @@ -148,7 +143,7 @@ class MaxMrgCsr: public Variable::IVariable, NextT, VCardMAX_MR // Intermediate values InitializeResultsFromStudy(AncestorType::pResults, study); - pValuesForTheCurrentYear = new VCardType::IntermediateValuesBaseType[pNbYearsParallel]; + pValuesForTheCurrentYear.resize(pNbYearsParallel); for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++) { pValuesForTheCurrentYear[numSpace].initializeFromStudy(study); diff --git a/src/solver/variable/include/antares/solver/variable/economy/max-mrg.h b/src/solver/variable/include/antares/solver/variable/economy/max-mrg.h index a53b893947..8cf83bc740 100644 --- a/src/solver/variable/include/antares/solver/variable/economy/max-mrg.h +++ b/src/solver/variable/include/antares/solver/variable/economy/max-mrg.h @@ -88,7 +88,7 @@ struct VCardMARGE static constexpr uint8_t isPossiblyNonApplicable = 0; typedef IntermediateValues IntermediateValuesBaseType; - typedef IntermediateValues* IntermediateValuesType; + typedef std::vector IntermediateValuesType; typedef IntermediateValuesBaseType* IntermediateValuesTypeForSpatialAg; @@ -133,11 +133,6 @@ class Marge: public Variable::IVariable, NextT, VCardMARGE> }; public: - ~Marge() - { - delete[] pValuesForTheCurrentYear; - } - void initializeFromStudy(Data::Study& study) { pNbYearsParallel = study.maxNbYearsInParallel; @@ -145,7 +140,7 @@ class Marge: public Variable::IVariable, NextT, VCardMARGE> // Intermediate values InitializeResultsFromStudy(AncestorType::pResults, study); - pValuesForTheCurrentYear = new VCardType::IntermediateValuesBaseType[pNbYearsParallel]; + pValuesForTheCurrentYear.resize(pNbYearsParallel); for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++) { pValuesForTheCurrentYear[numSpace].initializeFromStudy(study); diff --git a/src/solver/variable/include/antares/solver/variable/economy/nbOfDispatchedUnits.h b/src/solver/variable/include/antares/solver/variable/economy/nbOfDispatchedUnits.h index 173343f61f..01904bf7e8 100644 --- a/src/solver/variable/include/antares/solver/variable/economy/nbOfDispatchedUnits.h +++ b/src/solver/variable/include/antares/solver/variable/economy/nbOfDispatchedUnits.h @@ -90,7 +90,7 @@ struct VCardNbOfDispatchedUnits static constexpr uint8_t isPossiblyNonApplicable = 0; typedef IntermediateValues IntermediateValuesBaseType; - typedef IntermediateValues* IntermediateValuesType; + typedef std::vector IntermediateValuesType; typedef IntermediateValuesBaseType* IntermediateValuesTypeForSpatialAg; @@ -137,18 +137,13 @@ class NbOfDispatchedUnits }; public: - ~NbOfDispatchedUnits() - { - delete[] pValuesForTheCurrentYear; - } - void initializeFromStudy(Data::Study& study) { pNbYearsParallel = study.maxNbYearsInParallel; InitializeResultsFromStudy(AncestorType::pResults, study); - pValuesForTheCurrentYear = new VCardType::IntermediateValuesBaseType[pNbYearsParallel]; + pValuesForTheCurrentYear.resize(pNbYearsParallel); for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++) { pValuesForTheCurrentYear[numSpace].initializeFromStudy(study); diff --git a/src/solver/variable/include/antares/solver/variable/economy/nbOfDispatchedUnitsByPlant.h b/src/solver/variable/include/antares/solver/variable/economy/nbOfDispatchedUnitsByPlant.h index ed570bca43..6a54c40945 100644 --- a/src/solver/variable/include/antares/solver/variable/economy/nbOfDispatchedUnitsByPlant.h +++ b/src/solver/variable/include/antares/solver/variable/economy/nbOfDispatchedUnitsByPlant.h @@ -82,10 +82,8 @@ struct VCardNbOfDispatchedUnitsByPlant static constexpr uint8_t isPossiblyNonApplicable = 0; typedef IntermediateValues IntermediateValuesDeepType; - typedef IntermediateValues* IntermediateValuesBaseType; - typedef IntermediateValuesBaseType* IntermediateValuesType; - - // typedef IntermediateValues IntermediateValuesType; + typedef std::vector IntermediateValuesBaseType; + typedef std::vector IntermediateValuesType; }; // class VCard @@ -132,20 +130,10 @@ class NbOfDispatchedUnitsByPlant: public Variable::IVariablemaxNbYearsInParallel; - pValuesForTheCurrentYear = new VCardType::IntermediateValuesBaseType[pNbYearsParallel]; + pValuesForTheCurrentYear.resize(pNbYearsParallel); // Get the area pSize = area->thermal.list.enabledCount(); @@ -164,8 +152,7 @@ class NbOfDispatchedUnitsByPlant: public Variable::IVariablehour; + return pValuesForTheCurrentYear[numSpace][0].hour; } void localBuildAnnualSurveyReport(SurveyResults& results, diff --git a/src/solver/variable/include/antares/solver/variable/economy/nonProportionalCost.h b/src/solver/variable/include/antares/solver/variable/economy/nonProportionalCost.h index 8d26594739..e308ce15b8 100644 --- a/src/solver/variable/include/antares/solver/variable/economy/nonProportionalCost.h +++ b/src/solver/variable/include/antares/solver/variable/economy/nonProportionalCost.h @@ -90,7 +90,7 @@ struct VCardNonProportionalCost static constexpr uint8_t isPossiblyNonApplicable = 0; typedef IntermediateValues IntermediateValuesBaseType; - typedef IntermediateValues* IntermediateValuesType; + typedef std::vector IntermediateValuesType; typedef IntermediateValuesBaseType* IntermediateValuesTypeForSpatialAg; @@ -137,18 +137,13 @@ class NonProportionalCost }; public: - ~NonProportionalCost() - { - delete[] pValuesForTheCurrentYear; - } - void initializeFromStudy(Data::Study& study) { pNbYearsParallel = study.maxNbYearsInParallel; InitializeResultsFromStudy(AncestorType::pResults, study); - pValuesForTheCurrentYear = new VCardType::IntermediateValuesBaseType[pNbYearsParallel]; + pValuesForTheCurrentYear.resize(pNbYearsParallel); for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++) { pValuesForTheCurrentYear[numSpace].initializeFromStudy(study); diff --git a/src/solver/variable/include/antares/solver/variable/economy/npCostByDispatchablePlant.h b/src/solver/variable/include/antares/solver/variable/economy/npCostByDispatchablePlant.h index 2a9b806664..128f7b9a55 100644 --- a/src/solver/variable/include/antares/solver/variable/economy/npCostByDispatchablePlant.h +++ b/src/solver/variable/include/antares/solver/variable/economy/npCostByDispatchablePlant.h @@ -82,10 +82,10 @@ struct VCardNonProportionalCostByDispatchablePlant static constexpr uint8_t isPossiblyNonApplicable = 0; typedef IntermediateValues IntermediateValuesDeepType; - typedef IntermediateValues* IntermediateValuesBaseType; - typedef IntermediateValuesBaseType* IntermediateValuesType; + typedef std::vector IntermediateValuesBaseType; + typedef std::vector IntermediateValuesType; - // typedef IntermediateValues IntermediateValuesType; + // typedef std::vector IntermediateValuesType; }; // class VCard @@ -134,20 +134,10 @@ class NonProportionalCostByDispatchablePlant public: NonProportionalCostByDispatchablePlant(): - pValuesForTheCurrentYear(NULL), pSize(0) { } - ~NonProportionalCostByDispatchablePlant() - { - for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++) - { - delete[] pValuesForTheCurrentYear[numSpace]; - } - delete[] pValuesForTheCurrentYear; - } - void initializeFromStudy(Data::Study& study) { // Next @@ -158,7 +148,7 @@ class NonProportionalCostByDispatchablePlant { // Get the number of years in parallel pNbYearsParallel = study->maxNbYearsInParallel; - pValuesForTheCurrentYear = new VCardType::IntermediateValuesBaseType[pNbYearsParallel]; + pValuesForTheCurrentYear.resize(pNbYearsParallel); // Get the area pSize = area->thermal.list.enabledCount(); @@ -167,8 +157,7 @@ class NonProportionalCostByDispatchablePlant AncestorType::pResults.resize(pSize); for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++) { - pValuesForTheCurrentYear[numSpace] = new VCardType::IntermediateValuesDeepType - [pSize]; + pValuesForTheCurrentYear[numSpace].resize(pSize); } for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++) @@ -187,11 +176,6 @@ class NonProportionalCostByDispatchablePlant } else { - for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++) - { - pValuesForTheCurrentYear[numSpace] = nullptr; - } - AncestorType::pResults.clear(); } @@ -301,7 +285,7 @@ class NonProportionalCostByDispatchablePlant unsigned int, unsigned int numSpace) const { - return pValuesForTheCurrentYear[numSpace]->hour; + return pValuesForTheCurrentYear[numSpace][0].hour; } void localBuildAnnualSurveyReport(SurveyResults& results, diff --git a/src/solver/variable/include/antares/solver/variable/economy/operatingCost.h b/src/solver/variable/include/antares/solver/variable/economy/operatingCost.h index df95f6d65c..a39e506345 100644 --- a/src/solver/variable/include/antares/solver/variable/economy/operatingCost.h +++ b/src/solver/variable/include/antares/solver/variable/economy/operatingCost.h @@ -89,7 +89,7 @@ struct VCardOperatingCost static constexpr uint8_t isPossiblyNonApplicable = 0; typedef IntermediateValues IntermediateValuesBaseType; - typedef IntermediateValues* IntermediateValuesType; + typedef std::vector IntermediateValuesType; typedef IntermediateValuesBaseType* IntermediateValuesTypeForSpatialAg; @@ -135,18 +135,13 @@ class OperatingCost: public Variable::IVariable, NextT, VCa }; public: - ~OperatingCost() - { - delete[] pValuesForTheCurrentYear; - } - void initializeFromStudy(Data::Study& study) { pNbYearsParallel = study.maxNbYearsInParallel; InitializeResultsFromStudy(AncestorType::pResults, study); - pValuesForTheCurrentYear = new VCardType::IntermediateValuesBaseType[pNbYearsParallel]; + pValuesForTheCurrentYear.resize(pNbYearsParallel); for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++) { pValuesForTheCurrentYear[numSpace].initializeFromStudy(study); diff --git a/src/solver/variable/include/antares/solver/variable/economy/overallCost.h b/src/solver/variable/include/antares/solver/variable/economy/overallCost.h index ccb6632e9e..bbc10986ee 100644 --- a/src/solver/variable/include/antares/solver/variable/economy/overallCost.h +++ b/src/solver/variable/include/antares/solver/variable/economy/overallCost.h @@ -85,7 +85,7 @@ struct VCardOverallCost static constexpr uint8_t isPossiblyNonApplicable = 0; typedef IntermediateValues IntermediateValuesBaseType; - typedef IntermediateValues* IntermediateValuesType; + typedef std::vector IntermediateValuesType; typedef IntermediateValuesBaseType* IntermediateValuesTypeForSpatialAg; @@ -131,11 +131,6 @@ class OverallCost: public Variable::IVariable, NextT, VCardOv }; public: - ~OverallCost() - { - delete[] pValuesForTheCurrentYear; - } - void initializeFromStudy(Data::Study& study) { pNbYearsParallel = study.maxNbYearsInParallel; @@ -144,7 +139,7 @@ class OverallCost: public Variable::IVariable, NextT, VCardOv InitializeResultsFromStudy(AncestorType::pResults, study); // Intermediate values - pValuesForTheCurrentYear = new VCardType::IntermediateValuesBaseType[pNbYearsParallel]; + pValuesForTheCurrentYear.resize(pNbYearsParallel); for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++) { pValuesForTheCurrentYear[numSpace].initializeFromStudy(study); diff --git a/src/solver/variable/include/antares/solver/variable/economy/overallCostCsr.h b/src/solver/variable/include/antares/solver/variable/economy/overallCostCsr.h index 63739b686b..1735f81ba7 100644 --- a/src/solver/variable/include/antares/solver/variable/economy/overallCostCsr.h +++ b/src/solver/variable/include/antares/solver/variable/economy/overallCostCsr.h @@ -83,7 +83,7 @@ struct VCardOverallCostCsr static constexpr uint8_t isPossiblyNonApplicable = 0; typedef IntermediateValues IntermediateValuesBaseType; - typedef IntermediateValues* IntermediateValuesType; + typedef std::vector IntermediateValuesType; typedef IntermediateValuesBaseType* IntermediateValuesTypeForSpatialAg; @@ -129,11 +129,6 @@ class OverallCostCsr: public Variable::IVariable, NextT, V }; public: - ~OverallCostCsr() - { - delete[] pValuesForTheCurrentYear; - } - void initializeFromStudy(Data::Study& study) { pNbYearsParallel = study.maxNbYearsInParallel; @@ -142,7 +137,7 @@ class OverallCostCsr: public Variable::IVariable, NextT, V InitializeResultsFromStudy(AncestorType::pResults, study); // Intermediate values - pValuesForTheCurrentYear = new VCardType::IntermediateValuesBaseType[pNbYearsParallel]; + pValuesForTheCurrentYear.resize(pNbYearsParallel); for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++) { pValuesForTheCurrentYear[numSpace].initializeFromStudy(study); diff --git a/src/solver/variable/include/antares/solver/variable/economy/overflow.h b/src/solver/variable/include/antares/solver/variable/economy/overflow.h index 05a7cb5fbe..079c17a1f0 100644 --- a/src/solver/variable/include/antares/solver/variable/economy/overflow.h +++ b/src/solver/variable/include/antares/solver/variable/economy/overflow.h @@ -86,7 +86,7 @@ struct VCardOverflow static constexpr uint8_t isPossiblyNonApplicable = 1; typedef IntermediateValues IntermediateValuesBaseType; - typedef IntermediateValues* IntermediateValuesType; + typedef std::vector IntermediateValuesType; typedef IntermediateValuesBaseType* IntermediateValuesTypeForSpatialAg; @@ -131,18 +131,13 @@ class Overflows: public Variable::IVariable, NextT, VCardOverfl }; public: - ~Overflows() - { - delete[] pValuesForTheCurrentYear; - } - void initializeFromStudy(Data::Study& study) { pNbYearsParallel = study.maxNbYearsInParallel; InitializeResultsFromStudy(AncestorType::pResults, study); - pValuesForTheCurrentYear = new VCardType::IntermediateValuesBaseType[pNbYearsParallel]; + pValuesForTheCurrentYear.resize(pNbYearsParallel); for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++) { pValuesForTheCurrentYear[numSpace].initializeFromStudy(study); diff --git a/src/solver/variable/include/antares/solver/variable/economy/price.h b/src/solver/variable/include/antares/solver/variable/economy/price.h index f74567c938..7ac93069bf 100644 --- a/src/solver/variable/include/antares/solver/variable/economy/price.h +++ b/src/solver/variable/include/antares/solver/variable/economy/price.h @@ -87,7 +87,7 @@ struct VCardPrice static constexpr uint8_t isPossiblyNonApplicable = 0; typedef IntermediateValues IntermediateValuesBaseType; - typedef IntermediateValues* IntermediateValuesType; + typedef std::vector IntermediateValuesType; typedef IntermediateValuesBaseType* IntermediateValuesTypeForSpatialAg; @@ -132,11 +132,6 @@ class Price: public Variable::IVariable, NextT, VCardPrice> }; public: - ~Price() - { - delete[] pValuesForTheCurrentYear; - } - void initializeFromStudy(Data::Study& study) { pNbYearsParallel = study.maxNbYearsInParallel; @@ -145,7 +140,7 @@ class Price: public Variable::IVariable, NextT, VCardPrice> InitializeResultsFromStudy(AncestorType::pResults, study); // Intermediate values - pValuesForTheCurrentYear = new VCardType::IntermediateValuesBaseType[pNbYearsParallel]; + pValuesForTheCurrentYear.resize(pNbYearsParallel); for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++) { pValuesForTheCurrentYear[numSpace].initializeFromStudy(study); diff --git a/src/solver/variable/include/antares/solver/variable/economy/priceCSR.h b/src/solver/variable/include/antares/solver/variable/economy/priceCSR.h index 617d3ed772..d5209b6171 100644 --- a/src/solver/variable/include/antares/solver/variable/economy/priceCSR.h +++ b/src/solver/variable/include/antares/solver/variable/economy/priceCSR.h @@ -88,7 +88,7 @@ struct VCardPriceCSR static constexpr uint8_t isPossiblyNonApplicable = 0; typedef IntermediateValues IntermediateValuesBaseType; - typedef IntermediateValues* IntermediateValuesType; + typedef std::vector IntermediateValuesType; typedef IntermediateValuesBaseType* IntermediateValuesTypeForSpatialAg; @@ -133,11 +133,6 @@ class PriceCSR: public Variable::IVariable, NextT, VCardPriceCSR }; public: - ~PriceCSR() - { - delete[] pValuesForTheCurrentYear; - } - void initializeFromStudy(Data::Study& study) { pNbYearsParallel = study.maxNbYearsInParallel; @@ -146,7 +141,7 @@ class PriceCSR: public Variable::IVariable, NextT, VCardPriceCSR InitializeResultsFromStudy(AncestorType::pResults, study); // Intermediate values - pValuesForTheCurrentYear = new VCardType::IntermediateValuesBaseType[pNbYearsParallel]; + pValuesForTheCurrentYear.resize(pNbYearsParallel); for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++) { pValuesForTheCurrentYear[numSpace].initializeFromStudy(study); diff --git a/src/solver/variable/include/antares/solver/variable/economy/productionByDispatchablePlant.h b/src/solver/variable/include/antares/solver/variable/economy/productionByDispatchablePlant.h index b2b604a6fc..df35b21957 100644 --- a/src/solver/variable/include/antares/solver/variable/economy/productionByDispatchablePlant.h +++ b/src/solver/variable/include/antares/solver/variable/economy/productionByDispatchablePlant.h @@ -82,8 +82,8 @@ struct VCardProductionByDispatchablePlant static constexpr uint8_t isPossiblyNonApplicable = 0; typedef IntermediateValues IntermediateValuesDeepType; - typedef IntermediateValues* IntermediateValuesBaseType; - typedef IntermediateValuesBaseType* IntermediateValuesType; + typedef std::vector IntermediateValuesBaseType; + typedef std::vector IntermediateValuesType; }; // class VCard @@ -130,7 +130,6 @@ class ProductionByDispatchablePlant public: ProductionByDispatchablePlant(): - pValuesForTheCurrentYear(nullptr), pminOfTheClusterForYear(nullptr), pSize(0) { @@ -138,12 +137,6 @@ class ProductionByDispatchablePlant ~ProductionByDispatchablePlant() { - for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++) - { - delete[] pValuesForTheCurrentYear[numSpace]; - } - delete[] pValuesForTheCurrentYear; - for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++) { delete[] pminOfTheClusterForYear[numSpace]; @@ -161,7 +154,7 @@ class ProductionByDispatchablePlant { // Get the number of years in parallel pNbYearsParallel = study->maxNbYearsInParallel; - pValuesForTheCurrentYear = new VCardType::IntermediateValuesBaseType[pNbYearsParallel]; + pValuesForTheCurrentYear.resize(pNbYearsParallel); pminOfTheClusterForYear = new double*[pNbYearsParallel]; // Get the area @@ -172,8 +165,7 @@ class ProductionByDispatchablePlant for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++) { - pValuesForTheCurrentYear[numSpace] = new VCardType::IntermediateValuesDeepType - [pSize]; + pValuesForTheCurrentYear[numSpace].resize(pSize); } // Minimum power values of the cluster for the whole year - from the solver in the @@ -203,7 +195,6 @@ class ProductionByDispatchablePlant { for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++) { - pValuesForTheCurrentYear[numSpace] = nullptr; pminOfTheClusterForYear[numSpace] = nullptr; } diff --git a/src/solver/variable/include/antares/solver/variable/economy/productionByRenewablePlant.h b/src/solver/variable/include/antares/solver/variable/economy/productionByRenewablePlant.h index 1267c51b67..405f30b8a3 100644 --- a/src/solver/variable/include/antares/solver/variable/economy/productionByRenewablePlant.h +++ b/src/solver/variable/include/antares/solver/variable/economy/productionByRenewablePlant.h @@ -82,8 +82,8 @@ struct VCardProductionByRenewablePlant static constexpr uint8_t isPossiblyNonApplicable = 0; typedef IntermediateValues IntermediateValuesDeepType; - typedef IntermediateValues* IntermediateValuesBaseType; - typedef IntermediateValuesBaseType* IntermediateValuesType; + typedef std::vector IntermediateValuesBaseType; + typedef std::vector IntermediateValuesType; }; // class VCard @@ -129,20 +129,10 @@ class ProductionByRenewablePlant: public Variable::IVariablemaxNbYearsInParallel; - pValuesForTheCurrentYear = new VCardType::IntermediateValuesBaseType[pNbYearsParallel]; + pValuesForTheCurrentYear.resize(pNbYearsParallel); // Get the area pSize = area->renewable.list.enabledCount(); @@ -163,8 +153,7 @@ class ProductionByRenewablePlant: public Variable::IVariable IntermediateValuesBaseType; + typedef std::vector IntermediateValuesType; }; // class VCard /*! @@ -127,20 +127,10 @@ class ProfitByPlant: public Variable::IVariable, NextT, VCa public: ProfitByPlant(): - pValuesForTheCurrentYear(nullptr), pNbClustersOfArea(0) { } - ~ProfitByPlant() - { - for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++) - { - delete[] pValuesForTheCurrentYear[numSpace]; - } - delete[] pValuesForTheCurrentYear; - } - void initializeFromStudy(Data::Study& study) { // Next @@ -151,7 +141,7 @@ class ProfitByPlant: public Variable::IVariable, NextT, VCa { // Get the number of years in parallel pNbYearsParallel = study->maxNbYearsInParallel; - pValuesForTheCurrentYear = new VCardType::IntermediateValuesBaseType[pNbYearsParallel]; + pValuesForTheCurrentYear.resize(pNbYearsParallel); // Get the area pNbClustersOfArea = area->thermal.list.enabledCount(); @@ -160,8 +150,7 @@ class ProfitByPlant: public Variable::IVariable, NextT, VCa AncestorType::pResults.resize(pNbClustersOfArea); for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++) { - pValuesForTheCurrentYear[numSpace] = new VCardType::IntermediateValuesDeepType - [pNbClustersOfArea]; + pValuesForTheCurrentYear[numSpace].resize(pNbClustersOfArea); } for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++) @@ -180,11 +169,6 @@ class ProfitByPlant: public Variable::IVariable, NextT, VCa } else { - for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++) - { - pValuesForTheCurrentYear[numSpace] = nullptr; - } - AncestorType::pResults.clear(); } @@ -299,7 +283,7 @@ class ProfitByPlant: public Variable::IVariable, NextT, VCa unsigned int, unsigned int numSpace) const { - return pValuesForTheCurrentYear[numSpace]->hour; + return pValuesForTheCurrentYear[numSpace][0].hour; } void localBuildAnnualSurveyReport(SurveyResults& results, diff --git a/src/solver/variable/include/antares/solver/variable/economy/pumping.h b/src/solver/variable/include/antares/solver/variable/economy/pumping.h index db8d59289f..56ddcb6212 100644 --- a/src/solver/variable/include/antares/solver/variable/economy/pumping.h +++ b/src/solver/variable/include/antares/solver/variable/economy/pumping.h @@ -86,7 +86,7 @@ struct VCardPumping static constexpr uint8_t isPossiblyNonApplicable = 0; typedef IntermediateValues IntermediateValuesBaseType; - typedef IntermediateValues* IntermediateValuesType; + typedef std::vector IntermediateValuesType; typedef IntermediateValuesBaseType* IntermediateValuesTypeForSpatialAg; @@ -131,18 +131,13 @@ class Pumping: public Variable::IVariable, NextT, VCardPumping> }; public: - ~Pumping() - { - delete[] pValuesForTheCurrentYear; - } - void initializeFromStudy(Data::Study& study) { pNbYearsParallel = study.maxNbYearsInParallel; InitializeResultsFromStudy(AncestorType::pResults, study); - pValuesForTheCurrentYear = new VCardType::IntermediateValuesBaseType[pNbYearsParallel]; + pValuesForTheCurrentYear.resize(pNbYearsParallel); for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++) { pValuesForTheCurrentYear[numSpace].initializeFromStudy(study); diff --git a/src/solver/variable/include/antares/solver/variable/economy/reservoirlevel.h b/src/solver/variable/include/antares/solver/variable/economy/reservoirlevel.h index 9dad55e963..69befe1cc2 100644 --- a/src/solver/variable/include/antares/solver/variable/economy/reservoirlevel.h +++ b/src/solver/variable/include/antares/solver/variable/economy/reservoirlevel.h @@ -86,7 +86,7 @@ struct VCardReservoirLevel static constexpr uint8_t isPossiblyNonApplicable = 1; typedef IntermediateValues IntermediateValuesBaseType; - typedef IntermediateValues* IntermediateValuesType; + typedef std::vector IntermediateValuesType; typedef IntermediateValuesBaseType* IntermediateValuesTypeForSpatialAg; @@ -131,18 +131,13 @@ class ReservoirLevel: public Variable::IVariable, NextT, V }; public: - ~ReservoirLevel() - { - delete[] pValuesForTheCurrentYear; - } - void initializeFromStudy(Data::Study& study) { pNbYearsParallel = study.maxNbYearsInParallel; InitializeResultsFromStudy(AncestorType::pResults, study); - pValuesForTheCurrentYear = new VCardType::IntermediateValuesBaseType[pNbYearsParallel]; + pValuesForTheCurrentYear.resize(pNbYearsParallel); for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++) { pValuesForTheCurrentYear[numSpace].initializeFromStudy(study); diff --git a/src/solver/variable/include/antares/solver/variable/economy/spilledEnergy.h b/src/solver/variable/include/antares/solver/variable/economy/spilledEnergy.h index ad6c895d3f..707f8eeb18 100644 --- a/src/solver/variable/include/antares/solver/variable/economy/spilledEnergy.h +++ b/src/solver/variable/include/antares/solver/variable/economy/spilledEnergy.h @@ -86,7 +86,7 @@ struct VCardSpilledEnergy static constexpr uint8_t isPossiblyNonApplicable = 0; typedef IntermediateValues IntermediateValuesBaseType; - typedef IntermediateValues* IntermediateValuesType; + typedef std::vector IntermediateValuesType; typedef IntermediateValuesBaseType* IntermediateValuesTypeForSpatialAg; @@ -132,11 +132,6 @@ class SpilledEnergy: public Variable::IVariable, NextT, VCa }; public: - ~SpilledEnergy() - { - delete[] pValuesForTheCurrentYear; - } - void initializeFromStudy(Data::Study& study) { pNbYearsParallel = study.maxNbYearsInParallel; @@ -144,7 +139,7 @@ class SpilledEnergy: public Variable::IVariable, NextT, VCa // Intermediate values InitializeResultsFromStudy(AncestorType::pResults, study); - pValuesForTheCurrentYear = new VCardType::IntermediateValuesBaseType[pNbYearsParallel]; + pValuesForTheCurrentYear.resize(pNbYearsParallel); for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++) { pValuesForTheCurrentYear[numSpace].initializeFromStudy(study); diff --git a/src/solver/variable/include/antares/solver/variable/economy/unsupliedEnergy.h b/src/solver/variable/include/antares/solver/variable/economy/unsupliedEnergy.h index b3f15946ae..cb2eef6ad1 100644 --- a/src/solver/variable/include/antares/solver/variable/economy/unsupliedEnergy.h +++ b/src/solver/variable/include/antares/solver/variable/economy/unsupliedEnergy.h @@ -86,7 +86,7 @@ struct VCardUnsupliedEnergy static constexpr uint8_t isPossiblyNonApplicable = 0; typedef IntermediateValues IntermediateValuesBaseType; - typedef IntermediateValues* IntermediateValuesType; + typedef std::vector IntermediateValuesType; typedef IntermediateValuesBaseType* IntermediateValuesTypeForSpatialAg; @@ -133,11 +133,6 @@ class UnsupliedEnergy }; public: - ~UnsupliedEnergy() - { - delete[] pValuesForTheCurrentYear; - } - void initializeFromStudy(Data::Study& study) { pNbYearsParallel = study.maxNbYearsInParallel; @@ -145,7 +140,7 @@ class UnsupliedEnergy // Intermediate values InitializeResultsFromStudy(AncestorType::pResults, study); - pValuesForTheCurrentYear = new VCardType::IntermediateValuesBaseType[pNbYearsParallel]; + pValuesForTheCurrentYear.resize(pNbYearsParallel); for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++) { pValuesForTheCurrentYear[numSpace].initializeFromStudy(study); diff --git a/src/solver/variable/include/antares/solver/variable/economy/unsupliedEnergyCsr.h b/src/solver/variable/include/antares/solver/variable/economy/unsupliedEnergyCsr.h index a83ccb2e03..94e65e3820 100644 --- a/src/solver/variable/include/antares/solver/variable/economy/unsupliedEnergyCsr.h +++ b/src/solver/variable/include/antares/solver/variable/economy/unsupliedEnergyCsr.h @@ -83,7 +83,7 @@ struct VCardUnsupliedEnergyCSR static constexpr uint8_t isPossiblyNonApplicable = 0; typedef IntermediateValues IntermediateValuesBaseType; - typedef IntermediateValues* IntermediateValuesType; + typedef std::vector IntermediateValuesType; typedef IntermediateValuesBaseType* IntermediateValuesTypeForSpatialAg; @@ -126,11 +126,6 @@ class UnsupliedEnergyCSR }; public: - ~UnsupliedEnergyCSR() - { - delete[] pValuesForTheCurrentYear; - } - void initializeFromStudy(Data::Study& study) { pNbYearsParallel = study.maxNbYearsInParallel; @@ -138,7 +133,7 @@ class UnsupliedEnergyCSR // Intermediate values InitializeResultsFromStudy(AncestorType::pResults, study); - pValuesForTheCurrentYear = new VCardType::IntermediateValuesBaseType[pNbYearsParallel]; + pValuesForTheCurrentYear.resize(pNbYearsParallel); for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++) { pValuesForTheCurrentYear[numSpace].initializeFromStudy(study); diff --git a/src/solver/variable/include/antares/solver/variable/economy/waterValue.h b/src/solver/variable/include/antares/solver/variable/economy/waterValue.h index 488737ca5c..6ae43c0419 100644 --- a/src/solver/variable/include/antares/solver/variable/economy/waterValue.h +++ b/src/solver/variable/include/antares/solver/variable/economy/waterValue.h @@ -86,7 +86,7 @@ struct VCardWaterValue static constexpr uint8_t isPossiblyNonApplicable = 1; typedef IntermediateValues IntermediateValuesBaseType; - typedef IntermediateValues* IntermediateValuesType; + typedef std::vector IntermediateValuesType; typedef IntermediateValuesBaseType* IntermediateValuesTypeForSpatialAg; @@ -131,18 +131,13 @@ class WaterValue: public Variable::IVariable, NextT, VCardWate }; public: - ~WaterValue() - { - delete[] pValuesForTheCurrentYear; - } - void initializeFromStudy(Data::Study& study) { pNbYearsParallel = study.maxNbYearsInParallel; InitializeResultsFromStudy(AncestorType::pResults, study); - pValuesForTheCurrentYear = new VCardType::IntermediateValuesBaseType[pNbYearsParallel]; + pValuesForTheCurrentYear.resize(pNbYearsParallel); for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++) { pValuesForTheCurrentYear[numSpace].initializeFromStudy(study); diff --git a/src/solver/variable/include/antares/solver/variable/storage/intermediate.h b/src/solver/variable/include/antares/solver/variable/storage/intermediate.h index 661baf7eaa..dc95a5c39a 100644 --- a/src/solver/variable/include/antares/solver/variable/storage/intermediate.h +++ b/src/solver/variable/include/antares/solver/variable/storage/intermediate.h @@ -119,7 +119,6 @@ class IntermediateValues final const Type& operator[](const uint index) const; //@} -public: //! Range Antares::Data::StudyRangeLimits* pRange; //! Calendar, from the study, but dedicated to the output (with leap year) @@ -138,17 +137,6 @@ class IntermediateValues final //! Year Type year; -private: - // non copyable - IntermediateValues(const IntermediateValues&) - { - } - - IntermediateValues& operator=(const IntermediateValues&) - { - return *this; - } - template void internalExportAnnualValues(SurveyResults& report, const A& array, bool annual) const; From 12b43621bca031406c2ed5afa90cd5eb82cbd5e4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 28 Jan 2025 10:15:13 +0100 Subject: [PATCH 07/12] Bump mattnotmitt/doxygen-action from 1.9.8 to 1.12.0 (#2596) Bumps [mattnotmitt/doxygen-action](https://github.com/mattnotmitt/doxygen-action) from 1.9.8 to 1.12.0.
Release notes

Sourced from mattnotmitt/doxygen-action's releases.

Doxygen v1.12.0

  • Based on alpine 3.21

Doxygen v1.11.0

Based on Alpine 3.20.

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=mattnotmitt/doxygen-action&package-manager=github_actions&previous-version=1.9.8&new-version=1.12.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Abdoulbari Zaher <32519851+a-zakir@users.noreply.github.com> --- .github/workflows/doxygen.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/doxygen.yml b/.github/workflows/doxygen.yml index ed2bff5fa5..d299b5d0cb 100644 --- a/.github/workflows/doxygen.yml +++ b/.github/workflows/doxygen.yml @@ -27,7 +27,7 @@ jobs: git apply ../docs/antares-simulator-doxygen.patch - name: Doxygen - uses: mattnotmitt/doxygen-action@v1.9.8 + uses: mattnotmitt/doxygen-action@v1.12.0 with: doxyfile-path: docs/Doxyfile From 4882c1fb4d5fc65032bbec6e6cfd6dfec760048e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Omn=C3=A8s?= Date: Tue, 28 Jan 2025 10:22:18 +0100 Subject: [PATCH 08/12] Clean up container.h / container.hxx (#2601) - Remove default constructor/destructor - Remove useless `std::make_shared`, use the stack instead --- .../antares/solver/variable/container.h | 12 ---------- .../antares/solver/variable/container.hxx | 22 +++++-------------- 2 files changed, 6 insertions(+), 28 deletions(-) diff --git a/src/solver/variable/include/antares/solver/variable/container.h b/src/solver/variable/include/antares/solver/variable/container.h index 23938f71f1..74991a5926 100644 --- a/src/solver/variable/include/antares/solver/variable/container.h +++ b/src/solver/variable/include/antares/solver/variable/container.h @@ -55,18 +55,6 @@ class List: public NextT }; public: - //! \name Constructor & Destructor - //@{ - /*! - ** \brief Default Constructor - */ - List(); - /*! - ** \brief Destructor - */ - ~List(); - //@} - //! \name Variable initialization //@{ /*! diff --git a/src/solver/variable/include/antares/solver/variable/container.hxx b/src/solver/variable/include/antares/solver/variable/container.hxx index dd76f9b523..1488cd77aa 100644 --- a/src/solver/variable/include/antares/solver/variable/container.hxx +++ b/src/solver/variable/include/antares/solver/variable/container.hxx @@ -35,16 +35,6 @@ namespace Variable { namespace Container { -template -inline List::List() -{ -} - -template -inline List::~List() -{ -} - template inline void List::initializeFromStudy(Data::Study& study) { @@ -326,32 +316,32 @@ void List::exportSurveyResults(bool global, logs.info() << "Exporting the annual results"; } - auto survey = std::make_shared(*pStudy, output, writer); + SurveyResults survey(*pStudy, output, writer); // Year by year ? - survey->yearByYearResults = !global; + survey.yearByYearResults = !global; if (global) { // alias to the type of the report builder using Builder = SurveyReportBuilder; // Building the survey results for each possible state - Builder::Run(*this, *survey); + Builder::Run(*this, survey); // Exporting the Grid (information about the study) - survey->exportGridInfos(); + survey.exportGridInfos(); // Exporting the digest // The digest must be exported after the real report because some values // are computed at this moment. - Builder::RunDigest(*this, *survey, writer); + Builder::RunDigest(*this, survey, writer); } else { // alias to the type of the report builder using Builder = SurveyReportBuilder; // Building the survey results for each possible state - Builder::Run(*this, *survey, numSpace); + Builder::Run(*this, survey, numSpace); } } From a464fec3dcb522979c35ad828def6bf9f7a398fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Omn=C3=A8s?= Date: Tue, 28 Jan 2025 10:22:37 +0100 Subject: [PATCH 09/12] Add unit tests on class `Antares::Solver::Variable::IntermediateValues` (#2593) Add unit tests in class `IntermediateValues` which is used for the time aggregation of the results, both for a full year and a partial year. --- src/tests/src/solver/CMakeLists.txt | 1 + src/tests/src/solver/variable/CMakeLists.txt | 5 ++ .../src/solver/variable/test_intermediate.cpp | 88 +++++++++++++++++++ 3 files changed, 94 insertions(+) create mode 100644 src/tests/src/solver/variable/CMakeLists.txt create mode 100644 src/tests/src/solver/variable/test_intermediate.cpp diff --git a/src/tests/src/solver/CMakeLists.txt b/src/tests/src/solver/CMakeLists.txt index 9cf4843bd8..78390c0902 100644 --- a/src/tests/src/solver/CMakeLists.txt +++ b/src/tests/src/solver/CMakeLists.txt @@ -7,3 +7,4 @@ add_subdirectory(optimisation) add_subdirectory(optim-model-filler) add_subdirectory(simulation) add_subdirectory(utils) +add_subdirectory(variable) diff --git a/src/tests/src/solver/variable/CMakeLists.txt b/src/tests/src/solver/variable/CMakeLists.txt new file mode 100644 index 0000000000..f06cb7ee2e --- /dev/null +++ b/src/tests/src/solver/variable/CMakeLists.txt @@ -0,0 +1,5 @@ +include(${CMAKE_SOURCE_DIR}/tests/macros.cmake) + +add_boost_test(test-intermediate + SRC test_intermediate.cpp + LIBS antares-solver-variable) diff --git a/src/tests/src/solver/variable/test_intermediate.cpp b/src/tests/src/solver/variable/test_intermediate.cpp new file mode 100644 index 0000000000..62ccc5d045 --- /dev/null +++ b/src/tests/src/solver/variable/test_intermediate.cpp @@ -0,0 +1,88 @@ +/* + * 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 . + */ +#define BOOST_TEST_MODULE "test time series" + +#define WIN32_LEAN_AND_MEAN + +#include + +#include "antares/antares/constants.h" +#include "antares/solver/variable/storage/intermediate.h" + +constexpr double TOLERANCE = 1.e-6; +using Antares::Constants::nbHoursInAWeek; + +template +struct StudyFixture +{ + StudyFixture(): + study(std::make_unique()) + { + study->parameters.simulationDays.first = FirstDay; + study->parameters.simulationDays.end = LastDay; + study->initializeRuntimeInfos(); + } + + std::unique_ptr study; +}; + +BOOST_AUTO_TEST_SUITE(intermediate_suite) +using FullYearStudyFixture = StudyFixture<0, 365>; + +BOOST_FIXTURE_TEST_CASE(averageFromHourlyFullYear, FullYearStudyFixture) +{ + Antares::Solver::Variable::IntermediateValues intermediate; + intermediate.initializeFromStudy(*study); + intermediate[0] = 10; // hour 0 + intermediate[1] = 20; // hour 1 + intermediate.computeAveragesForCurrentYearFromHourlyResults(); + + constexpr int nbHoursInYear = 8736; + BOOST_CHECK_EQUAL(study->runtime.rangeLimits.hour[Antares::Data::rangeCount], nbHoursInYear); + + BOOST_CHECK_CLOSE(intermediate.year, (10. + 20.) / nbHoursInYear, TOLERANCE); + BOOST_CHECK_CLOSE(intermediate.week[0], (10. + 20.) / nbHoursInAWeek, TOLERANCE); + BOOST_CHECK_CLOSE(intermediate.month[0], (10. + 20.) / (31 * 24), TOLERANCE); + BOOST_CHECK_CLOSE(intermediate.day[0], (10. + 20.) / 24, TOLERANCE); +} + +using PartialYearStudyFixture = StudyFixture<0, 192>; + +BOOST_FIXTURE_TEST_CASE(averageFromHourlyPartialYear, PartialYearStudyFixture) +{ + Antares::Solver::Variable::IntermediateValues intermediate; + intermediate.initializeFromStudy(*study); + intermediate[0] = 10; // hour 0 + intermediate[1] = 20; // hour 1 + intermediate.computeAveragesForCurrentYearFromHourlyResults(); + + constexpr int nbWeeks = 27; // std::floor(192 / 7); + const int nbHoursInYear = nbWeeks * nbHoursInAWeek; + BOOST_CHECK_EQUAL(study->runtime.rangeLimits.week[Antares::Data::rangeCount], nbWeeks); + BOOST_CHECK_EQUAL(study->runtime.rangeLimits.hour[Antares::Data::rangeCount], nbHoursInYear); + + BOOST_CHECK_CLOSE(intermediate.year, (10. + 20.) / nbHoursInYear, TOLERANCE); + BOOST_CHECK_CLOSE(intermediate.week[0], (10. + 20.) / nbHoursInAWeek, TOLERANCE); + BOOST_CHECK_CLOSE(intermediate.month[0], (10. + 20.) / (31 * 24), TOLERANCE); + BOOST_CHECK_CLOSE(intermediate.day[0], (10. + 20.) / 24, TOLERANCE); +} + +BOOST_AUTO_TEST_SUITE_END() From 65938bd6c017f76918309b09b240e4c647a26dc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Omn=C3=A8s?= Date: Tue, 28 Jan 2025 12:49:56 +0100 Subject: [PATCH 10/12] Fix segfault on BP studies (#2598) --- .../antares/study/scenario-builder/ThermalTSNumberData.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/libs/antares/study/scenario-builder/ThermalTSNumberData.cpp b/src/libs/antares/study/scenario-builder/ThermalTSNumberData.cpp index 73e094a9b3..b3bbba7ae4 100644 --- a/src/libs/antares/study/scenario-builder/ThermalTSNumberData.cpp +++ b/src/libs/antares/study/scenario-builder/ThermalTSNumberData.cpp @@ -38,8 +38,7 @@ bool thermalTSNumberData::reset(const Study& study) // solver or not. // WARNING: At this point, the variable pArea->thermal.list.size() // might not be valid (because not really initialized yet) - uint clusterCount = (study.usedByTheSolver) ? (pArea->thermal.list.enabledCount()) - : pArea->thermal.list.allClustersCount(); + uint clusterCount = pArea->thermal.list.allClustersCount(); // Resize pTSNumberRules.reset(clusterCount, nbYears); From e62801cb4f7f9c3c99cfeb84bd53493212f80da0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Omn=C3=A8s?= Date: Tue, 28 Jan 2025 12:50:17 +0100 Subject: [PATCH 11/12] Throw exception instead of pointer to exception (#2600) --- src/solver/simulation/common-hydro-remix.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/solver/simulation/common-hydro-remix.cpp b/src/solver/simulation/common-hydro-remix.cpp index 13f8e5d49d..328868252a 100644 --- a/src/solver/simulation/common-hydro-remix.cpp +++ b/src/solver/simulation/common-hydro-remix.cpp @@ -336,7 +336,7 @@ void RemixHydroForAllAreas(const Data::AreaList& areas, if (!result) { - throw new Data::AssertionError( + throw Data::AssertionError( "Error in simplex optimisation. Check logs for more details."); } } From c5b512347df48cf11cfbfccb05c4a62603e736cd Mon Sep 17 00:00:00 2001 From: Abdoulbari Zaher <32519851+a-zakir@users.noreply.github.com> Date: Tue, 28 Jan 2025 15:35:48 +0100 Subject: [PATCH 12/12] [ANT-2608] add of unit tests for time dependant expression (#2597) Co-authored-by: Florian OMNES --- .../test_componentFiller.cpp | 130 +++++++++++++++++- 1 file changed, 124 insertions(+), 6 deletions(-) diff --git a/src/tests/src/solver/optim-model-filler/test_componentFiller.cpp b/src/tests/src/solver/optim-model-filler/test_componentFiller.cpp index 58e2745e62..5f8a8a8484 100644 --- a/src/tests/src/solver/optim-model-filler/test_componentFiller.cpp +++ b/src/tests/src/solver/optim-model-filler/test_componentFiller.cpp @@ -75,11 +75,12 @@ struct LinearProblemBuildingFixture Node* lb, Node* ub, const vector& constraintsData, - Node* objective = nullptr) + Node* objective = nullptr, + bool time_dependent = false) { createModel(modelId, parameterIds, - {{varId, ValueType::FLOAT, lb, ub, false, false}}, + {{varId, ValueType::FLOAT, lb, ub, time_dependent, false}}, constraintsData, objective); } @@ -117,7 +118,13 @@ struct LinearProblemBuildingFixture return nodes.create(node); } - void buildLinearProblem(); + void buildLinearProblem(FillContext& time_scenario_ctx); + + void buildLinearProblem() + { + FillContext time_scenario_ctx = {0, 0}; + buildLinearProblem(time_scenario_ctx); + } }; void LinearProblemBuildingFixture::createModel(string modelId, @@ -180,7 +187,7 @@ void LinearProblemBuildingFixture::createComponent(const string& modelId, components.push_back(move(component)); } -void LinearProblemBuildingFixture::buildLinearProblem() +void LinearProblemBuildingFixture::buildLinearProblem(FillContext& time_scenario_ctx) { vector> fillers; vector fillers_ptr; @@ -196,8 +203,8 @@ void LinearProblemBuildingFixture::buildLinearProblem() pb = make_unique(false, "sirius"); LinearProblemBuilder linear_problem_builder(fillers_ptr); LinearProblemData dummy_data; - FillContext dummy_time_scenario_ctx = {0, 0}; - linear_problem_builder.build(*pb.get(), dummy_data, dummy_time_scenario_ctx); + + linear_problem_builder.build(*pb, dummy_data, time_scenario_ctx); } BOOST_FIXTURE_TEST_SUITE(_ComponentFiller_addVariables_, LinearProblemBuildingFixture) @@ -218,6 +225,34 @@ BOOST_AUTO_TEST_CASE(var_with_literal_bounds_to_filler__problem_contains_one_var BOOST_CHECK_EQUAL(pb->getObjectiveCoefficient(var), 0); } +BOOST_AUTO_TEST_CASE(ten_timesteps_var_with_literal_bounds_to_filler__problem_contains_ten_vars) +{ + createModelWithOneFloatVar("some_model", + {}, + "var1", + literal(-5), + literal(10), + {}, + nullptr, + true); + createComponent("some_model", "some_component"); + constexpr unsigned int last_time_step = 9; + FillContext ctx{0, last_time_step}; + buildLinearProblem(ctx); + const auto nb_var = ctx.getNumberOfTimestep(); // = 10 + BOOST_CHECK_EQUAL(pb->variableCount(), nb_var); + BOOST_CHECK_EQUAL(pb->constraintCount(), 0); + for (unsigned int i = 0; i < nb_var; i++) + { + auto* var = pb->getVariable("some_component.var1_" + to_string(i)); + BOOST_REQUIRE(var); + BOOST_CHECK_EQUAL(var->getLb(), -5); + BOOST_CHECK_EQUAL(var->getUb(), 10); + BOOST_CHECK(!var->isInteger()); + BOOST_CHECK_EQUAL(pb->getObjectiveCoefficient(var), 0); + } +} + BOOST_AUTO_TEST_CASE(var_with_wrong_parameter_lb__exception_is_raised) { createModel("my-model", @@ -263,6 +298,35 @@ BOOST_AUTO_TEST_CASE(two_variables_given_to_different_fillers__LP_contains_the_t BOOST_CHECK_EQUAL(var2->getUb(), 2.); } +BOOST_AUTO_TEST_CASE( + two_times_10_variables_given_to_different_fillers__LP_contains_the_two_variables) +{ + createModelWithOneFloatVar("m1", {}, "var1", literal(-1), literal(6), {}, nullptr, true); + createModelWithOneFloatVar("m2", {}, "var2", literal(-3), literal(2), {}, nullptr, true); + createComponent("m1", "component_1"); + createComponent("m2", "component_2"); + constexpr unsigned int last_time_step = 9; + FillContext ctx{0, last_time_step}; + buildLinearProblem(ctx); + const auto nb_var = ctx.getNumberOfTimestep(); // = 10 + + BOOST_CHECK_EQUAL(pb->variableCount(), 2 * 10); + for (auto i = 0; i < nb_var; i++) + { + auto* var1 = pb->getVariable("component_1.var1_" + to_string(i)); + BOOST_REQUIRE(var1); + BOOST_CHECK(!var1->isInteger()); + BOOST_CHECK_EQUAL(var1->getLb(), -1.); + BOOST_CHECK_EQUAL(var1->getUb(), 6.); + + auto* var2 = pb->getVariable("component_2.var2_" + to_string(i)); + BOOST_REQUIRE(var2); + BOOST_CHECK(!var2->isInteger()); + BOOST_CHECK_EQUAL(var2->getLb(), -3.); + BOOST_CHECK_EQUAL(var2->getUb(), 2.); + } +} + BOOST_AUTO_TEST_CASE(var_whose_bounds_are_parameters_given_to_component__problem_contains_this_var) { createModel("model", @@ -372,6 +436,39 @@ BOOST_AUTO_TEST_CASE(ct_one_var__pb_contains_the_ct) BOOST_CHECK_EQUAL(ct->getCoefficient(var), 1); } +BOOST_AUTO_TEST_CASE(ct_with_ten_vars__pb_contains_ten_ct) +{ + // var1 <= 3 + auto var_node = variable("var1", Antares::Solver::Visitors::TimeIndex::VARYING_IN_TIME_ONLY); + auto three = literal(3); + auto ct_node = nodes.create(var_node, three); + + createModel("model", + {}, + {{"var1", ValueType::BOOL, literal(-5), literal(10), true, false}}, + {{"ct1", ct_node}}); + createComponent("model", "componentToto"); + constexpr unsigned int last_time_step = 9; + FillContext ctx{0, last_time_step}; + buildLinearProblem(ctx); + const auto nb_var = ctx.getNumberOfTimestep(); // = 10 + + BOOST_CHECK_EQUAL(pb->variableCount(), 10); + BOOST_CHECK_EQUAL(pb->constraintCount(), 10); + + for (auto i = 0; i < nb_var; i++) + { + auto ct = pb->getConstraint("componentToto.ct1_" + to_string(i)); + BOOST_REQUIRE(ct); + BOOST_CHECK_EQUAL(ct->getLb(), -pb->infinity()); + BOOST_CHECK_EQUAL(ct->getUb(), 3); + auto var = pb->getVariable("componentToto.var1_" + to_string(i)); + BOOST_REQUIRE(var); + BOOST_CHECK(var->isInteger()); + BOOST_CHECK_EQUAL(ct->getCoefficient(var), 1); + } +} + BOOST_AUTO_TEST_CASE(ct_one_var_with_coef__pb_contains_the_ct) { // 3 * var1 >= 5 * var1 + 5 @@ -512,6 +609,27 @@ BOOST_AUTO_TEST_CASE(one_var_with_objective) BOOST_CHECK_EQUAL(pb->getObjectiveCoefficient(pb->getVariable("componentA.x")), 1); } +BOOST_AUTO_TEST_CASE(one_time_dependent_var_with_objective) +{ + auto objective = variable("x", Antares::Solver::Visitors::TimeIndex::VARYING_IN_TIME_ONLY); + + createModelWithOneFloatVar("model", {}, "x", literal(-50), literal(-40), {}, objective, true); + createComponent("model", "componentA", {}); + + constexpr unsigned int last_time_step = 9; + FillContext ctx{0, last_time_step}; + buildLinearProblem(ctx); + const auto nb_var = ctx.getNumberOfTimestep(); // = 10 + + BOOST_CHECK_EQUAL(pb->variableCount(), nb_var); + for (auto i = 0; i < nb_var; i++) + { + const auto var_name = "componentA.x_" + to_string(i); + BOOST_CHECK_NO_THROW(pb->getVariable(var_name)); + BOOST_CHECK_EQUAL(pb->getObjectiveCoefficient(pb->getVariable(var_name)), 1); + } +} + BOOST_AUTO_TEST_CASE(two_vars_but_only_one_in_objective) { VariableData var1Data = {"v1", ValueType::FLOAT, literal(-50.), literal(300.), false, false};