-
Notifications
You must be signed in to change notification settings - Fork 25
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
Thermal clusters lists : cleaning #1844
Conversation
This PR handles a part of issue #1487 (simplify and clarify cluster lists) : Co-authored-by: Guillaume PIERRE <[email protected]>
…ass) and consequences
Watermelon AI SummaryAI Summary deactivated by guilpier-code GitHub PRs
Antares_Simulator is an open repo and Watermelon will serve it for free. |
d022bb6
to
7c7b6ea
Compare
…s, we remove that update
thermalTSRefresh | ||
= thermalTSRefresh || cluster.doWeGenerateTS(globalThermalTSgeneration); | ||
}); | ||
for (auto c : area.thermal.list.each_enabled_and_not_mustrun()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some redundancy. In some cases, we want to iterate over a container. In other cases, we want the number of elements.
It would be nicer to have
for (auto c : thermal.list.enabledNotMustRun.each())
{
// ...
}
auto nbClusters = thermal.list.enabledNotMustRun.count();
Also, clear
thermal.list.enabledNotMustRun.clear();
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So what you suggest is several lists, right ?
If so, it's goes in the opposite direction of the current work, which is to have only one list that we can filter.
@@ -136,8 +136,6 @@ class StudyRuntimeInfos | |||
void initializeRangeLimits(const Study& study, StudyRangeLimits& limits); | |||
//! Prepare all thermal clusters in 'must-run' mode | |||
void initializeThermalClustersInMustRunMode(Study& study) const; | |||
void removeDisabledThermalClustersFromSolverComputations(Study& study); | |||
void removeDisabledRenewableClustersFromSolverComputations(Study& study); | |||
void removeDisabledShortTermStorageClustersFromSolverComputations(Study& study); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean ?
@@ -293,7 +293,7 @@ void Create::createActionsForAStandardAreaCopy(Context& ctx, bool copyPosition) | |||
auto* root = new RootNodePlant(pOriginalAreaName); | |||
|
|||
// browsing each thermal cluster | |||
for (auto& c : area->thermal.list) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
About :
for (auto& c : area->thermal.list)
Actually, area->thermal.list.clusters
was traversed here, because of method begin() and end() (now gone) were used behind the scene.
@@ -24,37 +24,21 @@ struct CompareClusterName final | |||
class Cluster | |||
{ | |||
public: | |||
//! Map of renewable clusters | |||
using Map = std::map<ClusterName, Cluster*>; | |||
using Set = std::set<Cluster*, CompareClusterName>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using Set = std::set<Cluster*, CompareClusterName>;
: only moved from the bottom to the top of the class
** \brief Iterate through all clusters (const) | ||
*/ | ||
template<class PredicateT> | ||
void each(const PredicateT& predicate) const |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
void each(const PredicateT& predicate) const
:
each(...) was used to traverse list clusters (clusters enabled and not must-run) and process a task on each element. We don't need it anymore : it was often replaced with a loop over the filtered complete list.
** \param t The cluster to add | ||
** \return True if the cluster has been added, false otherwise | ||
*/ | ||
SharedPtr add(const SharedPtr clusters); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SharedPtr add(const SharedPtr clusters);
:
is replace with :
void addToCompleteList(std::shared_ptr<ClusterT> cluster);
** | ||
** \param id ID of the cluster to find | ||
** \return A pointer to a cluster. nullptr if not found | ||
*/ | ||
ClusterT* find(const Data::ClusterName& id) const; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ClusterT* find(const Data::ClusterName& id) const;
:
Used to be called only in GUI, searches in list clusters.
In GUI, clusters was containing all clusters.
It's been renamed findInAll , and now searches in private list allClusters_
@@ -32,17 +32,15 @@ bool renewableTSNumberData::apply(Study& study) | |||
|
|||
const uint tsGenCountRenewable = get_tsGenCount(study); | |||
|
|||
uint clusterIndex = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For renewable clusters, area.renewable.list
used to contain (at this point of execution) only enabled clusters.
That's why we now loop over area.renewable.list.each_enabled()
@@ -66,25 +64,16 @@ void renewableTSNumberData::saveToINIFile(const Study& /* study */, | |||
if (!pArea) | |||
return; | |||
|
|||
// Foreach year | |||
#ifndef NDEBUG |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#ifndef NDEBUG
..
#endif
was remove, unnecessary / too few benefit
@@ -99,7 +88,7 @@ bool renewableTSNumberData::reset(const Study& study) | |||
// solver or not. | |||
// WARNING: At this point in time, the variable pArea->renewable.clusterCount() | |||
// might not be valid (because not really initialized yet) | |||
const uint clusterCount = pArea->renewable.list.size(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reset() can be called both from GUI and solver. In GUI, the cluster list used contains contains all clusters. Otherwise, only enabled clusters. Setting clusterCount with allClustersCount() ensures that the matrix (of TS number) reset with clusterCount is large enough, as it is a max.
@@ -15,11 +15,11 @@ bool thermalTSNumberData::reset(const Study& study) | |||
// If an area is available, it can only be an overlay for thermal timeseries | |||
// WARNING: The total number of clusters may vary if used from the | |||
// solver or not. | |||
// WARNING: At this point in time, the variable pArea->thermal.clusterCount() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this file, the cluster lists usage used to be and still is particularly tricky.
What I mean :
the general philosophy in the scenario builder is :
- if a function of this file is called from GUI, the clusters list it processes contains all clusters
- if a function of this file is called from solver it contains only enabled clusters (must-run or not)
For example :
- reset() is called from load higher level functions, so it can be called from both solver and GUI. This why we have a ternary operator inside this function. But the code before changes is wrong : when loading, the list pArea->thermal.list.clusters contains all cluster. So size pArea->thermal.list.size() + pArea->thermal.mustrunList.size() is too large. New code is both more clear and correct.
- apply() : this function is only used by the solver. In the old code, it processes list area.thermal.clusters, that contains enabled thermal clusters (so it confirms that the intention is to process enabled clusters only in the scenario builder on the solver side). That's why each_enabled() is called in the new code.
- saveToINIFile(...) : this function is only called from the GUI. In the old code, it processes pArea->thermal.list, which (when using the GUI) contains all clusters. New code is much more clear about that.
src/solver/simulation/solver.hxx
Outdated
@@ -627,7 +627,7 @@ void ISimulation<Impl>::allocateMemoryForRandomNumbers(randomNumbers& randomForP | |||
{ | |||
// logs.info() << " area : " << a << " :"; | |||
auto& area = *(study.areas.byIndex[a]); | |||
size_t nbClusters = area.thermal.list.mapping.size(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Recall that area.thermal.list.mapping used to contain all thermal clusters
Quality Gate passedIssues Measures |
This PR follows the PR #1809 (about cleaning common cluster list and renewable cluster list)
It aims at simplifying thermal cluster lists as much as possible.
Goal :
Having only one list of thermal clusters.
This list would be private
Code would interact with this list through an interface. This interface would contain functions returning std::views that would result in filtering thermal clusters using a certain property of clusters : enabled / disabled, must-run or not, a combination of these.
What's done :
ClusterList<T>::add()
methodmapping
from class ThermalClusterList into a std::vector (namedallClusters_
)area.thermal.clusters
)area.thermal.mustrunList
)area.thermal.list.clusters
)Before starting a review, one should know several things :