From af75f200f829cbc0f1fe1092caa40e7c70ecbb2f Mon Sep 17 00:00:00 2001 From: Vincent Payet Date: Wed, 17 Jul 2024 15:29:57 +0200 Subject: [PATCH 01/21] replaced byindex with a vector --- src/libs/antares/study/area/list.cpp | 13 ++++--------- .../antares/study/include/antares/study/area/area.h | 2 +- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/libs/antares/study/area/list.cpp b/src/libs/antares/study/area/list.cpp index de3c2e9b1f..d16c6e9ab6 100644 --- a/src/libs/antares/study/area/list.cpp +++ b/src/libs/antares/study/area/list.cpp @@ -449,8 +449,7 @@ const AreaLink* AreaList::findLink(const AreaName& area, const AreaName& with) c void AreaList::clear() { - delete[] byIndex; - byIndex = nullptr; + byIndex.clear(); if (!areas.empty()) { @@ -467,16 +466,12 @@ void AreaList::clear() void AreaList::rebuildIndexes() { - delete[] byIndex; + byIndex.clear(); - if (areas.empty()) - { - byIndex = nullptr; - } - else + if (!areas.empty()) { using AreaWeakPtr = Area*; - byIndex = new AreaWeakPtr[areas.size()]; + byIndex.resize(areas.size()); uint indx = 0; auto end = areas.end(); 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 6661ab8556..7550d9840f 100644 --- a/src/libs/antares/study/include/antares/study/area/area.h +++ b/src/libs/antares/study/include/antares/study/area/area.h @@ -689,7 +689,7 @@ class AreaList final: public Yuni::NonCopyable public: //! All areas by their index - Area** byIndex = nullptr; + std::vector byIndex; //! All areas in the list Area::Map areas; From 70c6a2e15633fef925e35cb53667039b9f61be29 Mon Sep 17 00:00:00 2001 From: Vincent Payet Date: Wed, 17 Jul 2024 15:59:51 +0200 Subject: [PATCH 02/21] xcast a --- .../include/antares/solver/ts-generator/xcast/xcast.h | 2 +- src/solver/ts-generator/xcast/xcast.cpp | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/solver/ts-generator/include/antares/solver/ts-generator/xcast/xcast.h b/src/solver/ts-generator/include/antares/solver/ts-generator/xcast/xcast.h index 55bb128e85..3d798d1ea3 100644 --- a/src/solver/ts-generator/include/antares/solver/ts-generator/xcast/xcast.h +++ b/src/solver/ts-generator/include/antares/solver/ts-generator/xcast/xcast.h @@ -195,7 +195,7 @@ class XCast final: private Yuni::NonCopyable bool pAccuracyOnCorrelation; bool All_normal; // all processes are Normal - float* A; // les variables de A à CO sont des vues de ALPH à CORR pour un mois particulier + std::vector A; // les variables de A à CO sont des vues de ALPH à CORR pour un mois particulier float* B; float* G; float* D; diff --git a/src/solver/ts-generator/xcast/xcast.cpp b/src/solver/ts-generator/xcast/xcast.cpp index 56f7234119..93ae4174ce 100644 --- a/src/solver/ts-generator/xcast/xcast.cpp +++ b/src/solver/ts-generator/xcast/xcast.cpp @@ -246,7 +246,7 @@ void XCast::allocateTemporaryData() Allocator m; - A = m.allocate(p); + A.resize(p); B = m.allocate(p); G = m.allocate(p); D = m.allocate(p); @@ -330,7 +330,6 @@ void XCast::destroyTemporaryData() delete[] DATL; delete[] CORR; delete[] FO; - delete[] A; delete[] B; delete[] G; delete[] D; From f1a83779b79c8c7a1a59f2f831aa8d8b980f69b8 Mon Sep 17 00:00:00 2001 From: Vincent Payet Date: Wed, 17 Jul 2024 16:02:42 +0200 Subject: [PATCH 03/21] xcast b d g --- .../include/antares/solver/ts-generator/xcast/xcast.h | 6 +++--- src/solver/ts-generator/xcast/xcast.cpp | 9 +++------ 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/solver/ts-generator/include/antares/solver/ts-generator/xcast/xcast.h b/src/solver/ts-generator/include/antares/solver/ts-generator/xcast/xcast.h index 3d798d1ea3..6ff98f43ef 100644 --- a/src/solver/ts-generator/include/antares/solver/ts-generator/xcast/xcast.h +++ b/src/solver/ts-generator/include/antares/solver/ts-generator/xcast/xcast.h @@ -196,9 +196,9 @@ class XCast final: private Yuni::NonCopyable bool All_normal; // all processes are Normal std::vector A; // les variables de A à CO sont des vues de ALPH à CORR pour un mois particulier - float* B; - float* G; - float* D; + std::vector B; + std::vector G; + std::vector D; int* M; float* T; Data::XCast::Distribution* L; diff --git a/src/solver/ts-generator/xcast/xcast.cpp b/src/solver/ts-generator/xcast/xcast.cpp index 93ae4174ce..efefec463b 100644 --- a/src/solver/ts-generator/xcast/xcast.cpp +++ b/src/solver/ts-generator/xcast/xcast.cpp @@ -247,9 +247,9 @@ void XCast::allocateTemporaryData() Allocator m; A.resize(p); - B = m.allocate(p); - G = m.allocate(p); - D = m.allocate(p); + B.resize(p); + G.resize(p); + D.resize(p); M = m.allocate(p); T = m.allocate(p); BO = m.allocate(p); @@ -330,9 +330,6 @@ void XCast::destroyTemporaryData() delete[] DATL; delete[] CORR; delete[] FO; - delete[] B; - delete[] G; - delete[] D; delete[] M; delete[] T; delete[] L; From dcdf913ef74487c8714c1c3ba1731074624d7a41 Mon Sep 17 00:00:00 2001 From: Vincent Payet Date: Wed, 17 Jul 2024 16:06:50 +0200 Subject: [PATCH 04/21] xcast DIFF TREN WIEN BROW --- .../antares/solver/ts-generator/xcast/xcast.h | 8 ++++---- src/solver/ts-generator/xcast/xcast.cpp | 12 ++++-------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/solver/ts-generator/include/antares/solver/ts-generator/xcast/xcast.h b/src/solver/ts-generator/include/antares/solver/ts-generator/xcast/xcast.h index 6ff98f43ef..8a62b52d1c 100644 --- a/src/solver/ts-generator/include/antares/solver/ts-generator/xcast/xcast.h +++ b/src/solver/ts-generator/include/antares/solver/ts-generator/xcast/xcast.h @@ -220,10 +220,10 @@ class XCast final: private Yuni::NonCopyable float** LISS; float** DATL; - float* DIFF; - float* TREN; - float* WIEN; - float* BROW; + std::vector DIFF; + std::vector TREN; + std::vector WIEN; + std::vector BROW; float* BASI; // used only if all processes are Normal float* ALPH; // used only if all processes are Normal diff --git a/src/solver/ts-generator/xcast/xcast.cpp b/src/solver/ts-generator/xcast/xcast.cpp index efefec463b..6443090cb7 100644 --- a/src/solver/ts-generator/xcast/xcast.cpp +++ b/src/solver/ts-generator/xcast/xcast.cpp @@ -261,10 +261,10 @@ void XCast::allocateTemporaryData() MINI = m.allocate(p); ESPE = m.allocate(p); STDE = m.allocate(p); - DIFF = m.allocate(p); - TREN = m.allocate(p); - WIEN = m.allocate(p + 1); - BROW = m.allocate(p); + DIFF.resize(p); + TREN.resize(p); + WIEN.resize(p + 1); + BROW.resize(p); BASI = m.allocate(p); ALPH = m.allocate(p); @@ -343,10 +343,6 @@ void XCast::destroyTemporaryData() delete[] Presque_mini; delete[] ESPE; delete[] STDE; - delete[] DIFF; - delete[] TREN; - delete[] WIEN; - delete[] BROW; delete[] BASI; delete[] ALPH; delete[] BETA; From e9aed1968a6d70062e8cd538405abcb6584fa2da Mon Sep 17 00:00:00 2001 From: Vincent Payet Date: Thu, 18 Jul 2024 10:49:17 +0200 Subject: [PATCH 05/21] xcast POSI MINI MAXI ESPE STDE --- .../antares/solver/ts-generator/xcast/xcast.h | 13 +++++++------ src/solver/ts-generator/xcast/xcast.cpp | 15 +++++---------- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/src/solver/ts-generator/include/antares/solver/ts-generator/xcast/xcast.h b/src/solver/ts-generator/include/antares/solver/ts-generator/xcast/xcast.h index 8a62b52d1c..4e282e999a 100644 --- a/src/solver/ts-generator/include/antares/solver/ts-generator/xcast/xcast.h +++ b/src/solver/ts-generator/include/antares/solver/ts-generator/xcast/xcast.h @@ -195,7 +195,8 @@ class XCast final: private Yuni::NonCopyable bool pAccuracyOnCorrelation; bool All_normal; // all processes are Normal - std::vector A; // les variables de A à CO sont des vues de ALPH à CORR pour un mois particulier + // les variables de A à CO sont des vues de ALPH à CORR pour un mois particulier + std::vector A; std::vector B; std::vector G; std::vector D; @@ -209,14 +210,14 @@ class XCast final: private Yuni::NonCopyable float STEP; float SQST; - float* POSI; + std::vector POSI; float** CORR; - float* MAXI; - float* MINI; + std::vector MAXI; + std::vector MINI; float* Presque_maxi; float* Presque_mini; - float* ESPE; - float* STDE; + std::vector ESPE; + std::vector STDE; float** LISS; float** DATL; diff --git a/src/solver/ts-generator/xcast/xcast.cpp b/src/solver/ts-generator/xcast/xcast.cpp index 6443090cb7..0301922e93 100644 --- a/src/solver/ts-generator/xcast/xcast.cpp +++ b/src/solver/ts-generator/xcast/xcast.cpp @@ -256,11 +256,11 @@ void XCast::allocateTemporaryData() MA = m.allocate(p); MI = m.allocate(p); L = m.allocate(p); - POSI = m.allocate(p); - MAXI = m.allocate(p); - MINI = m.allocate(p); - ESPE = m.allocate(p); - STDE = m.allocate(p); + POSI.resize(p); + MAXI.resize(p); + MINI.resize(p); + ESPE.resize(p); + STDE.resize(p); DIFF.resize(p); TREN.resize(p); WIEN.resize(p + 1); @@ -336,13 +336,8 @@ void XCast::destroyTemporaryData() delete[] BO; delete[] MA; delete[] MI; - delete[] POSI; - delete[] MAXI; - delete[] MINI; delete[] Presque_maxi; delete[] Presque_mini; - delete[] ESPE; - delete[] STDE; delete[] BASI; delete[] ALPH; delete[] BETA; From 07c10f4476b2bbd475531ed7e5c631cb92974b12 Mon Sep 17 00:00:00 2001 From: Vincent Payet Date: Thu, 18 Jul 2024 10:51:38 +0200 Subject: [PATCH 06/21] xcast BO pUseConversion --- .../include/antares/solver/ts-generator/xcast/xcast.h | 4 ++-- src/solver/ts-generator/xcast/xcast.cpp | 6 ++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/solver/ts-generator/include/antares/solver/ts-generator/xcast/xcast.h b/src/solver/ts-generator/include/antares/solver/ts-generator/xcast/xcast.h index 4e282e999a..db6ae52e6e 100644 --- a/src/solver/ts-generator/include/antares/solver/ts-generator/xcast/xcast.h +++ b/src/solver/ts-generator/include/antares/solver/ts-generator/xcast/xcast.h @@ -203,7 +203,7 @@ class XCast final: private Yuni::NonCopyable int* M; float* T; Data::XCast::Distribution* L; - bool* BO; + std::vector BO; float* MA; float* MI; float** FO; // contrainte : FO >=0 @@ -243,7 +243,7 @@ class XCast final: private Yuni::NonCopyable float* pQCHOLTotal; //! - bool* pUseConversion; + std::vector pUseConversion; //! Name of the current timeseries Yuni::CString<32, false> pTSName; diff --git a/src/solver/ts-generator/xcast/xcast.cpp b/src/solver/ts-generator/xcast/xcast.cpp index 0301922e93..98aad64b46 100644 --- a/src/solver/ts-generator/xcast/xcast.cpp +++ b/src/solver/ts-generator/xcast/xcast.cpp @@ -252,7 +252,7 @@ void XCast::allocateTemporaryData() D.resize(p); M = m.allocate(p); T = m.allocate(p); - BO = m.allocate(p); + BO.resize(p); MA = m.allocate(p); MI = m.allocate(p); L = m.allocate(p); @@ -272,7 +272,7 @@ void XCast::allocateTemporaryData() D_COPIE = m.allocate(p); - pUseConversion = m.allocate(p); + pUseConversion.resize(p); Presque_maxi = m.allocate(p); Presque_mini = m.allocate(p); @@ -333,7 +333,6 @@ void XCast::destroyTemporaryData() delete[] M; delete[] T; delete[] L; - delete[] BO; delete[] MA; delete[] MI; delete[] Presque_maxi; @@ -342,7 +341,6 @@ void XCast::destroyTemporaryData() delete[] ALPH; delete[] BETA; delete[] pQCHOLTotal; - delete[] pUseConversion; } } From 250f36d39eb040dc77d9d6f747eb854ba5a926fa Mon Sep 17 00:00:00 2001 From: Vincent Payet Date: Thu, 18 Jul 2024 10:54:37 +0200 Subject: [PATCH 07/21] xcast T MA MI --- .../include/antares/solver/ts-generator/xcast/xcast.h | 6 +++--- src/solver/ts-generator/xcast/xcast.cpp | 9 +++------ 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/solver/ts-generator/include/antares/solver/ts-generator/xcast/xcast.h b/src/solver/ts-generator/include/antares/solver/ts-generator/xcast/xcast.h index db6ae52e6e..98824e0d2f 100644 --- a/src/solver/ts-generator/include/antares/solver/ts-generator/xcast/xcast.h +++ b/src/solver/ts-generator/include/antares/solver/ts-generator/xcast/xcast.h @@ -201,11 +201,11 @@ class XCast final: private Yuni::NonCopyable std::vector G; std::vector D; int* M; - float* T; + std::vector T; Data::XCast::Distribution* L; std::vector BO; - float* MA; - float* MI; + std::vector MA; + std::vector MI; float** FO; // contrainte : FO >=0 float STEP; diff --git a/src/solver/ts-generator/xcast/xcast.cpp b/src/solver/ts-generator/xcast/xcast.cpp index 98aad64b46..8b2af1c170 100644 --- a/src/solver/ts-generator/xcast/xcast.cpp +++ b/src/solver/ts-generator/xcast/xcast.cpp @@ -251,10 +251,10 @@ void XCast::allocateTemporaryData() G.resize(p); D.resize(p); M = m.allocate(p); - T = m.allocate(p); + T.resize(p); BO.resize(p); - MA = m.allocate(p); - MI = m.allocate(p); + MA.resize(p); + MI.resize(p); L = m.allocate(p); POSI.resize(p); MAXI.resize(p); @@ -331,10 +331,7 @@ void XCast::destroyTemporaryData() delete[] CORR; delete[] FO; delete[] M; - delete[] T; delete[] L; - delete[] MA; - delete[] MI; delete[] Presque_maxi; delete[] Presque_mini; delete[] BASI; From 9a41ba7ebefdce341198fd047726f4699caa09ae Mon Sep 17 00:00:00 2001 From: Vincent Payet Date: Thu, 18 Jul 2024 10:56:22 +0200 Subject: [PATCH 08/21] xcast BASI ALPH BETA --- .../include/antares/solver/ts-generator/xcast/xcast.h | 6 +++--- src/solver/ts-generator/xcast/xcast.cpp | 9 +++------ 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/solver/ts-generator/include/antares/solver/ts-generator/xcast/xcast.h b/src/solver/ts-generator/include/antares/solver/ts-generator/xcast/xcast.h index 98824e0d2f..0aa349542f 100644 --- a/src/solver/ts-generator/include/antares/solver/ts-generator/xcast/xcast.h +++ b/src/solver/ts-generator/include/antares/solver/ts-generator/xcast/xcast.h @@ -226,9 +226,9 @@ class XCast final: private Yuni::NonCopyable std::vector WIEN; std::vector BROW; - float* BASI; // used only if all processes are Normal - float* ALPH; // used only if all processes are Normal - float* BETA; // used only if all processes are Normal + std::vector BASI; // used only if all processes are Normal + std::vector ALPH; // used only if all processes are Normal + std::vector BETA; // used only if all processes are Normal float** Triangle_reference; float** Triangle_courant; diff --git a/src/solver/ts-generator/xcast/xcast.cpp b/src/solver/ts-generator/xcast/xcast.cpp index 8b2af1c170..47505e734e 100644 --- a/src/solver/ts-generator/xcast/xcast.cpp +++ b/src/solver/ts-generator/xcast/xcast.cpp @@ -266,9 +266,9 @@ void XCast::allocateTemporaryData() WIEN.resize(p + 1); BROW.resize(p); - BASI = m.allocate(p); - ALPH = m.allocate(p); - BETA = m.allocate(p); + BASI.resize(p); + ALPH.resize(p); + BETA.resize(p); D_COPIE = m.allocate(p); @@ -334,9 +334,6 @@ void XCast::destroyTemporaryData() delete[] L; delete[] Presque_maxi; delete[] Presque_mini; - delete[] BASI; - delete[] ALPH; - delete[] BETA; delete[] pQCHOLTotal; } } From bcfbc35ac4672f5bef6b82ecd40b9157009fbb73 Mon Sep 17 00:00:00 2001 From: Vincent Payet Date: Thu, 18 Jul 2024 10:57:26 +0200 Subject: [PATCH 09/21] xcast presque mini maxi --- .../include/antares/solver/ts-generator/xcast/xcast.h | 4 ++-- src/solver/ts-generator/xcast/xcast.cpp | 6 ++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/solver/ts-generator/include/antares/solver/ts-generator/xcast/xcast.h b/src/solver/ts-generator/include/antares/solver/ts-generator/xcast/xcast.h index 0aa349542f..e1bd46e9c4 100644 --- a/src/solver/ts-generator/include/antares/solver/ts-generator/xcast/xcast.h +++ b/src/solver/ts-generator/include/antares/solver/ts-generator/xcast/xcast.h @@ -214,8 +214,8 @@ class XCast final: private Yuni::NonCopyable float** CORR; std::vector MAXI; std::vector MINI; - float* Presque_maxi; - float* Presque_mini; + std::vector Presque_maxi; + std::vector Presque_mini; std::vector ESPE; std::vector STDE; float** LISS; diff --git a/src/solver/ts-generator/xcast/xcast.cpp b/src/solver/ts-generator/xcast/xcast.cpp index 47505e734e..8fb69c9961 100644 --- a/src/solver/ts-generator/xcast/xcast.cpp +++ b/src/solver/ts-generator/xcast/xcast.cpp @@ -274,8 +274,8 @@ void XCast::allocateTemporaryData() pUseConversion.resize(p); - Presque_maxi = m.allocate(p); - Presque_mini = m.allocate(p); + Presque_maxi.resize(p); + Presque_mini.resize(p); pQCHOLTotal = m.allocate(p); CORR = m.allocate(p); @@ -332,8 +332,6 @@ void XCast::destroyTemporaryData() delete[] FO; delete[] M; delete[] L; - delete[] Presque_maxi; - delete[] Presque_mini; delete[] pQCHOLTotal; } } From 21d99811005cfcbc6b104da83142ffed7ba3dba3 Mon Sep 17 00:00:00 2001 From: Vincent Payet Date: Thu, 18 Jul 2024 11:00:52 +0200 Subject: [PATCH 10/21] xcast M COPIE QCHOLTOTAL --- .../include/antares/solver/ts-generator/xcast/xcast.h | 6 +++--- src/solver/ts-generator/xcast/core.cpp | 8 ++++---- src/solver/ts-generator/xcast/xcast.cpp | 9 +++------ 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/solver/ts-generator/include/antares/solver/ts-generator/xcast/xcast.h b/src/solver/ts-generator/include/antares/solver/ts-generator/xcast/xcast.h index e1bd46e9c4..2caef5cff3 100644 --- a/src/solver/ts-generator/include/antares/solver/ts-generator/xcast/xcast.h +++ b/src/solver/ts-generator/include/antares/solver/ts-generator/xcast/xcast.h @@ -200,7 +200,7 @@ class XCast final: private Yuni::NonCopyable std::vector B; std::vector G; std::vector D; - int* M; + std::vector M; std::vector T; Data::XCast::Distribution* L; std::vector BO; @@ -235,12 +235,12 @@ class XCast final: private Yuni::NonCopyable float** Carre_reference; float** Carre_courant; - float* D_COPIE; + std::vector D_COPIE; float** DATA; // cholesky temporary data - float* pQCHOLTotal; + std::vector pQCHOLTotal; //! std::vector pUseConversion; diff --git a/src/solver/ts-generator/xcast/core.cpp b/src/solver/ts-generator/xcast/core.cpp index a3d373e2c1..568b5dfa0e 100644 --- a/src/solver/ts-generator/xcast/core.cpp +++ b/src/solver/ts-generator/xcast/core.cpp @@ -93,7 +93,7 @@ bool XCast::generateValuesForTheCurrentDay() // si les parametres ont change on reinitialise certaines variables intermediaires if (pNewMonth) { - if (Cholesky(Triangle_courant, pCorrMonth->entry, processCount, pQCHOLTotal)) + if (Cholesky(Triangle_courant, pCorrMonth->entry, processCount, pQCHOLTotal.data())) { // C n'est pas sdp, mais peut-etre proche de sdp // on tente un abattement de 0.999 @@ -107,7 +107,7 @@ bool XCast::generateValuesForTheCurrentDay() } } - if (Cholesky(Triangle_courant, pCorrMonth->entry, processCount, pQCHOLTotal)) + if (Cholesky(Triangle_courant, pCorrMonth->entry, processCount, pQCHOLTotal.data())) { // la matrice C n'est pas admissible, on abandonne logs.error() << "TS " << pTSName << " generator: invalid correlation matrix"; @@ -227,7 +227,7 @@ bool XCast::generateValuesForTheCurrentDay() Carre_reference, pCorrMonth->entry, processCount, - pQCHOLTotal); + pQCHOLTotal.data()); if (shrink == -1.f) { // sortie impossible car on a v�rifi� que C est d.p @@ -453,7 +453,7 @@ bool XCast::generateValuesForTheCurrentDay() Carre_courant, Carre_reference, processCount, - pQCHOLTotal); + pQCHOLTotal.data()); if (shrink <= 1.f) { if (shrink == -1.f) diff --git a/src/solver/ts-generator/xcast/xcast.cpp b/src/solver/ts-generator/xcast/xcast.cpp index 8fb69c9961..603e37b1f4 100644 --- a/src/solver/ts-generator/xcast/xcast.cpp +++ b/src/solver/ts-generator/xcast/xcast.cpp @@ -250,7 +250,7 @@ void XCast::allocateTemporaryData() B.resize(p); G.resize(p); D.resize(p); - M = m.allocate(p); + M.resize(p); T.resize(p); BO.resize(p); MA.resize(p); @@ -270,13 +270,13 @@ void XCast::allocateTemporaryData() ALPH.resize(p); BETA.resize(p); - D_COPIE = m.allocate(p); + D_COPIE.resize(p); pUseConversion.resize(p); Presque_maxi.resize(p); Presque_mini.resize(p); - pQCHOLTotal = m.allocate(p); + pQCHOLTotal.resize(p); CORR = m.allocate(p); Triangle_reference = m.allocate(p); @@ -322,7 +322,6 @@ void XCast::destroyTemporaryData() } delete[] Carre_courant; delete[] Carre_reference; - delete[] D_COPIE; delete[] DATA; delete[] Triangle_reference; delete[] Triangle_courant; @@ -330,9 +329,7 @@ void XCast::destroyTemporaryData() delete[] DATL; delete[] CORR; delete[] FO; - delete[] M; delete[] L; - delete[] pQCHOLTotal; } } From 250d606d504c8c18106fceb821f9a8ec6207be07 Mon Sep 17 00:00:00 2001 From: Vincent Payet Date: Thu, 18 Jul 2024 11:02:22 +0200 Subject: [PATCH 11/21] format --- src/solver/ts-generator/xcast/core.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/solver/ts-generator/xcast/core.cpp b/src/solver/ts-generator/xcast/core.cpp index 568b5dfa0e..f258507565 100644 --- a/src/solver/ts-generator/xcast/core.cpp +++ b/src/solver/ts-generator/xcast/core.cpp @@ -107,7 +107,10 @@ bool XCast::generateValuesForTheCurrentDay() } } - if (Cholesky(Triangle_courant, pCorrMonth->entry, processCount, pQCHOLTotal.data())) + if (Cholesky(Triangle_courant, + pCorrMonth->entry, + processCount, + pQCHOLTotal.data())) { // la matrice C n'est pas admissible, on abandonne logs.error() << "TS " << pTSName << " generator: invalid correlation matrix"; From 05c4c3ad141b8a9f1d472c0a04a2e708406bc389 Mon Sep 17 00:00:00 2001 From: Vincent Payet Date: Thu, 18 Jul 2024 11:12:41 +0200 Subject: [PATCH 12/21] xcast Triangle_reference courrant carre --- .../include/antares/solver/misc/cholesky.hxx | 6 ++--- .../antares/solver/ts-generator/xcast/xcast.h | 8 +++---- src/solver/ts-generator/xcast/xcast.cpp | 24 +++++++------------ 3 files changed, 15 insertions(+), 23 deletions(-) diff --git a/src/solver/misc/include/antares/solver/misc/cholesky.hxx b/src/solver/misc/include/antares/solver/misc/cholesky.hxx index 26c333d785..90418c17b2 100644 --- a/src/solver/misc/include/antares/solver/misc/cholesky.hxx +++ b/src/solver/misc/include/antares/solver/misc/cholesky.hxx @@ -42,7 +42,7 @@ bool Cholesky(U1& L, U2& A, uint size, T* temp) for (uint i = 0; i < size; ++i) { - typename MatrixSubColumn::Type Li = L[i]; + auto& Li = L[i]; // on calcule d'abord L[i][i] som = A[i][i]; @@ -58,8 +58,8 @@ bool Cholesky(U1& L, U2& A, uint size, T* temp) // maintenant on cherche L[k][i], k > i. for (uint k = i + 1; k < size; ++k) { - typename MatrixSubColumn::Type Lk = L[k]; - typename MatrixSubColumn::Type Ak = A[k]; + auto& Lk = L[k]; + auto& Ak = A[k]; if (temp[k] == Ak[k]) { diff --git a/src/solver/ts-generator/include/antares/solver/ts-generator/xcast/xcast.h b/src/solver/ts-generator/include/antares/solver/ts-generator/xcast/xcast.h index 2caef5cff3..dc3f6f9fdf 100644 --- a/src/solver/ts-generator/include/antares/solver/ts-generator/xcast/xcast.h +++ b/src/solver/ts-generator/include/antares/solver/ts-generator/xcast/xcast.h @@ -230,10 +230,10 @@ class XCast final: private Yuni::NonCopyable std::vector ALPH; // used only if all processes are Normal std::vector BETA; // used only if all processes are Normal - float** Triangle_reference; - float** Triangle_courant; - float** Carre_reference; - float** Carre_courant; + std::vector> Triangle_reference; + std::vector> Triangle_courant; + std::vector> Carre_reference; + std::vector> Carre_courant; std::vector D_COPIE; diff --git a/src/solver/ts-generator/xcast/xcast.cpp b/src/solver/ts-generator/xcast/xcast.cpp index 603e37b1f4..7bd32c133d 100644 --- a/src/solver/ts-generator/xcast/xcast.cpp +++ b/src/solver/ts-generator/xcast/xcast.cpp @@ -279,21 +279,21 @@ void XCast::allocateTemporaryData() pQCHOLTotal.resize(p); CORR = m.allocate(p); - Triangle_reference = m.allocate(p); - Triangle_courant = m.allocate(p); + Triangle_reference.resize(p); + Triangle_courant.resize(p); FO = m.allocate(p); LISS = m.allocate(p); DATL = m.allocate(p); DATA = m.allocate(p); - Carre_courant = m.allocate(p); - Carre_reference = m.allocate(p); + Carre_courant.resize(p); + Carre_reference.resize(p); for (uint i = 0; i != p; ++i) { - Triangle_reference[i] = m.allocate(p); - Triangle_courant[i] = m.allocate(p); - Carre_courant[i] = m.allocate(p); - Carre_reference[i] = m.allocate(p); + Triangle_reference[i].resize(p); + Triangle_courant[i].resize(p); + Carre_courant[i].resize(p); + Carre_reference[i].resize(p); CORR[i] = m.allocate(p); FO[i] = m.allocate(24); @@ -314,17 +314,9 @@ void XCast::destroyTemporaryData() delete[] FO[i]; delete[] LISS[i]; delete[] DATL[i]; - delete[] Triangle_reference[i]; - delete[] Triangle_courant[i]; delete[] DATA[i]; - delete[] Carre_courant[i]; - delete[] Carre_reference[i]; } - delete[] Carre_courant; - delete[] Carre_reference; delete[] DATA; - delete[] Triangle_reference; - delete[] Triangle_courant; delete[] LISS; delete[] DATL; delete[] CORR; From c50ea92928f502eca21084f1ca37697086c4d74c Mon Sep 17 00:00:00 2001 From: Vincent Payet Date: Thu, 18 Jul 2024 11:22:00 +0200 Subject: [PATCH 13/21] xcast other double vector float --- .../antares/solver/ts-generator/xcast/xcast.h | 10 ++-- src/solver/ts-generator/xcast/core.cpp | 2 +- src/solver/ts-generator/xcast/xcast.cpp | 48 +++++++------------ 3 files changed, 22 insertions(+), 38 deletions(-) diff --git a/src/solver/ts-generator/include/antares/solver/ts-generator/xcast/xcast.h b/src/solver/ts-generator/include/antares/solver/ts-generator/xcast/xcast.h index dc3f6f9fdf..f4c0e6af7a 100644 --- a/src/solver/ts-generator/include/antares/solver/ts-generator/xcast/xcast.h +++ b/src/solver/ts-generator/include/antares/solver/ts-generator/xcast/xcast.h @@ -206,20 +206,20 @@ class XCast final: private Yuni::NonCopyable std::vector BO; std::vector MA; std::vector MI; - float** FO; // contrainte : FO >=0 + std::vector> FO; // contrainte : FO >=0 float STEP; float SQST; std::vector POSI; - float** CORR; + std::vector> CORR; std::vector MAXI; std::vector MINI; std::vector Presque_maxi; std::vector Presque_mini; std::vector ESPE; std::vector STDE; - float** LISS; - float** DATL; + std::vector> LISS; + std::vector> DATL; std::vector DIFF; std::vector TREN; @@ -237,7 +237,7 @@ class XCast final: private Yuni::NonCopyable std::vector D_COPIE; - float** DATA; + std::vector> DATA; // cholesky temporary data std::vector pQCHOLTotal; diff --git a/src/solver/ts-generator/xcast/core.cpp b/src/solver/ts-generator/xcast/core.cpp index f258507565..1eab73d534 100644 --- a/src/solver/ts-generator/xcast/core.cpp +++ b/src/solver/ts-generator/xcast/core.cpp @@ -417,7 +417,7 @@ bool XCast::generateValuesForTheCurrentDay() for (uint s = 0; s != processCount; ++s) { - float* corr_s = CORR[s]; + auto& corr_s = CORR[s]; auto& userMonthlyCorr = pCorrMonth->column(s); for (uint t = 0; t < s; ++t) { diff --git a/src/solver/ts-generator/xcast/xcast.cpp b/src/solver/ts-generator/xcast/xcast.cpp index 7bd32c133d..c20caaebaf 100644 --- a/src/solver/ts-generator/xcast/xcast.cpp +++ b/src/solver/ts-generator/xcast/xcast.cpp @@ -114,8 +114,6 @@ void XCast::applyTransferFunction(PredicateT& predicate) float a[maxPoints]; float b[maxPoints]; - float* dailyResults; - const uint processCount = (uint)pData.localareas.size(); for (uint s = 0; s != processCount; ++s) @@ -145,7 +143,7 @@ void XCast::applyTransferFunction(PredicateT& predicate) b[i] = (p0[y] * p1[x] - p1[y] * p0[x]) / (p1[x] - p0[x]); } - dailyResults = DATA[s]; + auto& dailyResults = DATA[s]; for (h = 0; h != HOURS_PER_DAY; ++h) { for (i = 0; i != tf.width; ++i) @@ -278,13 +276,13 @@ void XCast::allocateTemporaryData() Presque_mini.resize(p); pQCHOLTotal.resize(p); - CORR = m.allocate(p); + CORR.resize(p); Triangle_reference.resize(p); Triangle_courant.resize(p); - FO = m.allocate(p); - LISS = m.allocate(p); - DATL = m.allocate(p); - DATA = m.allocate(p); + FO.resize(p); + LISS.resize(p); + DATL.resize(p); + DATA.resize(p); Carre_courant.resize(p); Carre_reference.resize(p); @@ -295,11 +293,11 @@ void XCast::allocateTemporaryData() Carre_courant[i].resize(p); Carre_reference[i].resize(p); - CORR[i] = m.allocate(p); - FO[i] = m.allocate(24); - LISS[i] = m.allocate(24); - DATL[i] = m.allocate(24); - DATA[i] = m.allocate(24); + CORR[i].resize(p); + FO[i].resize(24); + LISS[i].resize(24); + DATL[i].resize(24); + DATA[i].resize(24); } } @@ -307,20 +305,6 @@ void XCast::destroyTemporaryData() { if (!pNeverInitialized) { - uint p = (uint)pData.localareas.size(); - for (uint i = 0; i != p; ++i) - { - delete[] CORR[i]; - delete[] FO[i]; - delete[] LISS[i]; - delete[] DATL[i]; - delete[] DATA[i]; - } - delete[] DATA; - delete[] LISS; - delete[] DATL; - delete[] CORR; - delete[] FO; delete[] L; } } @@ -442,7 +426,7 @@ bool XCast::runWithPredicate(PredicateT& predicate, Progression::Task& progressi MA[s] = +std::numeric_limits::max(); } } - memcpy(FO[s], xcastdata.K[realmonth], sizeof(float) * HOURS_PER_DAY); + memcpy(FO[s].data(), xcastdata.K[realmonth], sizeof(float) * HOURS_PER_DAY); } uint nbDaysPerMonth = study.calendar.months[month].days; @@ -457,7 +441,7 @@ bool XCast::runWithPredicate(PredicateT& predicate, Progression::Task& progressi for (uint s = 0; s != processCount; ++s) { - float* dailyResults = DATA[s]; + auto& dailyResults = DATA[s]; for (uint h = 0; h != HOURS_PER_DAY; ++h) { @@ -478,7 +462,7 @@ bool XCast::runWithPredicate(PredicateT& predicate, Progression::Task& progressi } auto& column = srcData.translation[0]; - float* dailyResults = DATA[s]; + auto& dailyResults = DATA[s]; assert(hourInTheYear + HOURS_PER_DAY <= srcData.translation.height && "Bound checking"); @@ -495,7 +479,7 @@ bool XCast::runWithPredicate(PredicateT& predicate, Progression::Task& progressi for (uint s = 0; s != processCount; ++s) { - float* dailyResults = DATA[s]; + auto& dailyResults = DATA[s]; for (uint h = 0; h != HOURS_PER_DAY; ++h) { @@ -514,7 +498,7 @@ bool XCast::runWithPredicate(PredicateT& predicate, Progression::Task& progressi auto& series = predicate.matrix(currentArea); assert(tsIndex < series.width); auto& column = series.column(tsIndex); - float* dailyResults = DATA[s]; + auto& dailyResults = DATA[s]; for (uint h = 0; h != HOURS_PER_DAY; ++h) { From c91972457d27299b8934bff09027f6792d5935da Mon Sep 17 00:00:00 2001 From: Vincent Payet Date: Thu, 18 Jul 2024 11:22:54 +0200 Subject: [PATCH 14/21] xcast L --- .../include/antares/solver/ts-generator/xcast/xcast.h | 2 +- src/solver/ts-generator/xcast/xcast.cpp | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/solver/ts-generator/include/antares/solver/ts-generator/xcast/xcast.h b/src/solver/ts-generator/include/antares/solver/ts-generator/xcast/xcast.h index f4c0e6af7a..75aa6e1b37 100644 --- a/src/solver/ts-generator/include/antares/solver/ts-generator/xcast/xcast.h +++ b/src/solver/ts-generator/include/antares/solver/ts-generator/xcast/xcast.h @@ -202,7 +202,7 @@ class XCast final: private Yuni::NonCopyable std::vector D; std::vector M; std::vector T; - Data::XCast::Distribution* L; + std::vector L; std::vector BO; std::vector MA; std::vector MI; diff --git a/src/solver/ts-generator/xcast/xcast.cpp b/src/solver/ts-generator/xcast/xcast.cpp index c20caaebaf..257cf6ac4d 100644 --- a/src/solver/ts-generator/xcast/xcast.cpp +++ b/src/solver/ts-generator/xcast/xcast.cpp @@ -253,7 +253,7 @@ void XCast::allocateTemporaryData() BO.resize(p); MA.resize(p); MI.resize(p); - L = m.allocate(p); + L.resize(p); POSI.resize(p); MAXI.resize(p); MINI.resize(p); @@ -305,7 +305,6 @@ void XCast::destroyTemporaryData() { if (!pNeverInitialized) { - delete[] L; } } From e0f7409158f20f833d37de84a76ffad2bca32e61 Mon Sep 17 00:00:00 2001 From: Vincent Payet Date: Thu, 18 Jul 2024 11:25:29 +0200 Subject: [PATCH 15/21] remove xcast destuctor --- .../antares/solver/ts-generator/xcast/xcast.h | 3 +-- src/solver/ts-generator/xcast/xcast.cpp | 12 ------------ 2 files changed, 1 insertion(+), 14 deletions(-) diff --git a/src/solver/ts-generator/include/antares/solver/ts-generator/xcast/xcast.h b/src/solver/ts-generator/include/antares/solver/ts-generator/xcast/xcast.h index 75aa6e1b37..8093f4185a 100644 --- a/src/solver/ts-generator/include/antares/solver/ts-generator/xcast/xcast.h +++ b/src/solver/ts-generator/include/antares/solver/ts-generator/xcast/xcast.h @@ -74,7 +74,7 @@ class XCast final: private Yuni::NonCopyable /*! ** \brief Destructor */ - ~XCast(); + ~XCast() = default; //@} //! \name Loading @@ -105,7 +105,6 @@ class XCast final: private Yuni::NonCopyable private: void allocateTemporaryData(); - void destroyTemporaryData(); template void updateMissingCoefficients(PredicateT& predicate); diff --git a/src/solver/ts-generator/xcast/xcast.cpp b/src/solver/ts-generator/xcast/xcast.cpp index 257cf6ac4d..e5f261401f 100644 --- a/src/solver/ts-generator/xcast/xcast.cpp +++ b/src/solver/ts-generator/xcast/xcast.cpp @@ -58,11 +58,6 @@ XCast::XCast(Data::Study& study, Data::TimeSeriesType ts, IResultWriter& writer) { } -XCast::~XCast() -{ - destroyTemporaryData(); -} - template void XCast::exportTimeSeriesToTheOutput(Progression::Task& progression, PredicateT& predicate) { @@ -301,13 +296,6 @@ void XCast::allocateTemporaryData() } } -void XCast::destroyTemporaryData() -{ - if (!pNeverInitialized) - { - } -} - template bool XCast::runWithPredicate(PredicateT& predicate, Progression::Task& progression) { From 810b71e0a581ffb303fe93da92381b3c19250e19 Mon Sep 17 00:00:00 2001 From: Vincent Payet Date: Thu, 18 Jul 2024 11:52:24 +0200 Subject: [PATCH 16/21] unused alias --- src/libs/antares/study/area/list.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libs/antares/study/area/list.cpp b/src/libs/antares/study/area/list.cpp index d16c6e9ab6..b63d291ff5 100644 --- a/src/libs/antares/study/area/list.cpp +++ b/src/libs/antares/study/area/list.cpp @@ -470,7 +470,6 @@ void AreaList::rebuildIndexes() if (!areas.empty()) { - using AreaWeakPtr = Area*; byIndex.resize(areas.size()); uint indx = 0; From 8ba6f146da1b7339ae2f01e265159026d1b60c59 Mon Sep 17 00:00:00 2001 From: Vincent Payet Date: Thu, 18 Jul 2024 12:35:46 +0200 Subject: [PATCH 17/21] remove allocator class --- src/solver/ts-generator/xcast/xcast.cpp | 42 ------------------------- 1 file changed, 42 deletions(-) diff --git a/src/solver/ts-generator/xcast/xcast.cpp b/src/solver/ts-generator/xcast/xcast.cpp index e5f261401f..12f563f19f 100644 --- a/src/solver/ts-generator/xcast/xcast.cpp +++ b/src/solver/ts-generator/xcast/xcast.cpp @@ -193,52 +193,10 @@ void XCast::updateMissingCoefficients(PredicateT& predicate) } } -namespace -{ -template -class Allocator -{ -public: - Allocator(): - allocated(0) - { - } - - ~Allocator() - { - logs.debug() << " allocated " << (allocated / 1024) << "Ko"; - } - - template - inline T* allocate(const size_t s) - { - allocated += sizeof(T) * s; - return new T[s]; - } - -public: - size_t allocated; -}; - -template<> -class Allocator<0> -{ -public: - template - inline T* allocate(const size_t s) const - { - return new T[s]; - } -}; - -} // namespace - void XCast::allocateTemporaryData() { uint p = (uint)pData.localareas.size(); - Allocator m; - A.resize(p); B.resize(p); G.resize(p); From dc5f85b3b7709826b1b9c7b02b45b8a16a024eb7 Mon Sep 17 00:00:00 2001 From: Vincent Payet Date: Fri, 19 Jul 2024 15:02:07 +0200 Subject: [PATCH 18/21] xcast constructor --- .../include/antares/solver/ts-generator/xcast/xcast.h | 4 ++-- src/solver/ts-generator/xcast/xcast.cpp | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/solver/ts-generator/include/antares/solver/ts-generator/xcast/xcast.h b/src/solver/ts-generator/include/antares/solver/ts-generator/xcast/xcast.h index 8093f4185a..34b588b972 100644 --- a/src/solver/ts-generator/include/antares/solver/ts-generator/xcast/xcast.h +++ b/src/solver/ts-generator/include/antares/solver/ts-generator/xcast/xcast.h @@ -179,7 +179,7 @@ class XCast final: private Yuni::NonCopyable //! The correlation matrix for the current month const Matrix* pCorrMonth; - bool pNeverInitialized; + bool pNeverInitialized = true; uint Nombre_points_intermediaire; //! True when starting a new month (some data may have to be reinitialized) @@ -191,7 +191,7 @@ class XCast final: private Yuni::NonCopyable uint pNDPMatrixCount; uint pLevellingCount; - bool pAccuracyOnCorrelation; + bool pAccuracyOnCorrelation = false; bool All_normal; // all processes are Normal // les variables de A à CO sont des vues de ALPH à CORR pour un mois particulier diff --git a/src/solver/ts-generator/xcast/xcast.cpp b/src/solver/ts-generator/xcast/xcast.cpp index 12f563f19f..b431e8d8ff 100644 --- a/src/solver/ts-generator/xcast/xcast.cpp +++ b/src/solver/ts-generator/xcast/xcast.cpp @@ -52,8 +52,6 @@ enum XCast::XCast(Data::Study& study, Data::TimeSeriesType ts, IResultWriter& writer): study(study), timeSeriesType(ts), - pNeverInitialized(true), - pAccuracyOnCorrelation(false), pWriter(writer) { } From b4316f2a219fa54ed59459c6bf31d371b7319d79 Mon Sep 17 00:00:00 2001 From: Vincent Payet Date: Fri, 19 Jul 2024 15:14:35 +0200 Subject: [PATCH 19/21] remove useless if --- src/libs/antares/study/area/list.cpp | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/src/libs/antares/study/area/list.cpp b/src/libs/antares/study/area/list.cpp index b63d291ff5..c0e0e0d853 100644 --- a/src/libs/antares/study/area/list.cpp +++ b/src/libs/antares/study/area/list.cpp @@ -468,19 +468,16 @@ void AreaList::rebuildIndexes() { byIndex.clear(); - if (!areas.empty()) - { - byIndex.resize(areas.size()); - - uint indx = 0; - auto end = areas.end(); - for (auto i = areas.begin(); i != end; ++i, ++indx) - { - Area* area = i->second; - byIndex[indx] = area; - area->index = indx; - } - } + byIndex.resize(areas.size()); + + uint indx = 0; + auto end = areas.end(); + for (auto i = areas.begin(); i != end; ++i, ++indx) + { + Area* area = i->second; + byIndex[indx] = area; + area->index = indx; + } } Area* AreaList::add(Area* a) From d69b14daddb15c6041b4753860ba76d406831272 Mon Sep 17 00:00:00 2001 From: Vincent Payet Date: Fri, 19 Jul 2024 15:21:33 +0200 Subject: [PATCH 20/21] remove useless if 2 --- src/libs/antares/study/area/list.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/libs/antares/study/area/list.cpp b/src/libs/antares/study/area/list.cpp index c0e0e0d853..e89c43105c 100644 --- a/src/libs/antares/study/area/list.cpp +++ b/src/libs/antares/study/area/list.cpp @@ -451,16 +451,13 @@ void AreaList::clear() { byIndex.clear(); - if (!areas.empty()) - { - Area::Map copy; - copy.swap(areas); + Area::Map copy; + copy.swap(areas); - auto end = copy.end(); - for (auto i = copy.begin(); i != end; ++i) - { - delete i->second; - } + auto end = copy.end(); + for (auto i = copy.begin(); i != end; ++i) + { + delete i->second; } } From fe396d6dcae8127d3da955aabcb9970aa97a8510 Mon Sep 17 00:00:00 2001 From: Vincent Payet Date: Fri, 19 Jul 2024 15:49:44 +0200 Subject: [PATCH 21/21] format --- src/libs/antares/study/area/list.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/libs/antares/study/area/list.cpp b/src/libs/antares/study/area/list.cpp index e89c43105c..46a2e98c6f 100644 --- a/src/libs/antares/study/area/list.cpp +++ b/src/libs/antares/study/area/list.cpp @@ -465,16 +465,16 @@ void AreaList::rebuildIndexes() { byIndex.clear(); - byIndex.resize(areas.size()); - - uint indx = 0; - auto end = areas.end(); - for (auto i = areas.begin(); i != end; ++i, ++indx) - { - Area* area = i->second; - byIndex[indx] = area; - area->index = indx; - } + byIndex.resize(areas.size()); + + uint indx = 0; + auto end = areas.end(); + for (auto i = areas.begin(); i != end; ++i, ++indx) + { + Area* area = i->second; + byIndex[indx] = area; + area->index = indx; + } } Area* AreaList::add(Area* a)