style: use -> instead of value(). for std::optionals - #3809
Conversation
|
This PR is too big. Please break it up into smaller PRs. |
| if (!tryParseYamlField( | ||
| param.second, | ||
| area.allCapacityReservations.value().maxGlobalEnergyActivationRatio.up, | ||
| area.allCapacityReservations->maxGlobalEnergyActivationRatio.up, |
There was a problem hiding this comment.
is allCapacityReservations always defined?
if not
if(area.allCapacityReservations) should be added to dodge the UB that comes with the "->" operator.
if (root["global-parameters"])
{
ret = readReservesAreaParameters(area, root["global-parameters"]) && ret;
}
if (root["reserves"])
{
for (const auto& reserveNode: root["reserves"])
{
ret = readReserveParameters(folderInput, area, reserveNode) && ret;
}
}
validateCapacityReservations(area);
return ret;
it seems that the validations is done after the function is called.
| if (!tryParseYamlField( | ||
| param.second, | ||
| area.allCapacityReservations.value().maxGlobalEnergyActivationRatio.down, | ||
| area.allCapacityReservations->maxGlobalEnergyActivationRatio.down, |
| if (!tryParseYamlField( | ||
| param.second, | ||
| area.allCapacityReservations.value().referenceGlobalActivationDuration.up, | ||
| area.allCapacityReservations->referenceGlobalActivationDuration.up, |
| if (!tryParseYamlField( | ||
| param.second, | ||
| area.allCapacityReservations.value().referenceGlobalActivationDuration.down, | ||
| area.allCapacityReservations->referenceGlobalActivationDuration.down, |
|
|
||
| ReserveID reserveId = transformNameIntoID(reserveName); | ||
| if (area.allCapacityReservations.value().contains(reserveId)) | ||
| if (area.allCapacityReservations->contains(reserveId)) |
| capacityReservation.loadNeedFromFile(filePath); | ||
| area.allCapacityReservations.value().areaCapacityReservations.emplace(capacityReservation.id(), | ||
| capacityReservation); | ||
| area.allCapacityReservations->areaCapacityReservations.emplace(capacityReservation.id(), |
| const std::string& reserveID) | ||
| { | ||
| const auto* reserve = area.allCapacityReservations.value().getReserveByID(reserveID); | ||
| const auto* reserve = area.allCapacityReservations->getReserveByID(reserveID); |
There was a problem hiding this comment.
is allCapacityReservations always defined ?
| if constexpr (std::is_same_v<ClusterT, ShortTermStorage::STStorageCluster>) | ||
| { | ||
| area.allCapacityReservations.value().reserveGroupPartSTS[reserveID].insert( | ||
| area.allCapacityReservations->reserveGroupPartSTS[reserveID].insert( |
There was a problem hiding this comment.
is allCapacityReservations always defined ?
| else if constexpr (std::is_same_v<ClusterT, ThermalCluster>) | ||
| { | ||
| area.allCapacityReservations.value().reserveGroupPartThermal[reserveID].insert( | ||
| area.allCapacityReservations->reserveGroupPartThermal[reserveID].insert( |
There was a problem hiding this comment.
is allCapacityReservations always defined ?
| readProperties(cert, rp); | ||
|
|
||
| const auto* reserve = area.allCapacityReservations.value().getReserveByID(reserveId); | ||
| const auto* reserve = area.allCapacityReservations->getReserveByID(reserveId); |
There was a problem hiding this comment.
is allCapacityReservations always defined ?
|
|
||
| for (const auto& reserveID: | ||
| area->allCapacityReservations.value().areaCapacityReservations | std::views::keys) | ||
| area->allCapacityReservations->areaCapacityReservations | std::views::keys) |
There was a problem hiding this comment.
is allCapacityReservations always defined ?
| unsigned int column = 0; | ||
| for (const auto& reserveID: | ||
| area->allCapacityReservations.value().areaCapacityReservations | std::views::keys) | ||
| area->allCapacityReservations->areaCapacityReservations | std::views::keys) |
There was a problem hiding this comment.
is allCapacityReservations always defined ?
|
|
||
| for (const auto& reserveID: | ||
| area->allCapacityReservations.value().areaCapacityReservations | std::views::keys) | ||
| area->allCapacityReservations->areaCapacityReservations | std::views::keys) |
There was a problem hiding this comment.
is allCapacityReservations always defined ?
| area->allCapacityReservations->areaCapacityReservations | std::views::keys) | ||
| { | ||
| if (reserveParticipationContainer.value().isParticipatingInReserve(reserveID)) | ||
| if (reserveParticipationContainer->isParticipatingInReserve(reserveID)) |
There was a problem hiding this comment.
is reserveParticipationContainer defined ?
|
|
||
| for (const auto& reserveID: | ||
| area->allCapacityReservations.value().areaCapacityReservations | std::views::keys) | ||
| area->allCapacityReservations->areaCapacityReservations | std::views::keys) |
There was a problem hiding this comment.
is allCapacityReservations always defined ?
| unsigned int column = 0; | ||
| for (const auto& reserveID: | ||
| area->allCapacityReservations.value().areaCapacityReservations | std::views::keys) | ||
| area->allCapacityReservations->areaCapacityReservations | std::views::keys) |
There was a problem hiding this comment.
is allCapacityReservations always defined ?
| { | ||
| for (const auto& [_, reserveParticipation]: | ||
| cluster->reserveParticipationContainer.value().getReservesParticipations()) | ||
| cluster->reserveParticipationContainer->getReservesParticipations()) |
There was a problem hiding this comment.
is reserveParticipationContainer always defined ?
| r.counts.reserveParticipations += area.hydro.reserveParticipationsCount(); | ||
| r.counts.capacityReservations += area.allCapacityReservations.value() | ||
| .areaCapacityReservations.size(); | ||
| r.counts.capacityReservations += area.allCapacityReservations->areaCapacityReservations |
There was a problem hiding this comment.
is allCapacityReservations always defined ?
| .reservesIndices.value() | ||
| .HydroEnergyLevelParticipation[reserveParticipation | ||
| .globalIndexClusterParticipation] | ||
| .reservesIndices->HydroEnergyLevelParticipation |
There was a problem hiding this comment.
is reservesIndices always defined ?
| data.CorrespondanceCntNativesCntOptim[pdt] | ||
| .reservesIndices.value() | ||
| .HydroGlobalEnergyLevelParticipationUp[globalClusterIdx] | ||
| .reservesIndices->HydroGlobalEnergyLevelParticipationUp[globalClusterIdx] |
There was a problem hiding this comment.
is reservesIndices always defined ?
| data.CorrespondanceCntNativesCntOptim[pdt] | ||
| .reservesIndices.value() | ||
| .HydroGlobalEnergyLevelParticipationDown[globalClusterIdx] | ||
| .reservesIndices->HydroGlobalEnergyLevelParticipationDown[globalClusterIdx] |
There was a problem hiding this comment.
is reservesIndices always defined ?
| data.CorrespondanceCntNativesCntOptim[pdt] | ||
| .reservesIndices.value() | ||
| .HydroLevelParticipation[type][globalClusterIdx] | ||
| .reservesIndices->HydroLevelParticipation[type][globalClusterIdx] |
There was a problem hiding this comment.
is reservesIndices always defined ?
| data.CorrespondanceCntNativesCntOptim[pdt] | ||
| .reservesIndices.value() | ||
| .HydroReleaseCapacityThresholdsMin[globalClusterIdx] | ||
| .reservesIndices->HydroReleaseCapacityThresholdsMin[globalClusterIdx] |
There was a problem hiding this comment.
is reservesIndices always defined ?
|
|
||
| cnt = CorrespondanceCntNativesCntOptim.reservesIndices.value() | ||
| .HydroGlobalEnergyLevelParticipationDown[globalClusterIdx]; | ||
| cnt = CorrespondanceCntNativesCntOptim.reservesIndices |
There was a problem hiding this comment.
is reservesIndices always defined ?
|
|
||
| cnt = CorrespondanceCntNativesCntOptim.reservesIndices.value() | ||
| .HydroGlobalEnergyLevelParticipationUp[globalClusterIdx]; | ||
| cnt = CorrespondanceCntNativesCntOptim.reservesIndices |
There was a problem hiding this comment.
is reservesIndices always defined ?
| int cnt = CorrespondanceCntNativesCntOptim.reservesIndices.value() | ||
| .HydroMaxReleaseParticipation[reserveParticipation | ||
| .globalIndexClusterParticipation]; | ||
| int cnt = CorrespondanceCntNativesCntOptim.reservesIndices->HydroMaxReleaseParticipation |
There was a problem hiding this comment.
is reservesIndices always defined ?
| cnt = CorrespondanceCntNativesCntOptim.reservesIndices.value() | ||
| .HydroMaxStoreParticipation[reserveParticipation | ||
| .globalIndexClusterParticipation]; | ||
| cnt = CorrespondanceCntNativesCntOptim.reservesIndices->HydroMaxStoreParticipation |
There was a problem hiding this comment.
is reservesIndices always defined ?
| cnt = CorrespondanceCntNativesCntOptim.reservesIndices.value() | ||
| .HydroEnergyLevelParticipation[reserveParticipation | ||
| .globalIndexClusterParticipation]; | ||
| cnt = CorrespondanceCntNativesCntOptim.reservesIndices->HydroEnergyLevelParticipation |
There was a problem hiding this comment.
is reservesIndices always defined ?
| .internalUnsatisfied.assign(capacityReservationCount, 0); | ||
| variablesMapping.reservesIndices.value().internalExcess.assign(capacityReservationCount, | ||
| 0); | ||
| variablesMapping.reservesIndices->runningThermalClusterParticipation |
There was a problem hiding this comment.
is reservesIndices always defined ?
| { | ||
| areaReserves.referenceGlobalActivationDuration[type] | ||
| = area->allCapacityReservations.value().referenceGlobalActivationDuration[type]; | ||
| = area->allCapacityReservations->referenceGlobalActivationDuration[type]; |
There was a problem hiding this comment.
is allCapacityReservations always defined ?
|
|
||
| for (const auto& [reserveID, reserveCapacity]: | ||
| area->allCapacityReservations.value().areaCapacityReservations) | ||
| area->allCapacityReservations->areaCapacityReservations) |
There was a problem hiding this comment.
is allCapacityReservations always defined ?
| int areaReserveIdx = 0; | ||
| for (const auto& [reserveID, _]: | ||
| area->allCapacityReservations.value().areaCapacityReservations) | ||
| area->allCapacityReservations->areaCapacityReservations) |
There was a problem hiding this comment.
is allCapacityReservations always defined ?
| { | ||
| if (cluster.reserveParticipationContainer | ||
| && cluster.reserveParticipationContainer.value().isParticipatingInReserve( | ||
| && cluster.reserveParticipationContainer->isParticipatingInReserve( |
There was a problem hiding this comment.
is allCapacityReservations always defined ?
| if (hasIndexMapping(state.study, state.area)) | ||
| { | ||
| const auto& resData = state.reserveData.value().at(state.area->index); | ||
| const auto& resData = state.reserveData->at(state.area->index); |
There was a problem hiding this comment.
is reserveData always defined ?
| if (hasIndexMapping(state.study, state.area)) | ||
| { | ||
| const auto& resData = state.reserveData.value().at(state.area->index); | ||
| const auto& resData = state.reserveData->at(state.area->index); |
There was a problem hiding this comment.
is reserveData always defined ?
| for (const auto& [reserveName, reserveParticipation]: | ||
| state.reserveData.value() | ||
| .at(state.area->index) | ||
| state.reserveData->at(state.area->index) |
There was a problem hiding this comment.
is reserveData always defined ?
| if (hasIndexMapping(state.study, state.area)) | ||
| { | ||
| const auto& resData = state.reserveData.value().at(state.area->index); | ||
| const auto& resData = state.reserveData->at(state.area->index); |
There was a problem hiding this comment.
is reserveData always defined ?
| int column = 0; | ||
| for (const auto& reserveID: | ||
| area->allCapacityReservations.value().areaCapacityReservations | std::views::keys) | ||
| area->allCapacityReservations->areaCapacityReservations | std::views::keys) |
There was a problem hiding this comment.
is allCapacityReservations always defined ?
| pValuesForTheCurrentYear[numSpace][column].hour[state.hourInTheYear] | ||
| += state.reserveData.value() | ||
| .at(area->index) | ||
| += state.reserveData->at(area->index) |
There was a problem hiding this comment.
is reserveData always defined ?
| int column = 0; | ||
| for (const auto& reserveID: | ||
| results.data.area->allCapacityReservations.value().areaCapacityReservations | ||
| results.data.area->allCapacityReservations->areaCapacityReservations |
There was a problem hiding this comment.
is allCapacityReservations always defined ?
| pValuesForTheCurrentYear[numSpace][column].hour[state.hourInTheYear] | ||
| += state.reserveData.value() | ||
| .at(area->index) | ||
| += state.reserveData->at(area->index) |
There was a problem hiding this comment.
is reserveData always defined ?
|
|
||
| pSize = study->parameters.include.reserves | ||
| ? area->allCapacityReservations.value().areaCapacityReservations.size() | ||
| ? area->allCapacityReservations->areaCapacityReservations.size() |
There was a problem hiding this comment.
is allCapacityReservations always defined ?
| int column = 0; | ||
| for (const auto& reserveID: | ||
| results.data.area->allCapacityReservations.value().areaCapacityReservations | ||
| results.data.area->allCapacityReservations->areaCapacityReservations |
There was a problem hiding this comment.
is allCapacityReservations always defined ?
|
|
||
| pSize = study->parameters.include.reserves | ||
| ? area->allCapacityReservations.value().areaCapacityReservations.size() * 2 | ||
| ? area->allCapacityReservations->areaCapacityReservations.size() * 2 |
There was a problem hiding this comment.
is allCapacityReservations always defined ?
| { | ||
| auto [unsuppliedOrSpilled, reserveID] = results.data.area->allCapacityReservations.value() | ||
| .reserveParticipationUnsuppliedSpilledAt(i); | ||
| auto [unsuppliedOrSpilled, reserveID] = results.data.area->allCapacityReservations |
There was a problem hiding this comment.
is allCapacityReservations always defined ?
| { | ||
| const auto& reserveID = results.data.area->allCapacityReservations.value() | ||
| .getReserveAtIndex(i); | ||
| const auto& reserveID = results.data.area->allCapacityReservations->getReserveAtIndex(i); |
There was a problem hiding this comment.
is allCapacityReservations always defined ?
| && study.parameters.include.reserves && STStorageCluster->reserveParticipationContainer) | ||
| { | ||
| auto& resData = reserveData.value().at(area->index); | ||
| auto& resData = reserveData->at(area->index); |
There was a problem hiding this comment.
is reserveData always defined ?
| && study.parameters.include.reserves && Hydro.reserveParticipationContainer) | ||
| { | ||
| auto& resData = reserveData.value().at(area->index); | ||
| auto& resData = reserveData->at(area->index); |
There was a problem hiding this comment.
is reserveData always defined ?
| && study.parameters.include.reserves && thermalCluster->reserveParticipationContainer) | ||
| { | ||
| auto& resData = reserveData.value().at(area->index); | ||
| auto& resData = reserveData->at(area->index); |
There was a problem hiding this comment.
is reserveData always defined ?
| uint endHourForCurrentYear = startHourForCurrentYear | ||
| + study.runtime.rangeLimits.hour[Data::rangeCount]; | ||
| auto& resData = reserveData.value().at(area->index); | ||
| auto& resData = reserveData->at(area->index); |
There was a problem hiding this comment.
is reserveData always defined ?
YoshuaLisasi
left a comment
There was a problem hiding this comment.
I wonder if the optinals is always defined and not nullopt
# Conflicts: # src/solver/variable/include/antares/solver/variable/economy/reserves/reserveParticipationByHydro.h # src/solver/variable/include/antares/solver/variable/economy/reserves/reserveParticipationBySTStorage.h
|


std::optionalhas an->operator which is more compact than.value().Example
See
std::optional<T>::value,std::optional<T>::operator->