21 #ifndef __ANTARES_LIBS_STUDY_AREAS_H__
22 #define __ANTARES_LIBS_STUDY_AREAS_H__
29 #include "antares/study/parts/parts.h"
31 #include <yuni/yuni.h>
32 #include <yuni/core/noncopyable.h>
33 #include <yuni/core/string.h>
35 #include <antares/array/matrix.h>
36 #include <antares/study/parameters/adq-patch-params.h>
37 #include "antares/study/filter.h"
39 #include "constants.h"
43 namespace Antares::Data
45 struct CompareAreaName;
50 class Area final:
private Yuni::NonCopyable<Area>
53 using NameSet = std::set<AreaName>;
54 using Set = std::set<Area*, CompareAreaName>;
55 using LinkMap = std::map<Area*, AreaLink::Set, CompareAreaName>;
56 using Map = std::map<AreaName, Area*>;
57 using Vector = std::vector<Area*>;
58 using VectorConst = std::vector<const Area*>;
59 using List = std::list<Area*>;
60 using ScratchMap = std::map<const Area*, AreaScratchpad&>;
76 explicit Area(
const AnyString&
name);
83 Area(
const AnyString&
name,
const AnyString&
id);
103 std::vector<size_t>& layerList =
ui->mapLayersVisibilityList;
104 std::vector<size_t>::iterator layerPosition = std::find(layerList.begin(),
107 return layerPosition != layerList.end();
135 static void detachLink(
const AreaLink* lnk);
143 void buildLinksIndexes();
203 template<enum TimeSeriesType T>
205 template<enum TimeSeriesType T>
218 AdequacyPatch::AdequacyPatchMode
adequacyPatchMode = AdequacyPatch::physicalAreaOutsideAdqPatch;
302 std::unique_ptr<AreaUI>
ui;
326 void internalInitialize();
327 void createMissingTimeSeries();
328 void createMissingPrepros();
332 bool saveAreaOptimisationIniFile(
const Area& area,
const Yuni::Clob& buffer);
334 bool saveAreaAdequacyPatchIniFile(
const Area& area,
const Yuni::Clob& buffer);
364 class AreaList final:
public Yuni::NonCopyable<AreaList>
394 template<
class PredicateT>
395 void each(
const PredicateT& predicate);
399 template<
class PredicateT>
400 void each(
const PredicateT& predicate)
const;
456 bool saveToFolder(
const AnyString& folder)
const;
466 bool saveListToFile(
const AnyString& filename)
const;
508 const Area*
find(
const AreaName&
id)
const;
515 Area* findFromPosition(
const int x,
const int y)
const;
565 bool remove(
const AnyString&
id);
578 bool renameArea(
const AreaName& oldid,
const AreaName& newName);
592 bool renameArea(
const AreaName& oldid,
const AreaName& newid,
const AreaName& newName);
680 void AreaListDeleteLinkFromAreaPtr(
AreaList* l,
const Area* a);
692 AreaLink* AreaAddLinkBetweenAreas(
Area* area,
Area* with,
bool warning =
true);
701 bool AreaLinksLoadFromFolder(
Study& s,
704 const std::filesystem::path& folder);
714 bool AreaLinksSaveToFolder(
const Area* area,
const char*
const folder);
717 bool saveAreaLinksConfigurationFileToFolder(
const Area* area,
const char*
const folder);
755 Area* addAreaToListOfAreas(
AreaList& list,
const AnyString& name);
765 Area* AreaListAddFromNames(
AreaList& list,
const AnyString& name,
const AnyString& lname);
774 AreaLink* AreaListAddLink(
AreaList* l,
const char area[],
const char with[],
bool warning =
true);
776 void AreaListClearAllLinks(
AreaList* l);
781 void AreaListEnsureDataLoadPrepro(
AreaList* l);
786 void AreaListEnsureDataSolarPrepro(
AreaList* l);
791 void AreaListEnsureDataWindPrepro(
AreaList* l);
796 void AreaListEnsureDataHydroTimeSeries(
AreaList* l);
801 void AreaListEnsureDataHydroPrepro(
AreaList* l);
806 void AreaListEnsureDataThermalPrepro(
AreaList* l);
811 inline bool CheckForbiddenCharacterInAreaName(
const AnyString& name)
813 return name.contains(
'*');
818 #include "../load-options.h"
Definition of a link between two areas (Interconnection)
Definition: links.h:58
std::map< AreaName, AreaLink * > Map
Map of links.
Definition: links.h:65
A list of areas.
Definition: area.h:365
bool remove(const AnyString &id)
Remove an area from its ID.
Definition: list.cpp:1627
Area::Map::value_type value_type
Key-value type.
Definition: area.h:376
void rebuildIndexes()
Rebuild the indexes for accessing areas.
Definition: list.cpp:470
void saveLinkListToBuffer(Yuni::Clob &buffer) const
Write the list of all links into a file.
Definition: list.cpp:600
void removeSolarTimeseries()
Remove all solar timeseries.
Definition: list.cpp:1712
bool preloadAndMarkAsModifiedAllInvalidatedAreas(uint *invalidateCount=nullptr) const
Preload all areas which have been invalidated.
Definition: list.cpp:656
bool renameArea(const AreaName &oldid, const AreaName &newName)
Rename an area.
Definition: list.cpp:1458
AreaLink * findLink(const AreaName &area, const AreaName &with)
Find an interconnection between two areas.
Definition: list.cpp:428
Area::Map areas
All areas in the list.
Definition: area.h:668
AreaLink * findLinkFromINIKey(const AnyString &key)
Try to find the link from a given INI key (<area1>%<area2>)
Definition: list.cpp:1653
void markAsModified() const
Mark all data as modified.
Definition: list.cpp:680
void clear()
Remove all elements in the container.
Definition: list.cpp:456
bool loadFromFolder(const StudyLoadOptions &options)
Load all informations about areas from a folder (-> input/generalData)
Definition: list.cpp:1178
Area::ScratchMap buildScratchMap(uint numspace)
create a map with the corresponding scratchpad for each area link to this numspace
Definition: list.cpp:1734
void removeLoadTimeseries()
Remove all load timeseries.
Definition: list.cpp:1702
bool forceReload(bool reload=false) const
Invalidate all areas.
Definition: list.cpp:1568
Area::Map::const_reverse_iterator const_reverse_iterator
A const iterator.
Definition: area.h:374
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:1691
Area * find(const AreaName &id)
Find an area from its unique string id.
Definition: list.cpp:1285
Area::Map::reverse_iterator reverse_iterator
An iterator.
Definition: area.h:372
void fixOrientationForAllInterconnections(BindingConstraintsRepository &bindingconstraints)
Fix all invalid orientations.
Definition: list.cpp:1582
bool empty() const
Get if the container is empty.
Definition: list.cpp:394
Area::NameSet nameidSet
Name set (must be updated by updateNameSet)
Definition: area.h:672
uint areaLinkCount() const
Get the total number of interconnections between all areas.
Definition: list.cpp:1438
bool loadListFromFile(const std::filesystem::path &filename)
Fill the list of areas from an input file.
Definition: list.cpp:540
Area::Map::const_iterator const_iterator
A const iterator.
Definition: area.h:370
AreaList(Study &study)
Default constructor.
Definition: list.cpp:384
void removeThermalTimeseries()
Remove all thermal timeseries.
Definition: list.cpp:1722
void resizeAllTimeseriesNumbers(uint n)
Resize all matrices dedicated to the sampled timeseries numbers.
Definition: list.cpp:1575
void ensureDataIsInitialized(Parameters ¶ms, bool loadOnlyNeeded)
Ensure data for time series/prepro are initalized if they should be.
Definition: list.cpp:1139
Area * findFromName(const AreaName &name)
Find an area from its name.
Definition: list.cpp:1297
std::vector< Area * > byIndex
All areas by their index.
Definition: area.h:666
void removeWindTimeseries()
Remove all wind timeseries.
Definition: list.cpp:1717
void removeHydroTimeseries()
Remove all hydro timeseries.
Definition: list.cpp:1707
~AreaList()
Destructor.
Definition: list.cpp:389
Area::Map::iterator iterator
An iterator.
Definition: area.h:368
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:486
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:1670
Definition for a single area.
Definition: area.h:51
bool isVisibleOnLayer(const size_t &layerID) const
check visibility on layer
Definition: area.h:96
uint filterYearByYear
Print results for the area in the year-by-year mode.
Definition: area.h:297
AreaLink::Map links
All connections with this area.
Definition: area.h:275
double spreadUnsuppliedEnergyCost
Spread for the unsupplied energy cost.
Definition: area.h:287
uint filterSynthesis
Print results for the area in the simulation synthesis.
Definition: area.h:295
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:212
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:216
std::unique_ptr< AreaUI > ui
Information for the UI.
Definition: area.h:303
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:1445
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:236
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:62
void resizeAllTimeseriesNumbers(uint nbYears)
Resize all matrices dedicated to the sampled timeseries numbers.
Definition: area.cpp:236
~Area()
Destructor.
Definition: area.cpp:70
std::vector< AreaScratchpad > scratchpad
Scratchpad used temporary calculations (solver only)
Definition: area.h:311
void clearAllLinks()
Destroy all links.
Definition: area.cpp:81
AdequacyPatch::AdequacyPatchMode adequacyPatchMode
Use adequacy patch for this area.
Definition: area.h:218
bool invalidateJIT
Invalidate (JIT)
Definition: area.h:322
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:257
uint nodalOptimization
Nodal optimization (see AreaNodalOptimization)
Definition: area.h:281
double spreadSpilledEnergyCost
Spread for the spilled energy cost.
Definition: area.h:289
Matrix reserves
Reserves.
Definition: area.h:229
AreaName id
Name of the area in lowercase format.
Definition: area.h:214
Definition: BindingConstraintsRepository.h:36
Definition: container.h:34
General data for a study.
Definition: parameters.h:51
Hydro for a single area.
Definition: container.h:86
Definition: container.h:33
Definition: container.h:31
Definition: container.h:31
Definition: load-options.h:34
A single thermal cluster.
Definition: cluster.h:76
Definition: container.h:31
A n-by-n matrix.
Definition: matrix.h:44