Skip to content

Commit

Permalink
Add function floorDiv
Browse files Browse the repository at this point in the history
  • Loading branch information
payetvin committed Jan 9, 2025
1 parent d422b6d commit 93b4041
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
5 changes: 5 additions & 0 deletions src/libs/antares/utils/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,5 +167,10 @@ double ceilDiv(double numerator, double denominator)
return std::ceil(std::round(numerator / denominator * largeValue) / largeValue);
}

double floorDiv(double numerator, double denominator)
{
return std::floor(std::round(numerator / denominator * largeValue) / largeValue);
}

} // namespace Utils
} // namespace Antares
11 changes: 4 additions & 7 deletions src/solver/variable/state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,10 +316,8 @@ void State::yearEndBuildFromThermalClusterIndex(const uint clusterAreaWideIndex)
static_cast<uint>(
std::ceil(thermalClusterAvailableProduction
/ currentCluster->nominalCapacityWithSpinning))),
static_cast<uint>(
std::ceil(std::round(thermalClusterProduction
/ currentCluster->nominalCapacityWithSpinning * 1000000)
/ 1000000)));
static_cast<uint>(Utils::ceilDiv(thermalClusterProduction,
currentCluster->nominalCapacityWithSpinning)));
}
else
{
Expand Down Expand Up @@ -350,9 +348,8 @@ void State::yearEndBuildFromThermalClusterIndex(const uint clusterAreaWideIndex)

if (currentCluster->minStablePower > 0.)
{
maxUnitNeeded = static_cast<uint>(std::floor(
std::round(thermalClusterProduction / currentCluster->minStablePower * 1000000)
/ 1000000));
maxUnitNeeded = static_cast<uint>(
Utils::floorDiv(thermalClusterProduction, currentCluster->minStablePower));
if (ON_max[h] > maxUnitNeeded)
{
ON_max[h] = maxUnitNeeded;
Expand Down

0 comments on commit 93b4041

Please sign in to comment.