コード例 #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
ファイル: test_product.py プロジェクト: swanaka/pDESy
def test_initialize():
    """test_initialize."""
    c1 = Component("c1")
    c1.error = 4.0
    product = Product([c1])
    product.initialize()
    assert c1.error == 0.0
コード例 #3
0
ファイル: test_product.py プロジェクト: taiga4112/pDESy
def test_create_gantt_plotly():
    c1 = Component("c1")
    task11 = Task("task11")
    task12 = Task("task12")
    c1.extend_targeted_task_list([task11, task12])
    c2 = Component("c2")
    task2 = Task("task2")
    c2.append_targeted_task(task2)
    product = Product([c1, c2])

    # Set test case
    task11.start_time_list = [0, 2]
    task11.ready_time_list = [0, 2]
    task11.finish_time_list = [3, 5]
    task12.start_time_list = [1]
    task12.ready_time_list = [2]
    task12.finish_time_list = [5]
    task2.start_time_list = [1]
    task2.ready_time_list = [2]
    task2.finish_time_list = [5]

    init_datetime = datetime.datetime(2020, 4, 1, 8, 0, 0)
    timedelta = datetime.timedelta(days=1)
    product.create_gantt_plotly(init_datetime, timedelta, save_fig_path="test.png")
    if os.path.exists("test.png"):
        os.remove("test.png")
コード例 #4
0
ファイル: test_product.py プロジェクト: swanaka/pDESy
def test_create_data_for_gantt_plotly():
    """test_create_data_for_gantt_plotly."""
    c1 = Component("c1")
    c1.state_record_list = [
        BaseComponentState.WORKING,
        BaseComponentState.FINISHED,
        BaseComponentState.FINISHED,
        BaseComponentState.FINISHED,
        BaseComponentState.FINISHED,
    ]
    product = Product([c1])
    init_datetime = datetime.datetime(2020, 4, 1, 8, 0, 0)
    timedelta = datetime.timedelta(days=1)
    product.create_data_for_gantt_plotly(init_datetime, timedelta)
コード例 #5
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
コード例 #6
0
ファイル: test_product.py プロジェクト: swanaka/pDESy
def test_plot_simple_gantt(tmpdir):
    """test_plot_simple_gantt."""
    c1 = Component("c1")
    c1.state_record_list = [
        BaseComponentState.WORKING,
        BaseComponentState.FINISHED,
        BaseComponentState.FINISHED,
        BaseComponentState.FINISHED,
        BaseComponentState.FINISHED,
    ]
    init_datetime = datetime.datetime(2020, 4, 1, 8, 0, 0)
    timedelta = datetime.timedelta(days=1)
    c1.create_data_for_gantt_plotly(init_datetime, timedelta)
    product = Product([c1])
    product.plot_simple_gantt(
        save_fig_path=os.path.join(str(tmpdir), "test.png"))
コード例 #7
0
ファイル: test_product.py プロジェクト: taiga4112/pDESy
def test_get_node_and_edge_trace_for_plotly_network():
    c1 = Component("c1")
    c2 = Component("c2")
    c3 = Component("c3")
    c2.parent_component_list = [c1]
    c2.child_component_list = [c3]
    product = Product([c3, c2, c1])
    node_trace, edge_trace = product.get_node_and_edge_trace_for_plotly_network()
コード例 #8
0
ファイル: test_product.py プロジェクト: taiga4112/pDESy
def test_get_networkx_graph():
    c1 = Component("c1")
    c2 = Component("c2")
    c3 = Component("c3")
    c2.parent_component_list = [c1]
    c2.child_component_list = [c3]
    product = Product([c3, c2, c1])
    product.get_networkx_graph()
コード例 #9
0
ファイル: test_product.py プロジェクト: swanaka/pDESy
def test_draw_networkx(tmpdir):
    """test_draw_networkx."""
    c1 = Component("c1")
    c2 = Component("c2")
    c3 = Component("c3")
    c2.parent_component_list = [c1]
    c2.child_component_list = [c3]
    product = Product([c3, c2, c1])
    product.draw_networkx(save_fig_path=os.path.join(str(tmpdir), "test.png"))
コード例 #10
0
ファイル: test_product.py プロジェクト: taiga4112/pDESy
def test_draw_plotly_network():
    c1 = Component("c1")
    c2 = Component("c2")
    c3 = Component("c3")
    c2.parent_component_list = [c1]
    c2.child_component_list = [c3]
    product = Product([c3, c2, c1])
    product.draw_plotly_network(save_fig_path="test.png")
    if os.path.exists("test.png"):
        os.remove("test.png")
コード例 #11
0
ファイル: test_product.py プロジェクト: taiga4112/pDESy
def test_create_data_for_gantt_plotly():
    c1 = Component("c1")
    task11 = Task("task11")
    task12 = Task("task12")
    c1.extend_targeted_task_list([task11, task12])
    c2 = Component("c2")
    task2 = Task("task2")
    c2.append_targeted_task(task2)
    product = Product([c1, c2])

    # Set test case
    task11.start_time_list = [0, 2]
    task11.ready_time_list = [0, 2]
    task11.finish_time_list = [3, 5]
    task12.start_time_list = [1]
    task12.ready_time_list = [2]
    task12.finish_time_list = [5]
    task2.start_time_list = [1]
    task2.ready_time_list = [2]
    task2.finish_time_list = [5]

    init_datetime = datetime.datetime(2020, 4, 1, 8, 0, 0)
    timedelta = datetime.timedelta(days=1)
    df = product.create_data_for_gantt_plotly(init_datetime, timedelta)
    assert df[0]["Start"] == (init_datetime + 0 * timedelta).strftime(
        "%Y-%m-%d %H:%M:%S"
    )
    assert df[0]["Finish"] == (init_datetime + (5 + 1.0) * timedelta).strftime(
        "%Y-%m-%d %H:%M:%S"
    )
    assert df[0]["Type"] == "Component"
    assert df[1]["Start"] == (init_datetime + 1 * timedelta).strftime(
        "%Y-%m-%d %H:%M:%S"
    )
    assert df[1]["Finish"] == (init_datetime + (5 + 1.0) * timedelta).strftime(
        "%Y-%m-%d %H:%M:%S"
    )
    assert df[1]["Type"] == "Component"
コード例 #12
0
ファイル: test_product.py プロジェクト: taiga4112/pDESy
def test_create_simple_gantt():
    c1 = Component("c1")
    task11 = Task("task11")
    task12 = Task("task12")
    c1.extend_targeted_task_list([task11, task12])
    c2 = Component("c2")
    task2 = Task("task2")
    c2.append_targeted_task(task2)
    product = Product([c1, c2])

    # Set test case
    task11.start_time_list = [1, 5]
    task11.ready_time_list = [0, 4]
    task11.finish_time_list = [2, 6]
    task12.start_time_list = [2]
    task12.ready_time_list = [1]
    task12.finish_time_list = [5]
    task2.start_time_list = [2]
    task2.ready_time_list = [1]
    task2.finish_time_list = [5]

    product.create_simple_gantt(save_fig_path="test.png")
    if os.path.exists("test.png"):
        os.remove("test.png")
コード例 #13
0
ファイル: test_project.py プロジェクト: swanaka/pDESy
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
コード例 #14
0
ファイル: test_product.py プロジェクト: taiga4112/pDESy
def test_init():
    c1 = Component("c1")
    product = Product([c1])
    assert product.component_list == [c1]