Skip to content

Commit

Permalink
Move economic thermal costs input files into "series" directory (#1616)
Browse files Browse the repository at this point in the history
* Move economic thermal costs input files into series directory

* Move economic thermal costs input files into series directory : oops, forgot to implement the saving

* Move economic thermal costs input files into series directory : small simplifications
  • Loading branch information
guilpier-code authored Sep 12, 2023
1 parent 291b5bf commit 15b9285
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 48 deletions.
2 changes: 2 additions & 0 deletions src/libs/antares/study/area/list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ static bool AreaListSaveToFolderSingleArea(const Area& area, Clob& buffer, const
ret = area.thermal.list.savePreproToFolder(buffer) && ret;
buffer.clear() << folder << SEP << "input" << SEP << "thermal" << SEP << "series";
ret = area.thermal.list.saveDataSeriesToFolder(buffer) && ret;
ret = area.thermal.list.saveEconomicCosts(buffer) && ret;
}

// Renewable cluster list
Expand Down Expand Up @@ -944,6 +945,7 @@ static bool AreaListLoadFromFolderSingleArea(Study& study,
ret = area.thermal.list.loadPreproFromFolder(study, options, buffer) && ret;
buffer.clear() << study.folderInput << SEP << "thermal" << SEP << "series";
ret = area.thermal.list.loadDataSeriesFromFolder(study, options, buffer) && ret;
ret = area.thermal.list.loadEconomicCosts(study, buffer) && ret;

// In adequacy mode, all thermal clusters must be in 'mustrun' mode
if (study.usedByTheSolver && study.parameters.mode == stdmAdequacy)
Expand Down
30 changes: 5 additions & 25 deletions src/libs/antares/study/parts/common/cluster_list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -370,17 +370,17 @@ int ClusterList<ClusterT>::saveDataSeriesToFolder(const AnyString& folder, const
return ret;
}

template<>
int ClusterList<ThermalCluster>::loadDataSeriesFromFolder(Study& s,
const StudyLoadOptions& options,
const AnyString& folder)
template<class ClusterT>
int ClusterList<ClusterT>::loadDataSeriesFromFolder(Study& s,
const StudyLoadOptions& options,
const AnyString& folder)
{
if (empty())
return 1;

int ret = 1;

each([&ret, &options, &s, &folder](ThermalCluster& c) {
each([&](ClusterT& c) {
if (c.series)
ret = c.loadDataSeriesFromFolder(s, folder) and ret;

Expand All @@ -390,26 +390,6 @@ int ClusterList<ThermalCluster>::loadDataSeriesFromFolder(Study& s,
return ret;
}

template<>
int ClusterList<RenewableCluster>::loadDataSeriesFromFolder(Study& s,
const StudyLoadOptions& options,
const AnyString& folder)
{
if (empty())
return 1;

int ret = 1;

each([&](Cluster& cluster) {
if (cluster.series)
ret = cluster.loadDataSeriesFromFolder(s, folder) and ret;

++options.progressTicks;
options.pushProgressLogs();
});
return ret;
}

template<class ClusterT>
void ClusterList<ClusterT>::ensureDataTimeSeries()
{
Expand Down
69 changes: 46 additions & 23 deletions src/libs/antares/study/parts/thermal/cluster_list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -470,18 +470,29 @@ bool ThermalClusterList::savePreproToFolder(const AnyString& folder) const
Clob buffer;
bool ret = true;

each([&](const Data::ThermalCluster& c) {
each([&](const ThermalCluster& c) {
if (c.prepro)
{
assert(c.parentArea and "cluster: invalid parent area");
buffer.clear() << folder << SEP << c.parentArea->id << SEP << c.id();
ret = c.prepro->saveToFolder(buffer) and ret;
}
{
assert(c.parentArea and "cluster: invalid parent area");
buffer.clear() << folder << SEP << c.parentArea->id << SEP << c.id();
ret = c.ecoInput.saveToFolder(buffer) && ret;
}
});
return ret;
}

bool ThermalClusterList::saveEconomicCosts(const AnyString& folder) const
{
if (empty())
return true;

Clob buffer;
bool ret = true;

each([&](const ThermalCluster& c) {
assert(c.parentArea and "cluster: invalid parent area");
buffer.clear() << folder << SEP << c.parentArea->id << SEP << c.id();
ret = c.ecoInput.saveToFolder(buffer) && ret;
});
return ret;
}
Expand All @@ -499,39 +510,51 @@ bool ThermalClusterList::loadPreproFromFolder(Study& study,
Clob buffer;
bool ret = true;

for (auto it = begin(); it != end(); ++it)
for (auto& [name, c] : cluster)
{
auto& c = *(it->second);
if (c.prepro)
if (c->prepro)
{
assert(c.parentArea and "cluster: invalid parent area");
buffer.clear() << folder << SEP << c.parentArea->id << SEP << c.id();
assert(c->parentArea and "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))
if (result && study.usedByTheSolver && c->doWeGenerateTS(globalThermalTSgeneration))
{
// checking NPO max
result = c.prepro->normalizeAndCheckNPO();
result = c->prepro->normalizeAndCheckNPO();
}

ret = result and ret;
}

{
assert(c.parentArea and "cluster: invalid parent area");
buffer.clear() << folder << SEP << c.parentArea->id << SEP << c.id();

bool result = c.ecoInput.loadFromFolder(study, buffer);
c.ComputeCostTimeSeries();

ret = result && ret;
}
++options.progressTicks;
options.pushProgressLogs();
}
return ret;
}


bool ThermalClusterList::loadEconomicCosts(Study& study, const AnyString& folder)
{
if (empty())
return true;

Clob buffer;
bool ret = true;

for (auto& [name, c] : cluster)
{
assert(c->parentArea and "cluster: invalid parent area");
buffer.clear() << folder << SEP << c->parentArea->id << SEP << c->id();

bool result = c->ecoInput.loadFromFolder(study, buffer);
c->ComputeCostTimeSeries();

ret = result && ret;
}
return ret;
}

} // namespace Data
} // namespace Antares
3 changes: 3 additions & 0 deletions src/libs/antares/study/parts/thermal/cluster_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ class ThermalClusterList : public ClusterList<ThermalCluster>
*/
bool loadPreproFromFolder(Study& s, const StudyLoadOptions& options, const AnyString& folder);

bool loadEconomicCosts(Study& s, const AnyString& folder);

bool savePreproToFolder(const AnyString& folder) const;
bool saveEconomicCosts(const AnyString& folder) const;

bool saveToFolder(const AnyString& folder) const override;
}; // class ThermalClusterList
Expand Down

0 comments on commit 15b9285

Please sign in to comment.