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

Add ts-generation for links [ANT-1084] #1986

Merged
merged 114 commits into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from 111 commits
Commits
Show all changes
114 commits
Select commit Hold shift + click to select a range
a8bfb5b
Add thermal interface struct
payetvin Mar 12, 2024
7fd7fc7
Add preproVector, add template to convert to interface
payetvin Mar 12, 2024
8027c68
template in c++
payetvin Mar 13, 2024
dddfe91
template constructor
payetvin Mar 13, 2024
6c99233
References init
payetvin Mar 13, 2024
a301927
remove preproVector, use prepro pointer
payetvin Mar 13, 2024
91aae90
move ThermalInterface to generator.h
payetvin Mar 13, 2024
8b1a054
remove ts-generator/include
payetvin Mar 13, 2024
053dfef
use interface
payetvin Mar 13, 2024
604cde0
fix typo
payetvin Mar 13, 2024
b0c7c35
use column for modulation
payetvin Mar 13, 2024
ce3b8b3
Code smell
payetvin Mar 14, 2024
31d73e3
Move save out of generator
payetvin Mar 14, 2024
ee84f58
FIx results, spinning after writing
payetvin Mar 14, 2024
c6975ca
code smells
payetvin Mar 15, 2024
4d9ec99
remove mc-year directory from ts-generator output
payetvin Mar 15, 2024
b7ebf65
Merge branch 'develop' into feature/thermal-interface
payetvin Mar 18, 2024
04edcb2
remove id from interface
payetvin Mar 18, 2024
b16022f
Merge branch 'feature/thermal-interface' of https://github.com/Antare…
payetvin Mar 18, 2024
3591573
remove progression
payetvin Mar 18, 2024
d3a0c8b
Add data to link class, specify interface constructor for thermal
payetvin Mar 18, 2024
8e9ef16
Remove unused arg year
payetvin Mar 18, 2024
71c2265
Fix compile
payetvin Mar 18, 2024
5eb633f
Move constructor to cpp file
payetvin Mar 18, 2024
444a967
Add constructor for links
payetvin Mar 18, 2024
8068785
Add struct tsgeneration in arealink
payetvin Mar 18, 2024
bd1bfd8
merge develop, conflicts
payetvin Mar 19, 2024
452fd39
fix compile
payetvin Mar 19, 2024
7158a87
test link interface
payetvin Mar 19, 2024
ccf0ae5
remove link test
payetvin Mar 20, 2024
0751ed3
Add the output path to save as arg
payetvin Mar 21, 2024
751ce5c
comments
payetvin Mar 21, 2024
a9a8e6c
use year
payetvin Mar 21, 2024
c3c5dce
fix compilw
payetvin Mar 21, 2024
18fd7ab
Merge branch 'develop' into feature/thermal-interface
payetvin Mar 22, 2024
d8749ab
add function to get links to generate
payetvin Mar 22, 2024
3031b81
better handling of args
payetvin Mar 22, 2024
4fa72e8
add handling of link args
payetvin Mar 22, 2024
b5f545b
use ID
payetvin Mar 25, 2024
6dc3ea6
add function generateLinkTS
payetvin Mar 25, 2024
2c9a8f6
call function
payetvin Mar 25, 2024
5f9afcb
fix arg description
payetvin Mar 25, 2024
4f943e5
Invert dependency on TS-Generator data (#2006)
flomnes Mar 25, 2024
3dbd091
add save for links
payetvin Mar 25, 2024
6251f6b
save both capacities
payetvin Mar 25, 2024
b4f129a
fix type
payetvin Mar 25, 2024
5b0a621
add write call
payetvin Mar 25, 2024
5cf0319
add seed and param nb of link series
payetvin Mar 26, 2024
0165980
use correct number of ts to gen
payetvin Mar 26, 2024
19ed14c
use intermediate matrix
payetvin Mar 26, 2024
f930267
property struct for ts direct and indirect
payetvin Mar 26, 2024
0a55a49
try fixing res diff
payetvin Mar 26, 2024
ddc28df
Add ts generator test to ubuntu CI
payetvin Mar 27, 2024
0cb0919
Add ts generator test to windows CI
payetvin Mar 27, 2024
aab9d29
fix os windows ci
payetvin Mar 27, 2024
6daae6b
coding style
payetvin Mar 27, 2024
1a0fb46
add function to generate all links
payetvin Mar 27, 2024
ae6d129
working option all links
payetvin Mar 27, 2024
e1682e6
Use findlink, add enum linkDirection
payetvin Apr 2, 2024
d3a61a8
Use direction in generator
payetvin Apr 2, 2024
2df3e28
Fixes
payetvin Apr 2, 2024
09235de
Merge remote-tracking branch 'github/develop' into feature/thermal-in…
flomnes Apr 2, 2024
9f6eb17
Default nbtslink
payetvin Apr 2, 2024
f34b6de
Merge branch 'feature/thermal-interface' of https://github.com/Antare…
payetvin Apr 2, 2024
afb2b8d
comments 1
payetvin Apr 3, 2024
683d2b9
use filesystem for separator
payetvin Apr 3, 2024
0d597e4
remove dynamic alloc of generatorTempData
payetvin Apr 3, 2024
c7ffac3
use a function instead of operator() to generate TS
payetvin Apr 3, 2024
3e54378
remove yuni string for saving
payetvin Apr 3, 2024
fbe3554
Move some members to generation function
payetvin Apr 3, 2024
cc4a8ba
Move some members to generation function 2
payetvin Apr 3, 2024
9d98623
Use path instead of string
payetvin Apr 3, 2024
8a2d4a0
One write function
payetvin Apr 3, 2024
fdb7d60
archive condition
payetvin Apr 3, 2024
98b1a08
Revert "Move some members to generation function 2"
payetvin Apr 3, 2024
9d9261c
use string method to ceonvert path
payetvin Apr 3, 2024
3bc979c
code semlls
payetvin Apr 3, 2024
61ddedb
code smells 2
payetvin Apr 4, 2024
4e0732f
Fix description
payetvin Apr 4, 2024
6b7414d
Add I/O for links' TS generation (#2019)
flomnes Apr 9, 2024
e72c894
Merge remote-tracking branch 'github/develop' into feature/thermal-in…
flomnes Apr 9, 2024
b711528
Code smells
flomnes Apr 9, 2024
c9b34ef
Fix arg name linksToGen
payetvin Apr 10, 2024
cc0f30a
Remove prepro.hxx, few fix
payetvin Apr 10, 2024
269769a
Default value for tsGenLink struct
payetvin Apr 10, 2024
d7edcb6
Remove unused member study from generator class
payetvin Apr 10, 2024
5a5893e
rename to tsConfigData
payetvin Apr 16, 2024
b4b807d
use matrix instead of timeseries object
payetvin Apr 16, 2024
86601ef
move spinning to solver.hxx
payetvin Apr 17, 2024
ba69144
Merge branch 'develop' into feature/thermal-interface
payetvin Apr 22, 2024
f1c9caa
checkout clang format and script from develop
payetvin May 13, 2024
f2b1592
format conflicting filers
payetvin May 13, 2024
1a9dd44
conflicts
payetvin May 13, 2024
213603a
add app name
payetvin May 13, 2024
865cf14
merge develop, conflicts
payetvin May 29, 2024
2e62287
use std fs
payetvin May 29, 2024
aa3a794
use fs path
payetvin May 29, 2024
bda7e78
fs path in tool
payetvin May 29, 2024
abf50a0
first implem for generation direct
payetvin May 29, 2024
2edaee1
fix compile
payetvin May 29, 2024
ba0363b
key handling
payetvin May 29, 2024
6f62425
file loading
payetvin May 29, 2024
2522ca6
Use correct rnd generator for each type
payetvin Jun 4, 2024
38a4207
Add force-no-generation parameter
payetvin Jun 5, 2024
bfeead9
reference for mersenne gen
payetvin Jun 6, 2024
d1620f6
merge develop, conflitcs
payetvin Jun 6, 2024
ba2b84a
change help formatting for the exe cmd line
payetvin Jun 6, 2024
73b8007
conflict link options for cmd line
payetvin Jun 6, 2024
3a8929e
fix compile
payetvin Jun 6, 2024
8c5ba5c
fix compile
payetvin Jun 6, 2024
4a4a6fa
Merge develop, conflicts
payetvin Jun 7, 2024
8619ebf
Merge branch 'develop' into feature/thermal-interface
payetvin Jun 21, 2024
bcb91f3
Update docs/user-guide/04-migration-guides.md
flomnes Jun 21, 2024
41fd3c8
Update docs/user-guide/04-migration-guides.md
flomnes Jun 21, 2024
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
9 changes: 9 additions & 0 deletions .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,15 @@ jobs:
os: ${{ env.os }}
variant: "parallel"

- name: Run tests for time series generator tool
if: ${{ env.RUN_SIMPLE_TESTS == 'true' }}
uses: ./.github/workflows/run-tests
with:
simtest-tag: ${{steps.simtest-version.outputs.prop}}
batch-name: ts-generator
os: ${{ env.os }}
variant: "tsgenerator"

- name: Run medium-tests
if: ${{ env.RUN_EXTENDED_TESTS == 'true' }}
uses: ./.github/workflows/run-tests
Expand Down
11 changes: 10 additions & 1 deletion .github/workflows/windows-vcpkg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,15 @@ jobs:
os: ${{ env.test-platform }}
variant: "parallel"

- name: Run tests for time series generator tool
if: ${{ env.RUN_SIMPLE_TESTS == 'true' }}
uses: ./.github/workflows/run-tests
with:
simtest-tag: ${{steps.simtest-version.outputs.prop}}
batch-name: ts-generator
os: ${{ env.test-platform }}
variant: "tsgenerator"

- name: Run medium-tests
if: ${{ env.RUN_EXTENDED_TESTS == 'true' }}
uses: ./.github/workflows/run-tests
Expand Down Expand Up @@ -304,7 +313,7 @@ jobs:
run: |
cd _build
cpack -G ZIP

- name: Installer upload
uses: actions/upload-artifact@v4
with:
Expand Down
21 changes: 21 additions & 0 deletions docs/user-guide/04-migration-guides.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
# Migration guides
This is a list of all recent changes that came with new Antares Simulator features. The main goal of this document is to lower the costs of changing existing interfaces, both GUI and scripts.

## v9.2.0
### (TS-generator only) TS generation for links
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the quantity being generated for links ?
capacity ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then we should say it.
Otherwise it's unclear

flomnes marked this conversation as resolved.
Show resolved Hide resolved
In files input/links/<link1>/properties.ini, add the following properties
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doc is not very clear to me, especially when opening it with a markdown reader (I use VS Code).
This is a long list of different things.
Apparently, there are 4 files concerned by the links capacities TS generation.
So it should be separated into 4 parts.

- tsgen_direct_XXX,
- tsgen_indirect_XXX
with XXX in
- unitcount (unsigned int, default 1)
- nominalcapacity (float)
- law.planned (string "uniform"/"geometric")
- law.forced (same)
- volatility.planned (double in [0,1])
- volatility.forced (same)

- "prepro" timeseries => input/links/<link 1>/prepro/<link 2>_{direct, indirect}.txt, 365x6 values, respectively "forced outage duration", "planned outage duration", "forced outage rate", "planned outage rate", "minimum of groups in maintenance", "maximum of groups in maintenance".
- "modulation" timeseries => input/links/<link 1>/prepro/<link 2>_mod_{direct, indirect}.txt, 8760x1 values each in [0, 1]
- number of TS to generate => generaldata.ini/General/nbtimeserieslinks (unsigned int, default value 1)

Add bool argument to optionally load time-series. This bool is false (default value) in antares-solver, and true in antares-ts-generator. Parameters are loaded in any case.-
flomnes marked this conversation as resolved.
Show resolved Hide resolved


## v9.1.0
### Input
#### Hydro Maximum Generation/Pumping Power
Expand Down
106 changes: 104 additions & 2 deletions src/libs/antares/study/area/links.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@

#include "antares/study/area/links.h"

#include <filesystem>
#include <limits>

#include <boost/algorithm/string/case_conv.hpp>

#include <yuni/yuni.h>

#include <antares/exception/LoadingError.hpp>
Expand Down Expand Up @@ -134,6 +137,58 @@ bool AreaLink::linkLoadTimeSeries_for_version_820_and_later(const AnyString& fol
return success;
}

// This function is "lazy", it only loads files if they exist
// and set a `valid` flag
bool AreaLink::loadTSGenTimeSeries(const fs::path& folder)
{
const std::string idprepro = std::string(from->id) + "/" + std::string(with->id);
tsGeneration.prepro =
std::make_unique<Data::PreproAvailability>(idprepro, tsGeneration.unitCount);

bool anyFileWasLoaded = false;

// file name without suffix, .txt for general infos and mod_direct/indirect.txt
fs::path preproFile = folder / "prepro" / with->id.c_str();

// Prepro
fs::path filepath = preproFile;
filepath += ".txt";
if (fs::exists(filepath))
{
anyFileWasLoaded = true;
tsGeneration.valid = tsGeneration.prepro->data.loadFromCSVFile(
payetvin marked this conversation as resolved.
Show resolved Hide resolved
filepath.string(),
Antares::Data::PreproAvailability::preproAvailabilityMax,
DAYS_PER_YEAR)
&& tsGeneration.prepro->validate();
}

// Modulation
filepath = preproFile;
filepath += "_mod_direct.txt";
if (fs::exists(filepath))
{
anyFileWasLoaded = true;
tsGeneration.valid &= tsGeneration.modulationCapacityDirect
.loadFromCSVFile(filepath.string(), 1, HOURS_PER_YEAR);
}

filepath = preproFile;
filepath += "_mod_indirect.txt";
if (fs::exists(filepath))
{
anyFileWasLoaded = true;
tsGeneration.valid &= tsGeneration.modulationCapacityIndirect
.loadFromCSVFile(filepath.string(), 1, HOURS_PER_YEAR);
}

if (anyFileWasLoaded)
{
return tsGeneration.valid;
}
return true;
}

bool AreaLink::isLinkPhysical() const
{
// All link types are physical, except arVirt
Expand Down Expand Up @@ -448,13 +503,55 @@ bool handleKey(Data::AreaLink& link, const String& key, const String& value)
link.filterYearByYear = stringIntoDatePrecision(value);
return true;
}
return false;
}

