Skip to content

Commit

Permalink
add var MONTHS_PER_YEAR
Browse files Browse the repository at this point in the history
  • Loading branch information
payetvin committed Jun 27, 2024
1 parent d65c1d8 commit 2732eac
Show file tree
Hide file tree
Showing 16 changed files with 22 additions and 21 deletions.
1 change: 1 addition & 0 deletions src/libs/antares/include/antares/antares/constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
const unsigned int HOURS_PER_DAY = 24;
const unsigned int DAYS_PER_YEAR = 365;
const unsigned int HOURS_PER_YEAR = 8760;
const unsigned int MONTHS_PER_YEAR = 12;

namespace Antares::Constants
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#ifndef __SOLVER_VARIABLE_CATEGORIES_H__
#define __SOLVER_VARIABLE_CATEGORIES_H__

#include <antares/antares/constants.h>
#include "constants.h"

namespace Antares
Expand Down Expand Up @@ -307,7 +308,7 @@ struct MaxRowCount<monthly>
{
enum
{
value = maxMonths
value = MONTHS_PER_YEAR
};
};
} // namespace Category
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ constexpr unsigned int maxHoursInAYear = 8785;
constexpr unsigned int maxDaysInAYear = 7 * 53 + 1; // 366,
constexpr unsigned int maxWeeksInAYear = 53;
constexpr unsigned int maxHoursInADay = 24;
constexpr unsigned int maxMonths = 12;
constexpr unsigned int maxHoursInAWeek = 24 * 7; // 168

template<int I>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ class CongestionProbability
: 0.;
}

for (uint m = 0; m != maxMonths; ++m)
for (uint m = 0; m != MONTHS_PER_YEAR; ++m)
{
pValuesForYearLocalReport[numSpace][i].month[m] = (pValuesForTheCurrentYear
[numSpace][i]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ struct Average: public NextT
avgdata.weekly);
break;
case Category::monthly:
InternalExportValues<maxMonths, VCardT, Category::monthly>(report, avgdata.monthly);
InternalExportValues<MONTHS_PER_YEAR, VCardT, Category::monthly>(report, avgdata.monthly);
break;
case Category::annual:
InternalExportValues<1, VCardT, Category::annual>(report, avgdata.year);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class AverageData
}

public:
double monthly[maxMonths];
double monthly[MONTHS_PER_YEAR];
double weekly[maxWeeksInAYear];
double daily[maxDaysInAYear];
Antares::Memory::Stored<double>::Type hourly;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ class IntermediateValues final
Antares::Data::StudyRuntimeInfos* pRuntimeInfo;

//! Values for each month
Type month[maxMonths];
Type month[MONTHS_PER_YEAR];
//! Values for each week
Type week[maxWeeksInAYear];
//! Values for each day in the year
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ inline void IntermediateValues::buildAnnualSurveyReport(SurveyResults& report,
internalExportAnnualValues<maxWeeksInAYear, VCardT>(report, week, false);
break;
case Category::monthly:
internalExportAnnualValues<maxMonths, VCardT>(report, month, false);
internalExportAnnualValues<MONTHS_PER_YEAR, VCardT>(report, month, false);
break;
case Category::annual:
internalExportAnnualValues<1, VCardT>(report, &year, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class MinMaxData
void mergeSup(uint year, const IntermediateValues& rhs);

std::vector<Data> annual{1};
std::vector<Data> monthly{maxMonths};
std::vector<Data> monthly{MONTHS_PER_YEAR};
std::vector<Data> weekly{maxWeeksInAYear};
std::vector<Data> daily{maxDaysInAYear};
std::vector<Data> hourly{maxHoursInAYear};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ struct MinMaxBase: public NextT
InternalExportIndices<maxWeeksInAYear, VCardT>(report, minmax.weekly.data(), fileLevel);
break;
case Category::monthly:
InternalExportIndices<maxMonths, VCardT>(report, minmax.monthly.data(), fileLevel);
InternalExportIndices<MONTHS_PER_YEAR, VCardT>(report, minmax.monthly.data(), fileLevel);
break;
case Category::annual:
InternalExportIndices<1, VCardT>(report, minmax.annual.data(), fileLevel);
Expand All @@ -116,7 +116,7 @@ struct MinMaxBase: public NextT
InternalExportValues<maxWeeksInAYear, VCardT>(report, minmax.weekly.data());
break;
case Category::monthly:
InternalExportValues<maxMonths, VCardT>(report, minmax.monthly.data());
InternalExportValues<MONTHS_PER_YEAR, VCardT>(report, minmax.monthly.data());
break;
case Category::annual:
InternalExportValues<1, VCardT>(report, minmax.annual.data());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ struct Raw: public NextT
rawdata.weekly);
break;
case Category::monthly:
InternalExportValues<Category::monthly, maxMonths, VCardT>(report, rawdata.monthly);
InternalExportValues<Category::monthly, MONTHS_PER_YEAR, VCardT>(report, rawdata.monthly);
break;
case Category::annual:
InternalExportValues<Category::annual, 1, VCardT>(report, rawdata.year);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class RawData
void merge(unsigned int year, const IntermediateValues& rhs);

public:
double monthly[maxMonths];
double monthly[MONTHS_PER_YEAR];
double weekly[maxWeeksInAYear];
double daily[maxDaysInAYear];
Antares::Memory::Stored<double>::Type hourly;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ struct StdDeviation: public NextT
void reset()
{
// Reset
(void)::memset(stdDeviationMonthly, 0, sizeof(double) * maxMonths);
(void)::memset(stdDeviationMonthly, 0, sizeof(double) * MONTHS_PER_YEAR);
(void)::memset(stdDeviationWeekly, 0, sizeof(double) * maxWeeksInAYear);
(void)::memset(stdDeviationDaily, 0, sizeof(double) * maxDaysInAYear);
Antares::Memory::Zero(maxHoursInAYear, stdDeviationHourly);
Expand Down Expand Up @@ -119,7 +119,7 @@ struct StdDeviation: public NextT
stdDeviationWeekly[i] += rhs.week[i] * rhs.week[i] * pRatio;
}
// StdDeviation value for each month throughout all years
for (i = 0; i != maxMonths; ++i)
for (i = 0; i != MONTHS_PER_YEAR; ++i)
{
stdDeviationMonthly[i] += rhs.month[i] * rhs.month[i] * pRatio;
}
Expand Down Expand Up @@ -159,7 +159,7 @@ struct StdDeviation: public NextT
stdDeviationWeekly);
break;
case Category::monthly:
InternalExportValues<S, maxMonths, VCardT, Category::monthly>(report,
InternalExportValues<S, MONTHS_PER_YEAR, VCardT, Category::monthly>(report,
results,
stdDeviationMonthly);
break;
Expand Down Expand Up @@ -194,7 +194,7 @@ struct StdDeviation: public NextT
}

