Skip to content

Commit

Permalink
Small code improvement for ramping
Browse files Browse the repository at this point in the history
  • Loading branch information
flomnes committed Dec 18, 2023
1 parent b9801fe commit c4cd709
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
8 changes: 8 additions & 0 deletions src/libs/antares/study/parts/thermal/cluster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -875,5 +875,13 @@ bool ThermalCluster::Ramping::checkValidity(Area* parentArea, Data::ClusterName
return ret;
}

std::ostream& ThermalCluster::Ramping::operator<<(std::ostream& os) const
{
return os << powerIncreaseCost << '\t'
<< powerDecreaseCost << '\t'
<< maxUpwardPowerRampingRate << '\t'
<< maxDownwardPowerRampingRate << '\n';
}

} // namespace Data
} // namespace Antares
1 change: 1 addition & 0 deletions src/libs/antares/study/parts/thermal/cluster.h
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@ class ThermalCluster final : public Cluster, public std::enable_shared_from_this

void reset();
bool checkValidity(Area* area, Data::ClusterName clusterName);
std::ostream& operator<<(std::ostream&) const;
};
Ramping ramping;

Expand Down
21 changes: 9 additions & 12 deletions src/solver/variable/surveyresults/surveyresults.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include <antares/logs/logs.h>
#include <yuni/io/file.h>
#include <antares/io/file.h>
#include <sstream>

using namespace Yuni;
using namespace Antares;
Expand Down Expand Up @@ -115,9 +116,7 @@ static void ExportGridInfosAreas(const Data::Study& study,
const Yuni::String& originalOutput,
IResultWriter& writer)
{
Clob out;
Clob outLinks;
Clob outThermal;
std::ostringstream out, outLinks, outThermal;

out << "id\tname\n";
outLinks << "upstream\tdownstream\n";
Expand Down Expand Up @@ -158,23 +157,21 @@ static void ExportGridInfosAreas(const Data::Study& study,
outThermal << cluster.fixedCost << '\t';
outThermal << cluster.startupCost << '\t';
outThermal << cluster.marketBidCost << '\t';
outThermal << cluster.spreadCost << '\n';
outThermal << cluster.ramping.powerIncreaseCost << '\n';
outThermal << cluster.ramping.powerDecreaseCost << '\n';
outThermal << cluster.ramping.maxUpwardPowerRampingRate << '\n';
outThermal << cluster.ramping.maxDownwardPowerRampingRate << '\n';
outThermal << cluster.spreadCost << '\t';
outThermal << cluster.ramping;

} // each thermal cluster
}); // each area
auto add = [&writer, &originalOutput](const YString& filename, Clob&& buffer) {
// buffer must be copied since addEntryFromBuffer has no std::string&& variant, unfortunately
auto add = [&writer, &originalOutput](const YString& filename, std::string buffer) {
YString path;
path << originalOutput << SEP << "grid" << SEP << filename;
writer.addEntryFromBuffer(path.c_str(), buffer);
};

add("areas.txt", std::move(out));
add("links.txt", std::move(outLinks));
add("thermal.txt", std::move(outThermal));
add("areas.txt", out.str());
add("links.txt", outLinks.str());
add("thermal.txt", outThermal.str());
}

SurveyResultsData::SurveyResultsData(const Data::Study& s, const String& o) :
Expand Down

0 comments on commit c4cd709

Please sign in to comment.