Skip to content

Commit

Permalink
Merge branch 'main' into feature/parallel_sgs
Browse files Browse the repository at this point in the history
# Conflicts:
#	pyproject.toml
#	sampo/scheduler/generic.py
#	sampo/scheduler/genetic/converter.py
#	sampo/scheduler/genetic/operators.py
#	sampo/scheduler/timeline/just_in_time_timeline.py
#	sampo/scheduler/timeline/momentum_timeline.py
#	sampo/scheduler/timeline/zone_timeline.py
#	sampo/scheduler/utils/local_optimization.py
#	sampo/schemas/zones.py
#	tests/scheduler/genetic/converter_test.py
#	tests/scheduler/timeline/just_in_time_timeline_test.py
#	tests/scheduler/timeline/momentum_timeline_test.py
#	tests/scheduler/timeline/zone_timeline_test.py
  • Loading branch information
StannisMod committed Oct 20, 2023
2 parents e9304f8 + c6602b1 commit 18cf44e
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 39 deletions.
1 change: 1 addition & 0 deletions sampo/scheduler/genetic/operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from copy import deepcopy
from enum import Enum
from operator import attrgetter
from typing import Iterable, Callable
from typing import Iterable

import numpy as np
Expand Down
7 changes: 0 additions & 7 deletions sampo/scheduler/timeline/just_in_time_timeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,6 @@ def find_min_start_time_with_additional(self, node: GraphNode,

c_st = max(c_st, max_material_time, max_zone_time)

# max_zone_time_new = self.zone_timeline.find_min_start_time(node.work_unit.zone_reqs, c_st, exec_time)
# if max_zone_time_new != c_st:
# print('ERROR!!!')

c_ft = c_st + exec_time
return c_st, c_ft, None

Expand Down Expand Up @@ -305,9 +301,6 @@ def _schedule_with_inseparables(self,
c_ft = new_finish_time

zones = [zone_req.to_zone() for zone_req in node.work_unit.zone_reqs]
# zone_st = self.zone_timeline.find_min_start_time(node.work_unit.zone_reqs, start_time, c_ft - start_time)
# if zone_st != start_time:
# raise AssertionError(f'The Very Big Problems; start time: {start_time}, zone time: {zone_st}, exec_time: {c_ft - start_time}')
self.update_timeline(c_ft, c_ft - start_time, node, workers, spec)
node2swork[node].zones_pre = self.zone_timeline.update_timeline(len(node2swork), zones, start_time,
c_ft - start_time)
Expand Down
60 changes: 28 additions & 32 deletions tests/scheduler/genetic/converter_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,38 +28,34 @@ def test_convert_chromosome_to_schedule(setup_toolbox):

assert not schedule.execution_time.is_inf()

try:
validate_schedule(schedule, setup_wg, setup_contractors)
except:
print()


# TODO Now not passing, will be fixed in next update
# def test_converter_with_borders_contractor_accounting(setup_toolbox):
# tb, _, setup_wg, setup_contractors, _, setup_landscape_many_holders = setup_toolbox
#
# chromosome = tb.generate_chromosome(landscape=setup_landscape_many_holders)
#
# for contractor_index in range(len(chromosome[2])):
# for resource_index in range(len(chromosome[2][contractor_index])):
# chromosome[1][:, resource_index] = chromosome[1][:, resource_index] / 2
# chromosome[2][contractor_index, resource_index] = max(chromosome[1][:, resource_index])
#
# schedule, _, _, _ = tb.chromosome_to_schedule(chromosome, landscape=setup_landscape_many_holders)
# workers = list(setup_contractors[0].workers.keys())
#
# contractors = []
# for i in range(len(chromosome[2])):
# contractors.append(Contractor(id=setup_contractors[i].id,
# name=setup_contractors[i].name,
# workers={
# name: Worker(str(uuid4()), name, count, contractor_id=setup_contractors[i].id)
# for name, count in zip(workers, chromosome[2][i])},
# equipments={}))
#
# schedule = Schedule.from_scheduled_works(schedule.values(), setup_wg)
#
# validate_schedule(schedule, setup_wg, contractors)
validate_schedule(schedule, setup_wg, setup_contractors)


def test_converter_with_borders_contractor_accounting(setup_toolbox):
tb, _, setup_wg, setup_contractors, _, setup_landscape_many_holders = setup_toolbox

chromosome = tb.generate_chromosome(landscape=setup_landscape_many_holders)

for contractor_index in range(len(chromosome[2])):
for resource_index in range(len(chromosome[2][contractor_index])):
chromosome[1][:, resource_index] = chromosome[1][:, resource_index] / 2
chromosome[2][contractor_index, resource_index] = max(chromosome[1][:, resource_index])

schedule, _, _, _ = tb.chromosome_to_schedule(chromosome, landscape=setup_landscape_many_holders)
workers = list(setup_contractors[0].workers.keys())

contractors = []
for i in range(len(chromosome[2])):
contractors.append(Contractor(id=setup_contractors[i].id,
name=setup_contractors[i].name,
workers={
name: Worker(str(uuid4()), name, count, contractor_id=setup_contractors[i].id)
for name, count in zip(workers, chromosome[2][i])},
equipments={}))

schedule = Schedule.from_scheduled_works(schedule.values(), setup_wg)

validate_schedule(schedule, setup_wg, contractors)


def test_converter_with_borders_update(setup_toolbox):
Expand Down

0 comments on commit 18cf44e

Please sign in to comment.