def test_extend_targeted_task_list(): """test_extend_targeted_task_list.""" workplace = BaseWorkplace("workplace") task1 = BaseTask("task1") task2 = BaseTask("task2") workplace.extend_targeted_task_list([task1, task2]) assert workplace.targeted_task_list == [task1, task2] assert task1.allocated_workplace_list == [workplace] assert task2.allocated_workplace_list == [workplace]
def dummy_project(scope="function"): """dummy_project.""" # Components in Product c3 = Component("c3") c1 = Component("c1") c2 = Component("c2") c3.extend_child_component_list([c1, c2]) # Tasks in Workflow task1_1 = Task("task1_1", need_facility=True) task1_2 = Task("task1_2") task2_1 = Task("task2_1") task3 = Task("task3") task3.extend_input_task_list([task1_2, task2_1]) task1_2.append_input_task(task1_1) c1.extend_targeted_task_list([task1_1, task1_2]) c2.append_targeted_task(task2_1) c3.append_targeted_task(task3) # Facilities in workplace f1 = BaseFacility("f1") f1.workamount_skill_mean_map = { task1_1.name: 1.0, } # workplace.facility_list.append(f1) # Workplace in BaseOrganization workplace = BaseWorkplace("workplace", facility_list=[f1]) workplace.extend_targeted_task_list([task1_1, task1_2, task2_1, task3]) # Teams in Organization team = Team("team") team.extend_targeted_task_list([task1_1, task1_2, task2_1, task3]) # Workers in each Team w1 = Worker("w1", team_id=team.ID, cost_per_time=10.0) w1.workamount_skill_mean_map = { task1_1.name: 1.0, task1_2.name: 1.0, task2_1.name: 0.0, task3.name: 1.0, } w1.facility_skill_map = {f1.name: 1.0} team.worker_list.append(w1) w2 = Worker("w2", team_id=team.ID, cost_per_time=6.0) w2.workamount_skill_mean_map = { task1_1.name: 1.0, task1_2.name: 0.0, task2_1.name: 1.0, task3.name: 1.0, } w2.facility_skill_map = {f1.name: 1.0} team.worker_list.append(w2) # Project including Product, Workflow and Organization project = Project( init_datetime=datetime.datetime(2020, 4, 1, 8, 0, 0), unit_timedelta=datetime.timedelta(days=1), ) project.product = Product([c3, c1, c2]) project.workflow = Workflow([task1_1, task1_2, task2_1, task3]) project.organization = Organization(team_list=[team], workplace_list=[workplace]) return project
def dummy_conveyor_project_with_child_component(): """dummy_conveyor_project_with_child_component.""" c1_1 = BaseComponent("c1_1") c1_2 = BaseComponent("c1_2") c2_1 = BaseComponent("c2_1") c2_2 = BaseComponent("c2_2") c3_1 = BaseComponent("c3_1") c3_2 = BaseComponent("c3_2") c1_2.append_child_component(c1_1) c2_2.append_child_component(c2_1) c3_2.append_child_component(c3_1) taskA1 = BaseTask("A1", need_facility=True, default_work_amount=6) taskA2 = BaseTask("A2", need_facility=True, default_work_amount=2) taskA3 = BaseTask("A3", need_facility=True, default_work_amount=2) taskB1 = BaseTask("B1", need_facility=True, default_work_amount=2) taskB2 = BaseTask("B2", need_facility=True, default_work_amount=7) taskB3 = BaseTask("B3", need_facility=True, default_work_amount=2) c1_1.append_targeted_task(taskA1) c1_2.append_targeted_task(taskB1) c2_1.append_targeted_task(taskA2) c2_2.append_targeted_task(taskB2) c3_1.append_targeted_task(taskA3) c3_2.append_targeted_task(taskB3) taskB1.append_input_task(taskA1) taskB2.append_input_task(taskA2) taskB3.append_input_task(taskA3) f1 = BaseFacility("f1") f1.workamount_skill_mean_map = { taskA1.name: 1.0, taskA2.name: 1.0, taskA3.name: 1.0, } f2 = BaseFacility("f2") f2.workamount_skill_mean_map = { taskA1.name: 1.0, taskA2.name: 1.0, taskA3.name: 1.0, } f3 = BaseFacility("f3") f3.workamount_skill_mean_map = { taskB1.name: 1.0, taskB2.name: 1.0, taskB3.name: 1.0, } f4 = BaseFacility("f4") f4.workamount_skill_mean_map = { taskB1.name: 1.0, taskB2.name: 1.0, taskB3.name: 1.0, } # Workplace in BaseOrganization wp1 = BaseWorkplace("workplace1", facility_list=[f1], max_space_size=1.0) wp1.extend_targeted_task_list([taskA1, taskA2, taskA3]) wp2 = BaseWorkplace("workplace2", facility_list=[f2], max_space_size=2.0) wp2.extend_targeted_task_list([taskA1, taskA2, taskA3]) wp3 = BaseWorkplace("workplace3", facility_list=[f3], max_space_size=4.0) wp3.extend_targeted_task_list([taskB1, taskB2, taskB3]) wp4 = BaseWorkplace("workplace4", facility_list=[f4], max_space_size=4.0) wp4.extend_targeted_task_list([taskB1, taskB2, taskB3]) wp3.append_input_workplace(wp1) wp4.append_input_workplace(wp2) # BaseTeams in BaseOrganization team = BaseTeam("team") team_list = [team] team.extend_targeted_task_list( [taskA1, taskA2, taskA3, taskB1, taskB2, taskB3]) # BaseWorkers in each BaseTeam w1 = BaseWorker("w1", team_id=team.ID) w1.workamount_skill_mean_map = { taskA1.name: 1.0, taskA2.name: 1.0, taskA3.name: 1.0, } w1.facility_skill_map = {f1.name: 1.0} team.add_worker(w1) w2 = BaseWorker("w2", team_id=team.ID) w2.workamount_skill_mean_map = { taskA1.name: 1.0, taskA2.name: 1.0, taskA3.name: 1.0, } w2.facility_skill_map = {f2.name: 1.0} team.add_worker(w2) w3 = BaseWorker("w3", team_id=team.ID) w3.workamount_skill_mean_map = { taskB1.name: 1.0, taskB2.name: 1.0, taskB3.name: 1.0, } w3.facility_skill_map = {f3.name: 1.0} team.add_worker(w3) w4 = BaseWorker("w4", team_id=team.ID) w4.workamount_skill_mean_map = { taskB1.name: 1.0, taskB2.name: 1.0, taskB3.name: 1.0, } w4.facility_skill_map = {f4.name: 1.0} team.add_worker(w4) workplace_list = [wp1, wp2, wp3, wp4] # BaseProject including BaseProduct, BaseWorkflow and Organization project = BaseProject( init_datetime=datetime.datetime(2021, 8, 20, 8, 0, 0), unit_timedelta=datetime.timedelta(days=1), product=BaseProduct([c1_1, c1_2, c2_1, c2_2, c3_1, c3_2]), workflow=BaseWorkflow([taskA1, taskA2, taskA3, taskB1, taskB2, taskB3]), organization=BaseOrganization(team_list, workplace_list), ) return project
def project_for_checking_space_judge(cope="function"): """project_for_checking_space_judge.""" project = BaseProject( init_datetime=datetime.datetime(2021, 4, 2, 8, 0, 0), unit_timedelta=datetime.timedelta(minutes=1), ) # Components in Product a = BaseComponent("a") b = BaseComponent("b") # Register Product including Components in Project project.product = BaseProduct([a, b]) # Tasks in Workflow # define work_amount and whether or not to need facility for each task task_a = BaseTask( "task_a", need_facility=True, worker_priority_rule=ResourcePriorityRuleMode.HSV, default_work_amount=2, ) task_b = BaseTask( "task_b", need_facility=True, worker_priority_rule=ResourcePriorityRuleMode.HSV, default_work_amount=2, ) # Register Workflow including Tasks in Project project.workflow = BaseWorkflow([task_a, task_b]) # workplace in workplace model # define max_space_size which decide how many components can be placed workplace1 = BaseWorkplace("workplace1", max_space_size=3.0) workplace2 = BaseWorkplace("workplace2", max_space_size=3.0) # facility in workplace model # define workplace_id (each facility is placed which workplace) and cost_per_time machine1 = BaseFacility("machine1", workplace_id=workplace1.ID, cost_per_time=10, solo_working=True) machine2 = BaseFacility("machine2", workplace_id=workplace2.ID, cost_per_time=10, solo_working=True) # define each facility task skill value machine1.workamount_skill_mean_map = {task_a.name: 1.0, task_b.name: 1.0} machine2.workamount_skill_mean_map = {task_a.name: 1.0, task_b.name: 1.0} # define facilities belonging to wach workplace workplace1.add_facility(machine1) workplace2.add_facility(machine2) # Team in team mode team = BaseTeam("factory_A") # worker in team model # define cost_per_time and add each worker to the relevant team w1 = BaseWorker("w1", cost_per_time=10.0) team.add_worker(w1) w2 = BaseWorker("w2", cost_per_time=10.0) team.add_worker(w2) # define each worker task skill value # (Set the skill value of an average worker as 1.0) w1.workamount_skill_mean_map = {task_a.name: 1.0, task_b.name: 1.0} w2.workamount_skill_mean_map = {task_a.name: 1.0, task_b.name: 1.0} # define each worker facility skill value w1.facility_skill_map = {machine1.name: 1.0} w2.facility_skill_map = {machine2.name: 1.0} # Register Organization including Team in Project team_list = [team] workplace_list = [workplace1, workplace2] project.organization = BaseOrganization(team_list, workplace_list) # Component <-> Task a.append_targeted_task(task_a) b.append_targeted_task(task_b) # Team <-> Task team.extend_targeted_task_list([task_a, task_b]) # Workplace <-> Task workplace1.extend_targeted_task_list([task_a, task_b]) workplace2.extend_targeted_task_list([task_a, task_b]) return project
def dummy_project(scope="function"): """dummy_project.""" # BaseComponents in BaseProduct c3 = BaseComponent("c3") c1 = BaseComponent("c1") c2 = BaseComponent("c2") c3.extend_child_component_list([c1, c2]) # BaseTasks in BaseWorkflow task1_1 = BaseTask("task1_1", need_facility=True) task1_2 = BaseTask("task1_2", worker_priority_rule=ResourcePriorityRuleMode.HSV) task2_1 = BaseTask("task2_1") task3 = BaseTask("task3", due_time=30) task3.extend_input_task_list([task1_2, task2_1]) task1_2.append_input_task(task1_1) task0 = BaseTask("auto", auto_task=True, due_time=20) c1.extend_targeted_task_list([task1_1, task1_2]) c2.append_targeted_task(task2_1) c3.append_targeted_task(task3) # Facilities in workplace f1 = BaseFacility("f1") f1.workamount_skill_mean_map = { task1_1.name: 1.0, } # Workplace in BaseOrganization workplace = BaseWorkplace("workplace", facility_list=[f1]) workplace.extend_targeted_task_list([task1_1, task1_2, task2_1, task3]) # BaseTeams in BaseOrganization team = BaseTeam("team") team.extend_targeted_task_list([task1_1, task1_2, task2_1, task3]) # BaseWorkers in each BaseTeam w1 = BaseWorker("w1", team_id=team.ID, cost_per_time=10.0) w1.workamount_skill_mean_map = { task1_1.name: 1.0, task1_2.name: 1.0, task2_1.name: 0.0, task3.name: 1.0, } w1.facility_skill_map = {f1.name: 1.0} team.add_worker(w1) w2 = BaseWorker("w2", team_id=team.ID, cost_per_time=6.0) w2.workamount_skill_mean_map = { task1_1.name: 1.0, task1_2.name: 0.0, task2_1.name: 1.0, task3.name: 1.0, } w2.facility_skill_map = {f1.name: 1.0} team.add_worker(w2) # BaseProject including BaseProduct, BaseWorkflow and Organization project = BaseProject( init_datetime=datetime.datetime(2020, 4, 1, 8, 0, 0), unit_timedelta=datetime.timedelta(days=1), product=BaseProduct([c3, c1, c2]), workflow=BaseWorkflow([task1_1, task1_2, task2_1, task3, task0]), organization=BaseOrganization(team_list=[team], workplace_list=[workplace]), time=10, cost_list=[10], ) project.initialize() # project.product = BaseProduct([c3, c1, c2]) # project.workflow = BaseWorkflow([task1_1, task1_2, task2_1, task3]) # project.organization = BaseOrganization(team_list=[team], workplace_list=[workplace]) return project
def dummy_place_check(): """dummy_place_check.""" c3 = BaseComponent("c3", space_size=1.0) c1 = BaseComponent("c1", space_size=1.0) c2 = BaseComponent("c2", space_size=1.0) task1 = BaseTask("t1", need_facility=True) task2 = BaseTask("t2", need_facility=True) task3 = BaseTask("t3", need_facility=True) c1.append_targeted_task(task1) c2.append_targeted_task(task2) c3.append_targeted_task(task3) # Facilities in workplace f1 = BaseFacility("f1") f1.solo_working = True f1.workamount_skill_mean_map = { task1.name: 1.0, task2.name: 1.0, task3.name: 1.0, } f2 = BaseFacility("f2") f2.solo_working = True f2.workamount_skill_mean_map = { task1.name: 1.0, task2.name: 1.0, task3.name: 1.0, } # Workplace in BaseOrganization workplace = BaseWorkplace("workplace", facility_list=[f1, f2]) workplace.extend_targeted_task_list([task1, task2, task3]) # BaseTeams in BaseOrganization team = BaseTeam("team") team.extend_targeted_task_list([task1, task2, task3]) # BaseWorkers in each BaseTeam w1 = BaseWorker("w1", team_id=team.ID, cost_per_time=10.0) w1.workamount_skill_mean_map = { task1.name: 1.0, task2.name: 1.0, task3.name: 1.0, } w1.facility_skill_map = {f1.name: 1.0} team.add_worker(w1) w2 = BaseWorker("w2", team_id=team.ID, cost_per_time=6.0) w2.workamount_skill_mean_map = { task1.name: 1.0, task2.name: 1.0, task3.name: 1.0, } w2.facility_skill_map = {f2.name: 1.0} team.add_worker(w2) # BaseProject including BaseProduct, BaseWorkflow and Organization project = BaseProject( init_datetime=datetime.datetime(2020, 4, 1, 8, 0, 0), unit_timedelta=datetime.timedelta(days=1), product=BaseProduct([c1, c2, c3]), workflow=BaseWorkflow([task1, task2, task3]), organization=BaseOrganization(team_list=[team], workplace_list=[workplace]), ) return project