Skip to content

Commit

Permalink
Logs warnings instead of crashing when the bimap is empty when in sho…
Browse files Browse the repository at this point in the history
…uldn't (the solver did not find a solution)
  • Loading branch information
sylvmara committed Dec 11, 2024
1 parent 45073bf commit b16f18d
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 27 deletions.
2 changes: 1 addition & 1 deletion src/libs/antares/study/include/antares/study/area/area.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class BiMap
}

// Function to return the size of the bimap
int size()
int size() const
{
return key_to_value.size();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,15 +179,23 @@ class ReserveParticipationByDispatchableOffUnitsPlant
i <= state.study.runtime.rangeLimits.hour[Data::rangeEnd];
++i)
{
for (auto const& [reserveName, reserveParticipation] :
state.reserveParticipationPerThermalClusterForYear[i][state.thermalCluster->name()])
/*if (results.data.area->reserveParticipationThermalClustersIndexMap.size() == 0) //Bimap in empty
{
pValuesForTheCurrentYear
[numSpace][state.area->reserveParticipationThermalClustersIndexMap.get(
std::make_pair(reserveName, state.thermalCluster->name()))]
.hour[i]
= reserveParticipation.offUnitsParticipation;
logs.warning() << "Problem during the solver run, the thermal bimap is empty for area " << results.data.area->name;
break;
}
else
{*/
for (auto const& [reserveName, reserveParticipation] :
state.reserveParticipationPerThermalClusterForYear[i][state.thermalCluster->name()])
{
pValuesForTheCurrentYear
[numSpace][state.area->reserveParticipationThermalClustersIndexMap.get(
std::make_pair(reserveName, state.thermalCluster->name()))]
.hour[i]
= reserveParticipation.offUnitsParticipation;
}
//}
}
}
// Next variable
Expand Down Expand Up @@ -266,12 +274,20 @@ class ReserveParticipationByDispatchableOffUnitsPlant
// Write the data for the current year
for (uint i = 0; i < pSize; ++i)
{
auto [clusterName, reserveName]
= results.data.area->reserveParticipationThermalClustersIndexMap.get(i);
results.variableCaption = clusterName + "_" + reserveName; // VCardType::Caption();
results.variableUnit = VCardType::Unit();
pValuesForTheCurrentYear[numSpace][i].template buildAnnualSurveyReport<VCardType>(
results, fileLevel, precision);
if (results.data.area->reserveParticipationThermalClustersIndexMap.size() == 0) //Bimap is empty
{
logs.warning() << "Problem during the solver run, the thermal bimap is empty for area " << results.data.area->name;
break;
}
else
{
auto [clusterName, reserveName]
= results.data.area->reserveParticipationThermalClustersIndexMap.get(i);
results.variableCaption = clusterName + "_" + reserveName; // VCardType::Caption();
results.variableUnit = VCardType::Unit();
pValuesForTheCurrentYear[numSpace][i].template buildAnnualSurveyReport<VCardType>(
results, fileLevel, precision);
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,12 +266,20 @@ class ReserveParticipationByDispatchableOnUnitsPlant
// Write the data for the current year
for (uint i = 0; i < pSize; ++i)
{
auto [clusterName, reserveName]
= results.data.area->reserveParticipationThermalClustersIndexMap.get(i);
results.variableCaption = clusterName + "_" + reserveName; // VCardType::Caption();
results.variableUnit = VCardType::Unit();
pValuesForTheCurrentYear[numSpace][i].template buildAnnualSurveyReport<VCardType>(
results, fileLevel, precision);
if (results.data.area->reserveParticipationThermalClustersIndexMap.size() == 0) //Bimap is empty
{
logs.warning() << "Problem during the solver run, the thermal bimap is empty for area " << results.data.area->name;
break;
}
else
{
auto [clusterName, reserveName]
= results.data.area->reserveParticipationThermalClustersIndexMap.get(i);
results.variableCaption = clusterName + "_" + reserveName; // VCardType::Caption();
results.variableUnit = VCardType::Unit();
pValuesForTheCurrentYear[numSpace][i].template buildAnnualSurveyReport<VCardType>(
results, fileLevel, precision);
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,13 +258,21 @@ class ReserveParticipationBySTStorage
// Write the data for the current year
for (uint i = 0; i < pSize; ++i)
{
auto [clusterName, reserveName]
= results.data.area->reserveParticipationSTStorageClustersIndexMap.get(i);
// Write the data for the current year
results.variableCaption = clusterName + "_" + reserveName; // VCardType::Caption();
results.variableUnit = VCardType::Unit();
pValuesForTheCurrentYear[numSpace][i].template buildAnnualSurveyReport<VCardType>(
results, fileLevel, precision);
if (results.data.area->reserveParticipationSTStorageClustersIndexMap.size() == 0) //Bimap in empty
{
logs.warning() << "Problem during the solver run, the STS bimap is empty for area " << results.data.area->name;
break;
}
else
{
auto [clusterName, reserveName]
= results.data.area->reserveParticipationSTStorageClustersIndexMap.get(i);
// Write the data for the current year
results.variableCaption = clusterName + "_" + reserveName; // VCardType::Caption();
results.variableUnit = VCardType::Unit();
pValuesForTheCurrentYear[numSpace][i].template buildAnnualSurveyReport<VCardType>(
results, fileLevel, precision);
}
}
}
}
Expand Down

0 comments on commit b16f18d

Please sign in to comment.