Skip to content

Commit

Permalink
fix - calc number of maintenances - exclude edge case
Browse files Browse the repository at this point in the history
  • Loading branch information
Milos-RTEi committed Dec 7, 2023
1 parent bd5171e commit 7e65e89
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,19 @@ std::vector<int> OptimizationParameters::calculateNumberOfMaintenances(
/ (getAverageDurationBetweenMaintenances(cluster)
+ getAverageMaintenanceDuration(cluster));
numberOfMaintenances[unit] = std::max(1 + div, minNumberOfMaintenances);

// Exclude Edge case:
// first maintenance starts in day 0 + last maintenance starts last day of Horizon
// and breaks the solver - can only happen for number of maintenances > 2
int earliestStart
= std::max(0, calculateUnitEarliestStartOfFirstMaintenance(cluster, unit));
int lastMaintenanceStart = earliestStart
+ (numberOfMaintenances[unit] - 1)
* (getAverageDurationBetweenMaintenances(cluster)
+ getAverageMaintenanceDuration(cluster));

if (lastMaintenanceStart >= timeHorizon_)
numberOfMaintenances[unit]--;
}

return numberOfMaintenances;
Expand Down

0 comments on commit 7e65e89

Please sign in to comment.