Antares Simulator
Power System Simulator
Loading...
Searching...
No Matches
cluster_list.h
1/*
2** Copyright 2007-2024, RTE (https://www.rte-france.com)
3** See AUTHORS.txt
4** SPDX-License-Identifier: MPL-2.0
5** This file is part of Antares-Simulator,
6** Adequacy and Performance assessment for interconnected energy networks.
7**
8** Antares_Simulator is free software: you can redistribute it and/or modify
9** it under the terms of the Mozilla Public Licence 2.0 as published by
10** the Mozilla Foundation, either version 2 of the License, or
11** (at your option) any later version.
12**
13** Antares_Simulator is distributed in the hope that it will be useful,
14** but WITHOUT ANY WARRANTY; without even the implied warranty of
15** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16** Mozilla Public Licence 2.0 for more details.
17**
18** You should have received a copy of the Mozilla Public Licence 2.0
19** along with Antares_Simulator. If not, see <https://opensource.org/license/mpl-2-0/>.
20*/
21#ifndef __ANTARES_LIBS_STUDY_PARTS_COMMON_CLUSTER_LIST_H__
22#define __ANTARES_LIBS_STUDY_PARTS_COMMON_CLUSTER_LIST_H__
23
24#include <algorithm>
25#include <memory>
26#include <ranges>
27#include <vector>
28
29#include <antares/logs/logs.h>
30#include <antares/writer/i_writer.h>
31
32#include "../../fwd.h"
33
34namespace Antares
35{
36namespace Data
37{
44template<class ClusterT>
46{
47public:
48 using SharedPtr = typename std::shared_ptr<ClusterT>;
49
50 void clearAll();
51 bool empty() const;
52
59 ClusterT* findInAll(std::string_view id) const;
60
67 bool exists(const Data::ClusterName& id) const;
68
69 auto each_enabled() const
70 {
71 return allClusters_ | std::views::filter(&ClusterT::isEnabled);
72 }
73
74 std::vector<std::shared_ptr<ClusterT>> all() const;
75
86 bool rename(Data::ClusterName idToFind, Data::ClusterName newName);
87
91 virtual bool remove(const Data::ClusterName& id);
92
94
95 SharedPtr operator[](std::size_t idx)
96 {
97 return allClusters_[idx];
98 }
99
100 SharedPtr operator[](std::size_t idx) const
101 {
102 return allClusters_[idx];
103 }
104
105 SharedPtr enabledClusterAt(unsigned int index) const;
111 void resizeAllTimeseriesNumbers(uint n) const;
112
113 void storeTimeseriesNumbers(Solver::IResultWriter& writer) const;
114
116
120 bool forceReload(bool reload = false) const;
121
125 void markAsModified() const;
126
129 bool loadDataSeriesFromFolder(Study& study, const std::filesystem::path& folder);
130
131 bool saveDataSeriesToFolder(const AnyString& folder) const;
132
133 virtual bool saveToFolder(const AnyString& folder) const = 0;
135
146 void retrieveTotalCapacityAndUnitCount(double& total, uint& unitCount) const;
147
148 unsigned int enabledCount() const;
149 unsigned int allClustersCount() const;
150 void addToCompleteList(std::shared_ptr<ClusterT> cluster);
151 void sortCompleteList();
152
153protected:
154 std::vector<std::shared_ptr<ClusterT>> allClusters_;
155
156 virtual std::string typeID() const = 0;
157
158 // Give a special index to enabled clusters (thermal / renewable)
159 void rebuildIndexes();
160
161private:
162 bool alreadyInAllClusters(std::string clusterName);
163
164}; // class ClusterList
165} // namespace Data
166} // namespace Antares
167#endif /* __ANTARES_LIBS_STUDY_PARTS_COMMON_CLUSTER_LIST_H__ */
Generic list of clustersThis class implements the base functions for a list of cluster It's used for ...
Definition cluster_list.h:46
void resizeAllTimeseriesNumbers(uint n) const
Resize all matrices dedicated to the sampled timeseries numbers.
Definition cluster_list.cpp:83
void markAsModified() const
Mark the clusters as modified.
Definition cluster_list.cpp:232
bool exists(const Data::ClusterName &id) const
Get if a cluster exists.
Definition cluster_list.cpp:71
bool forceReload(bool reload=false) const
Invalidate all clusters.
Definition cluster_list.cpp:225
ClusterT * findInAll(std::string_view id) const
Try to find a cluster from its id (const) in the complete cluster list.
Definition cluster_list.cpp:52
virtual bool remove(const Data::ClusterName &id)
Remove properly a cluster.
Definition cluster_list.cpp:241
void retrieveTotalCapacityAndUnitCount(double &total, uint &unitCount) const
Retrieve the total capacity and the total unit count.
Definition cluster_list.cpp:269
bool rename(Data::ClusterName idToFind, Data::ClusterName newName)
Rename a cluster.
Definition cluster_list.cpp:167
Definition study.h:61
Definition i_writer.h:34