21#ifndef __ANTARES_LIBS_STUDY_AREAS_H__
22#define __ANTARES_LIBS_STUDY_AREAS_H__
30#include <yuni/core/noncopyable.h>
31#include <yuni/core/string.h>
33#include <antares/array/matrix.h>
34#include <antares/study/parameters/adq-patch-params.h>
35#include "antares/study/filter.h"
36#include "antares/study/parts/parts.h"
46struct CompareAreaName;
51class Area final:
private Yuni::NonCopyable<Area>
54 using NameSet = std::set<AreaName>;
55 using Set = std::set<Area*, CompareAreaName>;
56 using LinkMap = std::map<Area*, AreaLink::Set, CompareAreaName>;
57 using Map = std::map<AreaName, Area*>;
58 using Vector = std::vector<Area*>;
59 using VectorConst = std::vector<const Area*>;
60 using List = std::list<Area*>;
61 using ScratchMap = std::map<const Area*, AreaScratchpad&>;
77 explicit Area(
const AnyString&
name);
84 Area(
const AnyString&
name,
const AnyString&
id);
104 std::vector<size_t>& layerList =
ui->mapLayersVisibilityList;
105 std::vector<size_t>::iterator layerPosition = std::find(layerList.begin(),
108 return layerPosition != layerList.end();
136 static void detachLink(
const AreaLink* lnk);
144 void buildLinksIndexes();
204 template<enum TimeSeriesType T>
206 template<enum TimeSeriesType T>
219 AdequacyPatch::AdequacyPatchMode
adequacyPatchMode = AdequacyPatch::physicalAreaOutsideAdqPatch;
304 std::unique_ptr<AreaUI>
ui;
327 void internalInitialize();
328 void createMissingTimeSeries();
329 void createMissingPrepros();
333bool saveAreaOptimisationIniFile(
const Area& area,
const Yuni::Clob& buffer);
335bool saveAreaAdequacyPatchIniFile(
const Area& area,
const Yuni::Clob& buffer);
365class AreaList final:
public Yuni::NonCopyable<AreaList>
395 template<
class PredicateT>
396 void each(
const PredicateT& predicate);
400 template<
class PredicateT>
401 void each(
const PredicateT& predicate)
const;
507 const Area*
find(
const AreaName&
id)
const;
514 Area* findFromPosition(
const int x,
const int y)
const;
564 bool remove(
const AnyString&
id);
577 bool renameArea(
const AreaName& oldid,
const AreaName& newName);
591 bool renameArea(
const AreaName& oldid,
const AreaName& newid,
const AreaName& newName);
679void AreaListDeleteLinkFromAreaPtr(
AreaList* l,
const Area* a);
691AreaLink* AreaAddLinkBetweenAreas(
Area* area,
Area* with,
bool warning =
true);
700bool AreaLinksLoadFromFolder(
Study& s,
703 const std::filesystem::path& folder);
712bool AreaLinksSaveToFolder(
const Area* area,
const char*
const folder);
715bool saveAreaLinksConfigurationFileToFolder(
const Area* area,
const char*
const folder);
752Area* addAreaToListOfAreas(
AreaList& list,
const AnyString& name);
762Area* AreaListAddFromNames(
AreaList& list,
const AnyString& name,
const AnyString& lname);
771AreaLink* AreaListAddLink(
AreaList* l,
const char area[],
const char with[],
bool warning =
true);
773void AreaListClearAllLinks(
AreaList* l);
778void AreaListEnsureDataLoadPrepro(
AreaList* l);
783void AreaListEnsureDataSolarPrepro(
AreaList* l);
788void AreaListEnsureDataWindPrepro(
AreaList* l);
793void AreaListEnsureDataHydroTimeSeries(
AreaList* l);
798void AreaListEnsureDataHydroPrepro(
AreaList* l);
803void AreaListEnsureDataThermalPrepro(
AreaList* l);
808inline bool CheckForbiddenCharacterInAreaName(
const AnyString& name)
810 return name.contains(
'*');
816#include "../load-options.h"
Definition of a link between two areas (Interconnection)
Definition links.h:50
std::map< AreaName, AreaLink * > Map
Map of links.
Definition links.h:57
A list of areas.
Definition area.h:366
bool remove(const AnyString &id)
Remove an area from its ID.
Definition list.cpp:1608
Area::Map::value_type value_type
Key-value type.
Definition area.h:377
void rebuildIndexes()
Rebuild the indexes for accessing areas.
Definition list.cpp:467
void saveLinkListToBuffer(Yuni::Clob &buffer) const
Write the list of all links into a file.
Definition list.cpp:601
bool saveToFolder(const AnyString &folder) const
Save all informations about areas into a folder (-> input/generalData)
Definition list.cpp:684
void removeSolarTimeseries()
Remove all solar timeseries.
Definition list.cpp:1693
bool preloadAndMarkAsModifiedAllInvalidatedAreas(uint *invalidateCount=nullptr) const
Preload all areas which have been invalidated.
Definition list.cpp:655
bool renameArea(const AreaName &oldid, const AreaName &newName)
Rename an area.
Definition list.cpp:1435
AreaLink * findLink(const AreaName &area, const AreaName &with)
Find an interconnection between two areas.
Definition list.cpp:425
Area::Map areas
All areas in the list.
Definition area.h:667
AreaLink * findLinkFromINIKey(const AnyString &key)
Try to find the link from a given INI key (<area1>%<area2>)
Definition list.cpp:1634
void markAsModified() const
Mark all data as modified.
Definition list.cpp:679
void clear()
Remove all elements in the container.
Definition list.cpp:453
bool loadFromFolder(const StudyLoadOptions &options)
Load all informations about areas from a folder (-> input/generalData)
Definition list.cpp:1155
Area::ScratchMap buildScratchMap(uint numspace)
create a map with the corresponding scratchpad for each area link to this numspace
Definition list.cpp:1715
void removeLoadTimeseries()
Remove all load timeseries.
Definition list.cpp:1683
bool forceReload(bool reload=false) const
Invalidate all areas.
Definition list.cpp:1549
Area::Map::const_reverse_iterator const_reverse_iterator
A const iterator.
Definition area.h:375
Area * operator[](uint i)
Get an area from its index.
Definition area.hxx:36
void updateNameIDSet() const
Update the name id set.
Definition list.cpp:1672
Area * find(const AreaName &id)
Find an area from its unique string id.
Definition list.cpp:1262
Area::Map::reverse_iterator reverse_iterator
An iterator.
Definition area.h:373
void fixOrientationForAllInterconnections(BindingConstraintsRepository &bindingconstraints)
Fix all invalid orientations.
Definition list.cpp:1563
bool empty() const
Get if the container is empty.
Definition list.cpp:391
Area::NameSet nameidSet
Name set (must be updated by updateNameSet)
Definition area.h:671
uint areaLinkCount() const
Get the total number of interconnections between all areas.
Definition list.cpp:1415
bool loadListFromFile(const std::filesystem::path &filename)
Fill the list of areas from an input file.
Definition list.cpp:541
Area::Map::const_iterator const_iterator
A const iterator.
Definition area.h:371
AreaList(Study &study)
Default constructor.
Definition list.cpp:381
void removeThermalTimeseries()
Remove all thermal timeseries.
Definition list.cpp:1703
void resizeAllTimeseriesNumbers(uint n)
Resize all matrices dedicated to the sampled timeseries numbers.
Definition list.cpp:1556
void ensureDataIsInitialized(Parameters ¶ms, bool loadOnlyNeeded)
Ensure data for time series/prepro are initalized if they should be.
Definition list.cpp:1116
Area * findFromName(const AreaName &name)
Find an area from its name.
Definition list.cpp:1274
std::vector< Area * > byIndex
All areas by their index.
Definition area.h:665
void removeWindTimeseries()
Remove all wind timeseries.
Definition list.cpp:1698
void removeHydroTimeseries()
Remove all hydro timeseries.
Definition list.cpp:1688
~AreaList()
Destructor.
Definition list.cpp:386
bool saveListToFile(const AnyString &filename) const
Write the list of areas into a file.
Definition list.cpp:615
Area::Map::iterator iterator
An iterator.
Definition area.h:369
uint size() const
Get the total number of areas.
Definition area.hxx:108
Area * add(Area *a)
Add an area in the container.
Definition list.cpp:483
void each(const PredicateT &predicate)
Iterate through all areas.
Definition area.hxx:87
ThermalCluster * findClusterFromINIKey(const AnyString &key)
Try to find the cluster from a given INI key (<area>.<cluster>)
Definition list.cpp:1651
Definition for a single area.
Definition area.h:52
bool isVisibleOnLayer(const size_t &layerID) const
check visibility on layer
Definition area.h:97
uint filterYearByYear
Print results for the area in the year-by-year mode.
Definition area.h:298
AreaLink::Map links
All connections with this area.
Definition area.h:276
double spreadUnsuppliedEnergyCost
Spread for the unsupplied energy cost.
Definition area.h:288
uint filterSynthesis
Print results for the area in the simulation synthesis.
Definition area.h:296
void createMissingData()
Ensure all data are created.
Definition area.cpp:167
bool forceReload(bool reload=false) const
Load all data not already loaded.
Definition area.cpp:271
AreaName name
Name of the area.
Definition area.h:213
bool thermalClustersMinStablePowerValidity(std::vector< YString > &output) const
Check the validity of min stable power for all thermal clusters.
Definition area.cpp:254
void markAsModified() const
Mark all areas as modified.
Definition area.cpp:315
uint index
Index of the area - only valid when already added to an area list.
Definition area.h:217
std::unique_ptr< AreaUI > ui
Information for the UI.
Definition area.h:304
void resetToDefaultValues()
Reset all values to their default one.
Definition area.cpp:202
void detachLinkFromItsPointer(const AreaLink *lnk)
Remove a link from its raw pointer.
Definition list.cpp:1422
AreaLink * findExistingLinkWith(Area &with)
Check if a link with another area is already established.
Definition area.cpp:106
Area()
Default constructor.
Definition area.cpp:47
Matrix miscGen
Misc Gen.
Definition area.h:237
void detachAllLinks()
Properly detach all links attached to an area.
Definition area.cpp:98
std::map< AreaName, AreaName > NameMapping
Name mapping -> must be replaced by AreaNameMapping.
Definition area.h:63
void resizeAllTimeseriesNumbers(uint nbYears)
Resize all matrices dedicated to the sampled timeseries numbers.
Definition area.cpp:237
~Area()
Destructor.
Definition area.cpp:70
std::vector< AreaScratchpad > scratchpad
Scratchpad used temporary calculations (solver only)
Definition area.h:312
void clearAllLinks()
Destroy all links.
Definition area.cpp:81
AdequacyPatch::AdequacyPatchMode adequacyPatchMode
Use adequacy patch for this area.
Definition area.h:219
bool invalidateJIT
Invalidate (JIT)
Definition area.h:323
XCast * xcastData()
Get the XCast data according a given time-series type.
Definition area.hxx:49
AreaLink * findLinkByID(const AreaName &id)
Try to find the attached link from another area id.
Definition area.cpp:367
void detachLinkFromID(const AreaName &id)
Detach any link connected from this area to the given area.
Definition area.cpp:349
Wind::Container wind
Wind time-series and Wind prepro data.
Definition area.h:258
uint nodalOptimization
Nodal optimization (see AreaNodalOptimization)
Definition area.h:282
double spreadSpilledEnergyCost
Spread for the spilled energy cost.
Definition area.h:290
Matrix reserves
Reserves.
Definition area.h:230
AreaName id
Name of the area in lowercase format.
Definition area.h:215
Definition BindingConstraintsRepository.h:36
Definition container.h:38
General data for a study.
Definition parameters.h:51
Hydro for a single area.
Definition container.h:91
Definition container.h:35
Definition container.h:33
Definition container.h:35
Definition load-options.h:36
A single thermal cluster.
Definition cluster.h:78
Definition container.h:35
A n-by-n matrix.
Definition jit.h:30