diff --git a/src/libs/antares/InfoCollection/StudyInfoCollector.cpp b/src/libs/antares/InfoCollection/StudyInfoCollector.cpp index 05f9894f12..ba626a59ed 100644 --- a/src/libs/antares/InfoCollection/StudyInfoCollector.cpp +++ b/src/libs/antares/InfoCollection/StudyInfoCollector.cpp @@ -59,13 +59,8 @@ void StudyInfoCollector::enabledThermalClustersCountToFileContent(FileContent& f for (auto i = study_.areas.begin(); i != end; ++i) { Area& area = *(i->second); - auto end = area.thermal.list.end(); - for (auto i = area.thermal.list.begin(); i != end; ++i) - { - auto& cluster = i->second; - if (cluster->enabled) - nbEnabledThermalClusters++; - } + nbEnabledThermalClusters += + std::ranges::count_if(area.thermal.list, [](const auto& c) { return c->enabled; }); } // Adding an item related to number of enabled thermal clusters to the file content @@ -152,4 +147,4 @@ void SimulationInfoCollector::toFileContent(FileContent& file_content) "optimization problem", "non-zero coefficients", opt_info_.nbNonZeroCoeffs); } -} \ No newline at end of file +} diff --git a/src/libs/antares/study/area/list.cpp b/src/libs/antares/study/area/list.cpp index 9e6a324e26..8616410dbe 100644 --- a/src/libs/antares/study/area/list.cpp +++ b/src/libs/antares/study/area/list.cpp @@ -1534,8 +1534,8 @@ ThermalCluster* AreaList::findClusterFromINIKey(const AnyString& key) Area* parentArea = findFromName(parentName); if (parentArea == nullptr) return nullptr; - ThermalCluster* i = parentArea->thermal.list.find(id); - return (i != nullptr) ? i : nullptr; + return parentArea->thermal.list.find(id); + } void AreaList::updateNameIDSet() const diff --git a/src/libs/antares/study/cleaner/cleaner-v20.cpp b/src/libs/antares/study/cleaner/cleaner-v20.cpp index a0f4dea784..5f8e6636e1 100644 --- a/src/libs/antares/study/cleaner/cleaner-v20.cpp +++ b/src/libs/antares/study/cleaner/cleaner-v20.cpp @@ -135,23 +135,19 @@ static void listOfFilesAnDirectoriesToKeepForArea(PathList& e, PathList& p, cons buffer.clear() << "input/thermal/clusters/" << id << "/list.ini"; e.add(buffer); - auto end = area->thermal.list.end(); - for (auto i = area->thermal.list.begin(); i != end; ++i) + for (const auto& cluster : area->thermal.list) { - // Reference to the thermal cluster - auto& cluster = *(i->second); - - buffer.clear() << "input/thermal/prepro/" << id << '/' << cluster.id(); + buffer.clear() << "input/thermal/prepro/" << id << '/' << cluster->id(); p.add(buffer); - buffer.clear() << "input/thermal/series/" << id << '/' << cluster.id(); + buffer.clear() << "input/thermal/series/" << id << '/' << cluster->id(); p.add(buffer); - buffer.clear() << "input/thermal/series/" << id << '/' << cluster.id() << "/series.txt"; + buffer.clear() << "input/thermal/series/" << id << '/' << cluster->id() << "/series.txt"; e.add(buffer); - buffer.clear() << "input/thermal/prepro/" << id << '/' << cluster.id() << "/data.txt"; + buffer.clear() << "input/thermal/prepro/" << id << '/' << cluster->id() << "/data.txt"; e.add(buffer); - buffer.clear() << "input/thermal/prepro/" << id << '/' << cluster.id() + buffer.clear() << "input/thermal/prepro/" << id << '/' << cluster->id() << "/modulation.txt"; e.add(buffer); } @@ -168,16 +164,12 @@ static void listOfFilesAnDirectoriesToKeepForArea(PathList& e, PathList& p, cons buffer.clear() << "input/renewables/clusters/" << id << "/list.ini"; e.add(buffer); - auto end = area->renewable.list.end(); - for (auto i = area->renewable.list.begin(); i != end; ++i) + for (const auto& cluster : area->renewable.list) { - // Reference to the thermal cluster - auto& cluster = *(i->second); - - buffer.clear() << "input/renewables/series/" << id << '/' << cluster.id(); + buffer.clear() << "input/renewables/series/" << id << '/' << cluster->id(); p.add(buffer); - buffer.clear() << "input/renewables/series/" << id << '/' << cluster.id() + buffer.clear() << "input/renewables/series/" << id << '/' << cluster->id() << "/series.txt"; e.add(buffer); } diff --git a/src/libs/antares/study/parts/common/cluster.cpp b/src/libs/antares/study/parts/common/cluster.cpp index 64e925f8a5..265b8f4d51 100644 --- a/src/libs/antares/study/parts/common/cluster.cpp +++ b/src/libs/antares/study/parts/common/cluster.cpp @@ -49,45 +49,38 @@ void Cluster::setName(const AnyString& newname) } #define SEP Yuni::IO::Separator -int Cluster::saveDataSeriesToFolder(const AnyString& folder) const +bool Cluster::saveDataSeriesToFolder(const AnyString& folder) const { - if (not folder.empty()) - { - Yuni::Clob buffer; - - buffer.clear() << folder << SEP << parentArea->id << SEP << id(); - if (Yuni::IO::Directory::Create(buffer)) - { - int ret = 1; - buffer.clear() << folder << SEP << parentArea->id << SEP << id() << SEP << "series.txt"; - ret = series.timeSeries.saveToCSVFile(buffer, precision()) && ret; - - return ret; - } - return 0; - } - return 1; + if (folder.empty()) + return true; + + Yuni::Clob buffer; + buffer.clear() << folder << SEP << parentArea->id << SEP << id(); + if (!Yuni::IO::Directory::Create(buffer)) + return true; + + buffer.clear() << folder << SEP << parentArea->id << SEP << id() << SEP << "series.txt"; + return series.timeSeries.saveToCSVFile(buffer, precision()); } -int Cluster::loadDataSeriesFromFolder(Study& s, const AnyString& folder) +bool Cluster::loadDataSeriesFromFolder(Study& s, const AnyString& folder) { - if (not folder.empty()) - { - auto& buffer = s.bufferLoadingTS; + if (folder.empty()) + return true; + + auto& buffer = s.bufferLoadingTS; - int ret = 1; - buffer.clear() << folder << SEP << parentArea->id << SEP << id() << SEP << "series." - << s.inputExtension; - ret = series.timeSeries.loadFromCSVFile(buffer, 1, HOURS_PER_YEAR, &s.dataBuffer) && ret; + bool ret = true; + buffer.clear() << folder << SEP << parentArea->id << SEP << id() << SEP << "series." + << s.inputExtension; + ret = series.timeSeries.loadFromCSVFile(buffer, 1, HOURS_PER_YEAR, &s.dataBuffer) && ret; - if (s.usedByTheSolver && s.parameters.derated) - series.timeSeries.averageTimeseries(); + if (s.usedByTheSolver && s.parameters.derated) + series.timeSeries.averageTimeseries(); - series.timeseriesNumbers.clear(); + series.timeseriesNumbers.clear(); - return ret; - } - return 1; + return ret; } #undef SEP diff --git a/src/libs/antares/study/parts/common/cluster.h b/src/libs/antares/study/parts/common/cluster.h index eee596ede1..d552eb54b8 100644 --- a/src/libs/antares/study/parts/common/cluster.h +++ b/src/libs/antares/study/parts/common/cluster.h @@ -142,8 +142,8 @@ class Cluster //! Set of clusters using Set = std::set; - int saveDataSeriesToFolder(const AnyString& folder) const; - int loadDataSeriesFromFolder(Study& s, const AnyString& folder); + bool saveDataSeriesToFolder(const AnyString& folder) const; + bool loadDataSeriesFromFolder(Study& s, const AnyString& folder); private: virtual unsigned int precision() const = 0; diff --git a/src/libs/antares/study/parts/common/cluster_list.cpp b/src/libs/antares/study/parts/common/cluster_list.cpp index 3f08915727..bc5f8e5aa5 100644 --- a/src/libs/antares/study/parts/common/cluster_list.cpp +++ b/src/libs/antares/study/parts/common/cluster_list.cpp @@ -1,4 +1,6 @@ #include +#include +#include #include "cluster_list.h" #include #include "../../study.h" @@ -22,137 +24,63 @@ using namespace Antares; template inline uint ClusterList::size() const { - return (uint)cluster.size(); + return (uint)clusters.size(); } template inline bool ClusterList::empty() const { - return cluster.empty(); + return clusters.empty(); } template typename ClusterList::iterator ClusterList::begin() { - return std::begin(cluster); + return std::begin(clusters); } template typename ClusterList::const_iterator ClusterList::begin() const { - return std::begin(cluster); + return std::begin(clusters); } template typename ClusterList::iterator ClusterList::end() { - return std::end(cluster); + return std::end(clusters); } template typename ClusterList::const_iterator ClusterList::end() const { - return std::end(cluster); + return std::end(clusters); } template -const ClusterT* ClusterList::find(const Data::ClusterName& id) const +ClusterT* ClusterList::find(const Data::ClusterName& id) const { - auto i = cluster.find(id); - return (i != cluster.end()) ? i->second.get() : nullptr; -} - -template -ClusterT* ClusterList::find(const Data::ClusterName& id) -{ - auto i = cluster.find(id); - return (i != cluster.end()) ? i->second.get() : nullptr; -} + const auto& it = std::ranges::find_if(clusters, [&id](auto& c) { return c->id() == id; }); -template -typename std::shared_ptr ClusterList::detach(iterator i) -{ - SharedPtr c = i->second; - cluster.erase(i); - return c; -} - -template -void ClusterList::remove(iterator i) -{ - cluster.erase(i); + return (it != clusters.end()) ? it->get() : nullptr; } template bool ClusterList::exists(const Data::ClusterName& id) const { - if (not cluster.empty()) - { - auto element = cluster.find(id); - return (element != cluster.end()); - } - return false; -} - -template -Data::ClusterList::ClusterList() : groupCount(ClusterT::groupMax, 0) -{ -} - -template -Data::ClusterList::~ClusterList() -{ - // deleting all renewable clusters - clear(); + return std::ranges::any_of(clusters, [&id](const auto& c){ return c->id() == id; }); } template void ClusterList::clear() { - byIndex.clear(); - if (not cluster.empty()) - cluster.clear(); -} - -template -const ClusterT* ClusterList::find(const ClusterT* p) const -{ - auto end = cluster.end(); - for (auto i = cluster.begin(); i != end; ++i) - { - if (p == i->second.get()) - return i->second.get(); - } - return nullptr; -} - -template -ClusterT* ClusterList::find(const ClusterT* p) -{ - auto end = cluster.end(); - for (auto i = cluster.begin(); i != end; ++i) - { - if (p == i->second.get()) - return i->second.get(); - } - return nullptr; + clusters.clear(); } template void ClusterList::resizeAllTimeseriesNumbers(uint n) { - assert(n < 200000); // arbitrary number - if (not cluster.empty()) - { - if (0 == n) - { - each([&](Cluster& cluster) { cluster.series.timeseriesNumbers.clear(); }); - } - else - { - each([&](Cluster& cluster) { cluster.series.timeseriesNumbers.resize(1, n); }); - } - } + each([&](Cluster& cluster) { cluster.series.timeseriesNumbers.resize(1, n); }); } #define SEP IO::Separator @@ -160,9 +88,6 @@ void ClusterList::resizeAllTimeseriesNumbers(uint n) template void ClusterList::storeTimeseriesNumbers(Solver::IResultWriter& writer) const { - if (cluster.empty()) - return; - TSNumbersPredicate predicate; Clob path; std::string ts_content; @@ -179,38 +104,28 @@ void ClusterList::storeTimeseriesNumbers(Solver::IResultWriter& writer template void ClusterList::rebuildIndex() { - byIndex.clear(); + std::sort(clusters.begin(), clusters.end(), [](const auto& a, const auto& b){ + return a->id() < b->id(); + }); - if (not empty()) - { - uint indx = 0; - byIndex.resize(size()); - for (auto i = cluster.begin(); i != cluster.end(); ++i) - { - auto cluster = i->second.get(); - byIndex[indx] = cluster; - cluster->index = indx; - ++indx; - } - } + uint indx = 0; + for (auto& c : clusters) + c->index = indx++; } template typename ClusterList::SharedPtr ClusterList::add( - const ClusterList::SharedPtr& newcluster) + const ClusterList::SharedPtr newcluster) { - if (newcluster) - { - if (exists(newcluster->id())) - return cluster[newcluster->id()]; - - newcluster->index = (uint)size(); - cluster[newcluster->id()] = newcluster; - ++(groupCount[newcluster->groupId()]); - rebuildIndex(); - return cluster[newcluster->id()]; - } - return nullptr; + if (!newcluster) + return nullptr; + + if (exists(newcluster->id())) + return newcluster; + + clusters.push_back(newcluster); + rebuildIndex(); + return newcluster; } template @@ -218,7 +133,7 @@ uint64_t ClusterList::memoryUsage() const { uint64_t ret = sizeof(ClusterList) + (2 * sizeof(void*)) * this->size(); - each([&](const ClusterT& cluster) { ret += cluster.memoryUsage(); }); + each([&](const ClusterT& clusters) { ret += clusters.memoryUsage(); }); return ret; } @@ -241,37 +156,32 @@ bool ClusterList::rename(Data::ClusterName idToFind, Data::ClusterName Data::ClusterName newID; Antares::TransformNameIntoID(newName, newID); - // Looking for the renewable cluster in the list - auto it = cluster.find(idToFind); - if (it == cluster.end()) + // Looking for the renewable clusters in the list + auto* cluster_ptr = this->find(idToFind); + if (!cluster_ptr) return true; - SharedPtr p = it->second; - if (idToFind == newID) { - p->setName(newName); + cluster_ptr->setName(newName); return true; } // The name is the same. Aborting nicely. - if (p->name() == newName) + if (cluster_ptr->name() == newName) return true; // Already exist if (this->exists(newID)) return false; - cluster.erase(it); - - p->setName(newName); - cluster[newID] = p; + cluster_ptr->setName(newName); // Invalidate matrices attached to the area - // It is a bit excessive (all matrices not only those related to the renewable cluster) + // It is a bit excessive (all matrices not only those related to the renewable clusters) // will be rewritten but currently it is the less error-prone. - if (p->parentArea) - (p->parentArea)->invalidateJIT = true; + if (cluster_ptr->parentArea) + (cluster_ptr->parentArea)->invalidateJIT = true; // Rebuilding the index rebuildIndex(); @@ -281,88 +191,61 @@ bool ClusterList::rename(Data::ClusterName idToFind, Data::ClusterName template bool ClusterList::forceReload(bool reload) const { - bool ret = true; - auto end = cluster.end(); - for (auto i = cluster.begin(); i != end; ++i) - ret = (i->second)->forceReload(reload) and ret; - return ret; + return std::ranges::all_of(clusters, [&reload](const auto& c){ + return c->forceReload(reload); + }); + } template void ClusterList::markAsModified() const { - auto end = cluster.end(); - for (auto i = cluster.begin(); i != end; ++i) - (i->second)->markAsModified(); + for (const auto& c : clusters) + c->markAsModified(); } template bool ClusterList::remove(const Data::ClusterName& id) { - auto i = cluster.find(id); - if (i == cluster.end()) - return false; - - // Getting the pointer on the cluster - SharedPtr c = i->second; + auto nbDeletion = std::erase_if(clusters, [&id](const SharedPtr& c) { return c->id() == id; }); - // Removing it from the list - cluster.erase(i); // Invalidating the parent area - c->parentArea->forceReload(); + forceReload(); // Rebuilding the index rebuildIndex(); - return true; + + return nbDeletion > 0; } template -int ClusterList::saveDataSeriesToFolder(const AnyString& folder) const +bool ClusterList::saveDataSeriesToFolder(const AnyString& folder) const { - if (empty()) - return 1; - - int ret = 1; - - auto end = cluster.end(); - for (auto it = cluster.begin(); it != end; ++it) - { - auto& cluster = *(it->second); - ret = cluster.saveDataSeriesToFolder(folder) and ret; - } - return ret; + return std::ranges::all_of(clusters, [&folder](const auto& c){ + return c->saveDataSeriesToFolder(folder); + }); } template -int ClusterList::saveDataSeriesToFolder(const AnyString& folder, const String& msg) const +bool ClusterList::saveDataSeriesToFolder(const AnyString& folder, const String& msg) const { - if (empty()) - return 1; - - int ret = 1; uint ticks = 0; - auto end = cluster.end(); - for (auto it = cluster.begin(); it != end; ++it) + return std::ranges::all_of(clusters, [&](const auto& c) { - auto& cluster = *(it->second); - logs.info() << msg << " " << (ticks * 100 / (1 + this->cluster.size())) + logs.info() << msg << " " << (ticks * 100 / (1 + this->clusters.size())) << "% complete"; - ret = cluster.saveDataSeriesToFolder(folder) and ret; ++ticks; - } - return ret; + return c->saveDataSeriesToFolder(folder); + }); } template -int ClusterList::loadDataSeriesFromFolder(Study& s, +bool ClusterList::loadDataSeriesFromFolder(Study& s, const StudyLoadOptions& options, const AnyString& folder) { - if (empty()) - return 1; - - int ret = 1; + bool ret = true; each([&](ClusterT& c) { ret = c.loadDataSeriesFromFolder(s, folder) and ret; @@ -379,22 +262,26 @@ void ClusterList::retrieveTotalCapacityAndUnitCount(double& total, uin total = 0.; unitCount = 0; - if (not cluster.empty()) + for (const auto& c : clusters) { - auto end = cluster.cend(); - for (auto i = cluster.cbegin(); i != end; ++i) - { - if (not i->second) - return; - - // Reference to the thermal cluster - auto& cluster = *(i->second); - unitCount += cluster.unitCount; - total += cluster.unitCount * cluster.nominalCapacity; - } + unitCount += c->unitCount; + total += c->unitCount * c->nominalCapacity; } } +template +uint ClusterList::removeDisabledClusters() +{ + // nothing to do if there is no clusters available + if (empty()) + return 0; + + auto count = std::erase_if(clusters, [] (auto& c) { return !c->enabled; }); + + rebuildIndex(); + + return count; +} // Force template instantiation template class ClusterList; template class ClusterList; diff --git a/src/libs/antares/study/parts/common/cluster_list.h b/src/libs/antares/study/parts/common/cluster_list.h index 14f90d9fa3..9f3899aa8b 100644 --- a/src/libs/antares/study/parts/common/cluster_list.h +++ b/src/libs/antares/study/parts/common/cluster_list.h @@ -6,6 +6,7 @@ #include +#include #include #include @@ -14,65 +15,30 @@ namespace Antares namespace Data { /*! -** \brief List of clusters +** \brief Generic list of clusters ** \ingroup renewableclusters +** This class implements the base functions for a list of cluster +** It's used for thermal and renewable clusters */ template class ClusterList { public: - // Shared pointer using SharedPtr = typename std::shared_ptr; - // Map container - using Map = typename std::map; - //! iterator - using iterator = typename Map::iterator; - //! const iterator - using const_iterator = typename Map::const_iterator; + using Vect = typename std::vector; + using iterator = typename Vect::iterator; + using const_iterator = typename Vect::const_iterator; -public: - //! \name Constructor & Destructor - //@{ - /*! - ** \brief Default constructor - */ - ClusterList(); - /*! - ** \brief Destructor - */ - virtual ~ClusterList(); - //@} - - //! \name Iterating - //@{ - /*! - ** \brief Iterate through all clusters - */ - template - void each(const PredicateT& predicate) - { - auto end = cluster.cend(); - for (auto i = cluster.cbegin(); i != end; ++i) - { - auto& it = *(i->second); - predicate(it); - } - } /*! ** \brief Iterate through all clusters (const) */ template void each(const PredicateT& predicate) const { - auto end = cluster.end(); - for (auto i = cluster.begin(); i != end; ++i) - { - const auto& it = *(i->second); - predicate(it); - } + std::ranges::for_each(clusters, [&predicate](const auto& c) { predicate(*c); }); } - //! \name Cluster management + //! \name clusters management //@{ /*! ** \brief Destroy all clusters @@ -85,57 +51,15 @@ class ClusterList ** \param t The cluster to add ** \return True if the cluster has been added, false otherwise */ - - SharedPtr add(const SharedPtr& t); - /*! - ** \brief Detach a cluster represented by an iterator - ** - ** The cluster will be removed from the list but _not_ - ** destroyed. - ** The iterator should considered as invalid after using this method. - ** \return A pointer to the cluster, NULL if an error has occured - */ - SharedPtr detach(iterator i); - - /*! - ** \brief Remove a cluster represented by an iterator - ** - ** The cluster will be removed from the list but _not_ - ** destroyed. - ** The iterator should considered as invalid after using this method. - ** \return void - */ - virtual void remove(iterator i); + SharedPtr add(const SharedPtr clusters); - /*! - ** \brief Try to find a cluster from its id - ** - ** \param id ID of the cluster to find - ** \return A pointer to a cluster. nullptr if not found - */ - ClusterT* find(const Data::ClusterName& id); /*! ** \brief Try to find a cluster from its id (const) ** ** \param id ID of the cluster to find ** \return A pointer to a cluster. nullptr if not found */ - const ClusterT* find(const Data::ClusterName& id) const; - - /*! - ** \brief Try to find a cluster from its pointer - ** - ** \param p Pointer of the cluster to find - ** \return A pointer to a cluster. nullptr if not found - */ - ClusterT* find(const ClusterT* p); - /*! - ** \brief Try to find a cluster from its pointer (const) - ** - ** \param p Pointer of the cluster to find - ** \return A pointer to a cluster. nullptr if not found - */ - const ClusterT* find(const ClusterT* p) const; + ClusterT* find(const Data::ClusterName& id) const; /*! ** \brief Get if a cluster exists @@ -165,20 +89,18 @@ class ClusterList //! Get the number of items in the list uint size() const; - //! Get if the list is empty + //! Return true if the list is empty bool empty() const; //@} - //! iterator to the begining of the list iterator begin(); - //! iterator to the begining of the list const_iterator begin() const; - //! iterator to the end of the list iterator end(); - //! iterator to the end of the list const_iterator end() const; + SharedPtr operator[](std::size_t idx) { return clusters[idx]; } + const SharedPtr operator[](std::size_t idx) const { return clusters[idx]; } /*! ** \brief Resize all matrices dedicated to the sampled timeseries numbers ** @@ -190,27 +112,16 @@ class ClusterList //@} - //! \name Memory management - //@{ /*! ** \brief Invalidate all clusters */ bool forceReload(bool reload = false) const; /*! - ** \brief Mark the cluster as modified + ** \brief Mark the clusters as modified */ void markAsModified() const; - /*! - ** \brief Rebuild the index of clusters - ** - ** As a list of clusters is a hash table, it is not - ** possible to directly accees to a cluster from its index. - ** However an index can be built but it must be re-built when - ** the hash table is modified. - */ - void rebuildIndex(); /*! ** \brief Get the size (bytes) occupied in memory by a `ClusterList` structure @@ -218,48 +129,54 @@ class ClusterList */ uint64_t memoryUsage() const; -public: - //! All clusters by their index - std::vector byIndex; - //! All clusters - Map cluster; - - // thermal, renewable, etc. - virtual YString typeID() const = 0; - - /*! - ** \brief Number of dispatchable cluster per group - ** - ** You should rely on these values only after the loading of the study - ** and until the study is not modified. - ** These values are modified by 'ClusterListAdd()' - */ - std::vector groupCount; - - int loadDataSeriesFromFolder(Study& study, + /// \name IO functions + /// @{ + bool loadDataSeriesFromFolder(Study& study, const StudyLoadOptions& options, const AnyString& folder); - int saveDataSeriesToFolder(const AnyString& folder) const; + bool saveDataSeriesToFolder(const AnyString& folder) const; - int saveDataSeriesToFolder(const AnyString& folder, const YString& msg) const; + bool saveDataSeriesToFolder(const AnyString& folder, const YString& msg) const; virtual bool saveToFolder(const AnyString& folder) const = 0; + ///@} - //! \name Informations - //@{ /*! ** \brief Retrieve the total capacity and the total unit count ** ** Pseudo code: ** \code - ** each thermal cluster do - ** total += cluster{unit count} * cluster{nominal capacity} - ** unit += cluster{unit count} + ** each thermal clusters do + ** total += clusters{unit count} * clusters{nominal capacity} + ** unit += clusters{unit count} ** \endcode */ void retrieveTotalCapacityAndUnitCount(double& total, uint& unitCount) const; - //@} + + /*! + ** \brief Removes disabled clusters + ** + ** All clusters with the flag 'enabled' turned to false will be removed from 'list'. + ** As a consequence, they will no longer be seen as thermal clusters + ** from the solver's point of view. + ** \warning This method should only be used from the solver + ** + ** \return The number of disabled clusters found + */ + uint removeDisabledClusters(); + +protected: + /// The vector containing the clusters + Vect clusters; + + /// thermal, renewable, etc. + virtual std::string typeID() const = 0; + +private: + /// Sort the vector, set index value for each cluster + void rebuildIndex(); + }; // class ClusterList } // namespace Data } // namespace Antares diff --git a/src/libs/antares/study/parts/renewable/cluster_list.cpp b/src/libs/antares/study/parts/renewable/cluster_list.cpp index 5669429dff..e23f84fe2a 100644 --- a/src/libs/antares/study/parts/renewable/cluster_list.cpp +++ b/src/libs/antares/study/parts/renewable/cluster_list.cpp @@ -10,13 +10,13 @@ namespace Antares namespace Data { -YString RenewableClusterList::typeID() const +#define SEP IO::Separator + +std::string RenewableClusterList::typeID() const { return "renewables"; } -#define SEP IO::Separator - bool RenewableClusterList::saveToFolder(const AnyString& folder) const { // Make sure the folder is created diff --git a/src/libs/antares/study/parts/renewable/cluster_list.h b/src/libs/antares/study/parts/renewable/cluster_list.h index e4c3018ace..21f50b3694 100644 --- a/src/libs/antares/study/parts/renewable/cluster_list.h +++ b/src/libs/antares/study/parts/renewable/cluster_list.h @@ -16,8 +16,7 @@ namespace Data class RenewableClusterList : public ClusterList { public: - // Overriden virtual methods - YString typeID() const override; + std::string typeID() const override; bool loadFromFolder(const AnyString& folder, Area* area); bool saveToFolder(const AnyString& folder) const override; }; // class RenewableClusterList diff --git a/src/libs/antares/study/parts/renewable/container.cpp b/src/libs/antares/study/parts/renewable/container.cpp index ea7cbdb0fd..fee7793cdb 100644 --- a/src/libs/antares/study/parts/renewable/container.cpp +++ b/src/libs/antares/study/parts/renewable/container.cpp @@ -66,40 +66,14 @@ void PartRenewable::prepareAreaWideIndexes() return; } - auto end = list.end(); uint idx = 0; - for (auto i = list.begin(); i != end; ++i) + for (const auto& cluster : list) { - RenewableCluster* t = i->second.get(); - t->areaWideIndex = idx; + cluster->areaWideIndex = idx; ++idx; } } -uint PartRenewable::removeDisabledClusters() -{ - // nothing to do if there is no cluster available - if (list.empty()) - return 0; - - std::vector disabledClusters; - - for (auto& it : list) - { - if (!it.second->enabled) - disabledClusters.push_back(it.first); - } - - for (auto& cluster : disabledClusters) - list.remove(cluster); - - const auto count = disabledClusters.size(); - if (count) - list.rebuildIndex(); - - return count; -} - void PartRenewable::reset() { list.clear(); diff --git a/src/libs/antares/study/parts/renewable/container.h b/src/libs/antares/study/parts/renewable/container.h index ccb20d5b7f..ae4d439608 100644 --- a/src/libs/antares/study/parts/renewable/container.h +++ b/src/libs/antares/study/parts/renewable/container.h @@ -71,18 +71,6 @@ class PartRenewable */ void prepareAreaWideIndexes(); - /*! - ** \brief Removes disabled renewable clusters - ** - ** All clusters with the flag 'enabled' turned to false will be removed from 'list'. - ** As a consequence, they will no longer be seen as renewable clusters - ** from the solver's point of view. - ** \warning This method should only be used from the solver - ** - ** \return The number of disabled clusters found - */ - uint removeDisabledClusters(); - /*! ** \brief Invalidate all JIT data */ diff --git a/src/libs/antares/study/parts/thermal/cluster_list.cpp b/src/libs/antares/study/parts/thermal/cluster_list.cpp index 2cd45cfa14..3867bfeca4 100644 --- a/src/libs/antares/study/parts/thermal/cluster_list.cpp +++ b/src/libs/antares/study/parts/thermal/cluster_list.cpp @@ -1,6 +1,7 @@ #include "cluster_list.h" #include "cluster.h" #include "../../study.h" +#include namespace // anonymous { @@ -32,6 +33,11 @@ ThermalClusterList::~ThermalClusterList() #define SEP IO::Separator +std::string ThermalClusterList::typeID() const +{ + return "thermal"; +} + static bool ThermalClusterLoadFromSection(const AnyString& filename, ThermalCluster& cluster, const IniFile::Section& section); @@ -145,11 +151,6 @@ bool ThermalClusterList::loadFromFolder(Study& study, const AnyString& folder, A return ret; } -YString ThermalClusterList::typeID() const -{ - return "thermal"; -} - static bool ThermalClusterLoadFromProperty(ThermalCluster& cluster, const IniFile::Property* p) { if (p->key.empty()) @@ -278,31 +279,7 @@ void ThermalClusterList::calculationOfSpinning() void ThermalClusterList::reverseCalculationOfSpinning() { - auto end = cluster.end(); - for (auto it = cluster.begin(); it != end; ++it) - { - auto& cluster = *(it->second); - cluster.reverseCalculationOfSpinning(); - } -} - -bool ThermalClusterList::remove(const ClusterName& id) -{ - auto i = cluster.find(id); - if (i == cluster.end()) - return false; - - // Getting the pointer on the cluster - SharedPtr c = i->second; - - // Removing it from the list - cluster.erase(i); - // Invalidating the parent area - c->parentArea->forceReload(); - - // Rebuilding the index - rebuildIndex(); - return true; + each([&](ThermalCluster& cluster) { cluster.reverseCalculationOfSpinning(); }); } void ThermalClusterList::enableMustrunForEveryone() @@ -313,13 +290,9 @@ void ThermalClusterList::enableMustrunForEveryone() void ThermalClusterList::ensureDataPrepro() { - auto end = cluster.end(); - for (auto it = cluster.begin(); it != end; ++it) - { - auto c = it->second; - if (not c->prepro) + for (const auto& c : clusters) + if (!c->prepro) c->prepro = new PreproThermal(c); - } } bool ThermalClusterList::saveToFolder(const AnyString& folder) const @@ -391,7 +364,7 @@ bool ThermalClusterList::saveToFolder(const AnyString& folder) const // costs if (c.costgeneration != setManually) - s->add("costgeneration", c.costgeneration); + s->add("costgeneration", c.costgeneration); if (not Math::Zero(c.marginalCost)) s->add("marginal-cost", Math::Round(c.marginalCost, 3)); if (not Math::Zero(c.spreadCost)) @@ -439,9 +412,6 @@ bool ThermalClusterList::saveToFolder(const AnyString& folder) const bool ThermalClusterList::savePreproToFolder(const AnyString& folder) const { - if (empty()) - return true; - Clob buffer; bool ret = true; @@ -458,9 +428,6 @@ bool ThermalClusterList::savePreproToFolder(const AnyString& folder) const bool ThermalClusterList::saveEconomicCosts(const AnyString& folder) const { - if (empty()) - return true; - Clob buffer; bool ret = true; @@ -476,59 +443,47 @@ bool ThermalClusterList::loadPreproFromFolder(Study& study, const StudyLoadOptions& options, const AnyString& folder) { - if (empty()) - return true; - const bool globalThermalTSgeneration - = study.parameters.timeSeriesToGenerate & timeSeriesThermal; + = study.parameters.timeSeriesToGenerate & timeSeriesThermal; Clob buffer; - bool ret = true; - - for (auto& [name, c] : cluster) + auto hasPrepro = [&](auto c) + { + ++options.progressTicks; + options.pushProgressLogs(); + return (bool) c->prepro; + }; + + auto loadAndCheckPrepro = [&](auto c) { - if (c->prepro) - { - assert(c->parentArea and "cluster: invalid parent area"); - buffer.clear() << folder << SEP << c->parentArea->id << SEP << c->id(); + assert(c->parentArea && "cluster: invalid parent area"); + buffer.clear() << folder << SEP << c->parentArea->id << SEP << c->id(); - bool result = c->prepro->loadFromFolder(study, buffer); + bool result = c->prepro->loadFromFolder(study, buffer); - if (result && study.usedByTheSolver && c->doWeGenerateTS(globalThermalTSgeneration)) - { - // checking NPO max - result = c->prepro->normalizeAndCheckNPO(); - } - - ret = result and ret; + if (result && study.usedByTheSolver && c->doWeGenerateTS(globalThermalTSgeneration)) + { + result = c->prepro->normalizeAndCheckNPO(); } - - ++options.progressTicks; - options.pushProgressLogs(); - } - return ret; -} + return result; + }; + return std::ranges::all_of(clusters | std::views::filter(hasPrepro), + loadAndCheckPrepro); +} bool ThermalClusterList::loadEconomicCosts(Study& study, const AnyString& folder) { - if (empty()) - return true; - - Clob buffer; - bool ret = true; - - for (auto& [name, c] : cluster) + return std::ranges::all_of(clusters, [&study, folder](const auto& c) { - assert(c->parentArea and "cluster: invalid parent area"); + assert(c->parentArea && "cluster: invalid parent area"); + Clob buffer; buffer.clear() << folder << SEP << c->parentArea->id << SEP << c->id(); bool result = c->ecoInput.loadFromFolder(study, buffer); c->ComputeCostTimeSeries(); - - ret = result && ret; - } - return ret; + return result; + }); } } // namespace Data diff --git a/src/libs/antares/study/parts/thermal/cluster_list.h b/src/libs/antares/study/parts/thermal/cluster_list.h index 1d15b028a9..b23164bfb0 100644 --- a/src/libs/antares/study/parts/thermal/cluster_list.h +++ b/src/libs/antares/study/parts/thermal/cluster_list.h @@ -13,8 +13,9 @@ namespace Data class ThermalClusterList : public ClusterList { public: - // Overriden pure virtual methods - YString typeID() const override; + std::string typeID() const override; + // Map container + using Map = typename std::map>; /*! ** \brief Get the size (bytes) occupied in memory by a `ThermalClusterList` structure @@ -58,8 +59,6 @@ class ThermalClusterList : public ClusterList void enableMustrunForEveryone(); //@} - bool remove(const ClusterName& id) override; - Map mapping; /*! diff --git a/src/libs/antares/study/parts/thermal/container.cpp b/src/libs/antares/study/parts/thermal/container.cpp index 55cebd6440..a88bdf1e72 100644 --- a/src/libs/antares/study/parts/thermal/container.cpp +++ b/src/libs/antares/study/parts/thermal/container.cpp @@ -40,7 +40,6 @@ namespace Antares { namespace Data { -using NamedCluster = std::pair; PartThermal::PartThermal() : unsuppliedEnergyCost(0.), spilledEnergyCost(0.) { @@ -76,13 +75,11 @@ void PartThermal::prepareAreaWideIndexes() clusters.assign(list.size(), nullptr); - auto end = list.end(); uint idx = 0; - for (auto i = list.begin(); i != end; ++i) + for (const auto& cluster : list) { - ThermalCluster* t = i->second.get(); - t->areaWideIndex = idx; - clusters[idx] = t; + cluster->areaWideIndex = idx; + clusters[idx] = cluster.get(); ++idx; } } @@ -99,66 +96,34 @@ uint PartThermal::prepareClustersInMustRunMode() do { mustContinue = false; - auto end = list.end(); - for (auto i = list.begin(); i != end; ++i) + for (auto cluster : list) { - if ((i->second)->mustrun) + if (!cluster->mustrun) + continue; + + // Detaching the thermal cluster from the main list... + list.remove(cluster->id()); + if (!cluster->enabled) + continue; + // ...and attaching it into the second list + if (!mustrunList.add(cluster)) { - // Detaching the thermal cluster from the main list... - std::shared_ptr cluster = list.detach(i); - if (!cluster->enabled) - continue; - // ...and attaching it into the second list - if (!mustrunList.add(cluster)) - { - logs.error() << "Impossible to prepare the thermal cluster in 'must-run' mode: " - << cluster->parentArea->name << "::" << cluster->name(); - } - else - { - ++count; - logs.info() << "enabling 'must-run' mode for the cluster " - << cluster->parentArea->name << "::" << cluster->name(); - } - - // the iterator has been invalidated, loop again - mustContinue = true; - break; + logs.error() << "Impossible to prepare the thermal cluster in 'must-run' mode: " + << cluster->parentArea->name << "::" << cluster->name(); } + else + { + ++count; + logs.info() << "enabling 'must-run' mode for the cluster " + << cluster->parentArea->name << "::" << cluster->name(); + } + + // the iterator has been invalidated, loop again + mustContinue = true; + break; } } while (mustContinue); - // if some thermal cluster has been moved, we must rebuild all the indexes - if (count) - { - list.rebuildIndex(); - mustrunList.rebuildIndex(); - } - - return count; -} - -uint PartThermal::removeDisabledClusters() -{ - // nothing to do if there is no cluster available - if (list.empty()) - return 0; - - std::vector disabledClusters; - - for (auto& it : list) - { - if (!it.second->enabled) - disabledClusters.push_back(it.first); - } - - for (const auto& cluster : disabledClusters) - list.remove(cluster); - - const auto count = disabledClusters.size(); - if (count) - list.rebuildIndex(); - return count; } @@ -175,16 +140,16 @@ void PartThermal::reset() bool PartThermal::hasForcedTimeseriesGeneration() const { using Behavior = LocalTSGenerationBehavior; - return std::any_of(list.begin(), list.end(), [](const NamedCluster& namedCluster) { - return namedCluster.second->tsGenBehavior == Behavior::forceGen; + return std::any_of(list.begin(), list.end(), [](const ThermalClusterList::SharedPtr& cluster) { + return cluster->tsGenBehavior == Behavior::forceGen; }); } bool PartThermal::hasForcedNoTimeseriesGeneration() const { using Behavior = LocalTSGenerationBehavior; - return std::any_of(list.begin(), list.end(), [](const NamedCluster& namedCluster) { - return namedCluster.second->tsGenBehavior == Behavior::forceNoGen; + return std::any_of(list.begin(), list.end(), [](const ThermalClusterList::SharedPtr& cluster) { + return cluster->tsGenBehavior == Behavior::forceNoGen; }); } diff --git a/src/libs/antares/study/parts/thermal/container.h b/src/libs/antares/study/parts/thermal/container.h index 0c860abe53..6a413c479e 100644 --- a/src/libs/antares/study/parts/thermal/container.h +++ b/src/libs/antares/study/parts/thermal/container.h @@ -81,18 +81,6 @@ class PartThermal */ uint prepareClustersInMustRunMode(); - /*! - ** \brief Removes disabled thermal clusters - ** - ** All clusters with the flag 'enabled' turned to false will be removed from 'list'. - ** As a consequence, they will no longer be seen as thermal clusters - ** from the solver's point of view. - ** \warning This method should only be used from the solver - ** - ** \return The number of disabled clusters found - */ - uint removeDisabledClusters(); - /*! ** \brief Invalidate all JIT data */ diff --git a/src/libs/antares/study/runtime/runtime.cpp b/src/libs/antares/study/runtime/runtime.cpp index 1a58a14f73..bc4e352cfb 100644 --- a/src/libs/antares/study/runtime/runtime.cpp +++ b/src/libs/antares/study/runtime/runtime.cpp @@ -410,13 +410,13 @@ static void removeClusters(Study& study, void StudyRuntimeInfos::removeDisabledThermalClustersFromSolverComputations(Study& study) { removeClusters( - study, "thermal", [](Area& area) { return area.thermal.removeDisabledClusters(); }); + study, "thermal", [](Area& area) { return area.thermal.list.removeDisabledClusters(); }); } void StudyRuntimeInfos::removeDisabledRenewableClustersFromSolverComputations(Study& study) { removeClusters(study, "renewable", [](Area& area) { - uint ret = area.renewable.removeDisabledClusters(); + uint ret = area.renewable.list.removeDisabledClusters(); if (ret > 0) area.renewable.prepareAreaWideIndexes(); return ret; diff --git a/src/libs/antares/study/scenario-builder/RenewableTSNumberData.cpp b/src/libs/antares/study/scenario-builder/RenewableTSNumberData.cpp index 338f13a4b2..808fa9f93b 100644 --- a/src/libs/antares/study/scenario-builder/RenewableTSNumberData.cpp +++ b/src/libs/antares/study/scenario-builder/RenewableTSNumberData.cpp @@ -33,7 +33,7 @@ bool renewableTSNumberData::apply(Study& study) const uint tsGenCountRenewable = get_tsGenCount(study); uint clusterIndex = 0; - for (const auto& [name, cluster] : area.renewable.list) + for (const auto& cluster : area.renewable.list) { // alias to the current column assert(clusterIndex < pTSNumberRules.width); @@ -79,12 +79,12 @@ void renewableTSNumberData::saveToINIFile(const Study& /* study */, // Foreach renewable cluster... for (uint y = 0; y != pTSNumberRules.height; ++y) { - const uint val = get(pArea->renewable.list.byIndex[index], y); + const uint val = get(pArea->renewable.list[index].get(), y); // Equals to zero means 'auto', which is the default mode if (!val) continue; file << prefix << pArea->id << "," << y << ',' - << pArea->renewable.list.byIndex[index]->id() << " = " << val << '\n'; + << pArea->renewable.list[index]->id() << " = " << val << '\n'; } } } diff --git a/src/libs/antares/study/scenario-builder/ThermalTSNumberData.cpp b/src/libs/antares/study/scenario-builder/ThermalTSNumberData.cpp index d9fd64b378..b67ede4039 100644 --- a/src/libs/antares/study/scenario-builder/ThermalTSNumberData.cpp +++ b/src/libs/antares/study/scenario-builder/ThermalTSNumberData.cpp @@ -49,12 +49,12 @@ void thermalTSNumberData::saveToINIFile(const Study& /* study */, // Foreach year ... for (uint y = 0; y != pTSNumberRules.height; ++y) { - const uint val = get(pArea->thermal.list.byIndex[index], y); + const uint val = get(pArea->thermal.list[index].get(), y); // Equals to zero means 'auto', which is the default mode if (!val) continue; file << prefix << pArea->id << "," << y << ',' - << pArea->thermal.list.byIndex[index]->id() << " = " << val << '\n'; + << pArea->thermal.list[index]->id() << " = " << val << '\n'; } } } diff --git a/src/libs/antares/study/study.cpp b/src/libs/antares/study/study.cpp index dfaf427287..63a7a714b2 100644 --- a/src/libs/antares/study/study.cpp +++ b/src/libs/antares/study/study.cpp @@ -1128,12 +1128,8 @@ void Study::destroyAllWindTSGeneratorData() void Study::destroyAllThermalTSGeneratorData() { areas.each([&](Data::Area& area) { - auto pend = area.thermal.list.end(); - for (auto j = area.thermal.list.begin(); j != pend; ++j) - { - ThermalCluster& cluster = *(j->second); - FreeAndNil(cluster.prepro); - } + for (const auto& cluster : area.thermal.list) + FreeAndNil(cluster->prepro); }); } @@ -1531,10 +1527,8 @@ void Study::computePThetaInfForThermalClusters() const // Alias de la zone courant const auto& area = *(this->areas.byIndex[i]); - for (uint j = 0; j < area.thermal.list.size(); j++) + for (auto& cluster : area.thermal.list) { - // Alias du cluster courant - auto& cluster = area.thermal.list.byIndex[j]; for (uint k = 0; k < HOURS_PER_YEAR; k++) cluster->PthetaInf[k] = cluster->modulation[Data::thermalMinGenModulation][k] * cluster->unitCount * cluster->nominalCapacity; diff --git a/src/libs/antares/sys/policy.cpp b/src/libs/antares/sys/policy.cpp index c45de88af5..fd51aca74a 100644 --- a/src/libs/antares/sys/policy.cpp +++ b/src/libs/antares/sys/policy.cpp @@ -75,7 +75,7 @@ static void OpenFromINIFileWL(const String& filename, const StringT& hostname) ini.each([&](const IniFile::Section& section) { // This section is dedicated to another host if (section.name == "*:*" or section.name == "*:" ANTARES_VERSION - or section.name == hostnameAll or section.name == hostnameVersion) + or section.name.equals(hostnameAll) or section.name.equals(hostnameVersion)) { section.each([&](const IniFile::Property& property) { key = property.key; diff --git a/src/solver/optimisation/post_process_commands.cpp b/src/solver/optimisation/post_process_commands.cpp index 9c6c3f5d9d..c82892355a 100644 --- a/src/solver/optimisation/post_process_commands.cpp +++ b/src/solver/optimisation/post_process_commands.cpp @@ -31,15 +31,13 @@ void DispatchableMarginPostProcessCmd::execute(const optRuntimeData& opt_runtime { auto& hourlyResults = problemeHebdo_->ResultatsHoraires[area.index]; - auto end = area.thermal.list.end(); - for (auto i = area.thermal.list.begin(); i != end; ++i) + for (const auto& cluster : area.thermal.list) { - auto& cluster = *(i->second); - const auto& availableProduction = cluster.series.getColumn(year); + const auto& availableProduction = cluster->series.getColumn(year); for (uint h = 0; h != nbHoursInWeek; ++h) { double production = hourlyResults.ProductionThermique[h] - .ProductionThermiqueDuPalier[cluster.index]; + .ProductionThermiqueDuPalier[cluster->index]; dtgmrg[h] += availableProduction[h + hourInYear] - production; } } diff --git a/src/solver/simulation/common-eco-adq.cpp b/src/solver/simulation/common-eco-adq.cpp index c550b05610..d06335e094 100644 --- a/src/solver/simulation/common-eco-adq.cpp +++ b/src/solver/simulation/common-eco-adq.cpp @@ -132,40 +132,33 @@ void PrepareDataFromClustersInMustrunMode(Data::Study& study, uint numSpace, uin double* mrs = scratchpad.mustrunSum; double* adq = scratchpad.originalMustrunSum; - if (!area.thermal.mustrunList.empty()) + for (const auto& cluster : area.thermal.mustrunList) { - auto end = area.thermal.mustrunList.end(); - for (auto i = area.thermal.mustrunList.begin(); i != end; ++i) + const auto& availableProduction = cluster->series.getColumn(year); + if (inAdequacy && cluster->mustrunOrigin) { - auto& cluster = *(i->second); - const auto& availableProduction = cluster.series.getColumn(year); - if (inAdequacy && cluster.mustrunOrigin) + for (uint h = 0; h != cluster->series.timeSeries.height; ++h) { - for (uint h = 0; h != cluster.series.timeSeries.height; ++h) - { - mrs[h] += availableProduction[h]; - adq[h] += availableProduction[h]; - } - } - else - { - for (uint h = 0; h != cluster.series.timeSeries.height; ++h) - mrs[h] += availableProduction[h]; + mrs[h] += availableProduction[h]; + adq[h] += availableProduction[h]; } } + else + { + for (uint h = 0; h != cluster->series.timeSeries.height; ++h) + mrs[h] += availableProduction[h]; + } } if (inAdequacy) { - auto end = area.thermal.list.end(); - for (auto i = area.thermal.list.begin(); i != end; ++i) + for (const auto& cluster : area.thermal.mustrunList) { - auto& cluster = *(i->second); - if (!cluster.mustrunOrigin) + if (!cluster->mustrunOrigin) continue; - const auto& availableProduction = cluster.series.getColumn(year); - for (uint h = 0; h != cluster.series.timeSeries.height; ++h) + const auto& availableProduction = cluster->series.getColumn(year); + for (uint h = 0; h != cluster->series.timeSeries.height; ++h) adq[h] += availableProduction[h]; } } diff --git a/src/solver/simulation/sim_calcul_economique.cpp b/src/solver/simulation/sim_calcul_economique.cpp index 201f6b9899..cb582d723c 100644 --- a/src/solver/simulation/sim_calcul_economique.cpp +++ b/src/solver/simulation/sim_calcul_economique.cpp @@ -285,7 +285,7 @@ void SIM_InitialisationProblemeHebdo(Data::Study& study, for (uint clusterIndex = 0; clusterIndex != area.thermal.list.size(); ++clusterIndex) { - auto& cluster = *(area.thermal.list.byIndex[clusterIndex]); + auto& cluster = *(area.thermal.list[clusterIndex]); pbPalier.NumeroDuPalierDansLEnsembleDesPaliersThermiques[clusterIndex] = NombrePaliers + clusterIndex; pbPalier.TailleUnitaireDUnGroupeDuPalierThermique[clusterIndex] diff --git a/src/solver/simulation/timeseries-numbers.cpp b/src/solver/simulation/timeseries-numbers.cpp index 82fb8a3273..30cc4b32dc 100644 --- a/src/solver/simulation/timeseries-numbers.cpp +++ b/src/solver/simulation/timeseries-numbers.cpp @@ -100,7 +100,7 @@ static bool GenerateDeratedMode(Study& study) cluster.series.timeseriesNumbers.zero(); } - for (const auto& [name, cluster] : area.renewable.list) + for (const auto& cluster : area.renewable.list) cluster->series.timeseriesNumbers.zero(); }); @@ -226,7 +226,7 @@ class renewClustersAreaNumberOfTSretriever : public areaNumberOfTSretriever std::vector getAreaTimeSeriesNumber(const Area& area) { std::vector to_return; - for (const auto& [name, cluster] : area.renewable.list) + for (const auto& cluster : area.renewable.list) { to_return.push_back(cluster->series.timeSeries.width); } @@ -443,7 +443,7 @@ bool checkInterModalConsistencyForArea(Area& area, indexTS = ts_to_tsIndex.at(timeSeriesRenewable); if (isTSintermodal[indexTS]) { - for (const auto& [name, cluster] : area.renewable.list) + for (const auto& cluster : area.renewable.list) { uint nbTimeSeries = cluster->series.timeSeries.width; listNumberTsOverArea.push_back(nbTimeSeries); @@ -555,10 +555,8 @@ void storeTSnumbersForIntraModal(const array& intramo if (isTSintramodal[indexTS]) { - auto end_rn_clusters = area.renewable.list.cluster.end(); - for (auto j = area.renewable.list.cluster.begin(); j != end_rn_clusters; ++j) + for (auto& cluster : area.renewable.list) { - RenewableClusterList::SharedPtr cluster = j->second; if (cluster->enabled) cluster->series.timeseriesNumbers[0][year] = intramodal_draws[indexTS]; } @@ -667,10 +665,8 @@ void drawAndStoreTSnumbersForNOTintraModal(const array& i // -------------------------- indexTS = ts_to_tsIndex.at(timeSeriesRenewable); - auto end_rn_clusters = area.renewable.list.cluster.end(); - for (auto j = area.renewable.list.cluster.begin(); j != end_rn_clusters; ++j) + for (auto& cluster : area.renewable.list) { - RenewableClusterList::SharedPtr cluster = j->second; if (not cluster->enabled) study.runtime->random[seedTimeseriesNumbers].next(); else @@ -747,7 +743,7 @@ Matrix* getFirstTSnumberInterModalMatrixFoundInArea( tsNumbersMtx = &(area.thermal.clusters[0]->series.timeseriesNumbers); else if (isTSintermodal[ts_to_tsIndex.at(timeSeriesRenewable)] && area.renewable.list.size() > 0) - tsNumbersMtx = &(area.renewable.list.byIndex[0]->series.timeseriesNumbers); + tsNumbersMtx = &(area.renewable.list[0]->series.timeseriesNumbers); } assert(tsNumbersMtx); @@ -792,7 +788,7 @@ void applyMatrixDrawsToInterModalModesInArea(Matrix* tsNumbersMtx, } if (isTSintermodal[ts_to_tsIndex.at(timeSeriesRenewable)]) { - for (auto& [name, cluster] : area.renewable.list) + for (const auto& cluster : area.renewable.list) { assert(year < cluster->series.timeseriesNumbers.height); cluster->series.timeseriesNumbers[0][year] = draw; @@ -841,7 +837,7 @@ static void fixTSNumbersWhenWidthIsOne(Study& study) }); // Renewables - for (const auto& [name, cluster] : area.renewable.list) + for (const auto& cluster : area.renewable.list) fixTSNumbersSingleAreaSingleMode(cluster->series.timeseriesNumbers, cluster->series.timeSeries.width, years); diff --git a/src/solver/variable/economy/avail-dispatchable-generation.h b/src/solver/variable/economy/avail-dispatchable-generation.h index 80e3356055..9cea0fb713 100644 --- a/src/solver/variable/economy/avail-dispatchable-generation.h +++ b/src/solver/variable/economy/avail-dispatchable-generation.h @@ -194,7 +194,7 @@ class AvailableDispatchGen void addThermalClusterList(Data::ThermalClusterList& list, unsigned int year, unsigned int numSpace) { - for (auto& [name, cluster] : list) + for (const auto& cluster : list) { const auto& availableProduction = cluster->series.getColumn(year); for (unsigned int hour = 0; hour != cluster->series.timeSeries.height; ++hour) diff --git a/src/solver/variable/economy/productionByRenewablePlant.h b/src/solver/variable/economy/productionByRenewablePlant.h index 26e0cbc0b6..e1b08a189f 100644 --- a/src/solver/variable/economy/productionByRenewablePlant.h +++ b/src/solver/variable/economy/productionByRenewablePlant.h @@ -277,7 +277,7 @@ class ProductionByRenewablePlant : public Variable::IVariablerenewable.list) + for (const auto& renewableCluster : state.area->renewable.list) { double renewableClusterProduction = renewableCluster->valueAtTimeStep(state.year, state.hourInTheYear); @@ -327,7 +327,7 @@ class ProductionByRenewablePlant : public Variable::IVariablename(); + results.variableCaption = renewable.list[i]->name(); results.variableUnit = VCardType::Unit(); pValuesForTheCurrentYear[numSpace][i].template buildAnnualSurveyReport( results, fileLevel, precision); diff --git a/src/solver/variable/economy/renewableGeneration.h b/src/solver/variable/economy/renewableGeneration.h index 5634338ec8..5035cb59f4 100644 --- a/src/solver/variable/economy/renewableGeneration.h +++ b/src/solver/variable/economy/renewableGeneration.h @@ -267,7 +267,7 @@ class RenewableGeneration void hourForEachArea(State& state, unsigned int numSpace) { - for (const auto& [name, renewableCluster] : state.area->renewable.list) + for (const auto& renewableCluster : state.area->renewable.list) { double renewableClusterProduction = renewableCluster->valueAtTimeStep(state.year, state.hourInTheYear); diff --git a/src/solver/variable/info.h b/src/solver/variable/info.h index 088b4ddf7f..c07bf1ab60 100644 --- a/src/solver/variable/info.h +++ b/src/solver/variable/info.h @@ -407,7 +407,7 @@ struct VariableAccessor if (renewable_details) { auto& renewable = results.data.area->renewable; - results.variableCaption = renewable.list.byIndex[idx]->name(); + results.variableCaption = renewable.list[idx]->name(); return true; } if (st_storage_details) diff --git a/src/solver/variable/surveyresults/reportbuilder.hxx b/src/solver/variable/surveyresults/reportbuilder.hxx index 85f49dd3a5..28e9ef6abe 100644 --- a/src/solver/variable/surveyresults/reportbuilder.hxx +++ b/src/solver/variable/surveyresults/reportbuilder.hxx @@ -324,17 +324,15 @@ private: if (VariablesStatsByDataLevel::count) { auto& area = *results.data.area; - auto end = area.thermal.list.end(); - for (auto i = area.thermal.list.begin(); i != end; ++i) + for (const auto& cluster : area.thermal.list) { - auto& cluster = *(i->second); - results.data.thermalCluster = &cluster; + results.data.thermalCluster = cluster.get(); - logs.info() << "Exporting results : " << area.name << " :: " << cluster.name(); + logs.info() << "Exporting results : " << area.name << " :: " << cluster->name(); // The new output results.data.output.clear(); results.data.output << results.data.originalOutput << SEP << "areas" << SEP - << area.id << SEP << "thermal" << SEP << cluster.id(); + << area.id << SEP << "thermal" << SEP << cluster->id(); SurveyReportBuilderFile::Run(list, results, numSpace); } diff --git a/src/tools/yby-aggregator/job.cpp b/src/tools/yby-aggregator/job.cpp index 95b75dd7f3..6e4b405ea2 100644 --- a/src/tools/yby-aggregator/job.cpp +++ b/src/tools/yby-aggregator/job.cpp @@ -378,7 +378,7 @@ bool JobFileReader::prepareJumpTable() const DataFile::ShortString& timeLevel = datafile->timeLevel; for (uint i = 0; i != list.size(); ++i) { - if (timeLevel == list[i]) + if (timeLevel.equals(list[i])) { startIndex = i + 1; break; diff --git a/src/ui/action/handler/antares-study/area/create.cpp b/src/ui/action/handler/antares-study/area/create.cpp index 0348c2d253..e159af140d 100644 --- a/src/ui/action/handler/antares-study/area/create.cpp +++ b/src/ui/action/handler/antares-study/area/create.cpp @@ -293,11 +293,9 @@ void Create::createActionsForAStandardAreaCopy(Context& ctx, bool copyPosition) auto* root = new RootNodePlant(pOriginalAreaName); // browsing each thermal cluster - auto end = area->thermal.list.end(); - for (auto i = area->thermal.list.begin(); i != end; ++i) - { - *root += StandardActionsToCopyThermalCluster(pOriginalAreaName, i->second->name()); - } + for (auto& c : area->thermal.list) + *root += StandardActionsToCopyThermalCluster(pOriginalAreaName, c->name()); + *this += root; } } diff --git a/src/ui/action/handler/antares-study/thermal-cluster/create.cpp b/src/ui/action/handler/antares-study/thermal-cluster/create.cpp index 07eb50f546..67fcebb757 100644 --- a/src/ui/action/handler/antares-study/thermal-cluster/create.cpp +++ b/src/ui/action/handler/antares-study/thermal-cluster/create.cpp @@ -181,7 +181,6 @@ bool Create::performWL(Context& ctx) ctx.cluster->setName(pFuturPlantName); ctx.cluster->reset(); (ctx.area)->thermal.list.add(std::shared_ptr(ctx.cluster)); - (ctx.area)->thermal.list.rebuildIndex(); (ctx.area)->thermal.prepareAreaWideIndexes(); } else diff --git a/src/ui/simulator/toolbox/components/datagrid/renderer/area/renewable.areasummary.cpp b/src/ui/simulator/toolbox/components/datagrid/renderer/area/renewable.areasummary.cpp index 59ff293c0c..db746f9632 100644 --- a/src/ui/simulator/toolbox/components/datagrid/renderer/area/renewable.areasummary.cpp +++ b/src/ui/simulator/toolbox/components/datagrid/renderer/area/renewable.areasummary.cpp @@ -51,7 +51,7 @@ RenewableClusterSummarySingleArea::~RenewableClusterSummarySingleArea() wxString RenewableClusterSummarySingleArea::rowCaption(int rowIndx) const { if (pArea) - return wxStringFromUTF8(pArea->renewable.list.byIndex[rowIndx]->name()); + return wxStringFromUTF8(pArea->renewable.list[rowIndx]->name()); return wxEmptyString; } @@ -71,7 +71,7 @@ wxString RenewableClusterSummarySingleArea::columnCaption(int colIndx) const wxString RenewableClusterSummarySingleArea::cellValue(int x, int y) const { Data::RenewableCluster* cluster = (pArea and (uint) y < pArea->renewable.list.size()) - ? pArea->renewable.list.byIndex[y] + ? pArea->renewable.list[y].get() : nullptr; switch (x) { @@ -90,7 +90,7 @@ wxString RenewableClusterSummarySingleArea::cellValue(int x, int y) const double RenewableClusterSummarySingleArea::cellNumericValue(int x, int y) const { Data::RenewableCluster* cluster = (pArea and (uint) y < pArea->renewable.list.size()) - ? pArea->renewable.list.byIndex[y] + ? pArea->renewable.list[y].get() : nullptr; // gp : do we wish to have the line empty if cluster disabled // if (!cluster->enabled) @@ -112,7 +112,7 @@ double RenewableClusterSummarySingleArea::cellNumericValue(int x, int y) const bool RenewableClusterSummarySingleArea::cellValue(int x, int y, const String& v) { auto* cluster = (pArea and (uint) y < pArea->renewable.list.size()) - ? pArea->renewable.list.byIndex[y] + ? pArea->renewable.list[y].get() : nullptr; if (cluster) diff --git a/src/ui/simulator/toolbox/components/datagrid/renderer/area/thermal.areasummary.cpp b/src/ui/simulator/toolbox/components/datagrid/renderer/area/thermal.areasummary.cpp index c49cf595a0..ce87ecace2 100644 --- a/src/ui/simulator/toolbox/components/datagrid/renderer/area/thermal.areasummary.cpp +++ b/src/ui/simulator/toolbox/components/datagrid/renderer/area/thermal.areasummary.cpp @@ -51,7 +51,7 @@ ThermalClusterSummarySingleArea::~ThermalClusterSummarySingleArea() wxString ThermalClusterSummarySingleArea::rowCaption(int rowIndx) const { if (pArea) - return wxStringFromUTF8(pArea->thermal.list.byIndex[rowIndx]->name()); + return wxStringFromUTF8(pArea->thermal.list[rowIndx]->name()); return wxEmptyString; } @@ -82,7 +82,7 @@ wxString ThermalClusterSummarySingleArea::columnCaption(int colIndx) const wxString ThermalClusterSummarySingleArea::cellValue(int x, int y) const { Data::ThermalCluster* cluster = (pArea and (uint) y < pArea->thermal.list.size()) - ? pArea->thermal.list.byIndex[y] + ? pArea->thermal.list[y].get() : nullptr; if (!cluster->enabled) return wxEmptyString; @@ -125,7 +125,7 @@ wxString ThermalClusterSummarySingleArea::cellValue(int x, int y) const double ThermalClusterSummarySingleArea::cellNumericValue(int x, int y) const { Data::ThermalCluster* cluster = (pArea and (uint) y < pArea->thermal.list.size()) - ? pArea->thermal.list.byIndex[y] + ? pArea->thermal.list[y].get() : nullptr; if (!cluster->enabled) return 0.; @@ -168,7 +168,7 @@ double ThermalClusterSummarySingleArea::cellNumericValue(int x, int y) const bool ThermalClusterSummarySingleArea::cellValue(int x, int y, const String& v) { auto* cluster = (pArea and (uint) y < pArea->thermal.list.size()) - ? pArea->thermal.list.byIndex[y] + ? pArea->thermal.list[y].get() : nullptr; if (cluster) diff --git a/src/ui/simulator/toolbox/components/datagrid/renderer/scenario-builder-renewable-renderer.cpp b/src/ui/simulator/toolbox/components/datagrid/renderer/scenario-builder-renewable-renderer.cpp index c522544756..f2af7d9660 100644 --- a/src/ui/simulator/toolbox/components/datagrid/renderer/scenario-builder-renewable-renderer.cpp +++ b/src/ui/simulator/toolbox/components/datagrid/renderer/scenario-builder-renewable-renderer.cpp @@ -54,7 +54,7 @@ wxString renewableScBuilderRenderer::rowCaption(int rowIndx) const && (uint)rowIndx < selectedArea()->renewable.list.size()) { return wxString() << wxT( - " ") << wxStringFromUTF8(selectedArea()->renewable.list.byIndex[rowIndx]->name()) + " ") << wxStringFromUTF8(selectedArea()->renewable.list[rowIndx]->name()) << wxT(" "); } return wxEmptyString; @@ -70,7 +70,7 @@ bool renewableScBuilderRenderer::cellValue(int x, int y, const String& value) assert((uint)x < pRules->renewable[selectedArea()->index].height()); uint val = fromStringToTSnumber(value); pRules->renewable[selectedArea()->index].setTSnumber( - selectedArea()->renewable.list.byIndex[y], x, val); + selectedArea()->renewable.list[y].get(), x, val); return true; } return false; diff --git a/src/ui/simulator/toolbox/components/datagrid/renderer/scenario-builder-thermal-renderer.cpp b/src/ui/simulator/toolbox/components/datagrid/renderer/scenario-builder-thermal-renderer.cpp index 7449c3c9b0..c8e333c1c8 100644 --- a/src/ui/simulator/toolbox/components/datagrid/renderer/scenario-builder-thermal-renderer.cpp +++ b/src/ui/simulator/toolbox/components/datagrid/renderer/scenario-builder-thermal-renderer.cpp @@ -54,7 +54,7 @@ wxString thermalScBuilderRenderer::rowCaption(int rowIndx) const && (uint)rowIndx < selectedArea()->thermal.list.size()) { return wxString() << wxT(" ") - << wxStringFromUTF8(selectedArea()->thermal.list.byIndex[rowIndx]->name()) + << wxStringFromUTF8(selectedArea()->thermal.list[rowIndx]->name()) << wxT(" "); } return wxEmptyString; @@ -69,7 +69,7 @@ bool thermalScBuilderRenderer::cellValue(int x, int y, const String& value) assert((uint)y < pRules->thermal[selectedArea()->index].width()); assert((uint)x < pRules->thermal[selectedArea()->index].height()); uint val = fromStringToTSnumber(value); - pRules->thermal[selectedArea()->index].setTSnumber(selectedArea()->thermal.list.byIndex[y], x, val); + pRules->thermal[selectedArea()->index].setTSnumber(selectedArea()->thermal.list[y].get(), x, val); return true; } return false; diff --git a/src/ui/simulator/toolbox/components/htmllistbox/datasource/renewable-cluster-order.cpp b/src/ui/simulator/toolbox/components/htmllistbox/datasource/renewable-cluster-order.cpp index a79334cc6c..66681a7383 100644 --- a/src/ui/simulator/toolbox/components/htmllistbox/datasource/renewable-cluster-order.cpp +++ b/src/ui/simulator/toolbox/components/htmllistbox/datasource/renewable-cluster-order.cpp @@ -56,7 +56,7 @@ void GetRenewableClusterMap(Data::Area* area, RenewableClusterMap& l, const wxSt const Data::RenewableClusterList::iterator end = area->renewable.list.end(); for (Data::RenewableClusterList::iterator i = area->renewable.list.begin(); i != end; ++i) { - Data::RenewableCluster* cluster = i->second.get(); + Data::RenewableCluster* cluster = (*i).get(); if (search.empty()) { diff --git a/src/ui/simulator/toolbox/components/htmllistbox/datasource/thermal-cluster-order.cpp b/src/ui/simulator/toolbox/components/htmllistbox/datasource/thermal-cluster-order.cpp index 029c0b8a2f..cd8a2a8244 100644 --- a/src/ui/simulator/toolbox/components/htmllistbox/datasource/thermal-cluster-order.cpp +++ b/src/ui/simulator/toolbox/components/htmllistbox/datasource/thermal-cluster-order.cpp @@ -56,7 +56,7 @@ void GetThermalClusterMap(Data::Area* area, ThermalClusterMap& l, const wxString const Data::ThermalClusterList::iterator end = area->thermal.list.end(); for (Data::ThermalClusterList::iterator i = area->thermal.list.begin(); i != end; ++i) { - Data::ThermalCluster* cluster = i->second.get(); + Data::ThermalCluster* cluster = (*i).get(); if (search.empty()) { diff --git a/src/ui/simulator/toolbox/components/map/manager.cpp b/src/ui/simulator/toolbox/components/map/manager.cpp index 7193fbef99..d6030be21c 100644 --- a/src/ui/simulator/toolbox/components/map/manager.cpp +++ b/src/ui/simulator/toolbox/components/map/manager.cpp @@ -768,7 +768,7 @@ void Manager::selectFromBoundingBox(const wxPoint& a, const wxPoint& b, const si for (Data::ThermalClusterList::iterator t = area->thermal.list.begin(); t != tend; ++t) - clusterlist.push_back(t->second.get()); + clusterlist.push_back((*t).get()); } continue; } diff --git a/src/ui/simulator/toolbox/input/renewable-cluster.cpp b/src/ui/simulator/toolbox/input/renewable-cluster.cpp index 043ff85e3a..08bbb8f748 100644 --- a/src/ui/simulator/toolbox/input/renewable-cluster.cpp +++ b/src/ui/simulator/toolbox/input/renewable-cluster.cpp @@ -291,7 +291,6 @@ void RenewableCluster::internalDeletePlant(void*) Refresh(); MarkTheStudyAsModified(); updateInnerValues(); - pArea->renewable.list.rebuildIndex(); pArea->renewable.prepareAreaWideIndexes(); study->uiinfo->reload(); } @@ -389,7 +388,6 @@ void RenewableCluster::internalAddPlant(void*) cluster->setName(sFl); cluster->reset(); pArea->renewable.list.add(cluster); - pArea->renewable.list.rebuildIndex(); pArea->renewable.prepareAreaWideIndexes(); // Update the list @@ -467,7 +465,6 @@ void RenewableCluster::internalClonePlant(void*) cluster->copyFrom(selectedPlant); pArea->renewable.list.add(cluster); - pArea->renewable.list.rebuildIndex(); pArea->renewable.prepareAreaWideIndexes(); // Update the list diff --git a/src/ui/simulator/toolbox/input/thermal-cluster.cpp b/src/ui/simulator/toolbox/input/thermal-cluster.cpp index 0a40b9ee29..bc31719088 100644 --- a/src/ui/simulator/toolbox/input/thermal-cluster.cpp +++ b/src/ui/simulator/toolbox/input/thermal-cluster.cpp @@ -317,7 +317,6 @@ void ThermalCluster::internalDeletePlant(void*) Refresh(); MarkTheStudyAsModified(); updateInnerValues(); - pArea->thermal.list.rebuildIndex(); pArea->thermal.prepareAreaWideIndexes(); study->uiinfo->reload(); @@ -448,7 +447,6 @@ void ThermalCluster::internalAddPlant(void*) cluster->setName(sFl); cluster->reset(); pArea->thermal.list.add(cluster); - pArea->thermal.list.rebuildIndex(); pArea->thermal.prepareAreaWideIndexes(); // Update the list @@ -527,7 +525,6 @@ void ThermalCluster::internalClonePlant(void*) cluster->copyFrom(selectedPlant); pArea->thermal.list.add(cluster); - pArea->thermal.list.rebuildIndex(); pArea->thermal.prepareAreaWideIndexes(); // Update the list diff --git a/src/ui/simulator/windows/inspector/frame.cpp b/src/ui/simulator/windows/inspector/frame.cpp index 22b9ad28c9..7bfa6aeb54 100644 --- a/src/ui/simulator/windows/inspector/frame.cpp +++ b/src/ui/simulator/windows/inspector/frame.cpp @@ -178,9 +178,8 @@ void Frame::onSelectAllPlants(wxCommandEvent&) for (auto i = data->areas.begin(); i != areaEnd; ++i) { Data::Area& area = *(*i); - auto end = area.thermal.list.end(); - for (auto i = area.thermal.list.begin(); i != end; ++i) - data->ThClusters.insert(i->second.get()); + for (auto& c : area.thermal.list) + data->ThClusters.insert(c.get()); } data->areas.clear(); data->links.clear(); @@ -204,26 +203,6 @@ void Frame::onSelectPlant(wxCommandEvent& evt) } } -// gp : never used - to be removed -void Frame::onSelectAllPlantsFromArea(wxCommandEvent& evt) -{ - InspectorData::Ptr data = gData; - if (!(!data) and gInspector and evt.GetEventObject()) - { - Data::Area* area = (Data::Area*)mapIDPointer[evt.GetId()]; - if (!area) - return; - data->ThClusters.clear(); - auto end = area->thermal.list.end(); - for (auto i = area->thermal.list.begin(); i != end; ++i) - data->ThClusters.insert(i->second.get()); - data->areas.clear(); - data->links.clear(); - data->empty = data->ThClusters.empty(); - gInspector->delayApplyGlobalSelection(); - } -} - Frame::Frame(wxWindow* parent, bool allowAnyObject) : Antares::Component::Panel(parent), pNotes(nullptr), diff --git a/src/ui/simulator/windows/inspector/frame.h b/src/ui/simulator/windows/inspector/frame.h index 2d49c0bd8e..153be844c4 100644 --- a/src/ui/simulator/windows/inspector/frame.h +++ b/src/ui/simulator/windows/inspector/frame.h @@ -100,7 +100,6 @@ class Frame final : public Antares::Component::Panel, public Yuni::IEventObserve void onSelectAllPlants(wxCommandEvent& evt); void onSelectPlant(wxCommandEvent& evt); - void onSelectAllPlantsFromArea(wxCommandEvent& evt); void clearAssociatinsBetweenIDAndPtr() { diff --git a/src/ui/simulator/windows/inspector/inspector.cpp b/src/ui/simulator/windows/inspector/inspector.cpp index d895d26f1c..500ec48711 100644 --- a/src/ui/simulator/windows/inspector/inspector.cpp +++ b/src/ui/simulator/windows/inspector/inspector.cpp @@ -704,7 +704,7 @@ bool isConstraintSelected(const Yuni::String& constraintName) for (auto i = gData->constraints.begin(); i != end; ++i) { auto constraint = *i; - if (constraint->name() == constraintName) + if (constraint->name().equals(constraintName)) { return true; } diff --git a/src/ui/simulator/windows/output/spotlight-provider.cpp b/src/ui/simulator/windows/output/spotlight-provider.cpp index 0eb1cc5528..8f4877bf10 100644 --- a/src/ui/simulator/windows/output/spotlight-provider.cpp +++ b/src/ui/simulator/windows/output/spotlight-provider.cpp @@ -421,8 +421,8 @@ void SpotlightProviderGlobalSelection::search(Spotlight::IItem::Vector& out, auto aEnd = study.areas.end(); for (auto itArea = study.areas.begin(); itArea != aEnd; ++itArea) { - if (arealink->id == itArea->first) // this area is in the study (it is visible - // at least on layer 0) + if (arealink->id.equals(itArea->first)) // this area is in the study (it is visible + // at least on layer 0) { foundInALayer = true; break; @@ -482,7 +482,7 @@ void SpotlightProviderGlobalSelection::search(Spotlight::IItem::Vector& out, auto aEnd = study.areas.end(); for (auto itArea = study.areas.begin(); itArea != aEnd; ++itArea) { - if (arealink->id == itArea->first + if (arealink->id.equals(itArea->first) && itArea->second->isVisibleOnLayer( layerID)) // this area is in the study (it is visible at least on layer 0) {