diff --git a/sampo/scheduler/genetic/operators.py b/sampo/scheduler/genetic/operators.py index ef87070d..74884db8 100644 --- a/sampo/scheduler/genetic/operators.py +++ b/sampo/scheduler/genetic/operators.py @@ -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 diff --git a/sampo/scheduler/timeline/just_in_time_timeline.py b/sampo/scheduler/timeline/just_in_time_timeline.py index 5cfee740..5ec1c1bc 100644 --- a/sampo/scheduler/timeline/just_in_time_timeline.py +++ b/sampo/scheduler/timeline/just_in_time_timeline.py @@ -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 @@ -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) diff --git a/tests/scheduler/genetic/converter_test.py b/tests/scheduler/genetic/converter_test.py index 5c19cf5d..6eb4e06c 100644 --- a/tests/scheduler/genetic/converter_test.py +++ b/tests/scheduler/genetic/converter_test.py @@ -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):