Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix milp bug #2489

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/libs/antares/utils/include/antares/utils/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,12 @@ std::vector<std::pair<std::string, std::string>> splitStringIntoPairs(const std:

namespace Utils
{

bool isZero(double d);
double round(double d, unsigned precision);
double ceilDiv(double numerator, double denominator);
double floorDiv(double numerator, double denominator);

} // namespace Utils
} // namespace Antares

Expand Down
12 changes: 12 additions & 0 deletions src/libs/antares/utils/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,5 +160,17 @@ double round(double d, unsigned precision)
return std::round(d * factor) / factor;
}

#define largeValue 1000000

payetvin marked this conversation as resolved.
Show resolved Hide resolved
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
19 changes: 9 additions & 10 deletions src/solver/variable/state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,25 +316,24 @@ void State::yearEndBuildFromThermalClusterIndex(const uint clusterAreaWideIndex)
static_cast<uint>(
std::ceil(thermalClusterAvailableProduction
/ currentCluster->nominalCapacityWithSpinning))),
static_cast<uint>(std::ceil(thermalClusterProduction
/ currentCluster->nominalCapacityWithSpinning)));
static_cast<uint>(Utils::ceilDiv(thermalClusterProduction,
currentCluster->nominalCapacityWithSpinning)));
}
else
{
ON_min[h] = static_cast<uint>(std::ceil(
thermalClusterProduction / currentCluster->nominalCapacityWithSpinning));
ON_min[h] = static_cast<uint>(
Utils::ceilDiv(thermalClusterProduction,
currentCluster->nominalCapacityWithSpinning));
}
break;
}
case Antares::Data::UnitCommitmentMode::ucMILP:
case Antares::Data::UnitCommitmentMode::ucHeuristicAccurate:
{
ON_min[h] = std::max(
static_cast<uint>(
std::ceil(thermalClusterProduction / currentCluster->nominalCapacityWithSpinning)),
thermalClusterDispatchedUnitsCountForYear[h]); // eq. to thermalClusterON for
// that hour

static_cast<uint>(Utils::ceilDiv(thermalClusterProduction,
currentCluster->nominalCapacityWithSpinning)),
thermalClusterDispatchedUnitsCountForYear[h]); // eq to thermalClusterON for that hour
break;
}
case Antares::Data::UnitCommitmentMode::ucUnknown:
Expand All @@ -350,7 +349,7 @@ void State::yearEndBuildFromThermalClusterIndex(const uint clusterAreaWideIndex)
if (currentCluster->minStablePower > 0.)
{
maxUnitNeeded = static_cast<uint>(
std::floor(thermalClusterProduction / currentCluster->minStablePower));
Utils::floorDiv(thermalClusterProduction, currentCluster->minStablePower));
if (ON_max[h] > maxUnitNeeded)
{
ON_max[h] = maxUnitNeeded;
Expand Down
Loading