def test_create_data_for_gantt_plotly(): """test_create_data_for_gantt_plotly.""" team = BaseTeam("team") w1 = BaseWorker("w1", cost_per_time=10.0) w1.state_record_list = [ BaseWorkerState.WORKING, BaseWorkerState.WORKING, BaseWorkerState.FREE, BaseWorkerState.WORKING, BaseWorkerState.FREE, BaseWorkerState.FREE, ] w2 = BaseWorker("w2", cost_per_time=5.0) w2.state_record_list = [ BaseWorkerState.WORKING, BaseWorkerState.WORKING, BaseWorkerState.FREE, BaseWorkerState.WORKING, BaseWorkerState.FREE, BaseWorkerState.FREE, ] team.worker_list = [w1, w2] init_datetime = datetime.datetime(2020, 4, 1, 8, 0, 0) timedelta = datetime.timedelta(days=1) team.create_data_for_gantt_plotly(init_datetime, timedelta)
def test_get_worker_list(): """test_get_worker_list.""" # TODO if we have enough time for setting test case... team = BaseTeam("team") w1 = BaseWorker("w1", cost_per_time=10.0) w2 = BaseWorker("w2", cost_per_time=5.0) team.worker_list = [w2, w1] assert ( len( team.get_worker_list( name="test", ID="test", team_id="test", cost_per_time=99876, solo_working=True, workamount_skill_mean_map={}, workamount_skill_sd_map=[], facility_skill_map={}, state=BaseWorkerState.WORKING, cost_list=[], assigned_task_list=[], assigned_task_id_record=[], ) ) == 0 )
def test_create_data_for_cost_history_plotly(): team = BaseTeam("team") w1 = BaseResource("w1", cost_per_time=10.0) w1.cost_list = [0, 0, 10, 10, 0, 10] w2 = BaseResource("w2", cost_per_time=5.0) w2.cost_list = [5, 5, 0, 0, 5, 5] team.worker_list = [w1, w2] team.cost_list = list(map(sum, zip(w1.cost_list, w2.cost_list))) init_datetime = datetime.datetime(2020, 4, 1, 8, 0, 0) timedelta = datetime.timedelta(days=1) data = team.create_data_for_cost_history_plotly(init_datetime, timedelta) x = [ (init_datetime + time * timedelta).strftime("%Y-%m-%d %H:%M:%S") for time in range(len(team.cost_list)) ] # w1 assert data[0].name == w1.name assert data[0].x == tuple(x) assert data[0].y == tuple(w1.cost_list) # w2 assert data[1].name == w2.name assert data[1].x == tuple(x) assert data[1].y == tuple(w2.cost_list)
def test_init(): """test_init.""" team = BaseTeam("team") assert team.name == "team" assert len(team.ID) > 0 assert team.worker_list == [] assert team.targeted_task_list == [] assert team.parent_team is None assert team.cost_list == [] team.cost_list.append(1) assert team.cost_list == [1.0] w1 = BaseWorker("w1") t1 = BaseTask("task1") team1 = BaseTeam( "team1", parent_team=team, targeted_task_list=[t1], worker_list=[w1], cost_list=[10], ) assert team1.worker_list == [w1] assert team1.targeted_task_list == [t1] assert team1.parent_team == team assert team1.cost_list == [10]
def test_add_worker(): """test_add_worker.""" team = BaseTeam("team") worker = BaseWorker("worker") team.add_worker(worker) assert len(team.worker_list) == 1 assert worker.team_id == team.ID
def test_extend_targeted_task_list(): team = BaseTeam("team") task1 = BaseTask("task1") task2 = BaseTask("task2") team.extend_targeted_task_list([task1, task2]) assert team.targeted_task_list == [task1, task2] assert task1.allocated_team_list == [team] assert task2.allocated_team_list == [team]
def test_append_targeted_task(): team = BaseTeam("team") task1 = BaseTask("task1") task2 = BaseTask("task2") team.append_targeted_task(task1) team.append_targeted_task(task2) assert team.targeted_task_list == [task1, task2] assert task1.allocated_team_list == [team] assert task2.allocated_team_list == [team]
def dummy_simple_project(scope="function"): c = BaseComponent("c", space_size=1.0) task1 = BaseTask("task1", default_work_amount=2.0) task2 = BaseTask("task2", default_work_amount=2.0) auto_task2 = BaseTask("auto_task2", auto_task=True, default_work_amount=2.0) task2.append_input_task(auto_task2) task3 = BaseTask("task3", default_work_amount=2.0) auto_task3 = BaseTask("auto_task3", auto_task=True, default_work_amount=4.0) task3.append_input_task(auto_task3) workflow = BaseWorkflow([task1, task2, task3, auto_task2, auto_task3]) c.extend_targeted_task_list([task1, task2, task3]) product = BaseProduct([c]) # 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) w1.workamount_skill_mean_map = { task1.name: 1.0, } team.add_worker(w1) w2 = BaseWorker("w1", team_id=team.ID) w2.workamount_skill_mean_map = { task2.name: 1.0, } team.add_worker(w2) w3 = BaseWorker("w3", team_id=team.ID) w3.workamount_skill_mean_map = { task3.name: 1.0, } team.add_worker(w3) project = BaseProject( init_datetime=datetime.datetime(2020, 4, 1, 8, 0, 0), unit_timedelta=datetime.timedelta(days=1), product=product, workflow=workflow, organization=BaseOrganization(team_list=[team]), ) return project
def dummy_organization(scope="function"): c1 = BaseTeam("c1") w11 = BaseWorker("w11", cost_per_time=10.0) w12 = BaseWorker("w12", cost_per_time=5.0) w11.start_time_list = [0, 5] w11.finish_time_list = [2, 8] w12.start_time_list = [9] w12.finish_time_list = [11] c1.worker_list = [w11, w12] c2 = BaseTeam("c2") w2 = BaseWorker("w2", cost_per_time=5.0) w2.start_time_list = [9] w2.finish_time_list = [11] c2.worker_list = [w2] c2.parent_team = c1 f = BaseFacility("f", cost_per_time=20.0) f.start_time_list = [9] f.finish_time_list = [11] factory = BaseFactory("factory", facility_list=[f]) dummy_factory = BaseFactory("dummy") factory.parent_factory = dummy_factory organization = BaseOrganization(team_list=[c1, c2], factory_list=[factory, dummy_factory]) return organization
def test_create_gantt_plotly(tmpdir): """test_create_gantt_plotly.""" team = BaseTeam("team") w1 = BaseWorker("w1", cost_per_time=10.0) w1.state_record_list = [ BaseWorkerState.WORKING, BaseWorkerState.WORKING, BaseWorkerState.FREE, BaseWorkerState.WORKING, BaseWorkerState.FREE, BaseWorkerState.FREE, ] w2 = BaseWorker("w2", cost_per_time=5.0) w2.state_record_list = [ BaseWorkerState.WORKING, BaseWorkerState.WORKING, BaseWorkerState.FREE, BaseWorkerState.WORKING, BaseWorkerState.FREE, BaseWorkerState.FREE, ] team.worker_list = [w1, w2] init_datetime = datetime.datetime(2020, 4, 1, 8, 0, 0) timedelta = datetime.timedelta(days=1) team.create_gantt_plotly(init_datetime, timedelta) for ext in ["png", "html", "json"]: save_fig_path = os.path.join(str(tmpdir), "test." + ext) team.create_gantt_plotly(init_datetime, timedelta, save_fig_path=save_fig_path)
def test_remove_insert_absence_time_list(): """test_remove_insert_absence_time_list.""" w1 = BaseWorker("w1", "----") w1.cost_list = [1.0, 0.0, 1.0, 0.0, 0.0, 1.0] w1.assigned_task_id_record = ["aa", "bb", "cc", "dd", "ee", "ff"] w1.state_record_list = [2, 1, 2, 1, 1, 2] w2 = BaseWorker("w1", "----") w2.cost_list = [1.0, 0.0, 1.0, 0.0, 0.0, 1.0] w2.assigned_task_id_record = ["aa", "bb", "cc", "dd", "ee", "ff"] w2.state_record_list = [2, 1, 2, 1, 1, 2] team = BaseTeam("aa", worker_list=[w1, w2]) team.cost_list = [2.0, 0.0, 2.0, 0.0, 0.0, 2.0] absence_time_list = [1, 3, 4] team.remove_absence_time_list(absence_time_list) assert team.cost_list == [2.0, 2.0, 2.0] assert w1.cost_list == [1.0, 1.0, 1.0] assert w1.assigned_task_id_record == ["aa", "cc", "ff"] assert w1.state_record_list == [2, 2, 2] assert w2.cost_list == [1.0, 1.0, 1.0] assert w2.assigned_task_id_record == ["aa", "cc", "ff"] assert w2.state_record_list == [2, 2, 2] team.insert_absence_time_list(absence_time_list) assert team.cost_list == [2.0, 0.0, 2.0, 0.0, 0.0, 2.0] assert w1.cost_list == [1.0, 0.0, 1.0, 0.0, 0.0, 1.0] assert w1.assigned_task_id_record == ["aa", "aa", "cc", "cc", "cc", "ff"] assert w1.state_record_list == [2, 0, 2, 0, 0, 2] assert w2.cost_list == [1.0, 0.0, 1.0, 0.0, 0.0, 1.0] assert w2.assigned_task_id_record == ["aa", "aa", "cc", "cc", "cc", "ff"] assert w2.state_record_list == [2, 0, 2, 0, 0, 2]
def test_initialize(): """test_initialize.""" team = BaseTeam("team") w = BaseWorker("w1", team_id=team.ID) w.state = BaseWorkerState.WORKING w.cost_list = [9.0, 7.2] w.assigned_task_list = [BaseTask("task")] w.initialize() assert w.state == BaseWorkerState.FREE assert w.cost_list == [] assert w.assigned_task_list == []
def test_create_cost_history_plotly(): team = BaseTeam("team") w1 = BaseResource("w1", cost_per_time=10.0) w1.cost_list = [0, 0, 10, 10, 0, 10] w2 = BaseResource("w2", cost_per_time=5.0) w2.cost_list = [5, 5, 0, 0, 5, 5] team.worker_list = [w1, w2] team.cost_list = list(map(sum, zip(w1.cost_list, w2.cost_list))) init_datetime = datetime.datetime(2020, 4, 1, 8, 0, 0) timedelta = datetime.timedelta(days=1) team.create_cost_history_plotly(init_datetime, timedelta) team.create_cost_history_plotly(init_datetime, timedelta, title="bbbbbbb")
def test_create_data_for_gantt_plotly(): team = BaseTeam("team") w1 = BaseResource("w1", cost_per_time=10.0) w1.start_time_list = [0, 5] w1.finish_time_list = [2, 8] w2 = BaseResource("w2", cost_per_time=5.0) w2.start_time_list = [9] w2.finish_time_list = [11] team.worker_list = [w1, w2] init_datetime = datetime.datetime(2020, 4, 1, 8, 0, 0) timedelta = datetime.timedelta(days=1) df = team.create_data_for_gantt_plotly(init_datetime, timedelta) # w1 part1 assert df[0]["Task"] == team.name + ": " + w1.name assert df[0]["Start"] == ( init_datetime + w1.start_time_list[0] * timedelta ).strftime("%Y-%m-%d %H:%M:%S") assert df[0]["Finish"] == ( init_datetime + (w1.finish_time_list[0] + 1.0) * timedelta ).strftime("%Y-%m-%d %H:%M:%S") assert df[0]["Type"] == "Worker" # w1 part2 assert df[1]["Task"] == team.name + ": " + w1.name assert df[1]["Start"] == ( init_datetime + w1.start_time_list[1] * timedelta ).strftime("%Y-%m-%d %H:%M:%S") assert df[1]["Finish"] == ( init_datetime + (w1.finish_time_list[1] + 1.0) * timedelta ).strftime("%Y-%m-%d %H:%M:%S") assert df[1]["Type"] == "Worker" # w2 assert df[2]["Start"] == ( init_datetime + w2.start_time_list[0] * timedelta ).strftime("%Y-%m-%d %H:%M:%S") assert df[2]["Finish"] == ( init_datetime + (w2.finish_time_list[0] + 1.0) * timedelta ).strftime("%Y-%m-%d %H:%M:%S") assert df[2]["Type"] == "Worker"
def dummy_organization(scope="function"): """dummy_organization.""" c1 = BaseTeam("c1") w11 = BaseWorker("w11", cost_per_time=10.0) w12 = BaseWorker("w12", cost_per_time=5.0) w11.state_record_list = [ BaseWorkerState.WORKING, BaseWorkerState.WORKING, BaseWorkerState.FREE, BaseWorkerState.WORKING, BaseWorkerState.FREE, BaseWorkerState.FREE, ] w12.state_record_list = [ BaseWorkerState.WORKING, BaseWorkerState.WORKING, BaseWorkerState.FREE, BaseWorkerState.WORKING, BaseWorkerState.FREE, BaseWorkerState.FREE, ] c1.worker_list = [w11, w12] c2 = BaseTeam("c2") w2 = BaseWorker("w2", cost_per_time=5.0) w2.state_record_list = [ BaseWorkerState.WORKING, BaseWorkerState.WORKING, BaseWorkerState.FREE, BaseWorkerState.WORKING, BaseWorkerState.FREE, BaseWorkerState.FREE, ] c2.worker_list = [w2] c2.parent_team = c1 f = BaseFacility("f", cost_per_time=20.0) f.state_record_list = [ BaseFacilityState.WORKING, BaseFacilityState.WORKING, BaseFacilityState.FREE, BaseFacilityState.WORKING, BaseFacilityState.FREE, BaseFacilityState.FREE, ] workplace = BaseWorkplace("workplace", facility_list=[f]) dummy_workplace = BaseWorkplace("dummy") workplace.parent_workplace = dummy_workplace organization = BaseOrganization( team_list=[c1, c2], workplace_list=[workplace, dummy_workplace]) return organization
def test_plot_simple_gantt(): """test_plot_simple_gantt.""" team = BaseTeam("team") w1 = BaseWorker("w1", cost_per_time=10.0) w1.state_record_list = [ BaseWorkerState.WORKING, BaseWorkerState.WORKING, BaseWorkerState.FREE, BaseWorkerState.WORKING, BaseWorkerState.FREE, BaseWorkerState.FREE, ] w2 = BaseWorker("w2", cost_per_time=5.0) w2.state_record_list = [ BaseWorkerState.WORKING, BaseWorkerState.WORKING, BaseWorkerState.FREE, BaseWorkerState.WORKING, BaseWorkerState.FREE, BaseWorkerState.FREE, ] team.worker_list = [w1, w2] team.plot_simple_gantt()
def test_initialize(): team = BaseTeam("team") w = BaseWorker("w1", team_id=team.ID) w.state = BaseResourceState.WORKING w.cost_list = [9.0, 7.2] w.start_time_list = [0] w.finish_time_list = [1] w.assigned_task_list = [BaseTask("task")] w.initialize() assert w.state == BaseResourceState.FREE assert w.cost_list == [] assert w.start_time_list == [] assert w.finish_time_list == [] assert w.assigned_task_list == []
def test_add_labor_cost(): team = BaseTeam("team") w1 = BaseResource("w1", cost_per_time=10.0) w2 = BaseResource("w2", cost_per_time=5.0) team.worker_list = [w2, w1] w1.state = BaseResourceState.WORKING w2.state = BaseResourceState.FREE team.add_labor_cost() assert w1.cost_list == [10.0] assert w2.cost_list == [0.0] assert team.cost_list == [10.0] team.add_labor_cost(only_working=False) assert team.cost_list == [10.0, 15.0] assert w1.cost_list == [10.0, 10.0] assert w2.cost_list == [0.0, 5.0]
def test_create_cost_history_plotly(tmpdir): """test_create_cost_history_plotly.""" team = BaseTeam("team") w1 = BaseWorker("w1", cost_per_time=10.0) w1.cost_list = [0, 0, 10, 10, 0, 10] w2 = BaseWorker("w2", cost_per_time=5.0) w2.cost_list = [5, 5, 0, 0, 5, 5] team.worker_list = [w1, w2] team.cost_list = list(map(sum, zip(w1.cost_list, w2.cost_list))) init_datetime = datetime.datetime(2020, 4, 1, 8, 0, 0) timedelta = datetime.timedelta(days=1) team.create_cost_history_plotly(init_datetime, timedelta) for ext in ["png", "html", "json"]: save_fig_path = os.path.join(str(tmpdir), "test." + ext) team.create_cost_history_plotly( init_datetime, timedelta, title="bbbbbbb", save_fig_path=save_fig_path )
def test_create_gantt_plotly(): team = BaseTeam("team") w1 = BaseResource("w1", cost_per_time=10.0) w1.start_time_list = [0, 5] w1.finish_time_list = [2, 8] w2 = BaseResource("w2", cost_per_time=5.0) w2.start_time_list = [9] w2.finish_time_list = [11] team.worker_list = [w1, w2] init_datetime = datetime.datetime(2020, 4, 1, 8, 0, 0) timedelta = datetime.timedelta(days=1) team.create_gantt_plotly(init_datetime, timedelta) # not yet implemented team.create_gantt_plotly(init_datetime, timedelta, save_fig_path="test.png")
def dummy_team_for_extracting(scope="function"): """dummy_team_for_extracting.""" worker1 = BaseWorker("worker1") worker1.state_record_list = [ BaseWorkerState.FREE, BaseWorkerState.FREE, BaseWorkerState.FREE, BaseWorkerState.FREE, BaseWorkerState.FREE, ] worker2 = BaseWorker("worker2") worker2.state_record_list = [ BaseWorkerState.WORKING, BaseWorkerState.WORKING, BaseWorkerState.WORKING, BaseWorkerState.WORKING, BaseWorkerState.WORKING, ] worker3 = BaseWorker("worker3") worker3.state_record_list = [ BaseWorkerState.FREE, BaseWorkerState.WORKING, BaseWorkerState.WORKING, BaseWorkerState.FREE, BaseWorkerState.FREE, ] worker4 = BaseWorker("worker4") worker4.state_record_list = [ BaseWorkerState.FREE, BaseWorkerState.FREE, BaseWorkerState.WORKING, BaseWorkerState.WORKING, BaseWorkerState.FREE, ] worker5 = BaseWorker("worker5") worker5.state_record_list = [ BaseWorkerState.FREE, BaseWorkerState.FREE, BaseWorkerState.FREE, BaseWorkerState.FREE, BaseWorkerState.WORKING, ] return BaseTeam("test", worker_list=[worker1, worker2, worker3, worker4, worker5])
def test_initialize(): """test_initialize.""" team = BaseTeam("team") team.cost_list = [9.0, 7.2] w = BaseWorker("w1") team.worker_list = [w] w.state = BaseWorkerState.WORKING w.cost_list = [9.0, 7.2] w.assigned_task_list = [BaseTask("task")] team.initialize() assert team.cost_list == [] assert w.state == BaseWorkerState.FREE assert w.cost_list == [] assert w.assigned_task_list == []
def test_initialize(): team = BaseTeam("team") team.cost_list = [9.0, 7.2] w = BaseResource("w1") team.worker_list = [w] w.state = BaseResourceState.WORKING w.cost_list = [9.0, 7.2] w.start_time_list = [0] w.finish_time_list = [1] w.assigned_task_list = [BaseTask("task")] team.initialize() assert team.cost_list == [] assert w.state == BaseResourceState.FREE assert w.cost_list == [] assert w.start_time_list == [] assert w.finish_time_list == [] assert w.assigned_task_list == []
def test_remove_insert_absence_time_list(): """test_remove_insert_absence_time_list.""" f1 = BaseFacility("w1", "----") f1.cost_list = [1.0, 0.0, 1.0, 0.0, 0.0, 1.0] f1.assigned_task_id_record = ["aa", "bb", "cc", "dd", "ee", "ff"] f1.state_record_list = [2, 1, 2, 1, 1, 2] f2 = BaseFacility("w1", "----") f2.cost_list = [1.0, 0.0, 1.0, 0.0, 0.0, 1.0] f2.assigned_task_id_record = ["aa", "bb", "cc", "dd", "ee", "ff"] f2.state_record_list = [2, 1, 2, 1, 1, 2] workplace = BaseWorkplace("aa", facility_list=[f1, f2]) workplace.cost_list = [2.0, 0.0, 2.0, 0.0, 0.0, 2.0] w1 = BaseWorker("w1", "----") w1.cost_list = [1.0, 0.0, 1.0, 0.0, 0.0, 1.0] w1.assigned_task_id_record = ["aa", "bb", "cc", "dd", "ee", "ff"] w1.state_record_list = [2, 1, 2, 1, 1, 2] w2 = BaseWorker("w1", "----") w2.cost_list = [1.0, 0.0, 1.0, 0.0, 0.0, 1.0] w2.assigned_task_id_record = ["aa", "bb", "cc", "dd", "ee", "ff"] w2.state_record_list = [2, 1, 2, 1, 1, 2] team = BaseTeam("aa", worker_list=[w1, w2]) team.cost_list = [2.0, 0.0, 2.0, 0.0, 0.0, 2.0] organization = BaseOrganization(team_list=[team], workplace_list=[workplace]) organization.cost_list = [4.0, 0.0, 4.0, 0.0, 0.0, 4.0] absence_time_list = [1, 3, 4] organization.remove_absence_time_list(absence_time_list) assert organization.cost_list == [4.0, 4.0, 4.0] assert workplace.cost_list == [2.0, 2.0, 2.0] assert f1.cost_list == [1.0, 1.0, 1.0] assert f1.assigned_task_id_record == ["aa", "cc", "ff"] assert f1.state_record_list == [2, 2, 2] assert f2.cost_list == [1.0, 1.0, 1.0] assert f2.assigned_task_id_record == ["aa", "cc", "ff"] assert f2.state_record_list == [2, 2, 2] assert team.cost_list == [2.0, 2.0, 2.0] assert w1.cost_list == [1.0, 1.0, 1.0] assert w1.assigned_task_id_record == ["aa", "cc", "ff"] assert w1.state_record_list == [2, 2, 2] assert w2.cost_list == [1.0, 1.0, 1.0] assert w2.assigned_task_id_record == ["aa", "cc", "ff"] assert w2.state_record_list == [2, 2, 2] organization.insert_absence_time_list(absence_time_list) assert organization.cost_list == [4.0, 0.0, 4.0, 0.0, 0.0, 4.0] assert team.cost_list == [2.0, 0.0, 2.0, 0.0, 0.0, 2.0] assert w1.cost_list == [1.0, 0.0, 1.0, 0.0, 0.0, 1.0] assert w1.assigned_task_id_record == ["aa", "aa", "cc", "cc", "cc", "ff"] assert w1.state_record_list == [2, 0, 2, 0, 0, 2] assert w2.cost_list == [1.0, 0.0, 1.0, 0.0, 0.0, 1.0] assert w2.assigned_task_id_record == ["aa", "aa", "cc", "cc", "cc", "ff"] assert w2.state_record_list == [2, 0, 2, 0, 0, 2] assert workplace.cost_list == [2.0, 0.0, 2.0, 0.0, 0.0, 2.0] assert f1.cost_list == [1.0, 0.0, 1.0, 0.0, 0.0, 1.0] assert f1.assigned_task_id_record == ["aa", "aa", "cc", "cc", "cc", "ff"] assert f1.state_record_list == [2, 0, 2, 0, 0, 2] assert f2.cost_list == [1.0, 0.0, 1.0, 0.0, 0.0, 1.0] assert f2.assigned_task_id_record == ["aa", "aa", "cc", "cc", "cc", "ff"] assert f2.state_record_list == [2, 0, 2, 0, 0, 2]
def dummy_project2(scope="function"): # 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") 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 factory f1 = BaseFacility("f1") f1.workamount_skill_mean_map = { task1_1.name: 1.0, } # factory.facility_list.append(f1) # Factory in BaseOrganization factory = BaseFactory("factory", facility_list=[f1]) factory.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]) # BaseResources 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.worker_list.append(w1) w2 = BaseWorker("w2", team_id=team.ID, cost_per_time=6.0) w2.solo_working = True 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) # 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], factory_list=[factory]), 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], factory_list=[factory]) 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 test_str(): print(BaseTeam("aaaaaaaa"))
def test_set_parent_team(): team = BaseTeam("team") team.set_parent_team(BaseTeam("xxx")) assert team.parent_team.name == "xxx"
def test_str(): """test_str.""" print(BaseTeam("aaaaaaaa"))
def 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 factory 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, } # Factory in BaseOrganization factory = BaseFactory("factory", facility_list=[f1, f2]) factory.extend_targeted_task_list([task1, task2, task3]) # BaseTeams in BaseOrganization team = BaseTeam("team") team.extend_targeted_task_list([task1, task2, task3]) # BaseResources 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.worker_list.append(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.worker_list.append(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], factory_list=[factory]), ) return project