Пример #1
0
def test_perform():
    auto = Task("a", auto_task=True, state=BaseTaskState.WORKING)
    auto.perform(0, seed=1234)
    assert auto.remaining_work_amount == auto.default_work_amount - 1

    task = Task("task")
    task.state = BaseTaskState.READY
    w1 = Worker("w1")
    w2 = Worker("w2")
    w1.workamount_skill_mean_map = {"task": 1.0}
    task.allocated_worker_list = [w1, w2]
    w1.assigned_task_list = [task]
    w2.assigned_task_list = [task]
    c = Component("a")
    c.append_targeted_task(task)
    task.perform(10)
    assert task.remaining_work_amount == task.default_work_amount
    assert task.target_component == c
    assert c.error == 0.0

    task.state = BaseTaskState.WORKING
    task.perform(10)
    assert task.remaining_work_amount == task.default_work_amount - 1.0
    assert task.target_component == c
    assert c.error == 0.0

    # Next test case
    w1.workamount_skill_sd_map = {"task": 0.2}
    w1.quality_skill_mean_map = {"task": 0.9}
    w1.quality_skill_sd_map = {"task": 0.02}
    task.perform(11, seed=1234, increase_component_error=2.0)
    assert task.remaining_work_amount == 7.905712967253502
    assert c.error == 2.0
Пример #2
0
def test_has_quality_skill():
    w = Worker("w1", "----")
    # w.set_quality_skill_mean_map(
    #     {"task1": 1.0, "task2": 0.0}, update_other_skill_info=True
    # )
    w.quality_skill_mean_map = {"task1": 1.0, "task2": 0.0}
    assert w.has_quality_skill("task1")
    assert not w.has_quality_skill("task2")
    assert not w.has_quality_skill("task3")
Пример #3
0
def test_has_workamount_skill():
    """test_has_workamount_skill."""
    w = Worker("w1", "----")
    # w.set_workamount_skill_mean_map(
    #     {"task1": 1.0, "task2": 0.0}, update_other_skill_info=True
    # )
    w.workamount_skill_mean_map = {"task1": 1.0, "task2": 0.0}
    assert w.has_workamount_skill("task1")
    assert not w.has_workamount_skill("task2")
    assert not w.has_workamount_skill("task3")
Пример #4
0
def test_initialize():
    """test_initialize."""
    team = Team("team")
    team.cost_list = [9.0, 7.2]
    w = Worker("w1")
    team.worker_list = [w]
    w.state = BaseWorkerState.WORKING
    w.cost_list = [9.0, 7.2]
    w.assigned_task_list = [Task("task")]
    team.initialize()
    assert team.cost_list == []
    assert w.state == BaseWorkerState.FREE
    assert w.cost_list == []
    assert w.assigned_task_list == []