bool handleTSGenKey(Data::LinkTsGeneration& out,
const std::string& key,
const String& value)
{

if (key == "unitcount")
{
return value.to<uint>(out.unitCount);
}

if (key == "nominalcapacity")
{
return value.to<double>(out.nominalCapacity);
}

if (key == "law.planned")
{
return value.to(out.plannedLaw);
}

if (key == "law.forced")
{
return value.to(out.forcedLaw);
}

if (key == "volatility.planned")
{
return value.to(out.plannedVolatility);
}

if (key == "volatility.forced")
{
return value.to(out.forcedVolatility);
}

if (key == "force-no-generation")
{
return value.to<bool>(out.forceNoGeneration);
}

return false;
}

bool AreaLinksInternalLoadFromProperty(AreaLink& link, const String& key, const String& value)
{
return handleKey(link, key, value);
return handleKey(link, key, value) || handleTSGenKey(link.tsGeneration, key, value);
}

[[noreturn]] void logLinkDataCheckError(const AreaLink& link, const String& msg, int hour)
Expand All @@ -475,7 +572,7 @@ bool AreaLinksInternalLoadFromProperty(AreaLink& link, const String& key, const
}
} // anonymous namespace

bool AreaLinksLoadFromFolder(Study& study, AreaList* l, Area* area, const fs::path& folder)
bool AreaLinksLoadFromFolder(Study& study, AreaList* l, Area* area, const fs::path& folder, bool loadTSGen)
{
// Assert
assert(area);
Expand Down Expand Up @@ -601,6 +698,11 @@ bool AreaLinksLoadFromFolder(Study& study, AreaList* l, Area* area, const fs::pa
}
}

