Skip to content

Commit

Permalink
use hours per year
Browse files Browse the repository at this point in the history
  • Loading branch information
payetvin committed Jun 27, 2024
1 parent f44d045 commit 05ce637
Show file tree
Hide file tree
Showing 23 changed files with 80 additions and 81 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ namespace Solver
{
namespace Variable
{
constexpr unsigned int maxHoursInAYear = 8785;

template<int I>
struct PrecisionToPrintfFormat
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ class STSbyGroup: public Variable::IVariable<STSbyGroup<NextT>, NextT, VCardSTSb
{
uint64_t r = (sizeof(IntermediateValues) * nbColumns_ + IntermediateValues::MemoryUsage())
* pNbYearsParallel;
r += sizeof(double) * nbColumns_ * maxHoursInAYear * pNbYearsParallel;
r += sizeof(double) * nbColumns_ * HOURS_PER_YEAR * pNbYearsParallel;
r += AncestorType::memoryUsage();
return r;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ class STstorageCashFlowByCluster: public Variable::IVariable<STstorageCashFlowBy
{
uint64_t r = (sizeof(IntermediateValues) * nbClusters_ + IntermediateValues::MemoryUsage())
* pNbYearsParallel;
r += sizeof(double) * nbClusters_ * maxHoursInAYear * pNbYearsParallel;
r += sizeof(double) * nbClusters_ * HOURS_PER_YEAR * pNbYearsParallel;
r += AncestorType::memoryUsage();
return r;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ class STstorageInjectionByCluster: public Variable::IVariable<STstorageInjection
{
uint64_t r = (sizeof(IntermediateValues) * nbClusters_ + IntermediateValues::MemoryUsage())
* pNbYearsParallel;
r += sizeof(double) * nbClusters_ * maxHoursInAYear * pNbYearsParallel;
r += sizeof(double) * nbClusters_ * HOURS_PER_YEAR * pNbYearsParallel;
r += AncestorType::memoryUsage();
return r;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ class STstorageLevelsByCluster: public Variable::IVariable<STstorageLevelsByClus
{
uint64_t r = (sizeof(IntermediateValues) * nbClusters_ + IntermediateValues::MemoryUsage())
* pNbYearsParallel;
r += sizeof(double) * nbClusters_ * maxHoursInAYear * pNbYearsParallel;
r += sizeof(double) * nbClusters_ * HOURS_PER_YEAR * pNbYearsParallel;
r += AncestorType::memoryUsage();
return r;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ class STstorageWithdrawalByCluster: public Variable::IVariable<STstorageWithdraw
{
uint64_t r = (sizeof(IntermediateValues) * nbClusters_ + IntermediateValues::MemoryUsage())
* pNbYearsParallel;
r += sizeof(double) * nbClusters_ * maxHoursInAYear * pNbYearsParallel;
r += sizeof(double) * nbClusters_ * HOURS_PER_YEAR * pNbYearsParallel;
r += AncestorType::memoryUsage();
return r;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ class CongestionProbability
{
for (uint i = 0; i != VCardType::columnCount; ++i)
{
for (uint h = 0; h != maxHoursInAYear; ++h)
for (uint h = 0; h != HOURS_PER_YEAR; ++h)
{
pValuesForYearLocalReport[numSpace][i].hour[h] = (pValuesForTheCurrentYear[numSpace]
[i]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ class ProductionByDispatchablePlant

for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++)
{
pminOfTheClusterForYear[numSpace] = new double[pSize * maxHoursInAYear];
pminOfTheClusterForYear[numSpace] = new double[pSize * HOURS_PER_YEAR];
}

for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++)
Expand Down Expand Up @@ -242,9 +242,9 @@ class ProductionByDispatchablePlant
{
pValuesForTheCurrentYear[numSpace][i].reset();

for (unsigned int j = 0; j != maxHoursInAYear; ++j)
for (unsigned int j = 0; j != HOURS_PER_YEAR; ++j)
{
pminOfTheClusterForYear[numSpace][i * maxHoursInAYear + j] = 0;
pminOfTheClusterForYear[numSpace][i * HOURS_PER_YEAR + j] = 0;
}
}
// Next variable
Expand All @@ -262,7 +262,7 @@ class ProductionByDispatchablePlant
[state.thermalCluster->areaWideIndex]
.hour[i];
state.thermalClusterPMinOfTheClusterForYear[i] += pminOfTheClusterForYear
[numSpace][(state.thermalCluster->areaWideIndex * maxHoursInAYear) + i];
[numSpace][(state.thermalCluster->areaWideIndex * HOURS_PER_YEAR) + i];
}

// Next variable
Expand Down Expand Up @@ -322,7 +322,7 @@ class ProductionByDispatchablePlant
pValuesForTheCurrentYear[numSpace][cluster->areaWideIndex].hour[state.hourInTheYear]
+= thermal[area->index].thermalClustersProductions[cluster->areaWideIndex];

pminOfTheClusterForYear[numSpace][(cluster->areaWideIndex * maxHoursInAYear)
pminOfTheClusterForYear[numSpace][(cluster->areaWideIndex * HOURS_PER_YEAR)
+ state.hourInTheYear]
= thermal[area->index].PMinOfClusters[cluster->areaWideIndex];
}
Expand All @@ -348,7 +348,7 @@ class ProductionByDispatchablePlant
{
uint64_t r = (sizeof(IntermediateValues) * pSize + IntermediateValues::MemoryUsage())
* pNbYearsParallel;
r += sizeof(double) * pSize * maxHoursInAYear * pNbYearsParallel;
r += sizeof(double) * pSize * HOURS_PER_YEAR * pNbYearsParallel;
r += AncestorType::memoryUsage();
return r;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ class ProductionByRenewablePlant: public Variable::IVariable<ProductionByRenewab
{
uint64_t r = (sizeof(IntermediateValues) * pSize + IntermediateValues::MemoryUsage())
* pNbYearsParallel;
r += sizeof(double) * pSize * maxHoursInAYear * pNbYearsParallel;
r += sizeof(double) * pSize * HOURS_PER_YEAR * pNbYearsParallel;
r += AncestorType::memoryUsage();
return r;
}
Expand Down
30 changes: 15 additions & 15 deletions src/solver/variable/include/antares/solver/variable/info.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ struct VariableAccessor
for (uint i = 0; i != ColumnCountT; ++i)
{
Antares::Memory::Stored<double>::ReturnType array = intermediateValues[i].hour;
for (uint y = 0; y != maxHoursInAYear; ++y)
for (uint y = 0; y != HOURS_PER_YEAR; ++y)
{
array[y] *= v;
}
Expand All @@ -88,7 +88,7 @@ struct VariableAccessor
for (uint i = 0; i != ColumnCountT; ++i)
{
Antares::Memory::Stored<double>::ReturnType array = intermediateValues[i].hour;
for (uint y = 0; y != maxHoursInAYear; ++y)
for (uint y = 0; y != HOURS_PER_YEAR; ++y)
{
array[y] = std::abs(array[y]) > 0. ? 1. : 0.;
}
Expand All @@ -101,7 +101,7 @@ struct VariableAccessor
for (uint i = 0; i != ColumnCountT; ++i)
{
Antares::Memory::Stored<double>::ReturnType array = intermediateValues[i].hour;
for (uint y = 0; y != maxHoursInAYear; ++y)
for (uint y = 0; y != HOURS_PER_YEAR; ++y)
{
array[y] = std::abs(array[y]) > 0. ? 100. : 0.;
}
Expand Down Expand Up @@ -247,7 +247,7 @@ struct VariableAccessor
= var.retrieveRawHourlyValuesForCurrentYear(i, numSpace);

assert(src != NULL);
for (uint h = 0; h != maxHoursInAYear; ++h)
for (uint h = 0; h != HOURS_PER_YEAR; ++h)
{
out[i].hour[h] += src[h];
}
Expand All @@ -263,7 +263,7 @@ struct VariableAccessor
= var.retrieveRawHourlyValuesForCurrentYear(i, numSpace);

assert(src != NULL);
for (uint h = 0; h != maxHoursInAYear; ++h)
for (uint h = 0; h != HOURS_PER_YEAR; ++h)
{
if (out[i].hour[h] < src[h])
{
Expand All @@ -289,7 +289,7 @@ struct VariableAccessor<ResultsT, Category::dynamicColumns>
for (typename Type::const_iterator i = intermediateValues.begin(); i != end; ++i)
{
array = (*i).hour;
for (uint y = 0; y != maxHoursInAYear; ++y)
for (uint y = 0; y != HOURS_PER_YEAR; ++y)
{
array[y] *= v;
}
Expand All @@ -304,7 +304,7 @@ struct VariableAccessor<ResultsT, Category::dynamicColumns>
for (typename Type::const_iterator i = intermediateValues.begin(); i != end; ++i)
{
array = (*i).hour;
for (uint y = 0; y != maxHoursInAYear; ++y)
for (uint y = 0; y != HOURS_PER_YEAR; ++y)
{
array[y] = std::abs(array[y]) > 0. ? 1. : 0.;
}
Expand All @@ -319,7 +319,7 @@ struct VariableAccessor<ResultsT, Category::dynamicColumns>
for (typename Type::const_iterator i = intermediateValues.begin(); i != end; ++i)
{
array = (*i).hour;
for (uint y = 0; y != maxHoursInAYear; ++y)
for (uint y = 0; y != HOURS_PER_YEAR; ++y)
{
array[y] = std::abs(array[y]) > 0. ? 100. : 0.;
}
Expand Down Expand Up @@ -516,7 +516,7 @@ struct VariableAccessor<ResultsT, Category::dynamicColumns>
= var.retrieveRawHourlyValuesForCurrentYear(i, numSpace);

assert(src != NULL);
for (uint h = 0; h != maxHoursInAYear; ++h)
for (uint h = 0; h != HOURS_PER_YEAR; ++h)
{
out[i].hour[h] += src[h];
}
Expand All @@ -532,7 +532,7 @@ struct VariableAccessor<ResultsT, Category::dynamicColumns>
= var.retrieveRawHourlyValuesForCurrentYear(i, numSpace);

assert(src != NULL);
for (uint h = 0; h != maxHoursInAYear; ++h)
for (uint h = 0; h != HOURS_PER_YEAR; ++h)
{
if (out[i].hour[h] < src[h])
{
Expand All @@ -553,7 +553,7 @@ struct VariableAccessor<ResultsT, Category::singleColumn /* The default */>
static void MultiplyHourlyResultsBy(U& intermediateValues, const double v)
{
assert(!std::isnan(v));
for (uint y = 0; y != maxHoursInAYear; ++y)
for (uint y = 0; y != HOURS_PER_YEAR; ++y)
{
intermediateValues.hour[y] *= v;
}
Expand All @@ -562,7 +562,7 @@ struct VariableAccessor<ResultsT, Category::singleColumn /* The default */>
template<class U>
static void SetTo1IfPositive(U& intermediateValues)
{
for (uint y = 0; y != maxHoursInAYear; ++y)
for (uint y = 0; y != HOURS_PER_YEAR; ++y)
{
intermediateValues.hour[y] = std::abs(intermediateValues.hour[y]) > 0. ? 1. : 0.;
}
Expand All @@ -571,7 +571,7 @@ struct VariableAccessor<ResultsT, Category::singleColumn /* The default */>
template<class U>
static void Or(U& intermediateValues)
{
for (uint y = 0; y != maxHoursInAYear; ++y)
for (uint y = 0; y != HOURS_PER_YEAR; ++y)
{
intermediateValues.hour[y] = std::abs(intermediateValues.hour[y]) > 0. ? 100. : 0.;
}
Expand Down Expand Up @@ -683,7 +683,7 @@ struct VariableAccessor<ResultsT, Category::singleColumn /* The default */>
= var.retrieveRawHourlyValuesForCurrentYear(-1, numSpace);

assert(src != NULL);
for (uint h = 0; h != maxHoursInAYear; ++h)
for (uint h = 0; h != HOURS_PER_YEAR; ++h)
{
out.hour[h] += src[h];
}
Expand All @@ -696,7 +696,7 @@ struct VariableAccessor<ResultsT, Category::singleColumn /* The default */>
= var.retrieveRawHourlyValuesForCurrentYear(-1, numSpace);

assert(src != NULL);
for (uint h = 0; h != maxHoursInAYear; ++h)
for (uint h = 0; h != HOURS_PER_YEAR; ++h)
{
if (out.hour[h] < src[h])
{
Expand Down
20 changes: 10 additions & 10 deletions src/solver/variable/include/antares/solver/variable/state.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,14 @@ class State

void yearEndBuildThermalClusterCalculateStartupCosts(
const uint& maxDurationON,
const std::array<uint, Variable::maxHoursInAYear>& ON_min,
const std::array<uint, Variable::maxHoursInAYear>& ON_opt,
const std::array<uint, HOURS_PER_YEAR>& ON_min,
const std::array<uint, HOURS_PER_YEAR>& ON_opt,
const Data::ThermalCluster* currentCluster);

std::array<uint, Variable::maxHoursInAYear> computeEconomicallyOptimalNbClustersONforEachHour(
std::array<uint, HOURS_PER_YEAR> computeEconomicallyOptimalNbClustersONforEachHour(
const uint& maxDurationON,
const std::array<uint, Variable::maxHoursInAYear>& ON_min,
const std::array<uint, Variable::maxHoursInAYear>& ON_max) const;
const std::array<uint, HOURS_PER_YEAR>& ON_min,
const std::array<uint, HOURS_PER_YEAR>& ON_max) const;

/*!
** \brief Smooth the thermal units run after resolutions
Expand Down Expand Up @@ -182,17 +182,17 @@ class State
VALEURS_DE_NTC_ET_RESISTANCES ntc;

//! Thermal production for the current thermal cluster for the whole year
double thermalClusterProductionForYear[Variable::maxHoursInAYear];
double thermalClusterProductionForYear[HOURS_PER_YEAR];
//! Number of unit dispatched for all clusters for the whole year for ucHeruistic (fast) or
//! ucMILP (accurate)
uint thermalClusterDispatchedUnitsCountForYear[Variable::maxHoursInAYear];
uint thermalClusterDispatchedUnitsCountForYear[HOURS_PER_YEAR];

//! Thermal operating cost for the current thermal cluster for the whole year
double thermalClusterOperatingCostForYear[Variable::maxHoursInAYear];
double thermalClusterOperatingCostForYear[HOURS_PER_YEAR];
//! Thermal NP Cost for the current thermal cluster for the whole year
double thermalClusterNonProportionalCostForYear[Variable::maxHoursInAYear];
double thermalClusterNonProportionalCostForYear[HOURS_PER_YEAR];
//! Minimum power of the cluster for the whole year
double thermalClusterPMinOfTheClusterForYear[Variable::maxHoursInAYear];
double thermalClusterPMinOfTheClusterForYear[HOURS_PER_YEAR];

double renewableClusterProduction;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ struct Average: public NextT
switch (precision)
{
case Category::hourly:
InternalExportValues<maxHoursInAYear, VCardT, Category::hourly>(report,
InternalExportValues<HOURS_PER_YEAR, VCardT, Category::hourly>(report,
Memory::RawPointer(
avgdata.hourly));
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class AverageData

uint64_t dynamicMemoryUsage() const
{
return sizeof(double) * maxHoursInAYear + sizeof(double) * nbYearsCapacity;
return sizeof(double) * HOURS_PER_YEAR + sizeof(double) * nbYearsCapacity;
}

public:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ inline IntermediateValues::~IntermediateValues()

inline void IntermediateValues::reset()
{
Antares::Memory::Zero(maxHoursInAYear, hour);
Antares::Memory::Zero(HOURS_PER_YEAR, hour);
memset(month, 0, sizeof(month));
memset(week, 0, sizeof(week));
memset(day, 0, sizeof(day));
Expand All @@ -53,7 +53,7 @@ inline const IntermediateValues::Type& IntermediateValues::operator[](

inline uint64_t IntermediateValues::MemoryUsage()
{
return +sizeof(Type) * maxHoursInAYear;
return +sizeof(Type) * HOURS_PER_YEAR;
}

template<class VCardT>
Expand All @@ -66,7 +66,7 @@ inline void IntermediateValues::buildAnnualSurveyReport(SurveyResults& report,
switch (precision)
{
case Category::hourly:
internalExportAnnualValues<maxHoursInAYear, VCardT>(report, hour, false);
internalExportAnnualValues<HOURS_PER_YEAR, VCardT>(report, hour, false);
break;
case Category::daily:
internalExportAnnualValues<DAYS_PER_YEAR, VCardT>(report, day, false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class MinMaxData
std::vector<Data> monthly{MONTHS_PER_YEAR};
std::vector<Data> weekly{WEEKS_PER_YEAR};
std::vector<Data> daily{DAYS_PER_YEAR};
std::vector<Data> hourly{maxHoursInAYear};
std::vector<Data> hourly{HOURS_PER_YEAR};

}; // class MinMaxData

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ struct MinMaxBase: public NextT
switch (precision)
{
case Category::hourly:
InternalExportIndices<maxHoursInAYear, VCardT>(report,
InternalExportIndices<HOURS_PER_YEAR, VCardT>(report,
Memory::RawPointer(minmax.hourly.data()),
fileLevel);
break;
Expand All @@ -106,7 +106,7 @@ struct MinMaxBase: public NextT
switch (precision)
{
case Category::hourly:
InternalExportValues<maxHoursInAYear, VCardT>(report,
InternalExportValues<HOURS_PER_YEAR, VCardT>(report,
Memory::RawPointer(minmax.hourly.data()));
break;
case Category::daily:
Expand Down Expand Up @@ -137,7 +137,7 @@ struct MinMaxBase: public NextT

uint64_t memoryUsage() const
{
return sizeof(double) * maxHoursInAYear + NextType::memoryUsage();
return sizeof(double) * HOURS_PER_YEAR + NextType::memoryUsage();
}

template<template<class> class DecoratorT>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ struct Raw: public NextT
switch (precision)
{
case Category::hourly:
InternalExportValues<Category::hourly, maxHoursInAYear, VCardT>(
InternalExportValues<Category::hourly, HOURS_PER_YEAR, VCardT>(
report,
::Antares::Memory::RawPointer(rawdata.hourly));
break;
Expand Down Expand Up @@ -161,7 +161,7 @@ struct Raw: public NextT

uint64_t memoryUsage() const
{
return +sizeof(double) * maxHoursInAYear + NextType::memoryUsage();
return +sizeof(double) * HOURS_PER_YEAR + NextType::memoryUsage();
}

template<template<class, int> class DecoratorT>
Expand Down
Loading

0 comments on commit 05ce637

Please sign in to comment.