def do_process(exp_path, base_output_dir):
    now = datetime.now()
    dt_string = now.strftime("%Y%m%d_%H-%M-%S")

    exp_name = path.basename(exp_path)
    exp_name_date = "_".join([dt_string, exp_name])

    if exp_name == "sample_exp":
        return

    # check env
    prepare_output_env(exp_name_date, base_output_dir)

    blank_matrix, blank_sum = construct_blank(exp_path)

    names = get_names(exp_path, SAMPLE)
    for name in names:
        sample_matrix = construct_sample(exp_path, name)
        data = compare(blank_matrix, blank_sum, sample_matrix)

        # output ITN
        filename = "_".join([name, "ITN", dt_string]) + ".csv"
        path_itn = path.join(*base_output_dir, exp_name_date, filename)
        data["ITN"].to_csv(path_itn)
        print("[Done]", path_itn)

        # output RU
        filename = "_".join([name, "RU", dt_string]) + ".csv"
        path_ru = path.join(*base_output_dir, exp_name_date, filename)
        data["RU"].to_csv(path_ru)
        print("[Done]", path_ru)
def main(args):

    print("reading in instance")
    project_instance = build_instance(args)

    snapshot_list = []
    if args.compare:
        print("Start simulation of both schedulers")
        snapshots_simple, score_simple, snapshots, score = compare(
            project_instance)
        print("Lower score means better capacity distribution")
        print(f"standard scores {score_simple} > {score} our score ")
        snapshot_list.append(snapshots_simple)
        snapshot_list.append(snapshots)
    else:
        print("Start simulation capacity scheduler")
        snapshots = simulate(project_instance, CapacityScheduler())
        score = squared_deviation_from_optimal_capacity(project_instance)
        snapshot_list.append(snapshots)
        print("Score: ", score)

    if args.visualize:
        print("Start visualizing")
        visualize(project_instance, snapshot_list)

    if args.output:
        print("Writing output")
        write_output(project_instance)
def test_ITN_RU():
    exp_path = path.join(*TEST_INPUT_DATA_DIR, "test_exp1")

    sample_df = construct_sample(exp_path, "0124 SCX3 230 123")
    blank_df, blank_sum = construct_blank(exp_path)

    data = compare(blank_df, blank_sum, sample_df)

    ans_path = path.join(*TEST_INPUT_DATA_DIR, "test_exp1", "20200711.xlsx")
    itn_df = pd.read_excel(ans_path, sheet_name="result (ITN)", index_col=0)
    ru_df = pd.read_excel(ans_path, sheet_name="result (RU)", index_col=0)

    assert np.array_equal(np.around(itn_df.values, 6),
                          np.around(data["ITN"].values, 6))
    assert np.array_equal(np.around(ru_df.values, 6),
                          np.around(data["RU"].values, 6))
Exemple #4
0
 def test_compare_3_1_returns_3_is_greater_than_1(self):
     self.assertEqual("3 is greater than 1", compare(3, 1))
Exemple #5
0
 def test_10_and_10_are_equal(self):
     self.assertEqual("10 is equal to 10", compare(10, 10))
Exemple #6
0
 def test_compare_10_10_returns_10_is_equal_to_10(self):
     self.assertEqual("Both numbers are equal", compare(10, 10))
 def test_compare_10_15_returns_10_is_less_than_15(self):
     self.assertEqual("10 is less than 15", compare(10, 15))
Exemple #8
0
 def test_compare_3_3_returns_numbers_are_equal(self):
     self.assertEqual("The numbers are equal", compare(3, 3))
 def test_compare_6_3_returns_6_is_greater_than_3(self):
     self.assertEqual("6 is greater than 3", compare(6, 3))
Exemple #10
0
 def test_compare_can_tell_if_number_is_not_greater(self):
     self.assertEqual("5 is not greater than 7", compare(5, 7))
Exemple #11
0
 def test_can_compare_and_recognise_equal_numbers(self):
     self.assertEqual("2 is equal to 2", compare(2, 2))
Exemple #12
0
 def test_compare_10_10_returns_10_is_equal_to_10(self):
     self.assertEqual("10 is equal to 10", compare(10, 10))
 def test_compare_1_3_returns_1_is_les_than_3(self):
     self.assertEqual("1 is less than 3", compare(1, 3))
 def test_compare_3_3_returns_the_two_numbers_are_the_same(self):
     self.assertEqual("The two numbers are the same", compare(3, 3))
Exemple #15
0
 def test_compare__equal(self):
     self.assertEqual("both numbers are equal", compare(21, 21))
 def test_compare_int_and_float(self):
     self.assertEqual("both numbers are equal", compare(3, 3.0))
 def test_compare_string_and_number(self):
     self.assertEqual("both numbers are equal", compare("4", 4))
 def test_compare_4_4_returns_4_is_equal_to_4(self):
     self.assertEqual("4 is equal to 4", compare(4, 4))
 def test_compare_2_5_returns_2_is_less_than_5(self):
     self.assertEqual("2 is less than 5", compare(2, 5))
 def test_compare_6_6_returns_6_is_equal_to_6(self):
     self.assertEqual("6 is equal to 6", compare(6, 6))
 def test_compare_20_20_returns_20_is_equal_to_20(self):
     self.assertEqual("20 is equal to 20", compare(20, 20))
Exemple #22
0
 def test_compare_both_numbers_are_equal(self):
     self.assertEqual('5 is equal to 5', compare(5, 5))
 def test_comapre_4_4_return__number_are_same(self):
     self.assertEqual("numbers are the same", compare(4, 4))
Exemple #24
0
 def test_compare_10_10_returns_numbers_are_same(self):
     self.assertEqual("numbers are the same", compare(10, 10))
Exemple #25
0
 def test_compare_7_7_returns_both_numbers_are_equal(self):
     self.assertEqual("both numbers are equal", compare(7, 7))
 def test_compare_5_5_returns_numbers_are_the_same(self):
     self.assertEqual("numbers are the same", compare(5, 5))
Exemple #27
0
 def test_compare_10_10_returns_both_numbers_are_equal(self):
     self.assertEqual("both numbers are equal", compare(10, 10))
 def test_compare_3_5_returns_3_is_less_than_5(self):
     self.assertEqual('3 is less than 5', compare(3, 5))
Exemple #29
0
 def test_compare_5_10_returns_5_is_less_than_10(self):
     self.assertEqual("5 is less than 10", compare(5, 10))
 def test_compare_2_8_returns_2_is_less_than_8(self):
     self.assertEqual("2 is less than 8", compare(2, 8))