public:
double stdDeviationMonthly[maxMonths];
double stdDeviationMonthly[MONTHS_PER_YEAR];
double stdDeviationWeekly[maxWeeksInAYear];
double stdDeviationDaily[maxDaysInAYear];
Antares::Memory::Stored<double>::Type stdDeviationHourly;
Expand Down
4 changes: 2 additions & 2 deletions src/solver/variable/storage/averagedata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ AverageData::~AverageData()
void AverageData::reset()
{
Antares::Memory::Zero(maxHoursInAYear, hourly);
(void)::memset(monthly, 0, sizeof(double) * maxMonths);
(void)::memset(monthly, 0, sizeof(double) * MONTHS_PER_YEAR);
(void)::memset(weekly, 0, sizeof(double) * maxWeeksInAYear);
(void)::memset(daily, 0, sizeof(double) * maxDaysInAYear);
(void)::memset(year, 0, sizeof(double) * nbYearsCapacity);
Expand Down Expand Up @@ -85,7 +85,7 @@ void AverageData::merge(unsigned int y, const IntermediateValues& rhs)
weekly[i] += rhs.week[i] * ratio;
}
// Average value for each month throughout all years
for (i = 0; i != maxMonths; ++i)
for (i = 0; i != MONTHS_PER_YEAR; ++i)
{
monthly[i] += rhs.month[i] * ratio;
}
Expand Down
2 changes: 1 addition & 1 deletion src/solver/variable/storage/intermediate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ IntermediateValues::IntermediateValues():
{
Antares::Memory::Allocate<Type>(hour, maxHoursInAYear);
Antares::Memory::Zero(maxHoursInAYear, hour);
(void)::memset(month, 0, sizeof(Type) * maxMonths);
(void)::memset(month, 0, sizeof(Type) * MONTHS_PER_YEAR);
(void)::memset(week, 0, sizeof(Type) * maxWeeksInAYear);
(void)::memset(day, 0, sizeof(Type) * maxDaysInAYear);
}
Expand Down
4 changes: 2 additions & 2 deletions src/solver/variable/storage/rawdata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ void RawData::reset()
{
// Reset
Antares::Memory::Zero(maxHoursInAYear, hourly);
(void)::memset(monthly, 0, sizeof(double) * maxMonths);
(void)::memset(monthly, 0, sizeof(double) * MONTHS_PER_YEAR);
(void)::memset(weekly, 0, sizeof(double) * maxWeeksInAYear);
(void)::memset(daily, 0, sizeof(double) * maxDaysInAYear);
(void)::memset(year, 0, sizeof(double) * nbYearsCapacity);
Expand All @@ -76,7 +76,7 @@ void RawData::merge(unsigned int y, const IntermediateValues& rhs)
weekly[i] += rhs.week[i];
}
// StdDeviation value for each month throughout all years
for (i = 0; i != maxMonths; ++i)
for (i = 0; i != MONTHS_PER_YEAR; ++i)
{
monthly[i] += rhs.month[i];
}
Expand Down

0 comments on commit 2732eac

Please sign in to comment.