23 #include "antares/solver/variable/variable.h"
27 namespace Antares::Solver::Variable::Common
29 template<
int ColumnCountT,
class VCardT>
32 static std::string Caption(
const uint indx)
34 return VCardT::Multiple::Caption(indx);
37 static std::string Unit(
const unsigned int indx)
39 return VCardT::Multiple::Unit(indx);
43 template<
class VCardT>
46 static std::string Caption(
const uint)
51 static std::string Unit(
const uint)
57 template<
class VCardT>
60 static std::string Caption(
const uint)
65 static std::string Unit(
const uint)
71 template<
class VCardT>
74 static std::string Caption(
const uint)
79 static std::string Unit(
const uint)
85 template<
template<
class>
class V>
89 typedef typename V<Container::EndOfList>::VCardType
VCardOrigin;
94 return VCardOrigin::Caption();
100 return VCardOrigin::Unit();
106 return VCardOrigin::Description();
114 typedef typename VCardOrigin::IntermediateValuesType IntermediateValuesType;
115 typedef typename VCardOrigin::IntermediateValuesBaseType IntermediateValuesBaseType;
117 typename VCardOrigin::IntermediateValuesTypeForSpatialAg IntermediateValuesTypeForSpatialAg;
124 static constexpr uint8_t
precision = VCardOrigin::precision;
128 static constexpr uint8_t
decimal = VCardOrigin::decimal;
133 static constexpr uint8_t spatialAggregateMode = Category::spatialAggregateEachYear;
134 static constexpr uint8_t spatialAggregatePostProcessing = 0;
143 static std::string Caption(
const uint indx)
148 static std::string Unit(
const unsigned int indx)
180 template<
int CDataLevel,
int CFile>
197 typename VCardType::VCardOrigin::IntermediateValuesBaseType IntermediateValuesBaseType;
198 pNbYearsParallel = study.maxNbYearsInParallel;
202 pValuesForTheCurrentYear = std::make_unique<IntermediateValuesBaseType[]>(pNbYearsParallel);
203 for (
unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++)
205 VariableAccessorType::InitializeAndReset(pValuesForTheCurrentYear[numSpace], study);
209 NextType::initializeFromStudy(study);
215 NextType::initializeFromArea(study, area);
221 NextType::initializeFromAreaLink(study, link);
224 void simulationBegin()
227 NextType::simulationBegin();
232 NextType::simulationEnd();
235 void yearBegin(uint year)
238 NextType::yearBegin(year);
241 void yearEndBuildPrepareDataForEachThermalCluster(
State& state, uint year)
244 NextType::yearEndBuildPrepareDataForEachThermalCluster(state, year);
247 void yearEndBuildForEachThermalCluster(
State& state, uint year)
250 NextType::yearEndBuildForEachThermalCluster(state, year);
253 void yearEndBuild(
State& state,
unsigned int year,
unsigned int numSpace)
256 NextType::yearEndBuild(state, year, numSpace);
259 void yearEnd(uint year)
262 NextType::yearEnd(year);
265 void weekBegin(
State& state)
268 NextType::weekBegin(state);
271 void weekEnd(
State& state)
274 NextType::weekEnd(state);
277 void hourBegin(uint hourInTheYear)
280 NextType::hourBegin(hourInTheYear);
283 void hourForEachArea(
State& state,
unsigned int numSpace)
286 NextType::hourForEachArea(state, numSpace);
289 template<
class V,
class SetT>
290 void yearEndSpatialAggregates(V& allVars, uint year,
const SetT& set, uint numSpace)
292 if (VCardType::VCardOrigin::spatialAggregateMode & Category::spatialAggregateEachYear)
294 internalSpatialAggregateForCurrentYear(allVars, set, numSpace);
298 NextType::yearEndSpatialAggregates(allVars, year, set, numSpace);
302 void computeSpatialAggregatesSummary(V& allVars,
unsigned int year,
unsigned int numSpace)
304 if (VCardType::VCardOrigin::spatialAggregateMode & Category::spatialAggregateEachYear)
306 internalSpatialAggregateForParallelYears(year, numSpace);
310 NextType::computeSpatialAggregatesSummary(allVars, year, numSpace);
313 template<
class V,
class SetT>
314 void simulationEndSpatialAggregates(V& allVars,
const SetT& set)
316 if (VCardType::VCardOrigin::spatialAggregateMode & Category::spatialAggregateOnce)
318 internalSpatialAggregate(allVars, 0, set);
322 NextType::simulationEndSpatialAggregates(allVars, set);
325 inline void buildDigest(SurveyResults&
results,
int digestLevel,
int dataLevel)
const
332 results.isPrinted = AncestorType::isPrinted;
333 results.isCurrentVarNA = AncestorType::isNonApplicable;
335 VariableAccessorType::template BuildDigest<typename VCardType::VCardOrigin>(
342 NextType::buildDigest(
results, digestLevel, dataLevel);
345 void localBuildAnnualSurveyReport(SurveyResults&
results,
354 results.isPrinted = AncestorType::isPrinted;
355 results.isCurrentVarNA = AncestorType::isNonApplicable;
357 typedef VariableAccessor<
typename VCardType::IntermediateValuesBaseType,
360 VAType::template BuildAnnualSurveyReport<typename VCardType::VCardOrigin>(
362 pValuesForTheCurrentYear[numSpace],
369 template<
class V,
class SetT>
370 void internalSpatialAggregate(V& allVars, uint year,
const SetT& set)
374 VariableAccessorType::Reset(pValuesForTheCurrentYear[0]);
379 auto end = set.end();
380 for (
auto i = set.begin(); i != end; ++i)
384 (pValuesForTheCurrentYear[0], *i , 0);
388 if (VCardType::VCardOrigin::spatialAggregate & Category::spatialAggregateAverage)
390 VariableAccessorType::MultiplyHourlyResultsBy(pValuesForTheCurrentYear[0],
394 if (VCardType::VCardOrigin::spatialAggregate
395 & Category::spatialAggregateSumThen1IfPositive)
397 VariableAccessorType::SetTo1IfPositive(pValuesForTheCurrentYear[0]);
399 if (VCardType::VCardOrigin::spatialAggregate & Category::spatialAggregateOr)
401 VariableAccessorType::Or(pValuesForTheCurrentYear[0]);
406 assert(!set.empty() &&
"The set should not be empty at this point");
410 VariableAccessorType::template ComputeStatistics<VCardOrigin>(pValuesForTheCurrentYear[0]);
411 VariableAccessorType::ComputeSummary(pValuesForTheCurrentYear[0],
416 template<
class V,
class SetT>
417 void internalSpatialAggregateForCurrentYear(V& allVars,
const SetT& set, uint numSpace)
421 VariableAccessorType::Reset(pValuesForTheCurrentYear[numSpace]);
429 auto end = set.end();
430 for (
auto i = set.begin(); i != end; ++i)
452 if (VCardType::VCardOrigin::spatialAggregate & Category::spatialAggregateAverage)
454 VariableAccessorType::MultiplyHourlyResultsBy(pValuesForTheCurrentYear[numSpace],
458 if (VCardType::VCardOrigin::spatialAggregate
459 & Category::spatialAggregateSumThen1IfPositive)
461 VariableAccessorType::SetTo1IfPositive(pValuesForTheCurrentYear[numSpace]);
463 if (VCardType::VCardOrigin::spatialAggregate & Category::spatialAggregateOr)
465 VariableAccessorType::Or(pValuesForTheCurrentYear[numSpace]);
470 assert(!set.empty() &&
"The set should not be empty at this point");
474 VariableAccessorType::template ComputeStatistics<VCardOrigin>(
475 pValuesForTheCurrentYear[numSpace]);
478 void internalSpatialAggregateForParallelYears(
unsigned int year,
unsigned int numSpace)
481 VariableAccessorType::ComputeSummary(pValuesForTheCurrentYear[numSpace],
488 VCardType::IntermediateValuesTypeForSpatialAg pValuesForTheCurrentYear;
490 unsigned int pNbYearsParallel;
495 template<
template<
class>
class Head,
template<
class>
class... Tail>
501 template<
template<
class>
class Last>
Definition of a link between two areas (Interconnection)
Definition: links.h:58
Definition for a single area.
Definition: area.h:51
Definition: spatial-aggregate.h:159
VCardType::ResultsType ResultsType
List of expected results.
Definition: spatial-aggregate.h:170
Variable::IVariable< SpatialAggregate< VarT, NextT >, NextT, VCardType > AncestorType
Ancestor.
Definition: spatial-aggregate.h:167
@ count
How many items have we got.
Definition: spatial-aggregate.h:177
VCardProxy< VarT > VCardType
VCard.
Definition: spatial-aggregate.h:165
NextT NextType
Type of the next static variable.
Definition: spatial-aggregate.h:162
Definition: endoflist.h:37
Interface for any variable.
Definition: variable.h:47
const StoredResultType & results() const
The results.
Definition: variable.hxx:544
StoredResultType pResults
All the results about this variable.
Definition: variable.h:323
void computeSpatialAggregateWith(O &out, uint numSpace)
Compute the spatial cluster with the results of a single variable.
Definition: variable.hxx:383
Definition: cbuilder.h:120
Definition: spatial-aggregate.h:31
Definition: spatial-aggregate.h:497
Definition: spatial-aggregate.h:182
Definition: spatial-aggregate.h:142
Definition: spatial-aggregate.h:87
static constexpr uint8_t spatialAggregate
The Spatial aggregation.
Definition: spatial-aggregate.h:132
static constexpr uint8_t categoryFileLevel
File level (provided by the type of the results)
Definition: spatial-aggregate.h:122
static constexpr uint8_t isPossiblyNonApplicable
Can this variable be non applicable (0 : no, 1 : yes)
Definition: spatial-aggregate.h:139
static constexpr uint8_t decimal
Decimal precision.
Definition: spatial-aggregate.h:128
static constexpr int columnCount
Number of columns used by the variable (One ResultsType per column)
Definition: spatial-aggregate.h:130
static constexpr uint8_t nodeDepthForGUI
Indentation (GUI)
Definition: spatial-aggregate.h:126
static constexpr uint8_t precision
Precision (views)
Definition: spatial-aggregate.h:124
static std::string Caption()
Caption.
Definition: spatial-aggregate.h:92
static constexpr uint8_t hasIntermediateValues
Intermediate values.
Definition: spatial-aggregate.h:137
V< Container::EndOfList >::VCardType VCardOrigin
The real VCard for the variable.
Definition: spatial-aggregate.h:89
static std::string Unit()
Unit.
Definition: spatial-aggregate.h:98
VCardOrigin::VCardForSpatialAggregate VCardForSpatialAggregate
The VCard to look for for calculating spatial aggregates.
Definition: spatial-aggregate.h:112
static constexpr uint8_t categoryDataLevel
Data Level.
Definition: spatial-aggregate.h:120
static std::string Description()
The short description of the variable.
Definition: spatial-aggregate.h:104
VCardOrigin::ResultsType ResultsType
The expecte results.
Definition: spatial-aggregate.h:110