diff --git a/SAS/TMSS/backend/services/scheduling/lib/constraints.py b/SAS/TMSS/backend/services/scheduling/lib/constraints.py index 5ffd1595761928b2a4213c24e1a56338df6ad226..1ac68eba840ac17cc2bb062ec7777b55772ff3d1 100644 --- a/SAS/TMSS/backend/services/scheduling/lib/constraints.py +++ b/SAS/TMSS/backend/services/scheduling/lib/constraints.py @@ -2079,13 +2079,14 @@ def compute_scores_for_units_with_start_time(units_with_start_time: [SchedulingU def compute_scheduling_unit_start_time(scheduling_unit: models.SchedulingUnitBlueprint, lower_bound: datetime, upper_bound: datetime, gridder: Gridder) -> SchedulingUnitAndStartTime: '''Compute best fitting start_time, somewhere between the earliest_possible and the optimal at transit. At this start_time, compute the "fitness" scores per constraint for the given scheduling_unit depending on the sub's constrains-template/doc.''' - # if the unit is already scheduled, evaluate the scores at the known scheduled_start_time, + # if the unit is already scheduled within the given bounds, evaluate the scores at the known scheduled_start_time, # else compute a weighted between earliest- and optimal start_time. if scheduling_unit.status.value in models.SchedulingUnitStatus.ACTIVE_OR_FINISHED_STATUS_VALUES: # but scheduled B-prio units may get a new starttime, so skip those. if not (scheduling_unit.priority_queue.value == models.PriorityQueueType.Choices.B.value and scheduling_unit.status.value == models.SchedulingUnitStatus.Choices.SCHEDULED.value): - return SchedulingUnitAndStartTime(scheduling_unit=scheduling_unit, start_time=scheduling_unit.scheduled_start_time) + if scheduling_unit.scheduled_start_time >= lower_bound and scheduling_unit.scheduled_start_time <= upper_bound: + return SchedulingUnitAndStartTime(scheduling_unit=scheduling_unit, start_time=scheduling_unit.scheduled_start_time) at = get_at_constraint_timestamp(scheduling_unit) if at: