Beispiel #1
0
    def _unhappiness(self, table, language_combination):
        ranking_unhappiness = 0
        previous_round_unhappiness = 0
        levels = []

        for human in table:
            if (
                _is_teacher(human, language_combination)
                and human in self.already_teacher
                or _is_pupil(human, language_combination)
                and human in self.already_pupil
            ):
                previous_round_unhappiness += 9999

            for idx, (learning_language, level) in enumerate(human.learning_languages):
                if learning_language in language_combination:
                    ranking_unhappiness += idx
                    levels.append(level)
                    break
        levels = [int(i) for i in levels]
        levels = np.array(levels)
        maximum = max(levels)
        if maximum:
            levels = levels / maximum
        level_unhappiness = np.std(levels)
        total_unhappiness = ranking_unhappiness + level_unhappiness
        return total_unhappiness + previous_round_unhappiness
Beispiel #2
0
def _fill_already_seated(seated):
    already_teacher = set()
    already_pupil = set()

    for table, languages in seated:
        for human in table:
            if _is_teacher(human, languages):
                already_teacher.add(human)
            else:
                already_pupil.add(human)

    return already_pupil, already_teacher
Beispiel #3
0
def _fill_already_seated(seated):
    already_teacher = set()
    already_pupil = set()

    for table, languages in seated:
        for human in table:
            if _is_teacher(human, languages):
                already_teacher.add(human)
            else:
                already_pupil.add(human)
    
    return already_pupil, already_teacher
Beispiel #4
0
 def _unhappiness(self, table, language_combination):
     ranking_unhappiness = 0
     previous_round_unhappiness = 0
     levels = []
     
     for human in table:
         if (_is_teacher(human, language_combination) and human in self.already_teacher or
             _is_pupil(human, language_combination) and human in self.already_pupil):
             previous_round_unhappiness += 9999
         
         for idx, (learning_language, level) in enumerate(human.learning_languages):
             if learning_language in language_combination:
                 ranking_unhappiness += idx
                 levels.append(level)
                 break
     levels = [int(i) for i in levels]
     levels = np.array(levels)
     maximum = (max(levels))
     if maximum:
         levels = levels / maximum
     level_unhappiness = np.std(levels)
     total_unhappiness = ranking_unhappiness + level_unhappiness
     return total_unhappiness + previous_round_unhappiness