Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor common ClusterList class #1813

Merged
merged 58 commits into from
Dec 20, 2023
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
695d608
[DEV] Use vect instead of map
payetvin Dec 7, 2023
4ec8de1
[DEV] Change iterator typedef with vector iterator
payetvin Dec 8, 2023
dc72732
[DEV] FIx renewable
payetvin Dec 8, 2023
228280f
[DEV] More modif in common cluster_list
payetvin Dec 8, 2023
e68f7ed
[DEV] no error common clusterlist
payetvin Dec 8, 2023
8eeeb38
[FIX] compile cleaner-v20
payetvin Dec 8, 2023
0c2cc7b
[FIX] compile RenewableTSNumberData
payetvin Dec 8, 2023
5891cec
[FIX] compile thermal container
payetvin Dec 8, 2023
50d64f5
[FIX] compile thermal clusterlist
payetvin Dec 8, 2023
586c124
[FIX] compile ui, output var
payetvin Dec 8, 2023
d84cc59
[FIX] timeseries-numbers.cpp
payetvin Dec 8, 2023
35fda32
[FIX] common eco adq
payetvin Dec 8, 2023
1adcf49
[FIX] ui compile
payetvin Dec 8, 2023
039ddbf
[FIX] final compile
payetvin Dec 8, 2023
dd22673
[DEV] Sort cluster
payetvin Dec 8, 2023
d46d034
[DEV] removed byIndex
payetvin Dec 8, 2023
a7c8010
[DEV] small fix on add function
payetvin Dec 11, 2023
058a5b7
[DEV] code smells
payetvin Dec 11, 2023
66053ae
[DEV] comments 1
payetvin Dec 13, 2023
0249803
[DEV] change return type to bool
payetvin Dec 13, 2023
61fb467
[DEV] use std::all_of
payetvin Dec 13, 2023
758b349
[DEV] comments in renewables
payetvin Dec 13, 2023
ea38e89
[DEV] comments 2
payetvin Dec 13, 2023
2399d09
[DEV] refactor removeDisabledClusters by moving it in common
payetvin Dec 13, 2023
e653013
[DEV] comments ui
payetvin Dec 13, 2023
2c87746
[DEV] simplify common clusters : remove 2 useless find functions
guilpier-code Dec 14, 2023
04ce1bc
[DEV] simplify common clusters : "remove" function removal, because u…
guilpier-code Dec 14, 2023
0b42f10
[DEV] simplify common clusters : gathering find(...) functions defini…
guilpier-code Dec 18, 2023
c0de802
Merge branch 'fix/renew-lists' into fix/common-list
payetvin Dec 18, 2023
731076f
[DEV] simplify common clusters : we don't need to handle separately t…
guilpier-code Dec 18, 2023
7000fb1
Merge remote-tracking branch 'remotes/origin/fix/common-list' into fi…
guilpier-code Dec 18, 2023
64f31a3
[DEV] Using ranges and cpp 20 algo
payetvin Dec 18, 2023
e025643
Merge branch 'fix/common-list' of https://github.com/AntaresSimulator…
payetvin Dec 18, 2023
a200914
[DEV] renamed cluster into clusters
payetvin Dec 18, 2023
557201b
[FIX] compile
payetvin Dec 18, 2023
824282e
[DEV] Comments, removed groupCount
payetvin Dec 18, 2023
a52ea67
[DEV] more comments
payetvin Dec 18, 2023
92b2896
[DEV] rebuildIndex protected
payetvin Dec 18, 2023
e7f28c3
[DEV] doxygen comments
payetvin Dec 18, 2023
66a1852
[DEV] std::string typeID
payetvin Dec 18, 2023
1dffea3
[DEV] Remove non const each(predicate), use std::for_each for const one
payetvin Dec 18, 2023
2afb811
[DEV] add operator overload
payetvin Dec 18, 2023
334928e
[DEV] vector clusters protected
payetvin Dec 18, 2023
fff7e60
[DEV] study.cpp loop
payetvin Dec 18, 2023
f2244f7
[DEV] remove useless empty
payetvin Dec 19, 2023
716c858
[FIX] Adapt C++ 20 for win : make code compile when C++ 20 is forced
guilpier-code Dec 18, 2023
a653b1c
[DEV] simplify common clusters : use algorithm instead of a loop
guilpier-code Dec 19, 2023
e95d5a2
[DEV] using ranges allof
payetvin Dec 19, 2023
4177cc3
[DEV] remove reference for operator overload
payetvin Dec 19, 2023
e620d6e
[DEV] remove detach function
payetvin Dec 19, 2023
5545b12
Merge branch 'fix/common-list' of https://github.com/AntaresSimulator…
payetvin Dec 19, 2023
601da5a
[DEV] Add virtual func typeID back
payetvin Dec 20, 2023
ea797e6
[DEV] Clean save cluster function
payetvin Dec 20, 2023
9096788
[DEV] simplify ts function
payetvin Dec 20, 2023
f9a5d52
Revert "[DEV] remove detach function"
payetvin Dec 20, 2023
486a64a
[DEV] remove find(cluster)
payetvin Dec 20, 2023
dd96d28
[DEV] remove constructor destructor
payetvin Dec 20, 2023
8c55141
[DEV] remove detach function
payetvin Dec 20, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions src/libs/antares/InfoCollection/StudyInfoCollector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,9 @@ 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;
for (const auto& cluster : area.thermal.list)
payetvin marked this conversation as resolved.
Show resolved Hide resolved
if (cluster->enabled)
nbEnabledThermalClusters++;
}
}

// Adding an item related to number of enabled thermal clusters to the file content
Expand Down Expand Up @@ -152,4 +148,4 @@ void SimulationInfoCollector::toFileContent(FileContent& file_content)
"optimization problem", "non-zero coefficients", opt_info_.nbNonZeroCoeffs);
}

}
}
26 changes: 9 additions & 17 deletions src/libs/antares/study/cleaner/cleaner-v20.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
a-zakir marked this conversation as resolved.
Show resolved Hide resolved
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);
}
Expand All @@ -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);
}
Expand Down
56 changes: 27 additions & 29 deletions src/libs/antares/study/parts/common/cluster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,45 +49,43 @@ 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())
if (folder.empty())
return true;

Yuni::Clob buffer;

buffer.clear() << folder << SEP << parentArea->id << SEP << id();
if (Yuni::IO::Directory::Create(buffer))
{
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;
bool ret = true;
buffer.clear() << folder << SEP << parentArea->id << SEP << id() << SEP << "series.txt";
ret = series.timeSeries.saveToCSVFile(buffer, precision()) && ret;

return ret;
payetvin marked this conversation as resolved.
Show resolved Hide resolved
}
return 1;
return false;
payetvin marked this conversation as resolved.
Show resolved Hide resolved
}

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;

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;
auto& buffer = s.bufferLoadingTS;

if (s.usedByTheSolver && s.parameters.derated)
series.timeSeries.averageTimeseries();
bool 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;

series.timeseriesNumbers.clear();
if (s.usedByTheSolver && s.parameters.derated)
series.timeSeries.averageTimeseries();

return ret;
}
return 1;
series.timeseriesNumbers.clear();

return ret;
}
#undef SEP

Expand Down
4 changes: 2 additions & 2 deletions src/libs/antares/study/parts/common/cluster.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ class Cluster
//! Set of clusters
using Set = std::set<Cluster*, CompareClusterName>;

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;
Expand Down
Loading