if (loadTSGen)
{
ret = link.loadTSGenTimeSeries(folder) && ret;
}

// From the solver only
if (study.usedByTheSolver)
{
Expand Down
2 changes: 1 addition & 1 deletion src/libs/antares/study/area/list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,7 @@ static bool AreaListLoadFromFolderSingleArea(Study& study,
// Links
{
fs::path folder = fs::path(study.folderInput.c_str()) / "links" / area.id.c_str();
ret = AreaLinksLoadFromFolder(study, list, &area, folder) && ret;
ret = AreaLinksLoadFromFolder(study, list, &area, folder, options.linksLoadTSGen) && ret;
}

// UI
Expand Down
2 changes: 1 addition & 1 deletion src/libs/antares/study/cleaner/cleaner-v20.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ bool listOfFilesAnDirectoriesToKeep(StudyCleaningInfos* infos)
logs.verbosityLevel = Logs::Verbosity::Warning::level;
// load all links
buffer.clear() << infos->folder << "/input/links/" << area->id;
if (not AreaLinksLoadFromFolder(*study, arealist, area, buffer.c_str()))
if (not AreaLinksLoadFromFolder(*study, arealist, area, buffer.c_str(), false))
{
delete arealist;
delete study;
Expand Down
4 changes: 4 additions & 0 deletions src/libs/antares/study/fwd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ const char* SeedToCString(SeedIndex seed)
return "Noise on virtual Hydro costs";
case seedHydroManagement:
return "Initial reservoir levels";
case seedTsGenLinks:
return "Links time-series generation";
case seedMax:
return "";
}
Expand Down Expand Up @@ -85,6 +87,8 @@ const char* SeedToID(SeedIndex seed)
return "seed-hydro-costs";
case seedHydroManagement:
return "seed-initial-reservoir-levels";
case seedTsGenLinks:
return "seed-tsgen-links";
case seedMax:
return "";
}
Expand Down
3 changes: 2 additions & 1 deletion src/libs/antares/study/include/antares/study/area/area.h
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,8 @@ AreaLink* AreaAddLinkBetweenAreas(Area* area, Area* with, bool warning = true);
bool AreaLinksLoadFromFolder(Study& s,
AreaList* l,
Area* area,
const std::filesystem::path& folder);
const std::filesystem::path& folder,
bool loadTSGen);

