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
Beispiel #2
0
def test_create_gantt_plotly():
    factory = BaseFactory("factory")
    w1 = BaseFacility("w1", cost_per_time=10.0)
    w1.start_time_list = [0, 5]
    w1.finish_time_list = [2, 8]
    w2 = BaseFacility("w2", cost_per_time=5.0)
    w2.start_time_list = [9]
    w2.finish_time_list = [11]
    factory.facility_list = [w1, w2]

    init_datetime = datetime.datetime(2020, 4, 1, 8, 0, 0)
    timedelta = datetime.timedelta(days=1)
    factory.create_gantt_plotly(init_datetime,
                                timedelta,
                                save_fig_path="test.png")
    if os.path.exists("test.png"):
        os.remove("test.png")
Beispiel #3
0
def test_create_data_for_gantt_plotly():
    factory = BaseFactory("factory")
    w1 = BaseFacility("w1", cost_per_time=10.0)
    w1.start_time_list = [0, 5]
    w1.finish_time_list = [2, 8]
    w2 = BaseFacility("w2", cost_per_time=5.0)
    w2.start_time_list = [9]
    w2.finish_time_list = [11]
    factory.facility_list = [w1, w2]

    init_datetime = datetime.datetime(2020, 4, 1, 8, 0, 0)
    timedelta = datetime.timedelta(days=1)
    df = factory.create_data_for_gantt_plotly(init_datetime, timedelta)
    # w1 part1
    assert df[0]["Task"] == factory.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"] == "Facility"

    # w1 part2
    assert df[1]["Task"] == factory.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"] == "Facility"

    # 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"] == "Facility"
Beispiel #4
0
def test_initialize():
    team = BaseFactory("team")
    w = BaseFacility("w1", factory_id=team.ID)
    w.state = BaseFacilityState.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 == BaseFacilityState.FREE
    assert w.cost_list == []
    assert w.start_time_list == []
    assert w.finish_time_list == []
    assert w.assigned_task_list == []
Beispiel #5
0
def test_initialize():
    factory = BaseFactory("factory")
    factory.cost_list = [9.0, 7.2]
    w = BaseFacility("w1")
    factory.facility_list = [w]
    w.state = BaseFacilityState.WORKING
    w.cost_list = [9.0, 7.2]
    w.start_time_list = [0]
    w.finish_time_list = [1]
    w.assigned_task_list = [BaseTask("task")]
    factory.initialize()
    assert factory.cost_list == []
    assert w.state == BaseFacilityState.FREE
    assert w.cost_list == []
    assert w.start_time_list == []
    assert w.finish_time_list == []
    assert w.assigned_task_list == []