Skip to content

Commit

Permalink
Added comments
Browse files Browse the repository at this point in the history
  • Loading branch information
StannisMod committed Oct 17, 2023
1 parent e65afc3 commit 7c205ea
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions sampo/scheduler/timeline/zone_timeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ def find_min_start_time(self, zones: list[ZoneReq], parent_time: Time, exec_time

i = 0
while len(queue) > 0:
# This should be uncommented when there are problems with performance

# if i > 0 and i % 50 == 0:
# print(f'Warning! Probably cycle in looking for time slot for all reqs: {i} iteration')
# print(f'Current queue size: {len(queue)}')
Expand Down Expand Up @@ -75,8 +77,9 @@ def find_min_start_time(self, zones: list[ZoneReq], parent_time: Time, exec_time
scheduled_wreqs.append(wreq)
start = max(start, found_start)

for w in zones:
self._validate(start, exec_time, self._timeline[w.kind], w.required_status)
# This should be uncommented when there are problems with zone scheduling correctness
# for w in zones:
# self._validate(start, exec_time, self._timeline[w.kind], w.required_status)

return start

Expand Down Expand Up @@ -132,6 +135,7 @@ def _find_earliest_time_slot(self,
i += 1
end_idx = state.bisect_right(current_start_time + exec_time)

# TODO Test and uncomment code
# if we are inside the interval with wrong status
# we should go right and search the best begin
# if state[current_start_idx].event_type == EventType.START \
Expand Down Expand Up @@ -196,6 +200,8 @@ def _find_earliest_time_slot(self,
break

if current_start_idx >= len(state):
# This should be uncommented when there are problems with zone scheduling correctness

# cur_cpkt = state[-1]
# if cur_cpkt.time == current_start_time and not self._match_status(cur_cpkt.available_workers_count,
# required_status):
Expand All @@ -206,7 +212,8 @@ def _find_earliest_time_slot(self,

current_start_time = state[current_start_idx].time

self._validate(current_start_time, exec_time, state, required_status)
# This should be uncommented when there are problems with zone scheduling correctness
# self._validate(current_start_time, exec_time, state, required_status)

return current_start_time

Expand All @@ -216,9 +223,9 @@ def update_timeline(self, index: int, zones: list[Zone], start_time: Time, exec_
for zone in zones:
state = self._timeline[zone.name]
start_idx = state.bisect_right(start_time)
end_idx = state.bisect_right(start_time + exec_time)
start_status = state[start_idx - 1].available_workers_count

# This should be uncommented when there are problems with zone scheduling correctness
self._validate(start_time, exec_time, state, zone.status)

change_cost = self._config.time_costs[start_status, zone.status] \
Expand Down

0 comments on commit 7c205ea

Please sign in to comment.