Skip to content

Commit

Permalink
Merge branch 'develop' into fix/overflow
Browse files Browse the repository at this point in the history
  • Loading branch information
payetvin authored Jan 21, 2025
2 parents 83e191b + a5ea8f6 commit d0015e7
Show file tree
Hide file tree
Showing 16 changed files with 75 additions and 93 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,22 +50,6 @@ enum AdequacyPatchMode
physicalAreaInsideAdqPatch = 2
}; // enum AdequacyPatchMode

/*!
** \brief Setting Link Capacity (NTC) for Adequacy patch first step
*/
enum class NtcSetToZeroStatus_AdqPatchStep1
{
//! Leave NTC local values
leaveLocalValues = 0,
//! Set NTC to zero
setToZero,
//! set only origine->extremity NTC to zero
setOriginExtremityToZero,
//! set only extremity->origine NTC to zero
setExtremityOriginToZero

}; // enum NTC

/*!
** \brief Types of Price Taking Order (PTO) for Adequacy Patch
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,8 @@ class Cluster
double nominalCapacity = 0.;

//! The index of the cluster from the area's point of view
//! \warning this variable is only valid when used by the solver
// (initialized in the same time that the runtime data)
uint areaWideIndex = (uint)-1;
unsigned int areaWideIndex = (uint)-1;
unsigned int enabledIndex = (uint)-1;

//! tsNumbers must be constructed before series
TimeSeriesNumbers tsNumbers;
Expand Down
6 changes: 2 additions & 4 deletions src/libs/antares/study/parts/common/cluster_list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,15 +153,13 @@ void ClusterList<ClusterT>::rebuildIndexes()
unsigned int index = 0;
for (auto& c: allClusters_)
{
c->areaWideIndex = index;
index++;
c->areaWideIndex = index++;
}

index = 0;
for (auto& c: each_enabled())
{
c->areaWideIndex = index;
index++;
c->enabledIndex = index++;
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/solver/simulation/common-eco-adq.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,8 @@ void PrepareRandomNumbers(Data::Study& study,
//-----------------------------
for (auto& cluster: area.thermal.list.each_enabled())
{
// we use the areaWideIndex because the thermal noises are randomly calculated
// for every cluster to avoid different results if a cluster is deactivated
uint clusterIndex = cluster->areaWideIndex;
double& rnd = randomForYear.pThermalNoisesByArea[indexArea][clusterIndex];
double randomClusterProdCost(0.);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ class OverallCost: public Variable::IVariable<OverallCost<NextT>, NextT, VCardOv
for (auto& cluster: area->thermal.list.each_enabled())
{
pValuesForTheCurrentYear[numSpace][state.hourInTheYear]
+= thermal[area->index].thermalClustersOperatingCost[cluster->areaWideIndex];
+= thermal[area->index].thermalClustersOperatingCost[cluster->enabledIndex];
}

// Next variable
Expand Down
4 changes: 2 additions & 2 deletions src/solver/variable/include/antares/solver/variable/area.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ void Areas<NextT>::hourForEachArea(State& state, uint numSpace)
for (const auto& cluster: area.thermal.list.each_enabled())
{
// Intiializing the state for the current thermal cluster
state.initFromThermalClusterIndex(cluster->areaWideIndex);
state.initFromThermalClusterIndex(cluster->enabledIndex);
}

// Variables
Expand Down Expand Up @@ -456,7 +456,7 @@ void Areas<NextT>::yearEndBuild(State& state, uint year, uint numSpace)
variablesForArea.yearEndBuildPrepareDataForEachThermalCluster(state, year, numSpace);

// Building the end of year
state.yearEndBuildFromThermalClusterIndex(cluster->areaWideIndex);
state.yearEndBuildFromThermalClusterIndex(cluster->enabledIndex);

// Variables
variablesForArea.yearEndBuildForEachThermalCluster(state, year, numSpace);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ class DispatchableGeneration
for (auto& cluster: area->thermal.list.each_enabled())
{
pValuesForTheCurrentYear[numSpace][cluster->groupID][state.hourInTheYear]
+= thermal[area->index].thermalClustersProductions[cluster->areaWideIndex];
+= thermal[area->index].thermalClustersProductions[cluster->enabledIndex];
}

// Next variable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ class NbOfDispatchedUnitsByPlant: public Variable::IVariable<NbOfDispatchedUnits
for (unsigned int i = 0; i <= state.study.runtime.rangeLimits.hour[Data::rangeEnd]; ++i)
{
state.thermalClusterDispatchedUnitsCountForYear[i] += static_cast<uint>(
pValuesForTheCurrentYear[numSpace][state.thermalCluster->areaWideIndex].hour[i]);
pValuesForTheCurrentYear[numSpace][state.thermalCluster->enabledIndex].hour[i]);
}

// Next variable
Expand All @@ -251,7 +251,7 @@ class NbOfDispatchedUnitsByPlant: public Variable::IVariable<NbOfDispatchedUnits
i <= state.study.runtime.rangeLimits.hour[Data::rangeEnd];
++i)
{
pValuesForTheCurrentYear[numSpace][state.thermalCluster->areaWideIndex].hour[i]
pValuesForTheCurrentYear[numSpace][state.thermalCluster->enabledIndex].hour[i]
= state.thermalClusterDispatchedUnitsCountForYear[i];
}

Expand Down Expand Up @@ -308,8 +308,8 @@ class NbOfDispatchedUnitsByPlant: public Variable::IVariable<NbOfDispatchedUnits
auto& thermal = state.thermal;
for (auto& cluster: area->thermal.list.each_enabled())
{
pValuesForTheCurrentYear[numSpace][cluster->areaWideIndex].hour[state.hourInTheYear]
= thermal[area->index].numberOfUnitsONbyCluster[cluster->areaWideIndex];
pValuesForTheCurrentYear[numSpace][cluster->enabledIndex].hour[state.hourInTheYear]
= thermal[area->index].numberOfUnitsONbyCluster[cluster->enabledIndex];
}

// Next variable
Expand Down Expand Up @@ -342,7 +342,7 @@ class NbOfDispatchedUnitsByPlant: public Variable::IVariable<NbOfDispatchedUnits
// Write the data for the current year
results.variableCaption = cluster->name(); // VCardType::Caption();
results.variableUnit = VCardType::Unit();
pValuesForTheCurrentYear[numSpace][cluster->areaWideIndex]
pValuesForTheCurrentYear[numSpace][cluster->enabledIndex]
.template buildAnnualSurveyReport<VCardType>(results, fileLevel, precision);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ class NonProportionalCostByDispatchablePlant
i <= state.study.runtime.rangeLimits.hour[Data::rangeEnd];
++i)
{
pValuesForTheCurrentYear[numSpace][state.thermalCluster->areaWideIndex].hour[i]
pValuesForTheCurrentYear[numSpace][state.thermalCluster->enabledIndex].hour[i]
= state.thermalClusterNonProportionalCostForYear[i];
}

Expand Down Expand Up @@ -323,7 +323,7 @@ class NonProportionalCostByDispatchablePlant
// Write the data for the current year
results.variableCaption = cluster->name(); // VCardType::Caption();
results.variableUnit = VCardType::Unit();
pValuesForTheCurrentYear[numSpace][cluster->areaWideIndex]
pValuesForTheCurrentYear[numSpace][cluster->enabledIndex]
.template buildAnnualSurveyReport<VCardType>(results, fileLevel, precision);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,10 +259,10 @@ class ProductionByDispatchablePlant
{
state.thermalClusterProductionForYear[i] += pValuesForTheCurrentYear
[numSpace]
[state.thermalCluster->areaWideIndex]
[state.thermalCluster->enabledIndex]
.hour[i];
state.thermalClusterPMinOfTheClusterForYear[i] += pminOfTheClusterForYear
[numSpace][(state.thermalCluster->areaWideIndex * HOURS_PER_YEAR) + i];
[numSpace][(state.thermalCluster->enabledIndex * HOURS_PER_YEAR) + i];
}

// Next variable
Expand Down Expand Up @@ -319,12 +319,12 @@ class ProductionByDispatchablePlant
for (auto& cluster: area->thermal.list.each_enabled())
{
// Production for this hour
pValuesForTheCurrentYear[numSpace][cluster->areaWideIndex].hour[state.hourInTheYear]
+= thermal[area->index].thermalClustersProductions[cluster->areaWideIndex];
pValuesForTheCurrentYear[numSpace][cluster->enabledIndex].hour[state.hourInTheYear]
+= thermal[area->index].thermalClustersProductions[cluster->enabledIndex];

pminOfTheClusterForYear[numSpace]
[(cluster->areaWideIndex * HOURS_PER_YEAR) + state.hourInTheYear]
= thermal[area->index].PMinOfClusters[cluster->areaWideIndex];
[(cluster->enabledIndex * HOURS_PER_YEAR) + state.hourInTheYear]
= thermal[area->index].PMinOfClusters[cluster->enabledIndex];
}

// Next variable
Expand Down Expand Up @@ -363,7 +363,7 @@ class ProductionByDispatchablePlant
// Write the data for the current year
results.variableCaption = cluster->name(); // VCardType::Caption();
results.variableUnit = VCardType::Unit();
pValuesForTheCurrentYear[numSpace][cluster->areaWideIndex]
pValuesForTheCurrentYear[numSpace][cluster->enabledIndex]
.template buildAnnualSurveyReport<VCardType>(results, fileLevel, precision);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ class ProductionByRenewablePlant: public Variable::IVariable<ProductionByRenewab
state.year,
state.hourInTheYear);

pValuesForTheCurrentYear[numSpace][renewableCluster->areaWideIndex]
pValuesForTheCurrentYear[numSpace][renewableCluster->enabledIndex]
.hour[state.hourInTheYear]
+= renewableClusterProduction;
}
Expand Down Expand Up @@ -326,7 +326,7 @@ class ProductionByRenewablePlant: public Variable::IVariable<ProductionByRenewab
// Write the data for the current year
results.variableCaption = cluster->name();
results.variableUnit = VCardType::Unit();
pValuesForTheCurrentYear[numSpace][cluster->areaWideIndex]
pValuesForTheCurrentYear[numSpace][cluster->enabledIndex]
.template buildAnnualSurveyReport<VCardType>(results, fileLevel, precision);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,11 +281,11 @@ class ProfitByPlant: public Variable::IVariable<ProfitByPlant<NextT>, NextT, VCa
for (auto& cluster: area->thermal.list.each_enabled())
{
double hourlyClusterProduction = thermal[area->index]
.thermalClustersProductions[cluster->areaWideIndex];
.thermalClustersProductions[cluster->enabledIndex];
uint tsIndex = cluster->series.timeseriesNumbers[state.year];

// Thermal cluster profit
pValuesForTheCurrentYear[numSpace][cluster->areaWideIndex].hour[hourInTheYear]
pValuesForTheCurrentYear[numSpace][cluster->enabledIndex].hour[hourInTheYear]
= std::max((hourlyClusterProduction - cluster->PthetaInf[hourInTheYear]), 0.)
* (-areaMarginalCosts[hourInTheWeek]
- cluster->getCostProvider().getMarginalCost(tsIndex, hourInTheYear));
Expand Down Expand Up @@ -321,7 +321,7 @@ class ProfitByPlant: public Variable::IVariable<ProfitByPlant<NextT>, NextT, VCa
// Write the data for the current year
results.variableCaption = cluster->name(); // VCardType::Caption();
results.variableUnit = VCardType::Unit();
pValuesForTheCurrentYear[numSpace][cluster->areaWideIndex]
pValuesForTheCurrentYear[numSpace][cluster->enabledIndex]
.template buildAnnualSurveyReport<VCardType>(results, fileLevel, precision);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,7 @@ class ThermalAirPollutantEmissions: public Variable::IVariable<ThermalAirPolluta
{
pValuesForTheCurrentYear[numSpace][pollutant][state.hourInTheYear]
+= cluster->emissions.factors[pollutant]
* thermal[state.area->index]
.thermalClustersProductions[cluster->areaWideIndex];
* thermal[state.area->index].thermalClustersProductions[cluster->enabledIndex];
}
}

Expand Down
16 changes: 8 additions & 8 deletions src/solver/variable/include/antares/solver/variable/state.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,30 +85,30 @@ class State
** We assume here that the variables related to an area
** are properly initialized.
**
** \param areaWideIndex Index of the thermal cluster for the current area
** \param clusterEnabledIndex Index of the thermal cluster for the current area
*/
void initFromThermalClusterIndex(const unsigned int areaWideIndex);
void initFromThermalClusterIndex(const unsigned int clusterEnabledIndex);

/*!
** \brief End the year by smoothing the thermal units run
** and computing costs.
** We assume here that the variables related to an area
** are properly initialized.
**
** \param areaWideIndex Index of the thermal cluster for the current area
** \param clusterEnabledIndex Index of the thermal cluster for the current area
*/

void yearEndBuildFromThermalClusterIndex(const unsigned int areaWideIndex);
void yearEndBuildFromThermalClusterIndex(const unsigned int clusterEnabledIndex);

private:
/*!
** \brief Initialize some variable according a thermal cluster index
**
** Called in initFromAreaIndex to split code
**
** \param areaWideIndex Index of the thermal cluster for the current area
** \param clusterEnabledIndex Index of the thermal cluster for the current area
*/
void initFromThermalClusterIndexProduction(const unsigned int areaWideIndex);
void initFromThermalClusterIndexProduction(const unsigned int clusterEnabledIndex);

void yearEndBuildThermalClusterCalculateStartupCosts(
const uint& maxDurationON,
Expand All @@ -125,9 +125,9 @@ class State
** \brief Smooth the thermal units run after resolutions
** using heuristics
**
** \param areaWideIndex Index of the thermal cluster for the current area
** \param clusterEnabledIndex Index of the thermal cluster for the current area
*/
void yearEndSmoothDispatchedUnitsCount(const unsigned int areaWideIndex, uint numSpace);
void yearEndSmoothDispatchedUnitsCount(const unsigned int clusterEnabledIndex, uint numSpace);

public:
/*!
Expand Down
Loading

0 comments on commit d0015e7

Please sign in to comment.