Пример #5
0
def dummy_organization(scope="function"):
    """dummy_organization."""
    c1 = Team("c1")
    w11 = Worker("w11", cost_per_time=10.0)
    w12 = Worker("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 = Team("c2")
    w2 = Worker("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 = Organization(team_list=[c1, c2],
                                workplace_list=[workplace, dummy_workplace])
    return organization
Пример #6
0
def test_init():
    """test_init."""
    team = Team("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 = Worker("w1")
    t1 = Task("task1")
    team1 = Team(
        "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]
Пример #7
0
def test_initialize():
    """test_initialize."""
    task = Task("task")
    task.est = 2.0
    task.eft = 10.0
    task.lst = 3.0
    task.lft = 11.0
    task.remaining_work_amount = 7
    task.actual_work_amount = 6
    task.state = BaseTaskState.READY
    task.additional_task_flag = True
    task.allocated_worker_list = [Worker("w1")]
    task.initialize()
    assert task.est == 0.0
    assert task.eft == 0.0
    assert task.lst == -1.0
    assert task.lft == -1.0
    assert task.remaining_work_amount == task.default_work_amount * (
        1.0 - task.default_progress
    )
    assert task.actual_work_amount == task.default_work_amount * (
        1.0 - task.default_progress
    )
    assert task.state == BaseTaskState.NONE
    assert task.additional_task_flag is False
    assert task.allocated_worker_list == []

    task = Task("task", default_progress=0.2)
    task.initialize()
    assert task.state == BaseTaskState.READY

    task = Task("task", default_progress=1.0)
    task.initialize()
    assert task.state == BaseTaskState.FINISHED
Пример #8
0
def test_init(dummy_worker):
    """test_init."""
    # team = Team("team")
    assert dummy_worker.name == "wsss"
    assert dummy_worker.team_id == "---"
    assert dummy_worker.cost_per_time == 0.0
    assert dummy_worker.workamount_skill_mean_map == {}
    assert dummy_worker.workamount_skill_sd_map == {}
    assert dummy_worker.quality_skill_mean_map == {}
    assert dummy_worker.state == BaseWorkerState.FREE
    assert dummy_worker.cost_list == []
    assert dummy_worker.assigned_task_list == []
    w = Worker(
        "w1",
        state=BaseWorkerState.WORKING,
        cost_list=[10, 10],
        assigned_task_list=[Task("task")],
        assigned_task_id_record=[[], ["ss"]],
    )
    assert w.name == "w1"
    assert w.team_id is None
    assert w.cost_per_time == 0.0
    assert w.workamount_skill_mean_map == {}
    assert w.workamount_skill_sd_map == {}
    assert w.quality_skill_mean_map == {}
    assert w.state == BaseWorkerState.WORKING
    assert w.cost_list == [10, 10]
    assert w.assigned_task_list[0].name == "task"
    assert w.assigned_task_id_record == [[], ["ss"]]
Пример #9
0
def test_initialize():
    team = Team("team")
    w = Worker("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 = [Task("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 == []
Пример #10
0
def test_check_state():
    """test_check_state."""
    task1 = Task("task1")
    task2 = Task("task2")
    task3 = Task("task3")
    task4 = Task("task4")
    task5 = Task("task5")
    task3.extend_input_task_list([task1, task2])
    task5.extend_input_task_list([task3, task4])
    w = Workflow([task1, task2, task3, task4, task5])

    w1 = Worker("w1", assigned_task_list=[task1])

    # __check_ready test
    task1.state = BaseTaskState.FINISHED
    task2.state = BaseTaskState.FINISHED
    task3.state = BaseTaskState.NONE
    task4.state = BaseTaskState.NONE
    task5.state = BaseTaskState.NONE
    w.check_state(2, BaseTaskState.READY)
    assert task1.state == BaseTaskState.FINISHED
    assert task2.state == BaseTaskState.FINISHED
    assert task3.state == BaseTaskState.READY
    assert task4.state == BaseTaskState.READY
    assert task5.state == BaseTaskState.NONE

    # __check_working test
    task1.state = BaseTaskState.READY
    task2.state = BaseTaskState.READY
    task2.allocated_worker_list = [w1]
    task3.state = BaseTaskState.NONE
    task4.state = BaseTaskState.NONE
    task5.state = BaseTaskState.NONE
    w.check_state(2, BaseTaskState.WORKING)
    assert task1.state == BaseTaskState.READY
    assert task2.state == BaseTaskState.WORKING
    assert task3.state == BaseTaskState.NONE
    assert task4.state == BaseTaskState.NONE
    assert task5.state == BaseTaskState.NONE

    # __check_finished test

    task1.state = BaseTaskState.WORKING
    task1.allocated_worker_list = [w1]
    task1.remaining_work_amount = 0.0
    task2.state = BaseTaskState.FINISHED
    task3.state = BaseTaskState.NONE
    task4.state = BaseTaskState.NONE
    task5.state = BaseTaskState.NONE
    w.check_state(2, BaseTaskState.FINISHED)
    assert task1.state == BaseTaskState.FINISHED
    assert task2.state == BaseTaskState.FINISHED
    assert task3.state == BaseTaskState.NONE
    assert task4.state == BaseTaskState.NONE
    assert task5.state == BaseTaskState.NONE
Пример #11
0
def test_create_data_for_cost_history_plotly():
    team = Team("team")
    w1 = Worker("w1", cost_per_time=10.0)
    w1.cost_list = [0, 0, 10, 10, 0, 10]
    w2 = Worker("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)
Пример #12
0
def test_create_data_for_gantt_plotly():
    """test_create_data_for_gantt_plotly."""
    team = Team("team")
    w1 = Worker("w1", cost_per_time=10.0)
    w1.state_record_list = [
        BaseWorkerState.WORKING,
        BaseWorkerState.WORKING,
        BaseWorkerState.FREE,
        BaseWorkerState.WORKING,
        BaseWorkerState.FREE,
        BaseWorkerState.FREE,
    ]
    w2 = Worker("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)
Пример #13
0
def test_create_gantt_plotly(tmpdir):
    """test_create_gantt_plotly."""
    team = Team("team")
    w1 = Worker("w1", cost_per_time=10.0)
    w1.state_record_list = [
        BaseWorkerState.WORKING,
        BaseWorkerState.WORKING,
        BaseWorkerState.FREE,
        BaseWorkerState.WORKING,
        BaseWorkerState.FREE,
        BaseWorkerState.FREE,
    ]
    w2 = Worker("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)

    # not yet implemented
    team.create_gantt_plotly(init_datetime,
                             timedelta,
                             save_fig_path=os.path.join(
                                 str(tmpdir), "test.png"))
Пример #14
0
def test_initialize():
    """test_initialize."""
    team = Team("team")
    w = Worker("w1", team_id=team.ID)
    w.state = BaseWorkerState.WORKING
    w.cost_list = [9.0, 7.2]
    w.assigned_task_list = [Task("task")]
    w.initialize()
    assert w.state == BaseWorkerState.FREE
    assert w.cost_list == []
    assert w.assigned_task_list == []
Пример #15
0
def test_create_gantt_plotly():
    team = Team("team")
    w1 = Worker("w1", cost_per_time=10.0)
    w1.start_time_list = [0, 5]
    w1.finish_time_list = [2, 8]
    w2 = Worker("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")
Пример #16
0
def test_init():
    task = Task("task")
    assert task.name == "task"
    assert len(task.ID) > 0
    assert task.default_work_amount == 10.0
    assert task.input_task_list == []
    assert task.output_task_list == []
    assert task.due_time == -1
    assert task.allocated_team_list == []
    assert task.target_component is None
    assert task.default_progress == 0.0
    assert task.additional_work_amount == 0.0
    assert task.est == 0.0
    assert task.eft == 0.0
    assert task.lst == -1.0
    assert task.lft == -1.0
    assert task.remaining_work_amount == task.default_work_amount * (
        1.0 - task.default_progress)
    # assert task.actual_work_amount == task.default_work_amount * (
    #     1.0 - task.default_progress
    # )
    assert task.state == BaseTaskState.NONE
    assert task.ready_time_list == []
    assert task.start_time_list == []
    assert task.finish_time_list == []
    assert task.additional_task_flag is False
    assert task.allocated_worker_list == []

    tb = Task(
        "task_b1",
        remaining_work_amount=0.0,
        state=BaseTaskState.FINISHED,
        ready_time_list=[1],
        start_time_list=[2],
        finish_time_list=[5],
        allocated_worker_list=[Worker("a")],
        allocated_worker_id_record=[["idid"]],
        additional_task_flag=True,
    )
    assert tb.remaining_work_amount == 0.0
    assert tb.state == BaseTaskState.FINISHED
    assert tb.ready_time_list == [1]
    assert tb.start_time_list == [2]
    assert tb.finish_time_list == [5]
    assert tb.allocated_worker_list[0].name == "a"
    assert tb.allocated_worker_id_record == [["idid"]]
    assert tb.additional_task_flag is True
Пример #17
0
def test_perform():
    task = Task("task")
    task.state = BaseTaskState.WORKING
    w1 = Worker("w1")
    w2 = Worker("w2")
    w1.workamount_skill_mean_map = {"task": 1.0}
    task.allocated_worker_list = [w1, w2]
    w1.assigned_task_list = [task]
    w2.assigned_task_list = [task]
    c = Component("a")
    c.append_targeted_task(task)
    w = Workflow([task])
    w.perform(10)
    assert task.remaining_work_amount == task.default_work_amount - 1.0
    assert task.target_component == c
    assert c.error == 0.0
Пример #18
0
def test_create_cost_history_plotly():
    team = Team("team")
    w1 = Worker("w1", cost_per_time=10.0)
    w1.cost_list = [0, 0, 10, 10, 0, 10]
    w2 = Worker("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")
Пример #19
0
def test_create_data_for_gantt_plotly():
    team = Team("team")
    w1 = Worker("w1", cost_per_time=10.0)
    w1.start_time_list = [0, 5]
    w1.finish_time_list = [2, 8]
    w2 = Worker("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"
Пример #20
0
def test_add_labor_cost():
    team = Team("team")
    w1 = Worker("w1", cost_per_time=10.0)
    w2 = Worker("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]
Пример #21
0
def test_initialize():
    task = Task("task")
    task.est = 2.0
    task.eft = 10.0
    task.lst = 3.0
    task.lft = 11.0
    task.remaining_work_amount = 7
    task.actual_work_amount = 6
    task.state = BaseTaskState.FINISHED
    task.ready_time_list = [1]
    task.start_time_list = [2]
    task.finish_time_list = [15]
    task.additional_task_flag = True
    task.allocated_worker_list = [Worker("w1")]

    task_after1 = Task("task_after1")
    task_after2 = Task("task_after2", default_work_amount=5.0)
    task_after1.append_input_task(task)
    task_after2.append_input_task(task)

    w = Workflow([task, task_after1, task_after2])
    w.critical_path_length = 100.0
    w.initialize()
    assert w.critical_path_length == 20.0
    assert w.task_list[0].est == 0.0
    assert w.task_list[0].eft == 10.0
    assert w.task_list[0].lst == 0.0
    assert w.task_list[0].lft == 10.0
    assert w.task_list[0].state == BaseTaskState.READY
    assert w.task_list[1].est == 10.0
    assert w.task_list[1].eft == 20.0
    assert w.task_list[1].lst == 10.0
    assert w.task_list[1].lft == 20.0
    assert w.task_list[1].state == BaseTaskState.NONE
    assert w.task_list[2].est == 10.0
    assert w.task_list[2].eft == 15.0
    assert w.task_list[2].lst == 15.0
    assert w.task_list[2].lft == 20.0
    assert w.task_list[2].state == BaseTaskState.NONE
Пример #22
0
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
Пример #23
0
def dummy_worker():
    w = Worker("wsss", team_id="---")
    return w
Пример #24
0
def test_str():
    """test_str."""
    print(Worker("w1"))
Пример #25
0
def test_str():
    print(Worker("w1"))
Пример #26
0
def test_get_quality_skill_point():
    """test_get_quality_skill_point."""
    w = Worker("w1", "----")
    # w.set_quality_skill_mean_map(
    #     {"task1": 1.0, "task2": 0.0}, update_other_skill_info=True
    # )
    w.quality_skill_mean_map = {"task1": 1.0, "task2": 0.0}
    assert w.get_quality_skill_point("task3") == 0.0
    assert w.get_quality_skill_point("task2") == 0.0
    assert w.get_quality_skill_point("task1") == 1.0

    task1 = Task("task1")
    task1.state = BaseTaskState.NONE
    w.assigned_task_list = [task1]
    assert w.get_quality_skill_point("task1") == 1.0
    task1.state = BaseTaskState.READY
    assert w.get_quality_skill_point("task1") == 1.0
    task1.state = BaseTaskState.WORKING_ADDITIONALLY
    assert w.get_quality_skill_point("task1") == 1.0
    task1.state = BaseTaskState.FINISHED
    assert w.get_quality_skill_point("task1") == 1.0
    task1.state = BaseTaskState.WORKING
    assert w.get_quality_skill_point("task1") == 1.0

    w.quality_skill_sd_map["task1"] = 0.1
    assert w.get_quality_skill_point("task1", seed=1234) == 1.0471435163732492

    task2 = Task("task2")
    task2.state = BaseTaskState.NONE
    w.assigned_task_list.append(task2)
    w.quality_skill_sd_map["task1"] = 0.0
    assert w.get_quality_skill_point("task1") == 1.0
    task2.state = BaseTaskState.WORKING
    assert w.get_quality_skill_point("task1") == 1.0
Пример #27
0
def dummy_worker():
    """dummy_worker."""
    w = Worker("wsss", team_id="---")
    return w
Пример #28
0
def test_get_work_amount_skill_progress():
    """test_get_work_amount_skill_progress."""
    w = Worker("w1", "----")
    # w.set_workamount_skill_mean_map(
    #     {"task1": 1.0, "task2": 0.0}, update_other_skill_info=True
    # )
    w.workamount_skill_mean_map = {"task1": 1.0, "task2": 0.0}
    assert w.get_work_amount_skill_progress("task3") == 0.0
    assert w.get_work_amount_skill_progress("task2") == 0.0
    with pytest.raises(ZeroDivisionError):
        assert w.get_work_amount_skill_progress("task1") == 1.0

    task1 = Task("task1")
    task1.state = BaseTaskState.NONE
    w.assigned_task_list = [task1]
    with pytest.raises(ZeroDivisionError):
        assert w.get_work_amount_skill_progress("task1") == 1.0
    task1.state = BaseTaskState.READY
    with pytest.raises(ZeroDivisionError):
        assert w.get_work_amount_skill_progress("task1") == 1.0
    task1.state = BaseTaskState.WORKING_ADDITIONALLY
    assert w.get_work_amount_skill_progress("task1") == 1.0
    task1.state = BaseTaskState.FINISHED
    with pytest.raises(ZeroDivisionError):
        assert w.get_work_amount_skill_progress("task1") == 1.0
    task1.state = BaseTaskState.WORKING
    assert w.get_work_amount_skill_progress("task1") == 1.0

    w.workamount_skill_sd_map["task1"] = 0.1
    w.get_work_amount_skill_progress("task1", seed=1234)  # seed test

    task2 = Task("task2")
    task2.state = BaseTaskState.NONE
    w.assigned_task_list.append(task2)
    w.workamount_skill_sd_map["task1"] = 0.0
    assert w.get_work_amount_skill_progress("task1") == 1.0
    task2.state = BaseTaskState.WORKING
    assert w.get_work_amount_skill_progress("task1") == 0.5
Пример #29
0
def dummy_organization(scope="function"):
    c1 = Team("c1")
    w11 = Worker("w11", cost_per_time=10.0)
    w12 = Worker("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 = Team("c2")
    w2 = Worker("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 = Organization(
        team_list=[c1, c2], factory_list=[factory, dummy_factory]
    )
    return organization