Skip to content

Commit

Permalink
Split TS generation into files : renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
guilpier-code committed Jun 25, 2024
1 parent b2cc58e commit 2710aa4
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 27 deletions.
56 changes: 30 additions & 26 deletions src/solver/ts-generator/availability.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,13 @@ AvailabilityTSGeneratorData::AvailabilityTSGeneratorData(LinkTSgenerationParams&

namespace
{
class GeneratorTempData final
class AvailabilityTSgenerator final
{
public:
explicit GeneratorTempData(Data::Study&, unsigned, MersenneTwister&);
explicit GeneratorTempData(bool, unsigned, MersenneTwister&);
explicit AvailabilityTSgenerator(Data::Study&, unsigned, MersenneTwister&);
explicit AvailabilityTSgenerator(bool, unsigned, MersenneTwister&);

void generateTS(AvailabilityTSGeneratorData&) const;
void run(AvailabilityTSGeneratorData&) const;

private:
bool derated;
Expand All @@ -101,26 +101,30 @@ class GeneratorTempData final
const T& duration) const;
};

GeneratorTempData::GeneratorTempData(Data::Study& study, unsigned nbOfSeriesToGen, MersenneTwister& rndGenerator):
AvailabilityTSgenerator::AvailabilityTSgenerator(Data::Study& study,
unsigned nbOfSeriesToGen,
MersenneTwister& rndGenerator):
derated(study.parameters.derated),
nbOfSeriesToGen_(nbOfSeriesToGen),
rndgenerator(rndGenerator)
{
}

GeneratorTempData::GeneratorTempData(bool derated, unsigned int nbOfSeriesToGen, MersenneTwister& rndGenerator):
AvailabilityTSgenerator::AvailabilityTSgenerator(bool derated,
unsigned int nbOfSeriesToGen,
MersenneTwister& rndGenerator):
derated(derated),
nbOfSeriesToGen_(nbOfSeriesToGen),
rndgenerator(rndGenerator)
{
}

template<class T>
void GeneratorTempData::prepareIndispoFromLaw(Data::StatisticalLaw law,
double volatility,
std::array<double, 366>& A,
std::array<double, 366>& B,
const T& duration) const
void AvailabilityTSgenerator::prepareIndispoFromLaw(Data::StatisticalLaw law,
double volatility,
std::array<double, 366>& A,
std::array<double, 366>& B,
const T& duration) const
{
switch (law)
{
Expand Down Expand Up @@ -161,11 +165,11 @@ void GeneratorTempData::prepareIndispoFromLaw(Data::StatisticalLaw law,
}
}

int GeneratorTempData::durationGenerator(Data::StatisticalLaw law,
int expec,
double volat,
double a,
double b) const
int AvailabilityTSgenerator::durationGenerator(Data::StatisticalLaw law,
int expec,
double volat,
double a,
double b) const
{
if (volat == 0 || expec == 1)
{
Expand Down Expand Up @@ -193,7 +197,7 @@ int GeneratorTempData::durationGenerator(Data::StatisticalLaw law,
return 0;
}

void GeneratorTempData::generateTS(AvailabilityTSGeneratorData& tsGenerationData) const
void AvailabilityTSgenerator::run(AvailabilityTSGeneratorData& tsGenerationData) const
{
assert(tsGenerationData.prepro);

Expand Down Expand Up @@ -647,14 +651,14 @@ bool generateThermalTimeSeries(Data::Study& study,

bool archive = study.parameters.timeSeriesToArchive & Data::timeSeriesThermal;

auto generator = GeneratorTempData(study,
study.parameters.nbTimeSeriesThermal,
study.runtime->random[Data::seedTsGenThermal]);
auto generator = AvailabilityTSgenerator(study,
study.parameters.nbTimeSeriesThermal,
study.runtime->random[Data::seedTsGenThermal]);

for (auto* cluster: clusters)
{
AvailabilityTSGeneratorData tsGenerationData(cluster);
generator.generateTS(tsGenerationData);
generator.run(tsGenerationData);

if (archive) // For compatibilty with in memory thermal TS generation
{
Expand All @@ -675,9 +679,9 @@ bool generateLinkTimeSeries(std::vector<LinkTSgenerationParams>& links,
logs.info();
logs.info() << "Generation of links time-series";

auto generator = GeneratorTempData(generalParams.derated,
generalParams.nbLinkTStoGenerate,
generalParams.random);
auto generator = AvailabilityTSgenerator(generalParams.derated,
generalParams.nbLinkTStoGenerate,
generalParams.random);
for (auto& link: links)
{
if (! link.hasValidData)
Expand All @@ -696,7 +700,7 @@ bool generateLinkTimeSeries(std::vector<LinkTSgenerationParams>& links,
// DIRECT
AvailabilityTSGeneratorData tsConfigDataDirect(link, ts, link.modulationCapacityDirect, link.namesPair.second);

generator.generateTS(tsConfigDataDirect);
generator.run(tsConfigDataDirect);

std::string filePath = savePath + SEP + link.namesPair.first + SEP + link.namesPair.second
+ "_direct.txt";
Expand All @@ -705,7 +709,7 @@ bool generateLinkTimeSeries(std::vector<LinkTSgenerationParams>& links,
// INDIRECT
AvailabilityTSGeneratorData tsConfigDataIndirect(link, ts, link.modulationCapacityIndirect, link.namesPair.second);

generator.generateTS(tsConfigDataIndirect);
generator.run(tsConfigDataIndirect);

filePath = savePath + SEP + link.namesPair.first + SEP + link.namesPair.second
+ "_indirect.txt";
Expand Down
2 changes: 1 addition & 1 deletion src/tools/ts-generator/linksTSgenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ bool readLinkGeneralProperty(StudyParamsForLinkTS& params,
params.random.reset(seed);
return true;
}
return true; // gp : should we return true here ?
return true;
}

std::vector<LinkTSgenerationParams> CreateLinkList(const LinkPairs& linksFromCmdLine)
Expand Down

0 comments on commit 2710aa4

Please sign in to comment.