/*!
** \brief Save interconnections of a given area into a folder (`input/areas/[area]/ntc`)
Expand Down
5 changes: 5 additions & 0 deletions src/libs/antares/study/include/antares/study/area/links.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ class AreaLink final: public Yuni::NonCopyable<AreaLink>

bool loadTimeSeries(const StudyVersion& version, const AnyString& folder);

bool loadTSGenTimeSeries(const std::filesystem::path& folder);

void storeTimeseriesNumbers(Solver::IResultWriter& writer) const;

//! \name Area
Expand Down Expand Up @@ -206,6 +208,9 @@ class AreaLink final: public Yuni::NonCopyable<AreaLink>
int linkWidth;

friend struct CompareLinkName;

LinkTsGeneration tsGeneration;
guilpier-code marked this conversation as resolved.
Show resolved Hide resolved

}; // class AreaLink

struct CompareLinkName final
Expand Down
2 changes: 2 additions & 0 deletions src/libs/antares/study/include/antares/study/fwd.h
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,8 @@ enum SeedIndex
seedHydroCosts,
//! Seed - Hydro management
seedHydroManagement,
//! The seed for links
seedTsGenLinks,
//! The number of seeds
seedMax,
};
Expand Down
4 changes: 4 additions & 0 deletions src/libs/antares/study/include/antares/study/load-options.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ class StudyLoadOptions
bool loadOnlyNeeded;
//! Force the year-by-year flag
bool forceYearByYear;

//! Load data associated to link TS generation
bool linksLoadTSGen = false;

//! Force the derated mode
bool forceDerated;

Expand Down
2 changes: 2 additions & 0 deletions src/libs/antares/study/include/antares/study/parameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,8 @@ class Parameters final
uint nbTimeSeriesThermal;
//! Nb of timeSeries : Solar
uint nbTimeSeriesSolar;
//! Nb of timeSeries : Links
uint nbLinkTStoGenerate = 1;
//@}

//! \name Time-series refresh
Expand Down
9 changes: 9 additions & 0 deletions src/libs/antares/study/parameters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,10 @@ static bool SGDIntLoadFamily_General(Parameters& d,
{
return value.to<uint>(d.nbTimeSeriesSolar);
}
if (key == "nbtimeserieslinks")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We know generating TS for links should be fully separated from the Antares solver.
What is true for the code is true for data as well.
For now data required generating TS for links are mixed data with the study data.
Here is a good example : nbtimeserieslinks is still held by generaldata.ini. Same for seed_links.
Eventually, we should separate data for TS generation form study data.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See your PR @guilpier-code

{
return value.to<uint>(d.nbLinkTStoGenerate);
}
// Interval values
if (key == "refreshintervalload")
{
Expand Down Expand Up @@ -1078,6 +1082,10 @@ static bool SGDIntLoadFamily_SeedsMersenneTwister(Parameters& d,
{
return value.to<uint>(d.seed[seedTsGenSolar]);
}
if (key == "seed_links")
{
return value.to<uint>(d.seed[seedTsGenLinks]);
}
if (key == "seed_timeseriesnumbers")
{
return value.to<uint>(d.seed[seedTimeseriesNumbers]);
Expand Down Expand Up @@ -1798,6 +1806,7 @@ void Parameters::saveToINI(IniFile& ini) const
section->add("nbTimeSeriesWind", nbTimeSeriesWind);
section->add("nbTimeSeriesThermal", nbTimeSeriesThermal);
section->add("nbTimeSeriesSolar", nbTimeSeriesSolar);
section->add("nbtimeserieslinks", nbLinkTStoGenerate);

// Refresh
ParametersSaveTimeSeries(section, "refreshTimeSeries", timeSeriesToRefresh);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -972,6 +972,7 @@ static inline void logPerformedYearsInAset(setOfParallelYears& set)
<< " perfomed)";

std::string performedYearsToLog = "";

std::ranges::for_each(set.yearsIndices,
[&](const uint& y)
{
Expand Down
Loading
Loading