예제 #1
0
def gen_single_best_results(data):
    calc.normalize_data(data)
    total_adventure_capacity = calc.calc_total_adventure_capacity(data)
    total_funghi_capacity = calc.calc_total_funghi_capacity(data)
    funghi_combinations = calc.gen_funghi_combinations(
        data, total_adventure_capacity, total_funghi_capacity)
    results = calc.calc_allocations_results(data, funghi_combinations)
    funghi_combinations = calc.gen_funghi_combinations(
        data, total_adventure_capacity, total_funghi_capacity)
    return calc.filter_best_results(data, funghi_combinations, results)
예제 #2
0
def gen_single_best_results(args, data_dir_idx, allocated_counts):
    data_dir = args.data_dirs[data_dir_idx]
    data = load_data(data_dir, args.funghis_path)
    filter_out_allocated_funghis(data, allocated_counts)
    calc.normalize_data(data)
    calc.filter_out_subset_funghis(data)
    total_adventure_capacity = calc.calc_total_adventure_capacity(data)
    total_funghi_capacity = calc.calc_total_funghi_capacity(data)
    funghi_combinations = calc.gen_funghi_combinations(
        data, total_adventure_capacity, total_funghi_capacity)
    results = calc.calc_allocations_results(data, funghi_combinations)
    funghi_combinations = calc.gen_funghi_combinations(
        data, total_adventure_capacity, total_funghi_capacity)
    return calc.filter_best_results(data, funghi_combinations, results)
예제 #3
0
 def test_1(self):
     EXPECTED_SCORES = [14.0, 14.0, 21.0]
     EXPECTED_REQUIREMENT_REPORTS = [{
         1: [1, 2],
         2: [1, 2],
     }, {
         1: [1, 2],
         2: [1, 2],
     }, {
         1: [1, 2, 3],
         2: [1, 2],
     }]
     data = self.load_data(self.STUB_ADVENTURES, self.STUB_FUNGHIS,
                           self.STUB_REWARDS)
     calc.normalize_data(data)
     total_adventure_capacity = calc.calc_total_adventure_capacity(data)
     total_funghi_capacity = calc.calc_total_funghi_capacity(data)
     funghi_combinations = calc.gen_funghi_combinations(
         data, total_adventure_capacity, total_funghi_capacity)
     results = calc.calc_allocations_results(data, funghi_combinations)
     scores = [result['score'] for result in results]
     requirement_reports = [
         result['requirement_report'] for result in results
     ]
     self.assertAlmostEqual(scores, EXPECTED_SCORES)
     self.assertEqual(requirement_reports, EXPECTED_REQUIREMENT_REPORTS)
예제 #4
0
def main():
    args = parse_args()
    data = load_data(args)
    calc.normalize_data(data)
    total_adventure_capacity = calc.calc_total_adventure_capacity(data)
    total_funghi_capacity = calc.calc_total_funghi_capacity(data)
    funghi_combinations = calc.gen_funghi_combinations(
        data, total_adventure_capacity, total_funghi_capacity)
    results = calc.calc_allocations_results(data, funghi_combinations)
    funghi_combinations = calc.gen_funghi_combinations(
        data, total_adventure_capacity, total_funghi_capacity)
    best_results = calc.filter_best_results(data, funghi_combinations, results)
    limited = limit_best_results(best_results, args.max)
    calc.list_best_allocations(data, best_results, args.report_score,
                               args.report_success_rate,
                               args.report_failed_requirement)
    if limited:
        print('The limit has been reached')
예제 #5
0
 def test_simple_1(self):
     EXPECTED_COMBINATIONS = [
         {
             1: [1],
             2: [2, 3]
         },
         {
             1: [1],
             2: [2, 4]
         },
         {
             1: [1],
             2: [3, 4]
         },
         {
             1: [2],
             2: [1, 3]
         },
         {
             1: [2],
             2: [1, 4]
         },
         {
             1: [2],
             2: [3, 4]
         },
         {
             1: [3],
             2: [1, 2]
         },
         {
             1: [3],
             2: [1, 4]
         },
         {
             1: [3],
             2: [2, 4]
         },
         {
             1: [4],
             2: [1, 2]
         },
         {
             1: [4],
             2: [1, 3]
         },
         {
             1: [4],
             2: [2, 3]
         },
     ]
     combinations = calc.gen_funghi_combinations(self.STUB_DATA, 3, 4)
     self.assertEqual(list(combinations), EXPECTED_COMBINATIONS)
예제 #6
0
 def test_allowed_funghis_1(self):
     EXPECTED_COMBINATIONS = [
         {
             1: [1],
             2: [2, 4]
         },
         {
             1: [3],
             2: [2, 4]
         },
     ]
     data = copy.deepcopy(self.STUB_DATA)
     data['adventures'][2]['allowed_funghis'] = [2, 4]
     combinations = calc.gen_funghi_combinations(data, 3, 4)
     self.assertEqual(list(combinations), EXPECTED_COMBINATIONS)
예제 #7
0
 def test_multi_secondary_1(self):
     EXPECTED_COMBINATIONS = [
         {
             1: [1],
             2: [2, 2]
         },
         {
             1: [2],
             2: [1, 2]
         },
     ]
     data = copy.deepcopy(self.STUB_DATA)
     del data['funghis'][3]
     del data['funghis'][4]
     data['funghis'][2]['capacity'] = 2
     combinations = calc.gen_funghi_combinations(data, 3, 3)
     self.assertEqual(list(combinations), EXPECTED_COMBINATIONS)
예제 #8
0
 def test_simple_2(self):
     EXPECTED_COMBINATIONS = [
         {
             1: [1],
             2: [2, 3]
         },
         {
             1: [2],
             2: [1, 3]
         },
         {
             1: [3],
             2: [1, 2]
         },
     ]
     data = copy.deepcopy(self.STUB_DATA)
     del data['funghis'][4]
     combinations = calc.gen_funghi_combinations(data, 3, 3)
     self.assertEqual(list(combinations), EXPECTED_COMBINATIONS)