def test_cf_same_spot(self):
        input_data = (self.tiny_people,
                      self.tiny_tables,
                      self.days)
        solution = build_guess(*input_data)

        expected_same_spot = Counter({ 2:4, 1:4})
        nose.tools.assert_equal(solution.same_spot_freqs, expected_same_spot)
 def test_cf_overlaps(self):
     input_data = (self.tiny_people,
                   self.tiny_tables,
                   self.days)
     solution = build_guess(*input_data)
     expected_freqs2 = Counter({ 3:1, 2:2, 1:2 })
     expected_freqs3 = Counter()
     nose.tools.assert_equal(solution.overlaps2_freqs, expected_freqs2)
     nose.tools.assert_equal(solution.overlaps3_freqs, expected_freqs3)
 def test_build_guess(self):
     """
     Test that there are the correct number of people at each table each day
     """
     input_data = (self.tiny_people,
                   self.tiny_tables,
                   self.days)
     solution = build_guess(*input_data)
     self._validate_solution(input_data, solution)
예제 #4
0
파일: tests.py 프로젝트: KatrinaE/reGrouper
 def test_build_guess(self):
     """
     Test that there are the correct number of people at each group each day
     """
     input_data = InputData(self.ppl_file,
                        5,
                        None,
                        2,
                        None)
     solution = build_guess(input_data.people, input_data.groups, input_data.days)
     self._validate_solution(input_data.people, input_data.days, input_data.num_groups, solution)
 def test_build_guess_with_head(self):
     """
     Test that head table has correct people each day
     """
     # check the basics
     input_data = (self.tiny_people_with_head,
                   self.tiny_tables_with_head,
                   self.days_with_head)
     solution = build_guess(*input_data)
     expected_people_at_head = set(['Rosemary', 'Francine'])
     self._validate_solution(input_data, solution)
     self._validate_head_table(expected_people_at_head, solution)
예제 #6
0
파일: main.py 프로젝트: KatrinaE/reGrouper
def main(input_data):
    best_solution = None
    for i in range(0, config.num_tries):
        solution = build_guess(input_data.people, input_data.groups, input_data.days)

        print_init_cost(solution.cost)

        if config.anneal:
            for (solution, T) in anneal(solution):
                print_progress(solution, T)
                if best_solution == None or solution.cost < best_solution.cost:
                    best_solution = deepcopy(solution)
                yield best_solution, T
 def test_anneal_with_head(self):
     """
     Test that after annealing the correct people are still at the head table every day
     (on top of test_anneal)
     """
     input_data = (self.tiny_people_with_head,
                   self.tiny_tables_with_head,
                   self.days_with_head)
     init_solution = build_guess(*input_data)
     expected_people_at_head = set(['Rosemary', 'Francine'])
     gen = anneal(init_solution)
     for (solution, T) in gen:
         best_solution = solution
     self._validate_solution(input_data, best_solution)
     self._validate_head_table(expected_people_at_head, best_solution)
     nose.tools.assert_true(best_solution.cost < 2200)
예제 #8
0
파일: tests.py 프로젝트: KatrinaE/reGrouper
 def test_anneal(self):
     """
     Test that after annealing the solution has the correct number of people/groups
     """
     # TODO: figure out how to change settings in config.py for testing purposes
     input_data = InputData(self.ppl_file,
                        5,
                        None,
                        2,
                        None)
     init_solution = build_guess(input_data.people, input_data.groups, input_data.days)
     gen = anneal(init_solution)
     for (solution, T) in gen:
         best_solution = solution
     print best_solution.cost
     self._validate_solution(input_data.people, input_data.days, input_data.num_groups, best_solution)
 def test_anneal(self):
     """
     Test that after annealing the solution has the correct number of people/tables
     """
     # TODO: figure out how to change settings in config.py for testing purposes
     input_data = (self.tiny_people,
                   self.tiny_tables,
                   self.days)
     init_solution = build_guess(*input_data)
     gen = anneal(init_solution)
     for (solution, T) in gen:
         best_solution = solution
         print best_solution.cost
     self._validate_solution(input_data, best_solution)
     # final cost should be zero, because it's possible to create perfect
     # seating charts from these input files
     nose.tools.assert_true(best_solution.cost <= 2118)